-
Notifications
You must be signed in to change notification settings - Fork 0
/
cgiaudit.h
200 lines (174 loc) · 3.69 KB
/
cgiaudit.h
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
/* preprocessor constants */
/* Use this if no explicit Content Length is mentioned by the server. */
#define DEFAULT_CONTENT_LENGTH 65536
/* For urlencode() */
#define HEX_BUF_SIZE 8192
/* maximum length of configuration file entry */
#define CONF_BUF_SIZE 4096
/* Read chunks of HTTP this size. */
#define HTTP_BUF_SIZE 1024
#define DEFAULT_CONFIG_FILE "/usr/local/etc/cgiaudit.conf"
/* macros */
#define SKIP_SPACE(p) while(*p&&isspace(*p))if(*p++=='>')return;
typedef struct URLINFO_def
{
char*scheme;
char*host;
char*user;
char*pass;
char*path;
char*query;
char*fragment;
unsigned short port;
}
URLINFO;
typedef struct HTTPCLIINFO_def
{
long content_length;
char*method;
char*enctype;
}
HTTPCLIINFO;
typedef struct HTTPSRVINFO_def
{
long content_length;
char code[4];
char*phrase;
char*ver;
char*server;
}
HTTPSRVINFO;
typedef struct INPUTINFO_def
{
char*type;
char*name;
char*value;
char*size;
char*src;
char*align;
unsigned long maxlength;
unsigned char checked;
}
INPUTINFO;
typedef struct SELECTINFO_def
{
char*name;
char*value;
unsigned long size;
char multiple;
}
SELECTINFO;
typedef struct TEXTAREAINFO_def
{
char*name;
char*value;
void*next;
unsigned long cols;
unsigned long rows;
}
TEXTAREAINFO;
typedef struct FIELDINFO_def
{
void*field;
struct FIELDINFO_def*next;
char type;
}
FIELDINFO;
typedef struct FORMINFO_def
{
char*name;
char*url;
char*action;
char*method;
char*enctype;
FIELDINFO*fieldshead;
struct FORMINFO_def*next;
}
FORMINFO;
typedef struct AINFO_def
{
char*href;
struct AINFO_def*next;
}
AINFO;
typedef struct CONFINFO_def
{
char*ents[4]; /* null terminated array of configuration file entities */
struct CONFINFO_def*next;
}
CONFINFO;
typedef struct DOCINFO_def
{
FORMINFO*forminfo;
AINFO*ainfo;
}
DOCINFO;
typedef struct OPTIONS_def
{
char*c; /* user-defined configuration file */
char*s; /* spider netmask */
char*p; /* proxy hostname */
unsigned int h; /* help */
unsigned int v; /* verbosity */
unsigned int x; /* hexadecimal encoding */
unsigned int r; /* print http reply/request headers */
unsigned int t; /* proxy tcp port */
}
OPTIONS;
typedef struct REPORTINFO_def
{
HTTPSRVINFO httpsrvinfo;
char*string;
char*attack;
FORMINFO*forminfo;
FIELDINFO*fieldinfo;
URLINFO*urlinfo;
struct REPORTINFO_def*next;
}
REPORTINFO;
/* Nested headers. */
#ifndef _STDIO_H
#include<stdio.h>
#endif
#ifndef _SYS_TYPES_H
#include<sys/types.h>
#endif
#ifndef _NETINET_IN_H
#include<netinet/in.h>
#endif
FILE*http_connect(URLINFO*,HTTPSRVINFO*);
DOCINFO*parse_doc(char*,URLINFO*);
URLINFO*parse_url(char*);
CONFINFO*parse_conf(const char*);
int parse_form_field(char**,FIELDINFO*);
char*get_field_value(FIELDINFO*);
char*get_field_name(FIELDINFO*);
void show_doc_info(const HTTPCLIINFO*);
void show_srv_info(const HTTPSRVINFO*);
int cgiaudit(FORMINFO*);
void vexit(const char*);
void bug(const char*);
char*isolate_value(char**);
int parse_input_tag(char**,INPUTINFO*);
int parse_select_tag(char**,SELECTINFO*);
int parse_textarea_tag(char**,TEXTAREAINFO*);
void syntax_error(const char*,const unsigned int);
void discard_tokens_1(char**);
REPORTINFO*cgi_audit(FORMINFO*,URLINFO*);
char*parse_a_tag(char*,AINFO*,URLINFO*);
char*parse_form_tag(char*,FORMINFO*);
FILE*check_tags(FORMINFO*,char*,URLINFO*,HTTPSRVINFO*);
int hexencode(const char*,char*,const int);
int urlcmp(char*,char*);
void report(const REPORTINFO*);
#ifndef _MAIN_C
extern unsigned int i; /* document */
extern unsigned int n; /* form */
extern int j; /* field */
extern OPTIONS options;
extern CONFINFO*confinfo;
#endif
int setmask(int,struct in_addr*);
int mask(char*);
/* User-Agent: field for HTTP request header */
#define HTTP_USER_AGENT "Mozilla/4.61 [en] (X11; I; Linux 2.2.12-20 i586)"