Discussion:
BPF mode
Guillaume Valadon / ギョーム バラドン
2008-01-12 12:06:28 UTC
Permalink
Hi,

I wrote a patch that allows to directly use scapy.py without
installing py-pcap and py-dnet. It uses /dev/bpf to inject and
receive packets. Note that filters can only be used with the ctypes
module (it comes by default with Python 2.5).

I tested it on OS X 10.4.11 (ppc and intel) and FreeBSD. I will be
interested to have feedback on other platforms.

Guillaume

--
Guillaume Valadon / ギョヌム バラドン
***@hongo.wide.ad.jp
Mike Savory
2008-01-12 21:46:43 UTC
Permalink
Hi Guillaume

It is great that scapy can be used with the Apple supplied python on a
standard Leopard install.


This is what I get on a Leopard 10.5.1 Intel system (with Apple's
included python)
(I renamed your file scapy2)
Python 2.5.1 (r251:54863, Oct 5 2007, 21:08:09)
sudo bin/scapy2.py
Password:
bin/scapy2.py:3332: Warning: 'with' will become a reserved keyword in
Python 2.6
bin/scapy2.py:3334: Warning: 'with' will become a reserved keyword in
Python 2.6
INFO: did not find python gnuplot wrapper . Won't be able to plot
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump()
WARNING: did not find pcap module.
WARNING: did not find dnet module.
INFO: Can't find Crypto python lib. Won't be able to decrypt WEP
WARNING: Fallback to native BPF primitives.
Welcome to Scapy (1.2.0.2)
e=Ether(dst="00:11:22:33:44:55", src="00:55:44:33:22:11",
type=0x8100)
v=Dot1Q(vlan=100, type=0x0800)
i=IP(dst="1.1.1.1", src="2.2.2.2")
sendp( e/v/i , iface="en1", loop=1, inter=1)
....^C
Sent 4 packets.


$ sudo tcpdump -i en1
12:43:24.597024 IP 2.2.2.2 > 1.1.1.1: ip 0
12:43:25.599799 IP 2.2.2.2 > 1.1.1.1: ip 0

$ sudo tcpdump -exi en0 ether dst 00:11:22:33:44:55
12:44:41.333214 00:17:f2:e6:75:75 (oui Unknown) > 00:11:22:33:44:55
(oui Unknown),
ethertype 802.1Q (0x8100), length 38: vlan 100, p 0, ethertype IPv4,
2.2.2.2 > 1.1.1.1: ip 0
0x0000: 0064 0800 4500 0014 0001 0000 4000 74e4
0x0010: 0202 0202 0101 0101

So its not allowing me to rewrite my source MAC address, I was able to
do this on 10.4.11 I think.


Note that without the sudo

$ bin/scapy2.py
bin/scapy2.py:3332: Warning: 'with' will become a reserved keyword in
Python 2.6
bin/scapy2.py:3334: Warning: 'with' will become a reserved keyword in
Python 2.6
INFO: did not find python gnuplot wrapper . Won't be able to plot
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump()
WARNING: did not find pcap module.
WARNING: did not find dnet module.
INFO: Can't find Crypto python lib. Won't be able to decrypt WEP
WARNING: Fallback to native BPF primitives.
Traceback (most recent call last):
File "bin/scapy2.py", line 13478, in <module>
class Conf(ConfClass):
File "bin/scapy2.py", line 13507, in Conf
iface = get_working_if()
File "bin/scapy2.py", line 1186, in get_working_if
return f.readlines()[0].split('.')[1].rstrip()
IndexError: list index out of range

This needs a better failure mechanism (Insufficient priv on BPF)


On a standard 10.4.11 system I get (with apples supplied python)
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
$ ./scapy2.py
File "./scapy2.py", line 625
xx = sum(len(k) for k in linex)
^
SyntaxError: invalid syntax

