-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcp_scanner.h
53 lines (45 loc) · 1.24 KB
/
tcp_scanner.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
/**
* @file tcp_scanner.h
* @brief Tcp port scanner. Based on sending SYN packets.
* @author Juraj Holub <xholub40>
* @project IPK - project 2
* @date April 2019
*/
#ifndef PROJ2_TCP_SCANNER_H
#define PROJ2_TCP_SCANNER_H
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <pcap.h>
#include "scanner.h"
#include <string>
/**
* TCP scanner which using SYN packet.
*/
class TCP_Scanner : public Scanner{
public:
TCP_Scanner(string iface):Scanner(iface)
{
this->iface = iface;
buffer = (char*)malloc(sizeof(char)*BUFSIZE);
iphdr = (struct iphdr*)buffer;
tcphdr = (struct tcphdr*)(buffer + sizeof(struct iphdr));
};
~TCP_Scanner()
{
free(buffer);
};
/**
* Fill raw tcp header of packets which will be send for scanning purposes.
*/
void create_tcp_hdr();
/**
* Create TCP SYN packet and send it to destination port and addres and
* check if it is open/closed or filtered.
* @param dst_port Destination port.
* @param dst_addr Ip address of destination port.
* @return Result of scanning (open, closed, filtered).
*/
scan_result_e scan_port(int dst_port, string dst_addr);
};
#endif //PROJ2_TCP_SCANNER_H