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