Skip to Main Content
Sockets, Shellcode, Porting, and Coding: Reverse Engineering Exploits and Tool Coding for Security Professionals
book

Sockets, Shellcode, Porting, and Coding: Reverse Engineering Exploits and Tool Coding for Security Professionals

by James C Foster
April 2005
Intermediate to advanced content levelIntermediate to advanced
700 pages
20h 39m
English
Syngress
Content preview from Sockets, Shellcode, Porting, and Coding: Reverse Engineering Exploits and Tool Coding for Security Professionals
14
15
#include <winsock2.h>
16 #include <ws2tcpip.h>/* required for IP_HDRINCL option */
17
18
#else
19
20
/* UNIX header files */
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <netinet/in.h>
24
25
#endif
26
27
#include <stdio.h>
28
29
int
30 main(void)
31 {
32 #ifdef WIN32
33 WSADATA wsa; /* used by WSAStartup() */
34 SOCKET sd = 0;
35 #else
36 int sd = 0;
37 #endif
38
39
int flg = 1;
40 int ret = 0;
41
42
/* must initialize winsock if on win32 platform */
43 #ifdef WIN32
44 memset(&wsa, 0x0, sizeof(WSADATA));
45
46
if(WSAStartup(MAKEWORD(2, 0), &wsa) != 0x0)
47 {
48 printf("WSAStartup() failed.\n");
49 return(1);
50 }
51 #endif
52
53
/* create TCP raw socket */
54 sd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
55 /* if Win32, check for INVALID_SOCKET constant */
56 #ifdef WIN32 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

32/64-Bit 80x86 Assembly Language Architecture

32/64-Bit 80x86 Assembly Language Architecture

James Leiterman

Publisher Resources

ISBN: 9781597490054