summaryrefslogtreecommitdiff
path: root/other/shellkit/shellcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'other/shellkit/shellcode.c')
-rw-r--r--other/shellkit/shellcode.c61
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
12unsigned long int
13random_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
31void
32random_init (void)
33{
34 srandom (time (NULL));
35}
36
37
38int
39bad (unsigned char u)
40{
41 if (u == '\x00' || u == '\x0a' || u == '\x0d' || u == '\x25')
42 return (1);
43
44 return (0);
45}
46
47int
48badstr (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