اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی

121
-1

Published on

برای دانلود به
kamalifard.ir/pysec101
مراجعه کنید

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
121
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

اسلاید ارائه سوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی

  1. 1. Python for Ethical Hackers Mohammad reza Kamalifard kamalifard@datasec.ir
  2. 2. Python Language Essentials Part 7 : Subprocess Mohammad reza Kamalifard Kamalifard.ir/pysec101
  3. 3. #Subprocess New in version 2.4. The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several other, older modules and functions, such as: os.system os.spawn* os.popen* popen2.* commands.* Mohammad reza Kamalifard Kamalifard.ir/pysec101
  4. 4. Subprocess subprocess.call(['ls', '-l']) subprocess.check_output(['ls', '-al']) import subprocess subprocess.call(['ps', '-e']) PID TTY TIME CMD 1 ? 00:00:01 init 2 ? 00:00:00 kthreadd 3 ? 00:00:01 ksoftirqd/0 5 ? 00:00:00 kworker/0:0H 7 ? 00:00:00 kworker/u:0H 8 ? 00:00:00 migration/0 9 ? 00:00:00 rcu_bh 10 ? 00:00:01 rcu_sched ...Mohammad reza Kamalifard Kamalifard.ir/pysec101
  5. 5. subprocess.check_output import subprocess >>>subprocess.check_output(['ls', '-l']) 'total 76ndrwxr-xr-x 4 reza reza 4096 Sep 10 00:00 Desktopndrwxr-xr-x 6 reza reza 4096 Aug 8 22:45 Documentsndrwxr-xr-x 6 reza reza 12288 Sep 10 16:10 Downloadsndrwxr-xr-x 3 reza reza 4096 Aug 13 01:48 Musicndrwxr-xr-x 3 reza reza 4096 Sep 8 03:09 Picturesndrwxr-xr-x 2 reza reza 4096 Aug 9 01:32 Publicndrwxr-xr-x 2 reza reza 4096 Aug 9 01:32 Templatesndrwxr-xr-x 2 reza reza 4096 Aug 13 04:21 Videosndrwx------ 22 reza reza 4096 Sep 3 17:58' Mohammad reza Kamalifard Kamalifard.ir/pysec101
  6. 6. subprocess.check_output import subprocess resp = subprocess.check_output(['ls', '-l']) resp_list = resp.split('n') print resp_list Mohammad reza Kamalifard Kamalifard.ir/pysec101
  7. 7. This work is licensed under the Creative Commons Attribution-NoDerivs 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/ Copyright 2013 Mohammad reza Kamalifard. All rights reserved.

×