forked from robertdavidgraham/masscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.h
92 lines (73 loc) · 2.4 KB
/
output.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
#ifndef OUTPUT_H
#define OUTPUT_H
#include <stdio.h>
#include <stdint.h>
#include <time.h>
#include "main-src.h"
#include "unusedparm.h"
struct Masscan;
struct Output;
enum ApplicationProtocol;
struct OutputType {
const char *file_extension;
void *(*create)(struct Output *out);
void (*open)(struct Output *out, FILE *fp);
void (*close)(struct Output *out, FILE *fp);
void (*status)(struct Output *out, FILE *fp, int status, unsigned ip, unsigned port, unsigned reason, unsigned ttl);
void (*banner)(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, enum ApplicationProtocol proto, const unsigned char *px, unsigned length);
};
struct Output
{
const struct Masscan *masscan;
struct Source src[8];
FILE *fp;
const struct OutputType *funcs;
time_t next_rotate;
time_t last_rotate;
unsigned period;
unsigned offset;
struct {
struct {
uint64_t open;
uint64_t closed;
uint64_t banner;
} tcp;
struct {
uint64_t open;
uint64_t closed;
} udp;
struct {
uint64_t echo;
uint64_t timestamp;
} icmp;
struct {
uint64_t open;
} arp;
} counts;
struct {
char *redis_url;
int fd;
} redis;
};
const char *proto_from_status(unsigned status);
const char *normalize_string(const unsigned char *px, size_t length, char *buf, size_t buf_len);
extern const struct OutputType text_output;
extern const struct OutputType xml_output;
extern const struct OutputType binary_output;
extern const struct OutputType null_output;
struct Output *output_create(const struct Masscan *masscan);
void output_destroy(struct Output *output);
void output_report_status(struct Output *output, int status, unsigned ip, unsigned port, unsigned reason, unsigned ttl);
typedef void (*OUTPUT_REPORT_BANNER)(
struct Output *output,
unsigned ip, unsigned ip_proto, unsigned port,
unsigned proto,
const unsigned char *px, unsigned length);
void output_report_banner(
struct Output *output,
unsigned ip, unsigned ip_proto, unsigned port,
unsigned proto,
const unsigned char *px, unsigned length);
const char *status_string(int x);
const char *reason_string(int x, char *buffer, size_t sizeof_buffer);
#endif