forked from robertdavidgraham/masscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathout-text.c
92 lines (76 loc) · 2.42 KB
/
out-text.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
#include "output.h"
#include "masscan.h"
#include "masscan-app.h"
#include "masscan-status.h"
#include "unusedparm.h"
#include <ctype.h>
/****************************************************************************
****************************************************************************/
static void
text_out_open(struct Output *out, FILE *fp)
{
UNUSEDPARM(out);
fprintf(fp, "#masscan\n");
}
/****************************************************************************
****************************************************************************/
static void
text_out_close(struct Output *out, FILE *fp)
{
UNUSEDPARM(out);
fprintf(fp, "# end\n");
}
/****************************************************************************
****************************************************************************/
static void
text_out_status(struct Output *out, FILE *fp, time_t timestamp,
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
{
UNUSEDPARM(ttl);
UNUSEDPARM(reason);
UNUSEDPARM(out);
fprintf(fp, "%s %s %u %u.%u.%u.%u %u\n",
status_string(status),
name_from_ip_proto(ip_proto),
port,
(ip>>24)&0xFF,
(ip>>16)&0xFF,
(ip>> 8)&0xFF,
(ip>> 0)&0xFF,
(unsigned)timestamp
);
}
/*************************************** *************************************
****************************************************************************/
static void
text_out_banner(struct Output *out, FILE *fp, time_t timestamp,
unsigned ip, unsigned ip_proto, unsigned port,
enum ApplicationProtocol proto, unsigned ttl,
const unsigned char *px, unsigned length)
{
char banner_buffer[4096];
UNUSEDPARM(out);
UNUSEDPARM(ttl);
fprintf(fp, "%s %s %u %u.%u.%u.%u %u %s %s\n",
"banner",
name_from_ip_proto(ip_proto),
port,
(ip>>24)&0xFF,
(ip>>16)&0xFF,
(ip>> 8)&0xFF,
(ip>> 0)&0xFF,
(unsigned)timestamp,
masscan_app_to_string(proto),
normalize_string(px, length, banner_buffer, sizeof(banner_buffer))
);
}
/****************************************************************************
****************************************************************************/
const struct OutputType text_output = {
"txt",
0,
text_out_open,
text_out_close,
text_out_status,
text_out_banner
};