forked from govolution/avet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_avet.c
241 lines (208 loc) · 5.22 KB
/
make_avet.c
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
Author: Daniel Sauder
License: https://www.gnu.org/licenses/gpl.txt or LICENSE file
Web: https://github.com/govolution/avet
*/
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void print_start();
void print_help();
int print_debug;
int load_from_file;
int main (int argc, char **argv)
{
print_start();
print_debug = 0;
load_from_file = 0;
char *dvalue = NULL;
char *evalue = NULL;
char *fvalue = NULL;
char *uvalue = NULL;
char *wvalue = NULL;
int hflag = 0;
int Fflag = 0;
int Xflag = 0;
int Eflag = 0;
int Aflag = 0;
int index;
int c;
opterr = 0;
// compute the options
while ((c = getopt (argc, argv, "d:e:f:u:w:lphFXEA")) != -1)
switch (c)
{
case 'd':
dvalue = optarg;
break;
case 'e':
evalue = optarg;
break;
case 'l':
load_from_file = 1;
break;
case 'f':
fvalue = optarg;
break;
case 'u':
uvalue = optarg;
break;
case 'w':
wvalue = optarg;
break;
case 'h':
hflag = 1;
break;
case 'F':
Fflag = 1;
break;
case 'X':
Xflag = 1;
break;
case 'E':
Eflag = 1;
break;
case 'A':
Aflag = 1;
break;
case 'p':
print_debug = 1;
break;
case '?':
if (optopt == 'd')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
else if (optopt == 'e')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
else if (optopt == 'f')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
else if (optopt == 'u')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
else if (optopt == 'w')
fprintf (stderr, "Option -%w requires an argument.\n", optopt);
else if (isprint (optopt))
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
else
fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
return 1;
default:
abort ();
}
// print help
if (hflag)
print_help();
else if (load_from_file)
{
//write LVALUE to defs.h
FILE *file_def;
file_def = fopen ("defs.h","w");
if (file_def == NULL)
{
printf ("Error open defs.h\n");
return -1;
}
//fseek (file_def, 0, SEEK_END);
fprintf (file_def, "#define LVALUE\n");
fclose(file_def);
}
// write shellcode from a given file to defs.h
else if (fvalue)
{
printf ("write shellcode from %s to defs.h\n", fvalue);
FILE *file_def;
file_def = fopen ("defs.h","w");
if (file_def == NULL)
{
printf ("Error open defs.h\n");
return -1;
}
fseek (file_def, 0, SEEK_END);
// read the shellcode file, write to defs.h
FILE *file_sh = fopen ( fvalue, "r" );
if ( file_sh != NULL )
{
if(Eflag)
fprintf (file_def, "#define FVALUE \"");
else
fprintf (file_def, "#define FVALUE \"\"\n");
char line [ 5000 ];
while ( fgets ( line, sizeof line, file_sh ) != NULL )
fprintf (file_def, "%s", line);
if(Eflag)
fprintf (file_def, "\"\n");
//fprintf (file_def, "\\n");
fclose ( file_sh );
}
else
printf ("Error open %s\n", fvalue);
fclose (file_def);
}
// exec from url
else if (uvalue)
{
printf ("write url %s to defs.h\n", uvalue);
FILE *file_def;
file_def = fopen ("defs.h","w");
if (file_def == NULL)
{
printf ("Error open defs.h\n");
return -1;
}
fseek (file_def, 0, SEEK_END);
fprintf (file_def, "#define UVALUE \"%s\"\n", uvalue);
fclose (file_def);
}
//write flags to defs.h
FILE *file_def;
file_def = fopen ("defs.h","a");
if (file_def == NULL)
{
printf ("Error open defs.h\n");
return -1;
}
//write LVALUE to defs.h
if(print_debug)
fprintf (file_def, "#define PRINT_DEBUG\n");
//write SANDBOX_FOPEN to defs.h
if(Fflag)
fprintf (file_def, "#define SANDBOX_FOPEN\n");
//write X64 to defs.h
if(Xflag)
fprintf (file_def, "#define X64\n");
//write ENCRYPT to defs.h
if(Eflag)
fprintf (file_def, "#define ENCRYPT\n");
//write ASCIIMSF to defs.h
if(Aflag)
fprintf (file_def, "#define ASCIIMSF\n");
fclose(file_def);
} //main
void print_help()
{
printf("Options:\n");
printf("-l load and exec shellcode from given file, call is with mytrojan.exe myshellcode.txt\n");
printf("-f compile shellcode into .exe, needs filename of shellcode file\n");
printf("-u load and exec shellcode from url using internet explorer (url is compiled into executable)\n");
printf("-E use avets ASCII encryption, often do not has to be used\n");
printf(" Note: with -l -E is mandatory\n");
//printf("-A use metasploits ASCII encryption, usage is like -E\n");
printf("-F use fopen sandbox evasion\n");
printf("-X compile for 64 bit\n");
printf("-p print debug information\n");
printf("-h help\n\n");
printf("Please refer README.md for more information\n");
}
void print_start()
{
char output[] =
" ________ ___ ___ _______ _________ \n"
"|\\ __ \\|\\ \\ / /|\\ ___ \\|\\___ ___\\ \n"
"\\ \\ \\|\\ \\ \\ \\ / / | \\ __/\\|___ \\ \\_| \n"
" \\ \\ __ \\ \\ \\/ / / \\ \\ \\_|/__ \\ \\ \\ \n"
" \\ \\ \\ \\ \\ \\ / / \\ \\ \\_|\\ \\ \\ \\ \\ \n"
" \\ \\__\\ \\__\\ \\__/ / \\ \\_______\\ \\ \\__\\\n"
" \\|__|\\|__|\\|__|/ \\|_______| \\|__|\n"
"\n\nAnti Virus Evasion Make Tool by Daniel Sauder\n"
"use -h for help\n\n";
printf("\n%s", output);
}