scapy

Error writing scapy RTP packet with payload type to pcap

南笙酒味 提交于 2020-01-05 19:45:12
问题 When I create an RTP packet in scapy with the following code, I get an error: "TypeError: clone_with() got multiple values for keyword argument 'payload'" from scapy.all import IP, UDP, RTP, Ether from scapy.utils import PcapWriter pktdump = PcapWriter("banana.pcap", append=False, sync=True) rtp = { "sequence": 1, "timestamp": 1, "marker": 1, "payload": 17 } pkt = Ether()/IP()/UDP(sport=12345,dport=12346)/RTP(**rtp) pktdump.write(pkt) but removing payload works. rtp = { "sequence": 1,

Error writing scapy RTP packet with payload type to pcap

久未见 提交于 2020-01-05 19:45:11
问题 When I create an RTP packet in scapy with the following code, I get an error: "TypeError: clone_with() got multiple values for keyword argument 'payload'" from scapy.all import IP, UDP, RTP, Ether from scapy.utils import PcapWriter pktdump = PcapWriter("banana.pcap", append=False, sync=True) rtp = { "sequence": 1, "timestamp": 1, "marker": 1, "payload": 17 } pkt = Ether()/IP()/UDP(sport=12345,dport=12346)/RTP(**rtp) pktdump.write(pkt) but removing payload works. rtp = { "sequence": 1,

Packet building with Scapy and Gevent

无人久伴 提交于 2020-01-05 08:54:23
问题 I'm trying to write a program, which works multithread using gevent. The program will generate a packet, build it with scapy and then send it using raw_socket. Like so: def worker(...): s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) s.bind((iface, socket.htons(0x0800))) packet = fragment(Ether()/IP(dst=dst, src=str(src))/TCP(dport=dport, sport=sport)/pay_load, fragsize=100) data = [piece.build() for piece in packet] for packet in data: s.send(packet) The code run just fine in sequence,

Understanding Python struct.pack and binary input

橙三吉。 提交于 2020-01-05 04:01:09
问题 The following function accepts a binary 4 byte key for key . buf is binary input which is xor'd against the 4 byte key. def four_byte_xor(buf, key): #key = struct.pack(b">I", key) # removed for binary processing buf = bytearray(buf) for offset in range(0, len(buf), 4): for i, byte in enumerate(key): buf[offset + i] = chr(buf[offset + i] ^ ord(byte)) return str(buf) I removed key = struct.pack(b">I", key) from four_byte_xor() in order to specify binary data via str(p.payload.payload.payload)[

scapy - srp doesnt send my packet to the correct network interface

China☆狼群 提交于 2020-01-05 03:46:23
问题 I work on windows 10 machine and I am using scapy for some project I am doing. When I use the sniff function to sniff packets form my ethernet interface it is working as expected but when I use srp1 to send packet from the same interface it send my packet trough my vEthernet interface and not trough my physical ethernet interface(so the packet never gets to it destination). Here is my code of sniff versus srp1: a = sniff(count = 1, iface = "Ethernet") p = srp1(pkt, iface = "Ethernet") as you

Scapy sniff() in a class that subclassess threading.Thread()

风格不统一 提交于 2020-01-03 03:59:07
问题 I've got a strange issue with the Scapy sniff() function. This is how my class is looking: from scapy.all import * import sys import datetime import Queue from threading import Thread class packet_sniffer(Thread): def __init__(self,pass_queue): super(packet_sniffer,self).__init__() print 'Packet sniffer started' self.queue=pass_queue self.device_dict={} self.not_an_ap={} def PacketHandler(self,pkt): if pkt.haslayer(Dot11): sig_str = -(256-ord(pkt.notdecoded[-4:-3])) mac_addr="" ssid="" try:

How do you Identify the interface of a packet while listening to network traffic on all devices?

我的梦境 提交于 2020-01-02 20:09:11
问题 I am writing a python program that needs to listening to traffic on all networking devices and identify packets based on their incoming interface. To listen on all interfaces I started my capture without specify a device, but I am unable to denote the interface of a particular packet. How is this done? 回答1: I assume that the MAC address is sufficient information for you. The first 6 octets of a packet is the destination MAC address, which is immediately followed by the 6 octets of source MAC

Sending DHCP Discover using python scapy

≡放荡痞女 提交于 2019-12-31 15:50:49
问题 I am new to python and learning some network programming, I wish to send an DHCP Packet through my tap interface to my DHCP server and expecting some response from it. I tried with several packet building techniques such a structs and ctypes and ended up with using scapy. Here I am able to send DHCP Packet but unable to get any response from the DHCP server(Analyzed using wireshark and tcpdump)..My packet looked like same as original DHCP packet but failed to get response. Here is my code

Network bridge using Scapy and Python

女生的网名这么多〃 提交于 2019-12-28 18:13:18
问题 I am creating a network bridge that connects two ethernet cards on the same machine. One of the cards is connected to the LAN and the other is connected to a network device. It looks something like this, I am sniffing packets on both the interfaces and then sending them to the other using sendp(x,iface='eth0') for a packet that I sniffed on eth1 and vice versa. I verified the packets at both the interfaces and found them to be correct, but somehow I am unable to get an IP for the device.

使用Scapy向Mininet交换机注入流量 实验记录

僤鯓⒐⒋嵵緔 提交于 2019-12-28 13:40:03
使用Scapy向Mininet交换机注入流量 实验记录 用Python脚本及Scapy库写了一个简单的流量生成脚本,并打算使用该脚本往Mininet中的OpenvSwitch交换机注入流量。拓扑图如下: h1(10.0.0.1) :h1-eth0 <=> s1-eth1: s1 :s1-eth2 <=> h2-eth0: h2(10.0.0.2) 生成流量的目的IP: nw_dst=10.0.0.2/32 ; 注入流量的端口: s1-eth1 ; OVS此时已下好转发该流量的流表,主要作用是匹配该流量的目的IP地址,并转发到s1-eth2口。 然而,脚本往s1-eth1注入的流量全部被交换机丢弃,同时,使用 ovs-ofctl dump-flows s1 查看流表信息发现流表根本没有匹配到该流量。 逐步debug: 1.流量脚本没有问题; 2.下发的流表规则没有问题; 3.Mininet内主机互ping也正常。 随后开始怀疑脚本注入流量的端口不对,使用 ifconfig 查看端口信息,发现s1有三个端口,分别是 s1 , s1-eth1 和 s1-eth2 。 一试,发现当脚本往端口 s1 注入流量时,流量被s1正常转发,流表也有匹配到流量的数据。算是意外的收获,记之。 2018.1. 来源: https://www.cnblogs.com/qq952693358/p