forked from robertdavidgraham/masscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmasscan.h
250 lines (202 loc) · 5.88 KB
/
masscan.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
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
242
243
244
245
246
247
248
249
250
#ifndef MASSCAN_H
#define MASSCAN_H
#include "string_s.h"
#include "main-src.h"
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include "ranges.h"
#include "packet-queue.h"
struct Adapter;
struct TemplateSet;
struct Banner1;
enum {
Operation_Default = 0, /* nothing specified, so print usage */
Operation_List_Adapters = 1,
Operation_Selftest = 2,
Operation_Scan = 3, /* this is what you expect */
Operation_DebugIF = 4,
Operation_ListScan = 5,
Operation_ReadScan = 6, /* re-interpret output files in different format */
};
enum OutpuFormat {
Output_Interactive = 0x0001,
Output_List = 0x0002,
Output_Binary = 0x0004,
Output_XML = 0x0008,
Output_JSON = 0x0010,
Output_Nmap = 0x0020,
Output_ScriptKiddie = 0x0040,
Output_Grepable = 0x0080,
Output_Redis = 0x0100,
Output_None = 0x0200,
Output_All = 0xFFBF,
};
struct TcpCfgPayloads
{
char *payload_base64;
unsigned port;
struct TcpCfgPayloads *next;
};
struct Masscan
{
int op;
/**
* One or more network adapters that we'll use for scanning.
*/
struct {
char ifname[256];
struct Adapter *adapter;
struct Source src;
unsigned char my_mac[6];
unsigned char router_mac[6];
unsigned router_ip;
int link_type; /* libpcap definitions */
unsigned char my_mac_count;
} nic[8];
unsigned nic_count;
/**
* The target ranges of IPv4 addresses that are included in the scan.
*/
struct RangeList targets;
/**
* The ports we are scanning for
*/
struct RangeList ports;
/**
* IPv4 addresses/ranges that are to be exluded from the scan. This takes
* precedence over any 'include' statement
*/
struct RangeList exclude_ip;
struct RangeList exclude_port;
/**
* Maximum rate, in packets-per-second (--rate parameter)
*/
double max_rate;
/**
* Number of retries (--retries or --max-retries parameter)
*/
unsigned retries;
unsigned is_pfring:1; /* --pfring */
unsigned is_sendq:1; /* --sendq */
unsigned is_banners:1; /* --banners */
unsigned is_offline:1; /* --offline */
unsigned is_interactive:1; /* --interactive */
unsigned is_arp:1; /* --arp */
unsigned is_gmt:1; /* --gmt, all times in GMT */
unsigned is_capture_cert:1; /* --capture cert */
unsigned is_capture_html:1; /* --capture html */
unsigned is_test_csv:1; /* (temporary testing feature) */
/**
* Wait forever for responses, instead of the default 10 seconds
*/
unsigned wait;
struct {
uint64_t index;
uint64_t count;
struct {
unsigned ip;
unsigned port;
} target;
} resume;
struct {
unsigned one;
unsigned of;
} shard;
/**
* The packet template we are current using
*/
struct TemplateSet *pkt_template;
/**
* When we should rotate output into the target directory
*/
unsigned rotate_output;
/**
* A random seed for randomization if zero, otherwise we'll use
* the configured seed for repeatable tests.
*/
uint64_t seed;
/**
* When doing "--rotate daily", the rotation is done at GMT. In order
* to fix this, add an offset.
*/
unsigned rotate_offset;
struct {
unsigned data_length; /* number of bytes to randomly append */
unsigned ttl; /* starting IP TTL field */
unsigned badsum; /* bad TCP/UDP/SCTP checksum */
/* output options */
unsigned packet_trace:1; /* print transmit messages */
unsigned open_only:1; /* show only open ports */
unsigned reason; /* print reason port is open, which is redundant for us */
unsigned format; /* see enum OutputFormat */
unsigned append; /* append instead of clobber file */
char datadir[256];
char filename[256];
char stylesheet[256];
} nmap;
char rotate_directory[256];
char pcap_filename[256];
//PACKET_QUEUE *packet_buffers;
//PACKET_QUEUE *transmit_queue;
struct {
unsigned timeout;
} tcb;
struct NmapPayloads *payloads;
struct TcpCfgPayloads *tcp_payloads;
unsigned char *http_user_agent;
unsigned http_user_agent_length;
unsigned tcp_connection_timeout;
struct {
const char *header_name;
unsigned char *header_value;
unsigned header_value_length;
} http_headers[16];
char *bpf_filter;
struct {
unsigned ip;
unsigned port;
} redis;
/**
* --infinite
* Restarts the scan from the beginning, for load testing, but
* by incrementing the seed
*/
unsigned is_infinite:1;
/**
* --readscan
*/
unsigned is_readscan:1;
/**
* --min-packet
*/
unsigned min_packet_size;
/**
* --script <name>
* The name of the internal script that we are going to use during the
* scan. The script is responsible for crafting packets and parsing
* the results
*/
struct {
const char *name;
} script;
};
int mainconf_selftest(void);
void masscan_read_config_file(struct Masscan *masscan, const char *filename);
void masscan_command_line(struct Masscan *masscan, int argc, char *argv[]);
void masscan_usage(void);
void masscan_save_state(struct Masscan *masscan);
void main_listscan(struct Masscan *masscan);
/**
* Pre-scan the command-line looking for options that may affect how
* previous options are handled. This is a bit of a kludge, really.
*/
int masscan_conf_contains(const char *x, int argc, char **argv);
int
masscan_initialize_adapter(
struct Masscan *masscan,
unsigned index,
unsigned char *adapter_mac,
unsigned char *router_mac);
#endif