diff options
Diffstat (limited to 'other/tsig/shellcode/shellcode.c')
| -rw-r--r-- | other/tsig/shellcode/shellcode.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/other/tsig/shellcode/shellcode.c b/other/tsig/shellcode/shellcode.c new file mode 100644 index 0000000..0239f12 --- /dev/null +++ b/other/tsig/shellcode/shellcode.c | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* shellcode extraction utility, | ||
| 2 | * by typo / teso, small mods by scut. | ||
| 3 | */ | ||
| 4 | |||
| 5 | |||
| 6 | #include <stdio.h> | ||
| 7 | #include <stdlib.h> | ||
| 8 | #include <ctype.h> | ||
| 9 | |||
| 10 | extern void cbegin (); | ||
| 11 | extern void cend (); | ||
| 12 | |||
| 13 | |||
| 14 | int | ||
| 15 | main (int argc, char *argv[]) | ||
| 16 | { | ||
| 17 | int i; | ||
| 18 | unsigned char * buf = (unsigned char *) cbegin; | ||
| 19 | unsigned char ex_buf[1024]; | ||
| 20 | |||
| 21 | |||
| 22 | printf ("/* %d byte shellcode */\n", cend - cbegin); | ||
| 23 | printf ("\""); | ||
| 24 | for (i = 0 ; buf < (unsigned char *) cend; ++buf) { | ||
| 25 | |||
| 26 | printf ("\\x%02x", *buf & 0xff); | ||
| 27 | |||
| 28 | if (++i >= 12) { | ||
| 29 | i = 0; | ||
| 30 | printf ("\"\n\""); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | printf ("\";\n"); | ||
| 34 | |||
| 35 | printf("\n"); | ||
| 36 | |||
| 37 | if (argc > 1) { | ||
| 38 | printf ("%02x\n", ((unsigned char *) cbegin)[0]); | ||
| 39 | printf ("%02x\n", ex_buf[0]); | ||
| 40 | memcpy (ex_buf, cbegin, cend - cbegin); | ||
| 41 | printf ("%02x\n", ex_buf[0]); | ||
| 42 | |||
| 43 | ((void (*)()) &ex_buf)(); | ||
| 44 | } | ||
| 45 | |||
| 46 | exit (EXIT_SUCCESS); | ||
| 47 | } | ||
| 48 | |||
