packet interceptor

transfernly's Avatar, Join Date: Dec 2009
Go4Expert Member
hello all I am looking for a sample C code for packet interceptor....

Any help is appreciated

Thank you
0
karthigayan's Avatar, Join Date: Feb 2010
Go4Expert Member
please explain your requirement briefly .
0
transfernly's Avatar, Join Date: Dec 2009
Go4Expert Member
receive the packet as such and modify its contents and then forward it..its a part of my research work.....change few field details and den forward it my another code(which acts as a server)....and do let me know if its possible or not

Thank you
0
karthigayan's Avatar, Join Date: Feb 2010
Go4Expert Member
You can do it . Normally the whole packet will store as a structure .So when you receive a socket you can just change the particular structure member ( part of the packet ) then you can forward it .
0
transfernly's Avatar, Join Date: Dec 2009
Go4Expert Member
when i have done simple client server programme of data excahnge i used to receive only the data part(payload)

but how to get the entire packet assuch...do u have a sample snippet
0
karthigayan's Avatar, Join Date: Feb 2010
Go4Expert Member
I think you are using send and receive functions in you socket program.Instead try with sendto ,recvfrom functions you will get the address and port of the other informations in the packet .

man recvfrom
man sendto
0
transfernly's Avatar, Join Date: Dec 2009
Go4Expert Member
yeah....u r right am using send and receive functions....i am using visual studio ..am not coding in linux.....i think i get all the individual fields of the packet ...i think i will be able to get only source ip...port etc etc..but i want the packet right from IP header....

in which structure i receive the details.....and can i send the same packet as such to another server