Commit a2daff94 by 张航玮

Add new file

parent d79dc8c2
#_*_coding:UTF-8_*_
from scapy.all import *
import urllib.request
import urllib.parse
import time
import json
millis = int(round(time.time() * 1000))
millis = str(millis)
url1 = "http://192.168.1.1/cgi-bin/Login.asp?User=admin&Pwd=admin&_="+millis
res_data = urllib.request.urlopen(url1)
millis = int(round(time.time() * 1000))
millis = str(millis)
time.sleep(0.1)
url2 = "http://192.168.1.1/cgi-bin/get/New_GUI/get_sessionKey.asp?_="+millis
print(url2)
#req = urllib.parse.urlencode()
res_data = urllib.request.urlopen(url2)
res = res_data.read()
print(res,str(res, encoding = "utf-8") )
path = 'http://192.168.1.1/cgi-bin/New_GUI/Set/Diagnostics.asp'
params = {
"Type" :'p',
"sessionKey" :str(res, encoding = "utf-8"),
"Addr" :'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
}
params = json.dumps(params)
headers = {'Accept-Charset': 'utf-8', 'Content-Type': 'application/json'}
params = bytes(params, 'utf8')
req = urllib.request.Request(url=path, data=params, headers=headers, method='POST')
response = urllib.request.urlopen(req).read()
#print(req)
#import scapy_http.http
'''
def printPacket(packet):
if packet.haslayer('HTTP'):
print("============================")
print(packet.payload.payload.payload.show())
def write_cap(packet):
global pkts
global filename
global count
global pcapnum
pkts=[]
pkts.append(packet)
pname="pcap1.pcap"
wrpcap(pname,pkts)
#filename ="./1.pcap"
#test_dump_file(filename)
def test_dump_file(dump_file):
print ("Testing the dump file...")
if os.path.exists(dump_file):
print ("dump fie %s found.",dump_file)
pkts=sniff(offline=dump_file)
count = 0
while (count<=2):
print ("----Dumping pkt:%s----",dump_file)
print (hexdump(pkts[count]))
count +=1
else:
print ("dump fie %s not found.",dump_file)
dpkt = sniff(iface = "tap105572_0",count=10,prn=write_cap)
'''
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment