forked from robertdavidgraham/masscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproto-ssh.c
68 lines (60 loc) · 1.75 KB
/
proto-ssh.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 "proto-ssh.h"
#include "proto-banner1.h"
#include "unusedparm.h"
#include "masscan-app.h"
#include <ctype.h>
/***************************************************************************
***************************************************************************/
static void
ssh_parse( const struct Banner1 *banner1,
void *banner1_private,
struct ProtocolState *pstate,
const unsigned char *px, size_t length,
struct BannerOutput *banout,
struct InteractiveData *more)
{
unsigned state = pstate->state;
unsigned i;
UNUSEDPARM(banner1_private);
UNUSEDPARM(banner1);
UNUSEDPARM(more);
for (i=0; i<length; i++)
switch (state) {
case 0:
if (px[i] == '\r')
continue;
if (px[i] == '\n' || px[i] == '\0' || !isprint(px[i])) {
state = STATE_DONE;
continue;
}
banout_append_char(banout, PROTO_SSH2, px[i]);
break;
default:
i = (unsigned)length;
break;
}
pstate->state = state;
}
/***************************************************************************
***************************************************************************/
static void *
ssh_init(struct Banner1 *banner1)
{
UNUSEDPARM(banner1);
return 0;
}
/***************************************************************************
***************************************************************************/
static int
ssh_selftest(void)
{
return 0;
}
/***************************************************************************
***************************************************************************/
const struct ProtocolParserStream banner_ssh = {
"ssh", 22, 0, 0, 0,
ssh_selftest,
ssh_init,
ssh_parse,
};