forked from CoolerVoid/payloadmask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
payloadmask.c
187 lines (148 loc) · 4.25 KB
/
payloadmask.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
/*
Author:Antonio Costa aka " Cooler_ "
contact: c00f3r[at]gmail[dot]com
Copyright (C) 2015 payload mask authors,
This file is part of payloadmask
Payload mask is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
payload mask is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
$ make
$./payloadmask
*/
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/resource.h>
#include "mem_ops.h"
#include "file_ops.h"
#include "validate.h"
// colors macro
#define RED "\033[22;31m"
#define YELLOW "\033[01;33m"
#define CYAN "\033[22;36m"
#define GREEN "\033[22;32m"
#define LAST "\033[0m"
void init_banner_mask()
{
puts(
GREEN
"\n ...:::_PAYLOAD:MASK_:::... v0.1 \n"
" Just another payload lists editor to bypass WAF \n\n"
YELLOW
LAST
"--payload : Payload list to make edit\n\n"
"--out : Output of new payload list\n\n"
"--tamper : Payload tamper to try bypass filters\n Choice one option :\n encode64 : to encode payload to 64 base \n randcase : to use lower and upper case random position in string\n"
" urlencode : converts characters into a format that can be transmitted over the Internet, percent encoding\n double_urlencode : converts payload two times with urlencode\n"
" spaces2comment: change spaces ' ' to comment '/**/'\n unmagicquote: change apostrophe to a multi-byte \n"
" apostrophe2nullencode: change apostrophe to illegal double unicode counterpart\n rand_comment: to use random comment '/**/' position in payload string\n"
" rand_space: write random ' ' blank spaces\n"
YELLOW
YELLOW
LAST
"\n Example: ./payloadmask -p payloads/xss.txt -o test_new.txt -t randcase\n...\n"
"Coded by Cooler_\n c00f3r[at]gmail[dot]com\n "
);
puts(LAST);
}
static struct option long_options[] =
{
{"payload", required_argument, NULL, 'p'},
{"out", required_argument, NULL, 'o'},
{"tamper", required_argument, NULL, 't'},
{NULL, 0, NULL, 0}
};
int
main(int argc, char ** argv)
{
char c;
char *pack[4];
short y=3;
no_write_coredump ();
load_signal_alarm ();
if(argc < 3)
{
init_banner_mask();
DEBUG(" Need more arguments.\n");
exit(0);
}
while(y>-1)
{
pack[y]=NULL;
y--;
}
opterr = 0;
while((c = getopt_long(argc, argv, "p:o:t:",long_options,NULL)) != -1)
switch(c)
{
// payload list
case 'p':
if ( strnlen(optarg,256)<= 128 )
{
pack[0] = optarg;
printf("Payloads: %s \n",optarg);
} else {
DEBUG("Error \nArgument Payloads is very large \n");
exit(1);
}
break;
// output
case 'o':
if ( strnlen(optarg,256)<= 128 )
{
pack[1] = optarg;
printf("Custom output: %s \n",optarg);
} else {
DEBUG("Error \nArgument output is very large \n");
exit(1);
}
break;
case 't':
if ( strnlen(optarg,256)<= 128 )
{
pack[2] = optarg;
printf("Tamper type: %s \n",optarg);
} else {
DEBUG("Error \nArgument tamper type is very large \n");
exit(1);
}
break;
case '?':
if(optopt == 'p' || optopt == 'o' || optopt == 't')
{
init_banner_mask();
puts(RED);
DEBUG("Option -%c requires an argument.\n", optopt);
puts(LAST);
exit(1);
}
break;
}
if(pack[1]==NULL)
{
DEBUG("need use argument output file");
exit(1);
}
if(pack[0]==NULL)
{
DEBUG("need use argument payload");
exit(1);
}
if(pack[2]==NULL)
{
DEBUG("need use argument tamper");
exit(1);
}
convert_payload(pack[0],pack[1],pack[2]);
fprintf(stdout,"%s Look file %s%s\n%s",RED,GREEN,pack[1],LAST);
exit(0);
}