summaryrefslogtreecommitdiff
path: root/other/tsig/shellcode/shellcode.c
diff options
context:
space:
mode:
authorRoot THC2026-02-24 12:42:47 +0000
committerRoot THC2026-02-24 12:42:47 +0000
commitc9cbeced5b3f2bdd7407e29c0811e65954132540 (patch)
treeaefc355416b561111819de159ccbd86c3004cf88 /other/tsig/shellcode/shellcode.c
parent073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff)
initial
Diffstat (limited to 'other/tsig/shellcode/shellcode.c')
-rw-r--r--other/tsig/shellcode/shellcode.c48
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
10extern void cbegin ();
11extern void cend ();
12
13
14int
15main (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