views:

102

answers:

3

Hi, Is there a way to control the data coming from the internet from specific address through the network card before it received by the kernel of the operating system using C++ or any language?

In another word, Is there a way to access OSI Seven Layer Model using C++ to control the data passing through any layer of the seven layer or they are just logically implemented.

In case they are not logically implemented and you can access I want to access the packages passing the physical layer that received from specific address and do some operation before they move to the next layer.

also is there any simulation software for OSI?.

+1  A: 

Are you asking if an untrusted application can control what the operating system sees coming from the network?

The answer should be obvious.

Most operating systems provide interfaces to access the raw data coming off the network, and you should use those, rather than trying to wedge yourself between the network card and the operating system.

Also, C++ != C#. Not even close.

Anon.
+2  A: 

Device driver is what sits between between hardware and kernel so this is your only choice. It depends of the OS but one can write a device driver in C++ for all the major ones. Be ready to encounter plain C interface though.

Oleg Zhylin
The OP will need a kernel module matter what, this is the right answer.
Dr. Watson
also, the implementation will vary greatly depending on the underlying OS. there will not be one single implementation working on every platform.
Adrien Plisson
+1  A: 

You could conceivably create a layered service provider that can intercept data by inserting itself onto the winsock stack, but this won't short-circuit the data going through the kernel and the NDIS layer in windows. Your only real solution here would be a device driver. Also, there are some network cards that implement their own TCP/IP stack in hardware and you can communicate with those directly however these are not very common. Any of these approaches is not trivial and you're looking at a lot of kernel-mode C. If you're not comfortable with that, you shouldn't be trying this.

You could also consider using winpcap as this would give you a lot of the functionality that you need. http://www.winpcap.org/devel.htm

Jeff Tucker
+1 for winpcap; there's also libpcap (of which winpcap is a port) for Unix/Linux. That'll get you the packets off the wire, but they still get passed directly to the IP stack as well. I don't know if there's a way to use pcap to intercapt the packets, modify them and then pass them up the stack, which is what it sounds like the OP wants.
ceo