forked from p0f/p0f
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p0f_auditor.cpp
66 lines (44 loc) · 1.5 KB
/
p0f_auditor.cpp
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
#include "p0f_auditor.h"
#include "QDebug"
#include <stdio.h>
#include "p0f_info.h"
#include "QString"
#include "QDebug"
#include "network_db.h"
p0f_info *current_packet;
network_db* nt = network_db::get_istance();
//the method creates a new packet looking at the keyword that identifies the packet's type
void create_packet(char* host, char *keyword){
QString qClient = QString::fromUtf8(host);
if(strcmp(keyword,"mtu") == 0){
current_packet = new p0f_info(qClient,MTU_INFO);
}
else if(strcmp(keyword,"syn") == 0 || strcmp(keyword,"syn+ack") == 0){
current_packet = new p0f_info(qClient,SYN_INFO);
}
else if(strcmp(keyword,"http request") == 0){
current_packet = new p0f_info(qClient,HTTP_REQUEST);
}
else if(strcmp(keyword,"http response") == 0){
current_packet = new p0f_info(qClient,HTTP_RESPONSE);
}
else if(strcmp(keyword,"uptime") == 0){
current_packet = new p0f_info(qClient,UPTIME_INFO);
}else if(strcmp(keyword,"host change") == 0){
current_packet = new p0f_info(qClient,HOST_CHANGE);
}else if(strcmp(keyword,"ip sharing") == 0){
current_packet = new p0f_info(qClient,IP_SHARING);
}
}
//add information to packet
void add_info(char *key, char *value){
QString qKey = QString::fromUtf8(key);
QString qValue = QString::fromUtf8(value);
current_packet->set_info_field(qKey,qValue);
}
/*
*Add packet to network database
*/
void end_packet(){
nt->add_info_network(current_packet);
}