By pointing scapy2.py at the ActiveState installed python on 10.4.11
PPC it seems tp work OK
Python 2.5.1 (r251:54863, May 1 2007, 17:40:00)
$ sudo ./scapy2.py
Password:
./scapy2.py:3332: Warning: 'with' will become a reserved keyword in
Python 2.6
./scapy2.py:3334: Warning: 'with' will become a reserved keyword in
Python 2.6
INFO: did not find python gnuplot wrapper . Won't be able to plot
INFO: Can't import PyX. Won't be able to use psdump() or pdfdump()
WARNING: did not find pcap module.
WARNING: did not find dnet module.
INFO: Can't find Crypto python lib. Won't be able to decrypt WEP
WARNING: Fallback to native BPF primitives.
INFO: Can't load Python libreadline or completer
Welcome to Scapy (1.2.0.2)
e=Ether(dst="00:11:22:33:44:55", src="00:55:44:33:22:11",
type=0x8100)
v=Dot1Q(vlan=100, type=0x0800)
i=IP(dst="1.1.1.1", src="2.2.2.2")
sendp( e/v/i , iface="en0", loop=1, inter=1)
......^C
Sent 6 packets.
^D
Although the lack of readline makes it hard to use !!

On 10.4.11 I use the MacPorts Scapy, but on 10.5.1 it had problems
building py-crypto



Regards

Mike


On Jan 12, 2008, at 4:06 AM, Guillaume Valadon / ギョーム バラド
I wrote a patch that allows to directly use scapy.py without
installing py-pcap and py-dnet. It uses /dev/bpf to inject and
receive packets. Note that filters can only be used with the ctypes
module (it comes by default with Python 2.5).
I tested it on OS X 10.4.11 (ppc and intel) and FreeBSD. I will be
interested to have feedback on other platforms.
Guillaume
--
Guillaume Valadon / ギョーム バラドン
---------------------------------------------------------------------
To unsubscribe, send a mail to scapy.ml-***@secdev.org
Guillaume Valadon / ギョーム バラドン
2008-01-13 12:10:23 UTC
Permalink
Hi,

Thanks for you quick feedback !

Both MAC spoofing, and without-sudo bugs are fixed in the attached
version.

Guillaume

--
Guillaume Valadon / ギョヌム バラドン
***@hongo.wide.ad.jp
Guillaume Valadon / ギョーム バラドン
2008-01-14 09:23:12 UTC
Permalink
Hi,
Post by Guillaume Valadon / ギョーム バラドン
Both MAC spoofing, and without-sudo bugs are fixed in the attached
version.
Thanks to Arnaud, the code is now available under a mercurial
repository:

$ hg clone http://hg.natisbad.org/scapy-bpf

Guillaume

--
Guillaume Valadon / ギョーム バラドン
***@hongo.wide.ad.jp




---------------------------------------------------------------------
To unsubscribe, send a mail to scapy.ml-***@secdev.org
Guillaume Valadon / ギョーム バラドン
2008-01-25 10:01:58 UTC
Permalink
Hi,
Post by Guillaume Valadon / ギョーム バラドン
$ hg clone http://hg.natisbad.org/scapy-bpf
I am looking for beta testers especially under OpenBSD and NetBSD.
So far, I tested it under OSX 10.4 and 10.5; FreeBSD 5, 6 and 7;
NetBSD 4.0; and OpenBSD 4.2.

Note that on OpenBSD, Scapy does not behave exactly as on other
platforms as the libpcap do not have a pcap_findalldevs() function. I
am working on a ctypes-based workaround that mimic this function by
directly calling getifaddrs(). As of today, if you do not have a
default route, you will need to set conf.iface yourself otherwise
Scapy will use lo0.

Thanks,
Guillaume

--
Guillaume Valadon / ギョーム バラドン
***@hongo.wide.ad.jp




---------------------------------------------------------------------
To unsubscribe, send a mail to scapy.ml-***@secdev.org
Guillaume Valadon / ギョーム バラドン
2008-01-25 10:15:12 UTC
Permalink
Hi,
Post by Guillaume Valadon / ギョーム バラドン
$ hg clone http://hg.natisbad.org/scapy-bpf
I am looking for beta testers especially under OpenBSD and NetBSD.
So far, I tested it under OSX 10.4 and 10.5; FreeBSD 5, 6 and 7;
NetBSD 4.0; and OpenBSD 4.2.

Note that on OpenBSD, Scapy does not behave exactly as on other
platforms as the libpcap do not have a pcap_findalldevs() function. I
am working on a ctypes-based workaround that mimic this function by
directly calling getifaddrs(). As of today, if you do not have a
default route, you will need to set conf.iface yourself otherwise
Scapy will use lo0.

Thanks,
Guillaume

--
Guillaume Valadon / ギョーム バラドン
***@hongo.wide.ad.jp




---------------------------------------------------------------------
To unsubscribe, send a mail to scapy.ml-***@secdev.org

Loading...