1.Python使用for循环依次打开该目录下的各文件
import os
path = r"F:\Python\第一周作业\task"
otherpath=r"F:\Python\其它目录"
for filename in os.listdir(path):
print(path,filename)
fullname=os.path.join(path,filename)
if os.path.isfile(fullname):
othername=os.path.join(otherpath,filename)
otherfile=open(othername,'wb')
for line in open(fullname,'rb'):
for c in line:
if not c.isdigit():otherfile.write(c)
otherfile.close()
2.python编程unix破解器怎么用在文件上
一个比较实用的脚本吧。
破解一些弱口令还行? 其他的只能去md5相关网站交钱破解喽 还是要自备字典?和?待破解文件? password文件一定是从/etc/shadow?获取的哦 #!/usr/bin/env?python#?coding=utf-8#By?LiT0import?cryptimport?sysfrom?concurrent。 futures?import?(user,crypt_pass,word):????salt?=?crypt_pass。
split('$')[2]????insalt?=?'${}${}$'。 format('6',salt)????word?=?word。
strip(' ')????crypt_word?=?crypt。crypt(word,insalt)????if?crypt_pass?==?crypt_word:????????print?("[*]?Successful?Cracked?user?:?{}?"。
format(user))????????print?("[ ]?Found?Password:?{} "。format(word))????????returndefreadpasswd():with?open(sys。
argv[1],'r')?as?passwd_file:????????for?line?in?passwd_file:????????????if":"in?line:????????????????user?=?line。 split(':')[0]????????????????crypt_pass?=?line。
split(':')[1]。strip('?')????????????????if?len(crypt_pass)?>?16:????????????????????with?ThreadPoolExecutor(2)?as?Executor:????????????????????????with?open(sys。
argv[2],'r')?as?dict_file:????????????????????????????for?word?in?dict_file:????????????????????????????????Executor。submit(testpasswd,user,crypt_pass,word)????print?('[*]?All?Done!')if?__name__?==?'__main__':????if?len(sys。
argv)?3:????????print?("Usage: 请准备好阴影文件和爆破字典 如:?。/nix_passwd。
py?password。txt?dict。
txt?")????????sys。exit(0)????print?('[*]?Runing。
')????readpasswd()。
3.python 3.6.5中 如何将 两个算法 如 for I in range()依次运行
# python中只有for i in range()语法,没有for i range()# for i in 。
是遍历一个可遍历的对象,主要还是了解一下range()函数# range() 可以接受三个参数值,start, end, step# start : 开始的位置# end : 结束的位置# step : 步长# e.g.l = list("ABCDEFG")# 指定 endfor i in range(len(l)): print(l[i])>>> A B C D E F G# 指定start,endfor i in range(4, len(l)): print(l[i])>>> E F G# 指定start,end,stepfor i in range(0, len(l), 2): print(l[i])>>> A C E G。
转载请注明出处编程代码网 » pythonforinfile