-
Notifications
You must be signed in to change notification settings - Fork 1
/
tcp_spoof.h
67 lines (49 loc) · 1.14 KB
/
tcp_spoof.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
#ifndef TCP_SPOOF_H
#define TCP_SPOOF_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__linux__)
#define _BSD_SOURCE
#endif
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <linux/if_ether.h>
#include <netinet/ip.h> //broken
#include <netinet/tcp.h>
#include <sys/time.h>
#define IP_TCP(ip_hdr) (struct tcphdr*)(((char *)ip_hdr) + (4 * ip_hdr->ihl))
#define TCP_DATA(tcp_hdr) (((char *)tcp_hdr) + (4 * tcp_hdr->doff))
//packet format
struct tcp_option_ts {
uint16_t nops; // 0x0101
uint8_t op_type; // 0x08
uint8_t op_len; // 0x0a
uint32_t tsval;
int32_t tsecr;
} __attribute__((__packed__));
struct pkt_data {
uint32_t daddr;
uint32_t saddr;
uint16_t dport;
uint16_t sport;
uint16_t id;
uint8_t ttl;
uint32_t seq;
uint32_t ack;
uint16_t window;
uint8_t flags;
};
void init_sock();
int tcp_forge_xmit(struct pkt_data *pkt, char *payload, int len);
extern int raw_sock;
#ifdef __cplusplus
}
#endif
#endif