packet-capture

Could anyone suggest a good packet sniffer class for c++? [closed]

北城以北 提交于 2019-12-03 09:45:11
Could anyone suggest a good packet sniffer class for c++? Looking for a easy insertable class I can use in my c++ program, nothing complicated. You will never be able to intercept network traffic just by inserting a class into your project. Packet capture functionality requires kernel mode support, hence you will at the very least need to have your application require or install libpcap/WinPcap, as Will Dean pointed out. Most modern Unix-like distributions include libpcap out of the box, in which case you could take a look at this very simple example: http://www.tcpdump.org/pcap.htm If you're

How do I hook the TCP stack in Windows to sniff and modify packets?

喜你入骨 提交于 2019-12-03 04:34:44
问题 I'd like to write a packet sniffer and editor for Windows. I want to able to see the contents of all packets entering and leaving my system and possibly modify them. Any language is fine but I'd like it to run fast enough that it won't burden the system. I've read a little about WinPcap but the documentation claims that you can't use WinPcap to create a firewall because it can't drop packets. What tools will help me write this software? 回答1: Been there, done that :-) Back in 2000 my first

How to send pcap file packets on NIC?

醉酒当歌 提交于 2019-12-03 00:38:55
I have some network traffic captured pcap file and want to send its packets on NIC; is it possible? Is there any application to do this? You should be able to use some kind of replay application like this one (tcpreplay) . bit-twist can do this. just install it and inject your packet like this : # bittwist -i eth0 pcap-file.pcap There is a libpcap/winpcap library, that allows the programmer to send/receive packets and work directly with NDIS-level driver. http://www.winpcap.org Anand Yes there is a way - sending a packet to NIC means injecting it to an interface. You can do this with the help

Python raw socket listening for UDP packets; only half of the packets received

筅森魡賤 提交于 2019-12-03 00:28:26
I am trying to create a raw socket in Python that listens for UDP packets only: import socket s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_UDP) s.bind(('0.0.0.0', 1337)) while True: print s.recvfrom(65535) This needs to be run as root, and creates a raw socket on port 1337, which listens for UDP packets and prints them whenever they are received; no problems there. Now let's make a little client to test if this works: import socket c = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) c.connect(('127.0.0.1', 1337)) c.send('message 1') c.send('message 2') c.send('message 3')

How to use structure with dynamically changing size of data?

霸气de小男生 提交于 2019-12-02 10:14:44
Question for C only, C++ and vectors do not solve problem. I have such structure: typedef __packed struct Packet_s { U8 head; U16 len; U32 id; U8 data; U8 end; U16 crc; } Packet_t, *Packet_p; ( EDIT : U8 is uint8_t (unsigned char) and so on) For example, I've received packet(hex): 24 0B 00 07 00 00 00 AA 0D 16 1C where head = 0x24 len = 0x0B 0x00 id = 0x07 0x00 0x00 0x00 data = 0xAA end = 0x0D crc = 0x16 0x1C I can copy it from incoming buffer like this U8 Buffer[SIZE]; // receives all bytes here memcpy(&Packet, &Buffer, buffer_len); and work futher with it. Is it possible to use my structure

Breaking TLS security by fully recording the handshake

假如想象 提交于 2019-12-02 07:57:52
问题 I have been looking at TLS recently, and I am unsure as to why it is so secure, but probably thanks to a misunderstanding of how it works. But if the entire handshake is recorded, either using a man in the middle attack or a packet sniffer on the target computer, then any of the remaining communication can be decrypted as you would have all the info that the client and the server used to generate the encryption keys. I doubt there would be such a hole in tls, but could anyone tell me how tls

How to check if flag in TCP struct is set?

梦想与她 提交于 2019-12-02 07:30:51
I'm using the pcap C library to read packets. Currently, I use the following to check and see whether a flag in the struct tcphdr (this struct is defined in the netinet/tcp.h library) is set: struct tcphdr *tcp = .... if(tcp->th_flags & TH_SYN) { //SYN FLAG IS SET? } Will this always work for checking if a particular flag is set in the struct? Or is there a better way? Would greatly appreciate any advice/tips :) That looks fine to me. TH_SYN is a single bit, so that expression will be true (nonzero) if that bit is set in th_flags . 来源: https://stackoverflow.com/questions/35388217/how-to-check

Breaking TLS security by fully recording the handshake

微笑、不失礼 提交于 2019-12-02 07:25:06
I have been looking at TLS recently, and I am unsure as to why it is so secure, but probably thanks to a misunderstanding of how it works. But if the entire handshake is recorded, either using a man in the middle attack or a packet sniffer on the target computer, then any of the remaining communication can be decrypted as you would have all the info that the client and the server used to generate the encryption keys. I doubt there would be such a hole in tls, but could anyone tell me how tls defends against this? The critical data sent by the client to the server in the TLS handshake is

How to stop IDM from grabbing video/audio [closed]

喜欢而已 提交于 2019-11-30 19:20:43
Every time a video/audio streaming starts the Internet Download Manager (IDM) feels that there is a multimedia content on the page and allows you to download that multimedia content. I don't think it's possible to prevent IDM from grabbing video/audio but is there a way to fool IDM to get a wrong video instead or make it very hard for IDM to guess which is the real video/audio playing? EDIT: Actually My Question was from the server side point of view not the client running an IDM. So i guess the misunderstanding here is my fault. Many good answers here but not the one i was looking for bh

Get TCP Flags with Scapy

微笑、不失礼 提交于 2019-11-30 07:10:32
问题 I'm parsing a PCAP file and I need to extract TCP flags (SYN, ACK, PSH, URG, ...). I'm using the packet['TCP'].flags value to obtain all the flags at once. pkts = PcapReader(infile) for p in pkts: F = bin(p['TCP'].flags) print F, bin(F), p.summary() # manual flags extraction from F Is there a way to obtain a single TCP flag without manually extract it from packet['TCP'].flags value? 回答1: Normally, the usual way to handle FLAGS is with a bitmap and bitwise operators. If your Packet class doesn