Showing posts with label libpcap. Show all posts
Showing posts with label libpcap. Show all posts
Monday, March 14, 2011
Saturday, July 17, 2010
Libpcap in Ubuntu
You can begin by downloading and installing a new Ubuntu VM. Follow my older post for instructions regarding the installation http://zaidmunir.blogspot.com/2010/06/ubuntu-installation-on-virtual-box.html.
Once you are done installing you will need to download and install the libpcap development libraries. In case you need to find them your self, you can use the command to list possible matches:
aptitude search libpcap
You need to install the libpcap-dev package, for this use the command:
sudo apt-get install libpcap-dev
Once you are done installing you will need to download and install the libpcap development libraries. In case you need to find them your self, you can use the command to list possible matches:
aptitude search libpcap
You need to install the libpcap-dev package, for this use the command:
sudo apt-get install libpcap-dev
Friday, July 16, 2010
Making ARP packets
In order to successfully make your ARP request packet, you need to understand the ARP header. You need to declare an appropriate structure for it in your code. Be advised, the ARP header follows immediately after the Ethernet header.
There had been some confusion regarding the values of different fields, please refer to the following screen shot if in confusion. You should be very clear that in order to broadcast the packet on layer 2, you need to adjust the destination MAC in the Ethernet header only, whereas for the value regarding destination hardware address in ARP header, pay special attention to the field destination MAC address in the ARP header in the image attached.

Also observe the total number of bytes received/captured. You will also need to adjust this value accordingly in your code when you send down the packet, you would need to adjust the parameters of pcap_sendpacket (...) accordingly. Refer to my older post for the code related part.Software router
For those students working on software router, you need to be able to capture packets coming on the interface and analyze them as a first step towards your goal. This link is a useful resource.
You should especially look into this.
You should especially look into this.
Wednesday, July 14, 2010
Libpcap
I have written a small sample code to get you started. You can download it here. to compile the code: gcc code.c -lpcap
and then execute the output file as: sudo ./a.out
Here is a code which generates an ICMP packet, you should follow the structure given in this code. Compile and run the code as mentioned above.
and then execute the output file as: sudo ./a.out
Here is a code which generates an ICMP packet, you should follow the structure given in this code. Compile and run the code as mentioned above.
Subscribe to:
Posts (Atom)