手记

python命令行脚本

copy命令脚本:

import os
import optparse

def main():
parse = optparse.OptionParser(“usage%prog " + “-i -c -o “)
parse.add_option(”-i”, dest=“iname”, type=“string”, help=“specify img file”)
parse.add_option(”-c", dest=“cname”, type=“string”, help=“specify compress File”)
parse.add_option("-o", dest=“oname”, type=“string”, help=“specify outname”)

(options, args) = parse.parse_args()
if (options.iname == None) | (options.cname == None):
    print(parse.usage)
else:
    iname = options.iname
    cname = options.cname
    oname = options.oname
    p = os.popen("copy /b %s+%s %s" % (iname,cname,oname))
    print(p.read())

if name == “main”:
main()


暴力破解脚本:
import optparse
import zipfile
from threading import Thread

def check_pwd(zf,pwd):
try:
zf = zipfile.ZipFile(zf)
zf.extractall(pwd=pwd.encode(“ascii”))
print(“found password %s” % pwd)
except Exception as e:
print(e)

def zip() :
parse = optparse.OptionParser(“usage%prog -f -d “)
parse.add_option(”-f”, dest=“fname”, help=“get zip file”)
parse.add_option("-d", dest=“dname”, help=“get dictionary”)
(options,args) = parse.parse_args()
if (options.fname == None) | (options.dname == None) :
print(parse.usage)
else:
fname = options.fname
dname = options.dname
f=open(dname)
for line in f.readlines():
pwd = line.strip(’\n’)
print(“Try password %s” % pwd)
t = Thread(target=check_pwd, args=(fname, pwd))
t.start()

if name == “main”:
zip()

0人推荐
随时随地看视频
慕课网APP