To test it out, let??™s start with the meet.c examplewe introduced in Chapter 6
and then exploited in Linux in Chapter 7. Type in the example or copy it from the Linux
machine you built it on earlier.
C:\grayhat>type hello.c
//hello.c
#include
main ( ) {
printf("Hello haxor");
}
The Windows compiler is cl.exe. Passing the compiler the name of the source file will
generate hello.exe. (Remember from Chapter 6 that compiling is simply the process of
turning human-readable source code into machine-readable binary files that can be
digested by the computer and executed.)
C:\grayhat>cl hello.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
hello.c
Microsoft (R) Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.
/out:hello.exe
hello.obj
C:\grayhat>hello.exe
Hello haxor
Pretty simple, eh? Let??™s move on to build the program we??™ll be exploiting later in the
chapter. Create meet.c from Chapter 6 and compile it using cl.exe.
C:\grayhat>type meet.c
//meet.c
#include
greeting(char *temp1, char *temp2) {
char name[400];
strcpy(name, temp2);
printf("Hello %s %s\n", temp1, name);
}
main(int argc, char *argv[]){
greeting(argv[1], argv[2]);
printf("Bye %s %s\n", argv[1], argv[2]);
}
C:\grayhat>cl meet.
Pages:
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454