Skip to main content

Packet crafting

More
19 years 7 months ago #5306 by cybersorcerer
I was wondering if anyone could point me a good linux socket tutorial that will give me the basics on how to create my own crafted packets. Try not to get the wrong idea, this is purely because I want to satisfy my own curiousity. I do have SOME experience with C as well as other random programming languages. Programming has always been a tough subject for me to grasp as it takes a lot of abstract lines of thinking and isn't always as logical as many people make it.

So by saying that, direct me towards a tutorial that doesnt assume a lot and has applicable examples. Thanks in advance for whomever can find me one. :D

"He who breaks something to find out what it is, has left the path of wisdom."

Gandalf the Grey
More
19 years 7 months ago #5311 by KiLLaBeE
Replied by KiLLaBeE on topic Re: Packet crafting
Socket Programming:
www.scit.wlv.ac.uk/~jphb/comms/sockets.html
www.fortunecity.com/skyscraper/arpanet/6/cc.htm

If you're looking to learn c/c++, this site has a pretty good quantity of c++ tutorials, along with tutorials of other languages, astalavista.com/index.php?section=dir&id=119

Fallenzer0 posted this link a few weeks ago: www.comms.scitech.susx.ac.uk/fft/
it also has lots of e-books, and e-books usually have applicable examples

I thought myself a few languages, but then I lost interest, maybe I was learning from the wrong place because I couldn't relate what I was learning to what I wanted to do. Programming isn't for everyone. Some are born programmers, it comes easy to some, and some struggle to learn it.

In my opinion, for c/c++ its good to learn the purposes and functions of a good quantity of header files, because most c/c++ tutorials only tell you about the basic ones, and not those that you can do "cool" things with. Checking out a book in the library is also a good idea, I used Teach Yourself C++ in 21 Days.

Hope that helps

::::Gees, the guy asks a simple question and I answer him in essay form :-p :::::
More
19 years 7 months ago #5313 by sahirh
Replied by sahirh on topic Re: Packet crafting
Linux socket programming in C is 99% the same as in Windows, don't use any of the functions starting with WSA (you wont need WSAstartup, WSAsocket etc), your basic functions will be exactly the same :

socket
accept
bind
recv
send
sendto
gethostbyname


etc
etc

The packet structures are also still the same

sockaddr_in
in_addr
hostent

etc
etc

As far as the header files go, you'll want to include
#include <sys\socket.h>
#include <netinet\in.h>
#include <netdb.h>

Just grab yourself the code for any small client-server application and you'll understand instantly.

Since you're talking about crafting your own packets you will have to use SOCK_RAW when you declare the socket. Then you will have to create structures for the IP header and TCP header and fill these up with the values you want.

If you need more help, let me know I will post sample code for you to get started.

Hmmm socket programming 101 ;)

Cheers,

Sahir Hidayatullah.
Firewall.cx Staff - Associate Editor & Security Advisor
tftfotw.blogspot.com
More
19 years 7 months ago #5319 by cybersorcerer
Replied by cybersorcerer on topic Re: Packet crafting
Killa- Thanks for those links, very informative. But, I decided to pick up a book specifically for sooket programming. Im more of a visual learner so diagrams would be helpful. any suggestions?

P.S. essay form is a hell of a lotter easier to read :-P

Sahirh- Well Im always for seeing another persons style of code (no hurt in taking direction from somelses style of coding), so if you're up to feel free 8)

"He who breaks something to find out what it is, has left the path of wisdom."

Gandalf the Grey
Time to create page: 0.137 seconds