Your SlideShare is downloading. ×
اسلاید سوم جلسه هفتم کلاس پایتون برای هکرهای قانونی
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

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

89
views

Published on

Published in: Education, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

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

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Python for Ethical Hackers Mohammad reza Kamalifard
  • 2. Python Language Essentials Module 2: System Programming Part 2 : Directory Navigation
  • 3. Directory Details Methods for traversing directories Listing file and their information Creating and deleting directories and files Test to check if something is a file or directory
  • 4. >>> import os >>> >>> os.getcwd() '/home/reza/code/PYSEC101/dir' >>> >>> >>>os.mkdir('class') $ ls Class jalase7 jalase7.py os.rmdir()
  • 5. >>> os.listdir('.') ['class', 'jalase7', 'jalase7.py'] >>> >>> os.listdir('/') ['opt', 'initrd.img.old', 'lib', 'selinux', 'dev', 'home', 'initrd.img', 'lost+found', 'bin', 'usr', 'sys', 'lib64', 'windows', 'vmlinuz.old', 'proc', 'tmp', 'cdrom', 'run', 'sbin', 'mnt', 'root', 'boot', 'media', 'var', 'vmlinuz', 'etc', 'srv'] >>>
  • 6. >>> for item in os.listdir('.'): ... if os.path.isfile(item): ... print item + ' is a file' ... elif os.path.isdir(item): ... print item + ' is a directory' ... else: ... print 'unknown' ... Class is a directory Jalase7 is a directory jalase7.py is a file >>>
  • 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.