-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathShellcoders08sampleprogram11.c
More file actions
42 lines (34 loc) · 968 Bytes
/
Shellcoders08sampleprogram11.c
File metadata and controls
42 lines (34 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
The Shellcoder's Handbook: Discovering and Exploiting Security Holes
Jack Koziol, David Litchfield, Dave Aitel, Chris Anley,
Sinan Eren, Neel Mehta, Riley Hassell
Publisher: John Wiley & Sons
ISBN: 0764544683
Chapter 8: Windows Overflows
Sample Program #11
Please send comments/feedback to jack@infosecinstitute.com or visit http://www.infosecinstitute.com
*/
#include <stdio.h>
#include <windows.h>
unsigned char buffer[32]="";
FARPROC mprintf = 0;
FARPROC mstrcpy = 0;
int main(int argc, char *argv[])
{
HMODULE l = 0;
l = LoadLibrary("msvcrt.dll");
if(!l)
return 0;
mprintf = GetProcAddress(l,"printf");
if(!mprintf)
return 0;
mstrcpy = GetProcAddress(l,"strcpy");
if(!mstrcpy)
return 0;
(mstrcpy)(buffer,argv[1]);
__asm{ add esp,8 }
(mprintf)("%s",buffer);
__asm{ add esp,8 }
FreeLibrary(l);
return 0;
}