python的util函数
winkar_utils的Python项目详细描述
安装
pip install winkar_utils
python的实用程序
链接
为iterable添加链式枚举支持
importutilsrange(10).map(lambdax:x**2) \ .filter(lambdax:x>10) \ .take(5) \ .reduce(lambdax,y:x+y)
编码
为str添加其他编码
importutilsprint"asd".encode("bin")# => 011000010111001101100100print"011000010111001101100100".decode("bin")# => asd
并发
并发编码的实用程序
fromutils.concurrentimportmultiThread@multiThread(10)# the param indicate how many threads to startdefox(x):returnxox(range(10))# this will run concurrently# param should be a collection of orgin param type
对数
日志实用程序
importloggingfromutils.logimportstream_handler,formatter,loggerlogger.warn("test")# the logger has been set level to warn# use formatter as its default output format# and will only print to stdoutlogger.setLevel(logging.INFO)# change log levellogger.name="test"# change logger name
因子
fromutils.factorimportfactorfactor(130)# => [2,5,13]factor(131)# => [1,131]
它还将向path添加一个factor命令,如linux
有用的第三方库
酚
一个非常有用的集成pwn库。
只能通过pip安装。
frompwnimport*context(arch='i386',os='linux')r=remote('exploitme.example.com',31337)# EXPLOIT CODE GOES HEREr.send(asm(shellcraft.sh()))r.interactive()
libformatstr
专门用于格式字符串攻击的库。
用PIP安装。
importsysfromlibformatstrimportFormatStraddr=0x08049580system_addr=0x080489a3p=FormatStr()p[addr]=system_addr# buf is 14th argument, 4 bytes are already printedsys.stdout.write(p.payload(14,start_len=4))
fnmatch
支持bash样式通配符的库。
使用pip安装
fromfnmatchimportfnmatchfnmatch("target","tar*")# => truefnmatch("target","TARG.T")# => false