View Full Version : how to recieve all packets coming to machine??
shady_Dev
03-27-2008, 08:41 AM
Hi,
I need to write a code which receives all the packets received on the network interface of my machine
i.e. my code will create a copy of all the packets and then analyze the packets and then will drop or forward the packet to the application to which it was headed to.
please suggest any tutorial links or any other information regarding this .
Thanks in advance!!
matsp
03-27-2008, 08:45 AM
To receive _ALL_ packets, you'll need to set the network-card into "promiscuous mode" - this means that it will accept all packages.
I have no further suggestions as to how you receive all packets into a user-level application, but I'm pretty sure there are "net filtering" applications out there that have suitable examples.
Are you trying to write your own firewall, or doing something else?
--
Mats
shady_Dev
03-27-2008, 09:40 AM
Thanks for your quick reply..
I basically want to parse the content of all the HTTP packets received at the interface of the machine and then allow or disallow that packet to go its destined application.I hope now you understood wat m looking for.Plz help me sir !!
matsp
03-27-2008, 09:43 AM
So you need some sort of HTTP proxy server to do that - there should be Open Source proxy servers on the web.
However, the principle is pretty simple (if you know how to write socket programs in general, if that's not known to you, then you need to practice that first): Listen to a port which will make a http request, then send that out on a different port, receive the answer and filter as appropriate.
--
Mats
shady_Dev
03-27-2008, 10:18 AM
I did nt get what you intend to say:
Let mw elaborate first what i wan t to do.For example i surfing internet then i try to open some website then my browser [which is of course HTTP client] sends request to the web site and then my machine receives the HTTP reply on its interface .I need to filter out this particular packet received and then allow or disallow the browser from receiving this packet.I hope i m able to deliver what i really want to do.And yes i want my application code to run on the same machine on which my browser is running
so i dont need a proxy server.
Please suggest how to do this task and how to allow and disallow the browser from receiving the packets.
Thanks for help!!!!
39ster
03-28-2008, 08:40 PM
Actually what you're looking for is a proxy server. You run the proxy server on the same machine as the web browser, and set the proxy settings to 127.0.0.1:8080 (or whatever port it will run on). This channels all packets to the proxy server (a local proxy server, not remote proxy server) and if you have the source code to this proxy server, you can program it to block/modify packets.
shady_Dev
03-29-2008, 10:21 AM
Thank you very much sir.I finally got wats the exact solution.
Thank you once again.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.