scapy

Scapy forwarding packages

你离开我真会死。 提交于 2019-12-10 10:05:53
问题 I'm just learning python with scapy. I read and use the book "Network Hacks - Intensivkurs - Angriff und Verteidigung mit Python" (German). I would like to try a man in the middle attack by using arp-spoofing. I have My Computer, the victim (my raspberry pi) and the standard gateway. To spoofing, i use a code snippet from the book #!/usr/bin/python import sys import time from scapy.all import sniff, sendp, ARP, Ether if len(sys.argv) < 3: print sys.argv[0] + " <target> <spoof_ip>" sys.exit(0)

Specify timestamp on each packet in Scapy?

爱⌒轻易说出口 提交于 2019-12-10 09:31:50
问题 With Scapy, when I create a packet and write it to a pcap file, it sets the timestamp of the packet to the current time. This is my current usage. 1335494712.991895 being the time I created the packet: >>> a = Ether()/IP(src='1.1.1.1',dst='2.2.2.2')/TCP(sport=1337,dport=31337) >>> wrpcap('single-tcp-packet.pcap', a) # tcpdump -tt -r single-tcp-packet.pcap reading from file single-tcp-packet.pcap, link-type EN10MB (Ethernet) 1335494712.991895 IP 1.1.1.1.menandmice-dns > arennes-651-1-107-2.w2

sending ICMP packets in scapy and choosing the correct interface

一个人想着一个人 提交于 2019-12-10 03:50:57
问题 Can we use the srp() function for a Layer 3 ICMP packet? I see that when we craft an ICMP echo-request packet and use the sr() to send/receive, we do NOT see it getting sent out of the interface , hence no response from the destination. But the same packet if we use the srp() function we see the response. When should we use sr() and when srp()? In the documentation it states sr() is to be used for L3 packet and srp() to be used for L2? But in my case I am not sure why sr() is not working for

Scapy.all import * does not work

那年仲夏 提交于 2019-12-10 02:45:02
问题 So, I wrote a little script in Ubuntu for scapy. #!/usr/bin/env python import sys #from scapy.all import * try import scapy except ImportError: del scapy from scapy import all as scapy i= IP() t= TCP() i.dst='192.168.56.100' t.dport=22 pakket=i/t answered,unanswered=sr(pakket) answered.nsummary() i wrote the 'try' because of another topic here (tried it as a solution). My current output with this code is the following Traceback (most recent call last): File "./scapy.py", line 5, in <module>

python/scapy DNS sniffer and parser

本小妞迷上赌 提交于 2019-12-09 22:55:26
问题 I have python/scapy sniffer for DNS. I am able to sniff DNS messages and get IP/UDP source and destination IP address and ports but I have problems parsing DNS part I would appreciate some help or solution to work this out. #!/usr/bin/env python from scapy.all import * from datetime import datetime import time import datetime import sys ############# MODIFY THIS PART IF NECESSARY ############### interface = 'eth0' filter_bpf = 'udp and port 53' # ------ SELECT/FILTER MSGS def select_DNS(pkt):

Scapy and Python 3.2

橙三吉。 提交于 2019-12-09 15:39:51
问题 Will Scapy be compatible with Python 3.2? I've been trying to find some info on how it performs, since the Scapy website has rather scarce (if any) info on Python 3.X compatibility, and I didn't come up with anything informative. Has anyone tried using it on Python 3.X and how did it perform? 回答1: Intrusive edit: Many answers below are outdated. Scapy now supports Python 3. See https://github.com/secdev/scapy Python 3 compatibility for parts of Scapy seems to have been attempted. It's perhaps

Scapy installation fails due to invalid token

北城余情 提交于 2019-12-09 07:30:28
问题 I have recently taken up learning networks, and I want to install scapy. I have downloaded the latest version (2.2.0), and have two versions of python on my computer- 2.6.1 and 3.3.2. My OS is windows 7 64 bit. After extracting scapy and navigating to the correct folder in the terminal, I was instructed to run "python setup.py install". I get the following error- File "setup.py", line 35 os.chmod(fname,0755) ................................^ ......................invalid token (dots for

Modify with scapy and netfilterqueue

谁说我不能喝 提交于 2019-12-08 19:25:32
I'm running Debian with Python 2.7, and scapy/netfilterqueue. I've added the following in my iptables: iptables -A OUTPUT -p tcp --dport 5678 -j NFQUEUE --queue-num 1 And this is my code for getting HTTP packages and changing URL and PORT: #! /usr/bin/env python2.7 from scapy.all import * from netfilterqueue import NetfilterQueue def modify(packet): pkt = IP(packet.get_payload()) if pkt.haslayer(TCP) and pkt.getlayer(TCP).dport == 5678: pkt.dst = 'https://my-secure-domain.com' pkt.dport = 443 del pkt[IP].chksum del pkt[TCP].chksum packet.set_payload(str(pkt)) packet.accept() nfqueue =

RadioTap headers in scapy

丶灬走出姿态 提交于 2019-12-08 16:01:37
I'm trying to send and receive packets with scapy and read the RadioTap Header. The wireless adapter (and driver) is able to handle those headers, but I can't seem to get them. Whenever I send a normal packet in scapy, is does not contain such a header (thus, sniffing packets and checking one with pkt.haslayer(RadioTap) returns "0", and I am not able to display the header like with pkt[RadioTap].show() ). If I explicitely construct my packets with a RadioTap header (like in a pkt = RadioTap() and view it, I can get a RadioTap header, but it is empty. After sending it and receiving it, I can

Python scapy import error

人走茶凉 提交于 2019-12-08 15:59:21
问题 If I include following line in my python source file from scapy.all import * I get this error from scapy.all import * ImportError: No module named all Which is true in Console and IDLE, but not eclipse. I am very much confused why this is happening. Can some one help me out? 回答1: I think this may be a problem with your version: If you are using Scapy v1.X: from scapy import * Otherwise, with Scapy V2.X+ from scapy.all import * Is the way to go. Hope that helps! 回答2: If scapy is not installed