diff options
Diffstat (limited to 'other/shellkit/shellcode.h')
| -rw-r--r-- | other/shellkit/shellcode.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/other/shellkit/shellcode.h b/other/shellkit/shellcode.h new file mode 100644 index 0000000..02e090c --- /dev/null +++ b/other/shellkit/shellcode.h | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | |||
| 2 | /* shellcode.h - shellcode structure and function definitions | ||
| 3 | * | ||
| 4 | * team teso | ||
| 5 | */ | ||
| 6 | |||
| 7 | #ifndef SHELLCODE_H | ||
| 8 | #define SHELLCODE_H | ||
| 9 | |||
| 10 | |||
| 11 | /* (nop_gen) function type which will generate a nop space: | ||
| 12 | * parameters: unsigned char *dest, unsigned int dest_len | ||
| 13 | * | ||
| 14 | * will generate no more than dest_len bytes of nop space. the length | ||
| 15 | * is rounded down to a multiple of arch_codelen, so for risc archs be | ||
| 16 | * sure dest_len % arch_codelen is zero | ||
| 17 | * | ||
| 18 | * return the number of nop bytes generated (not the instruction count) | ||
| 19 | * | ||
| 20 | * XXX: name your functions <arch>_nop | ||
| 21 | */ | ||
| 22 | typedef unsigned int (* nop_gen)(unsigned char *, unsigned int, | ||
| 23 | unsigned char *, int); | ||
| 24 | |||
| 25 | /* helper macro to set individual bits | ||
| 26 | */ | ||
| 27 | #define BSET(dest, len, val, bw) { \ | ||
| 28 | dest &= ~(((unsigned char) ~0) >> bw); /* clear lower bits */ \ | ||
| 29 | dest |= val << (8 - bw - len); /* set value bits */ \ | ||
| 30 | bw += len; \ | ||
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | typedef struct { | ||
| 35 | char * code_string; /* description string of the code */ | ||
| 36 | unsigned int code_len; /* length of code in bytes */ | ||
| 37 | unsigned char * code; /* code byte array */ | ||
| 38 | } shellcode; | ||
| 39 | |||
| 40 | |||
| 41 | typedef struct { | ||
| 42 | char * arch_string; /* description string of this arch */ | ||
| 43 | unsigned int arch_codelen; /* minimum instruction length */ | ||
| 44 | nop_gen arch_nop; /* nop space generation function */ | ||
| 45 | shellcode ** arch_codes; /* shellcode array for this arch */ | ||
| 46 | } arch; | ||
| 47 | |||
| 48 | |||
| 49 | unsigned long int | ||
| 50 | random_get (unsigned long int low, unsigned long int high); | ||
| 51 | |||
| 52 | void | ||
| 53 | random_init (void); | ||
| 54 | |||
| 55 | int | ||
| 56 | bad (unsigned char u); | ||
| 57 | |||
| 58 | int | ||
| 59 | badstr (unsigned char *code, int code_len, unsigned char *bad, int bad_len); | ||
| 60 | |||
| 61 | #endif | ||
| 62 | |||
