Closed aboelkassem closed 2 years ago
Hi, could you please share a snippet that reproduces the issue exactly? Thanks
./run_scapy
arping('192.168.1.0/24')
>>> arping('192.168.1.0/24')
Begin emission:
WARNING: Could not get the source MAC: invalid literal for int() with base 16: ''
WARNING: Could not get the source MAC: invalid literal for int() with base 16: ''
WARNING: more Could not get the source MAC: invalid literal for int() with base 16: ''
Finished sending 256 packets.
*
Received 1 packets, got 1 answers, remaining 255 packets
<CorrectMACAdress> unknown 192.168.1.2
(<ARPing: TCP:0 UDP:0 ICMP:0 Other:1>, <Unanswered: TCP:0 UDP:0 ICMP:0 Other:255>)
Expected result
Using scapy version 2.4.4
solved the problem for me and sending a packet message for more than one device without getting these WARNING messages
Did you retry using the current github version?
yea, I just cloning the current Github version to reproduce this
Interesting. Could you show the results of the following (feel free to censor the IPs, but we need to make sure the IPs/MACs are well-formed):
conf.route
conf.route.route('192.168.1.0/24')
conf.ifaces
of course, but I see everything is normal, you can try it yourself but the result was
>>> conf.route
Network Netmask Gateway Iface Output IP Metric
0.0.0.0 0.0.0.0 192.168.1.1 VMware Virtual Ethernet Adapter for VMnet1 CorrectIP 291
0.0.0.0 0.0.0.0 192.168.1.1 Realtek PCIe FE Family Controller CorrectIP 35
0.0.0.0 0.0.0.0 192.168.1.1 Qualcomm QCA9377 802.11ac Wireless Adapter CorrectIP 55
CorrectIP 255.255.255.0 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet1 CorrectIP 291
CorrectIP 255.255.255.0 0.0.0.0 Realtek PCIe FE Family Controller CorrectIP 291
CorrectIP 255.255.255.0 0.0.0.0 Qualcomm QCA9377 802.11ac Wireless Adapter CorrectIP 311
CorrectIP 255.255.255.255 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet1 CorrectIP 291
CorrectIP 255.255.255.255 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet1 CorrectIP 291
CorrectIP 255.255.255.255 0.0.0.0 Realtek PCIe FE Family Controller CorrectIP 291
CorrectIP 255.255.255.255 0.0.0.0 Qualcomm QCA9377 802.11ac Wireless Adapter CorrectIP 311
CorrectIP 255.255.255.255 0.0.0.0 Qualcomm QCA9377 802.11ac Wireless Adapter CorrectIP 311
CorrectIP 255.255.255.255 0.0.0.0 Realtek PCIe FE Family Controller CorrectIP 291
CorrectIP 255.255.255.0 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet8 CorrectIP 291
CorrectIP 255.255.255.255 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet8 CorrectIP 291
CorrectIP 255.255.255.255 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet8 CorrectIP 291
CorrectIP 240.0.0.0 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet1 CorrectIP 291
CorrectIP 240.0.0.0 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet8 CorrectIP 291
CorrectIP 240.0.0.0 0.0.0.0 Realtek PCIe FE Family Controller CorrectIP 291
CorrectIP 240.0.0.0 0.0.0.0 Qualcomm QCA9377 802.11ac Wireless Adapter CorrectIP 311
CorrectIP 240.0.0.0 0.0.0.0 Microsoft Wi-Fi Direct Virtual Adapter #5 CorrectIP 281
255.255.255.255 255.255.255.255 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet1 CorrectIP 291
255.255.255.255 255.255.255.255 0.0.0.0 VMware Virtual Ethernet Adapter for VMnet8 CorrectIP 291
255.255.255.255 255.255.255.255 0.0.0.0 Realtek PCIe FE Family Controller CorrectIP 291
255.255.255.255 255.255.255.255 0.0.0.0 Qualcomm QCA9377 802.11ac Wireless Adapter CorrectIP 311
255.255.255.255 255.255.255.255 0.0.0.0 Microsoft Wi-Fi Direct Virtual Adapter #5 CorrectIP 281
>>> conf.route.route('192.168.1.0/24')
('\\Device\\NPF_{.....}', 'CorrectIP', '0.0.0.0')
>>> conf.ifaces
INFO: Table cropped to fit the terminal (conf.auto_crop_tables==True)
Source Index Name MAC IPv4 IPv6
libpcap 11 Qualcomm QCA9377 802.11ac Wirele_ CorrectMAC CorrectIP CorrectIPv6
libpcap 14 Microsoft Wi-Fi Direct Virtual A_ CorrectMAC CorrectIP CorrectIPv6
libpcap 15 Realtek PCIe FE Family Controller CorrectMAC CorrectIP CorrectIPv6
libpcap 3 VMware Virtual Ethernet Adapter _ CorrectMAC CorrectIP CorrectIPv6
libpcap 6 VMware Virtual Ethernet Adapter _ CorrectMAC CorrectIP CorrectIPv6
I'm getting the same error when I attempt to get the MAC of my own machine from a python script. .
From the command line Ether().src
returns my MAC address.
But, if I attempt to run Ether().src
from a python script, I get WARNING: Could not get the source MAC: invalid literal for int() with base 16: ''
and an empty MAC of 00:00:00:00:00:00.
Environment
Are you sure you're running the same version of scapy in script and on the CLI?
You can check scapy.__version__
Could you add the following line, in scapy/utils.py
, after def mac2str(mac):
:
log_runtime.info("MAC in mac2str: %r", mac)
So that it reads:
def mac2str(mac):
# type: (str) -> bytes
log_runtime.info("MAC in mac2str: %r", mac)
return b"".join(chb(int(x, 16)) for x in plain_str(mac).split(':'))
And then run your test again (Ether().src
), and report the output here?
Could you add the following line, in
scapy/utils.py
, afterdef mac2str(mac):
:log_runtime.info("MAC in mac2str: %r", mac)
So that it reads:
def mac2str(mac): # type: (str) -> bytes log_runtime.info("MAC in mac2str: %r", mac) return b"".join(chb(int(x, 16)) for x in plain_str(mac).split(':'))
And then run your test again (
Ether().src
), and report the output here?
Thanks for your reply,
the output which I get when I try to test Ether().src
was:
>>> Ether().src
INFO: MAC in mac2str: 'xx:xx:xx:xx:xx:xx'
'xx:xx:xx:xx:xx:xx'
and its correct,
but when I try arping('192.168.1.0/24')
to send packages as broadcast still getting this warning message
>>> arping('192.168.1.0/24')
Begin emission:
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: ''
WARNING: Could not get the source MAC: invalid literal for int() with base 16: ''
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: ''
WARNING: Could not get the source MAC: invalid literal for int() with base 16: ''
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: ''
WARNING: more Could not get the source MAC: invalid literal for int() with base 16: ''
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: ''
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: ''
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: ''
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: '00:00:00:00:00:00'
INFO: MAC in mac2str: 'ff:ff:ff:ff:ff:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
INFO: MAC in mac2str: 'aa:bb:cc:dd:ee:ff'
.........continue printing the same Info messages as above
Ok this part is interesting:
INFO: MAC in mac2str: ''
WARNING: Could not get the source MAC: invalid literal for int() with base 16: ''
Sometimes, mac2str()
is called with an empty string (as I suspected). I have no idea why, but that's a start.
I have the same issue.
Scapy version: 2.4.5
Python version: 3.9.5
Operating System: Windows 10
I can't replicate. The routes must be wrong somehow, please provide them entirely.
Could you make sure you're using the github version and provide the output of
a = Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.1.0/24") # change here
for x in a:
z = Ether(raw(x))
print(z.sprintf("%Ether.src% -> %Ether.dst%: %ARP.hwsrc% -> %ARP.hwdst%"))
Closing for inactivity.
Brief description
I'm trying to use
scapy.arping()
to create packets with ARP message to IP addresses, but when I passing the correct IP Address e.g192.168.1.0/24
it gives me the following warning message and didn't send packets for local IP addressesEnvironment
2.4.5
3.9
Windows 10
Update
Using Scapy version
2.4.4
worked for me, so hoping to fix this problem in the latest version