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
96 string &req)
97 {
98 struct sockaddr_in sin;
99 SOCKET sock = 0;
100 bool vuln = false;
101 char *buf = NULL;
102 int ret = 0;
103
104
buf = new char[bufsize];
105 if(buf == NULL)
106 {
107 printf("\r\n*** memory allocation error (new char[%d] failed).\r\n”,
bufsize);
108 return(false);
109 }
110
111
sock = socket(AF_INET, SOCK_STREAM, 0);
112 if(sock < 0)
113 {
114 delete buf;
115 printf("\r\n*** error connecting to target for this request (socket()
failed).\r\n”);
116 return(false);
117 }
118
119
memset(&sin, 0x0, sizeof(sin));
120 sin.sin_family = AF_INET;
121 sin.sin_port = htons(port);
122 sin.sin_addr.s_addr = addr;
123
124
// connect to remote TCP port
125 ret = connect(sock, (struct sockaddr *) &sin, sizeof(sin));
126 if(ret < 0)
127 {
128 delete buf;
129 printf("\r\n*** ...
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