diff options
| author | Root THC | 2026-02-24 12:42:47 +0000 |
|---|---|---|
| committer | Root THC | 2026-02-24 12:42:47 +0000 |
| commit | c9cbeced5b3f2bdd7407e29c0811e65954132540 (patch) | |
| tree | aefc355416b561111819de159ccbd86c3004cf88 /other/shellkit/shellcode.c | |
| parent | 073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff) | |
initial
Diffstat (limited to 'other/shellkit/shellcode.c')
| -rw-r--r-- | other/shellkit/shellcode.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/other/shellkit/shellcode.c b/other/shellkit/shellcode.c new file mode 100644 index 0000000..330fe2e --- /dev/null +++ b/other/shellkit/shellcode.c | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | |||
| 2 | /* TODO: better randomness | ||
| 3 | */ | ||
| 4 | |||
| 5 | #include <sys/types.h> | ||
| 6 | #include <time.h> | ||
| 7 | #include <stdio.h> | ||
| 8 | #include <stdlib.h> | ||
| 9 | #include "shellcode.h" | ||
| 10 | |||
| 11 | |||
| 12 | unsigned long int | ||
| 13 | random_get (unsigned long int low, unsigned long int high) | ||
| 14 | { | ||
| 15 | unsigned long int val; | ||
| 16 | |||
| 17 | if (low > high) { | ||
| 18 | low ^= high; | ||
| 19 | high ^= low; | ||
| 20 | low ^= high; | ||
| 21 | } | ||
| 22 | |||
| 23 | val = (unsigned long int) random (); | ||
| 24 | val %= (high - low); | ||
| 25 | val += low; | ||
| 26 | |||
| 27 | return (val); | ||
| 28 | } | ||
| 29 | |||
| 30 | |||
| 31 | void | ||
| 32 | random_init (void) | ||
| 33 | { | ||
| 34 | srandom (time (NULL)); | ||
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | int | ||
| 39 | bad (unsigned char u) | ||
| 40 | { | ||
| 41 | if (u == '\x00' || u == '\x0a' || u == '\x0d' || u == '\x25') | ||
| 42 | return (1); | ||
| 43 | |||
| 44 | return (0); | ||
| 45 | } | ||
| 46 | |||
| 47 | int | ||
| 48 | badstr (unsigned char *code, int code_len, unsigned char *bad, int bad_len) | ||
| 49 | { | ||
| 50 | int n; | ||
| 51 | |||
| 52 | for (code_len -= 1 ; code_len >= 0 ; --code_len) { | ||
| 53 | for (n = 0 ; n < bad_len ; ++n) | ||
| 54 | if (code[code_len] == bad[n]) | ||
| 55 | return (1); | ||
| 56 | } | ||
| 57 | |||
| 58 | return (0); | ||
| 59 | } | ||
| 60 | |||
| 61 | |||
