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
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <netinet/in.h>
21
22
#endif
23
24
#include <stdio.h>
25
26
/* local port to bind to */
27 #define LOCAL_PORT 1234
28
29
/* receive buffer length */
30 #define BUF_LEN 1024
31
32
int
33 main(void)
34 {
35 #ifdef WIN32
36 WSADATA wsa; /* used by WSAStartup() */
37 SOCKET sd = 0;
38 #else
39 int sd = 0;
40 #endif
41
42
struct sockaddr_in sin ;
43 char buf[BUF_LEN];
44 int ret = 0;
45
46
/* must initialize winsock if on win32 platform */
47 #ifdef WIN32
48 memset(&wsa, 0x0, sizeof(WSADATA));
49
50
if(WSAStartup(MAKEWORD(2, 0), &wsa) != 0x0)
51 {
52 printf("WSAStartup() failed.\n");
53 return(1);
54 }
55 #endif
56
57
/* create UDP socket */
58 sd = socket(AF_INET, SOCK_DGRAM, 0);
59 /* if Win32, check for INVALID_SOCKET constant */ ...
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