【发布时间】:2023-03-06 13:50:01
【问题描述】:
我需要一些关于 scapy 和 python 的帮助。 我向特定站点发送获取请求...然后使用嗅探和 HTTP 过滤器过滤相关数据包,然后我只想获取 HTML 代码,但我不知道该怎么做...
os.system('iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP')
os.system('iptables -L')
randport = random.randint(1024,65535)
syn = IP(dst=ip) / TCP(sport = randport, dport=80, flags='S')
syn_ack = sr1(syn) #getting the ack
getstr = 'GET / HTTP/1.1\r\nHost:' + url + '\r\n\r\n'
ack = IP(dst=ip) / TCP(dport=80, sport=syn_ack[TCP].dport,
seq=syn_ack[TCP].ack, ack=syn_ack[TCP].seq + 1, flags='A') / getstr
send(ack)
packets = sniff(count=0, lfilter=http_filter, timeout=20)
http = open(url + ".html", "w")
for p in packets:
if p[IP].src == ip:
#what i need to do here?
帮帮我,我需要做什么才能只保存 HTML 代码,整个代码?保存不带 HTTP 标头的代码,只是我可以打开的 HTML,它会像在线网站一样加载我的网站
【问题讨论】:
标签: python html http scapy packets