I am using scapy to send arp packets to my another computer in LAN it runs for sometimes and sends some packets but after that scapy stops with an error.
Sent Packets: 28Traceback (most recent call last):
File "main.py", line 33, in <module>
spoof('192.168.43.65', '192.168.43.1')
File "main.py", line 15, in spoof
target_mac = get_mac(target_ip)
File "main.py", line 11, in get_mac
return answered[0][1].hwsrc
File "/usr/lib/python3/dist-packages/scapy/plist.py", line 118, in __getitem__
return self.res.__getitem__(item)
IndexError: list index out of range
def spoof(target_ip, source_ip):
target_mac = get_mac(target_ip)
packet = scapy.ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=source_ip)
scapy.send(packet, verbose=False)
This is my function I am running it in a while loop infinitely.
Why am I getting this error?
Related
(I'm following this tutorial : https://www.pubnub.com/blog/raspberry-pi-gps-lte-google-maps-api/ and I use a Raspberry pi 4 model B connected trough wifi )
I carefully followed all steps carefully untill I tried to run the modified gps_simpletest.py file. When I try to run it I get the following error:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 323, in _rec onfigure_port
orig_attr = termios.tcgetattr(self.fd)
termios.error: (5, 'Input/output error')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "gps_simpletest.py", line 21, in <module>
uart = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=10)
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 240, in __ini t__
self.open()
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 272, in open
self._reconfigure_port(force_update=True)
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 326, in _rec onfigure_port
raise SerialException("Could not configure port: {}".format(msg))
serial.seria
I'm pretty sure I installed all modules, libraries, ....
Any help would be much appreciated!Thanks in advance
I'm currently trying to extract the payload of a TCP packet (which is just a single letter) with Scapy, but it keeps giving me a NoneType exception after going through the first two packets.
from scapy.all import *
import base64
capture = rdpcap('Data.pcapng') # pcap file
output = open('output.bin','wb') # save dumped data to output.bin
for packet in capture:
# if packet is ICMP and type is 8 (echo request)
if packet[TCP].src == '172.16.139.128':
output.write(packet[TCP].payload) # write packet data to output.bin
The exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scapy/packet.py", line 372, in __getattr__
fld, v = self.getfield_and_val(attr)
TypeError: cannot unpack non-iterable NoneType object
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "exploit.py", line 10, in <module>
if packet[TCP].src == '172.16.139.128':
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scapy/packet.py", line 374, in __getattr__
return self.payload.__getattr__(attr)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scapy/packet.py", line 372, in __getattr__
fld, v = self.getfield_and_val(attr)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/scapy/packet.py", line 1600, in getfield_and_val
raise AttributeError(attr)
AttributeError: src
Does anyone know what's causing this? It should be outputting more.
The IP source address is in the IP payload, not in TCP's. Hence, the error. So if you want to check whether the packet comes from 172.16.139.128 and has a TCP payload, the appropriate test would be:
if IP in packet and packet[IP].src == '172.16.139.128' and TCP in packet:
output.write(packet[TCP].payload)
Im trying to write little http proxy server just for testing how scapy handles packet with StreamSocket.
from scapy.all import *
import socket
sk = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print "Start"
sk.bind(("127.0.0.1",8090))
sk.listen(1)
conn , addr = sk.accept()
ss = StreamSocket(conn)
r = ss.recv(2048)
print r
ss.close()
When I got the line r = ss.recv(2048) it says (on scapy 2.2.0):
Traceback (most recent call last):
File "<string>", line 254, in run_nodebug
File "C:\Python26\ProxyServer\module1.py", line 21, in <module>
r = ss.recv()
File "C:\Python26\lib\site-packages\scapy\supersocket.py", line 126, in recv
pad = pkt.getlayer(Padding)
NameError: global name 'Padding' is not defined
I have tried to update my scapy (from 2.2.0 to 2.3.2) and it does the same error:
Traceback (most recent call last):
File "<string>", line 254, in run_nodebug
File "C:\Python26\ProxyServer\module1.py", line 21, in <module>
r = ss.recv()
File "C:\Python26\lib\site-packages\scapy\supersocket.py", line 126, in recv
pkt = self.basecls(pkt)
NameError: global name 'Padding' is not defined
Please Help?
sorry for my bad english
Note: I have windows 7 64 bit , python 2.6 and now scapy 2.3.2
I found that after uninstalling and reinstalling scapy I didnt reboot my machine and that made the error!
For people that might get my error about, just remove scapy from your machine and reboot it and install latest scapy version.
I tried to send icmp packet with scapy without success,
to understand where and what is the problem. I wrote some code in python that sends icmp packet.
Of course the code is running successfully without any problem.
also in scapy the problem is present,
My internal ip is 10.0.0.8 in 10.0.0.0/24 network
the code with error in scapy for example is :
send(IP(dst="10.0.0.138")/ICMP())
send(IP(dst="8.8.8.8")/ICMP())
the error message is:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python26\lib\site-packages\scapy\sendrecv.py", line 251, in send
__gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)
File "C:\Python26\lib\site-packages\scapy\sendrecv.py", line 234, in __gen_send
s.send(p)
File "C:\Python26\lib\site-packages\scapy\arch\pcapdnet.py", line 237, in send
ifs = dnet.eth(iff)
File "dnet.pyx", line 112, in dnet.eth.__init__
OSError: Result too large
Note: when I try to run:
send(IP(dst="10.0.0.8")/ICMP())
or
send(IP(dst="127.0.0.1")/ICMP())
the packet is sent successfully!
you must start scapy with sudo scapy
I was trying to transfer a log file using tftp. For client side I am using TFTPY module in python. But it is showing below mentioned error messages.
WARNING:tftpy:Timeout waiting for traffic, retrying...
ERROR:tftpy:Timed-out waiting for traffic
WARNING:tftpy:resending last packet
WARNING:tftpy:Resending packet RRQ packet: filename = /opt/TDK/logs//55194186195512_Console.log mode = octet on sessions <tftpy.TftpStates.TftpStateSentRRQ object at 0xb70a0f8c>
Traceback (most recent call last):
File "callConsoleLogTransfer.py", line 30, in <module>
consoleLogTransfer(IP,Port,logTransferPort,fileName,localFilePath)
File "/file/consoleLogTransfer.py", line 68, in consoleLogTransfer
client.download( remoteFile, localFile, timeout=20 )
File "/usr/local/lib/python2.7/dist-packages/tftpy/TftpClient.py", line 52, in download
self.context.start()
File "/usr/local/lib/python2.7/dist-packages/tftpy/TftpContexts.py", line 378, in start
self.state.resendLast()
File "/usr/local/lib/python2.7/dist-packages/tftpy/TftpStates.py", line 203, in resendLast
(self.context.host, self.context.tidport))
TypeError: an integer is required