LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Need to "cheat" my router to make it think IP X.X.X.X is through another gateway. (http://www.linuxquestions.org/questions/programming-9/need-to-cheat-my-router-to-make-it-think-ip-x-x-x-x-is-through-another-gateway-4175440443/)

franmf 12-07-2012 10:30 AM

Need to "cheat" my router to make it think IP X.X.X.X is through another gateway.
 
Hi, I'm finishing my degree project. What I have to do left is to "cheat" my router in order to make it think IP X.X.X.X is through another gateway.

I'm doing a sniffer in C, which has to sniff every packet passing through the router, and detect where they go to. If they go to any PC in the private net, and that PC is asleep, the sniffer itself WAKES IT UP.

so, supposing I have the next net:

http://img443.imageshack.us/img443/999/sinttulo2de.png

If PC4 fells asleep, when PC3 sends a packet to PC4, this frame doesn't go to the router, because S has its own arp table and knows where has to go the packet to. If PC4 is asleep and PC3 sends a packet to PC4, my sniffer will never detect that packet. If I make that broadcast, S will think PC4 is going UP, so will send the packet from PC3 to PC4 up there, and the router will sniff it.

You have to know that the proccessor is in the router and my sniffer is executed in that proccessor. That's the reason why I need to send the packets up there.

So my question is, how can I create a Broadcast packet? and how can I send it? thank you.

Sorry for my english, is quite hard for me to explain such things. Thanks in advanced.

edit: the draw cant be seing as expected. Doing a new one.

tallship 12-08-2012 06:43 AM

Does this help?

Code:

..........................ROUTER--------internet
.............................|
..............---------------------------------
...............|...........|.............|............|
.............PC1........PC2...------S-----....PC5
.................................|.............|
...............................PC3 ........PC4
S=switch.


franmf 12-08-2012 07:59 AM

http://img443.imageshack.us/img443/999/sinttulo2de.png

the draw was not important, sorry anywany

eSelix 12-08-2012 08:41 AM

Can you specify, that you can do anything with this PC which start communication (for example PC3) or you can only make changes on router? If latter then you can't force PC3 to send broadcast or send packets to computer on the same network through router.

franmf 12-08-2012 12:29 PM

Quote:

Originally Posted by eSelix (Post 4845132)
Can you specify, that you can do anything with this PC which start communication (for example PC3) or you can only make changes on router? If latter then you can't force PC3 to send broadcast or send packets to computer on the same network through router.

I'll explain the best I can. the router has it's own arp table, and the router has a different one. The arp table knows which IPs are connected to which gateway. So if the switcher(the arp table from the switcher, I mean) think PC4 is through gateway 1 it will send the packets to that gateway. If that happens, the packets will never pass through the router, which is the same, through the proccessor, where my sniffer is executing.

If each time PC4 fells asleep, the router detects it (I've already done that) and sends a broadcast to any PC connected in the private net making them think that PC4 is himself. So each time any PC will send a packet to PC4, they will guide them to the router and not to the real gateway and my sniffer will be able to detect that any PC is sending packets to PC4, so it can wake PC4 up. Once a packet arrives to the router asking if he is PC4, and the router says ( NO, I AM THE ROUTER STUPID :P ), then PC3 will send a broadcast asking who is really PC4.

Of course, that first packets will get lost, and the PCX will have to send them again, but that is not a problem.

edit: sot what I need is to know HOW can I create that broadcast packet making all PCs to know that PC4 is the router, when it isn't.

sarin 12-08-2012 08:32 PM

I did not understand your questions well. But, is this what you want? http://en.wikipedia.org/wiki/ARP_spoofing

franmf 12-09-2012 10:00 AM

I think that is not what I want.

To sum up, I need to send a broadcast where I can modify IP SOURCE field.

franmf 12-11-2012 11:48 AM

Does anyone know how to create a broadcast packet from a raw socket? maybe I'll be able to do something from that

eSelix 12-11-2012 06:47 PM

You create broadcast packet by changing destination IP to broadcast IP, for example 192.168.1.255 in 192.168.1.0/24 network and setting all "1" on MAC address. But I don't think it will help you. If you change IP, then you lose information about real destination.

If you want exactly that: "make all PCs and switches on network which want to send packets to PC4 - send it to Router" then ARP spoofing is the answer. This is not a proper way to accomplish your task, because for example some PCs might be protected against address spoofing or alert their administrators.


All times are GMT -5. The time now is 01:07 PM.