-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan.h
144 lines (124 loc) · 2.72 KB
/
scan.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef SCAN_H
# define SCAN_H
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <sys/socket.h>
# include <errno.h>
# include <pthread.h>
# include <netdb.h>
# include <arpa/inet.h>
# include <unistd.h>
# include <netinet/tcp.h>
# include <netinet/udp.h>
# include <netinet/ip_icmp.h>
# include <netinet/ip.h>
# include <sys/types.h>
# include <ifaddrs.h>
# include <pcap/pcap.h>
# include <netdb.h>
#include "argc_argv/parameter.h"
/*
** Using bitmap for identifying the types of scan needed
*/
# define PKT_LEN 65536
# define NUL 0x1
# define SYN 0x2
# define ACK 0x4
# define FIN 0x8
# define UDP 0x10
# define XMS 0x20
# define ALL (NUL|SYN|ACK|FIN|UDP|XMS)
/*
** bitmap values for coordinating flag assignment
*/
/*# define HELP 1
# define PORTS 2
# define IP 4
# define MFILE 8
# define SPEEDRUN 16
# define SCAN 32
** hash table for command line argument handling
*/
/*typedef struct s_arg
{
char *option;
char *param;
struct s_arg *next;
} t_keyval;
*/
/*typedef struct s_ip_port_list
{
char **ip_list;
char **port_list;
} t_ip_port_list;
*/
//t_keyval *key_value_pair(t_keyval *keyvalue,
// char *key, char *val);
/*
** Help screen.
*/
//void usage(void);
/*
** basic cmd error message and exit command.
*/
//void error_and_exit(char *msg);
/*
*****
*/
//used for checksum calculation of tcp
typedef struct s_pseudo
{
unsigned int source_address;
unsigned int dest_address;
unsigned char placeholder;
unsigned char protocol;
unsigned short tcp_length;
struct tcphdr tcp;
} t_pseudo;
// holds the results of all ports scanned... Do we fucken need a linked list though ?
typedef struct s_results
{
int port;
int syn;
int xms;
int udp;
int nul;
int ack;
int fin;
char s_name[40];
char res[20];
struct s_results *next;
} t_results;
typedef struct s_nmap
{
int threads;
int type;
int port;
char source_ip[20];
char *d_ip;
struct sockaddr_in dest;
struct in_addr dest_ip;
int source_port;
int sock_fd;
char dev[20]; //device used for monitoring //pcap craps
t_results *results;
} t_nmap;
typedef struct s_scan
{
int port;
int type;
t_nmap *nmap;
} t_scan;
int get_local(char *ip, char *device);
void exit_err(char *s);
char *dns_lookup(char *addr_host, struct sockaddr_in *addr_con);
unsigned short csum(unsigned short *ptr,int nbytes);
void recv_pkt(u_char *args, const struct pcap_pkthdr *header, const u_char *pkt);
void create_pkt(t_nmap *p, char *buff);
/* changes by VHULA */
void add_ports(t_results **res, int port);
void open_port(t_results **res, int port, int type, int set);
void results(t_results *res);
void no_msg(void *pkt, t_scan *scan);
#endif