Packet Captureing/Sniffing w/ BSD Sockets
I'm looking for resources to create a simple packet capturing app...
Platform = MacOSX (BSD Sockets) Goal = Capture traffic to/from my PC (looking for some specific info from port X via TCP in this case and then do something with it) creating the socket is easy and processing is easy but how do i configure the socket to listen? I think my problem is either in bind() or ioctl() but it is not an easy thing to search for... (lots of linux results and linux does things differently (I'll add that later =) Note: I would like to stay away from 3rd party libraries. |
BSD Sockets = berkley sockets which i believe besides a very few things is compatiable around most os's(including winsock as its based on bsd)
http://beej.us/guide/bgnet/output/html/index.html <edit> If there are any differences between linux and mac implementation of bsd I would appreciate a point in the right direction; as I'm currently making a cross platfrom app which used this. cheers </edit> |
Unfortunately the link doesn't help me much in this case... I will recheck the IOCTL() functions just in case...
Linux, Mac, Windows... Most functions are the same... accept() connect() recv() recvfrom() etc... There are a few differences but most are *nix to win... (I'll post this just in case it may save you some time :-) Code:
#ifndef WIN32 As far as the differences from what I am doing... It looks like Linux and BSD use different includes and variables.... I was going to give an example, but can't find them ATM... Linux allows for a lower level (kernel I think) workings with the packets than BSD Sockets would allow. (I haven't checked windows yet) I am not findng much information on how to use: Code:
int s = socket(PF_INET, SOCK_RAW, IPPROTO_RAW); |
thanks for the reply, but it seems ive got most of them an ones which are not in a header are #ifdef, for the likes of close and closesocket.
Code:
#ifdef WINDOWS_BUILD |
Quick Update:
http://www.machacking.net/forums/ind...23&hl=sock_raw Code:
int s = socket(PF_INET, SOCK_RAW, 0); |
Does anyone know how to get TCP/UDP to work with BSD Sockets? (even with Winsock) -- or perhaps where to go to ask =)
|
On Linux >= 2.2 you use PF_PACKET, SOCK_PACKET otherwise. I suggest you browse the libpcap code, you may find the MacOS X specifics there
|
Quote:
ya... think i must go through libpcap code... not my pref though =P Thanks! |
Quote:
|
All times are GMT -5. The time now is 02:28 AM. |