forked from robertdavidgraham/masscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathout-certs.c
69 lines (58 loc) · 2.01 KB
/
out-certs.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
#include "output.h"
#include "masscan-app.h"
#include "masscan-status.h"
#include "string_s.h"
#include <ctype.h>
/****************************************************************************
****************************************************************************/
static void
cert_out_open(struct Output *out, FILE *fp)
{
}
/****************************************************************************
****************************************************************************/
static void
cert_out_close(struct Output *out, FILE *fp)
{
fprintf(fp, "{finished: 1}\n");
}
/******************************************************************************
******************************************************************************/
static void
cert_out_status(struct Output *out, FILE *fp, time_t timestamp, int status,
unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
{
}
/******************************************************************************
******************************************************************************/
static void
cert_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)
{
unsigned i;
if (length > 5 && memcmp(px, "cert:", 5) == 0) {
px += 5;
length -= 5;
}
printf("-----BEGIN CERTIFICATE-----\n");
for (i=0; i<length; i += 72) {
unsigned len = length - i;
if (len > 72)
len = 72;
printf("%.*s\n", len, px+i);
}
printf("-----END CERTIFICATE-----\n");
}
/****************************************************************************
****************************************************************************/
const struct OutputType certs_output = {
"cert",
0,
cert_out_open,
cert_out_close,
cert_out_status,
cert_out_banner
};