-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmyarpt.hpp
85 lines (83 loc) · 2.08 KB
/
myarpt.hpp
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
#ifndef ARPTOOLS_MYARPT_HPP
#define ARPTOOLS_MYARPT_HPP
#include <cstdlib>
#include <sys/socket.h>
#include <netinet/in.h>
#include <memory.h>
#include <linux/if_ether.h>
#include <unistd.h>
#include <cstdio>
#include <netpacket/packet.h>
#include <net/if.h>
#include <thread>
typedef unsigned char byte;
class bytestr {
byte *ustr;
int size;
bool tempFlag;
public:
byte *getStr(){
return ustr;
}
int getSize(){
return size;
}
bytestr(byte *str, int s){
ustr = str;
size = s;
tempFlag = false;
}
bytestr & operator+(bytestr & b){
auto nstr = new bytestr(nullptr, 0);
nstr->tempFlag = true;
nstr->ustr = new byte[this->size + b.size];
nstr->size = this->size + b.size;
memcpy(nstr->ustr, this->ustr, this->size);
memcpy(nstr->ustr + this->size, b.ustr, b.size);
return *nstr;
}
bytestr & ref(){
return *this;
}
~bytestr(){
if (tempFlag) {
delete[]ustr;
}
}
};
struct IMMAP {
byte IPAddress[4] = {0x00};
byte MACAddress[6] = {0x00};
};
struct countMutex {
volatile bool mutex = false;
int count = 0;
};
struct EtherPack {
byte destMAC[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};//Broadcast MAC
byte srcMAC[6] = {0xb0, 0x35, 0x9f, 0x6e, 0x49, 0x52};//Host MAC
byte frameType[2] = {0x08, 0x06};
struct {
byte hardType[2] = {0x00, 0x01};
byte proType[2] = {0x08, 0x00};
byte hardLen = 0x06;
byte proLen = 0x04;
byte opreate[2] = {0x00, 0x01};
byte hostMAC[6] = {0X00};
byte hostIP[4] = {0xc0, 0xa8, 0x01, 0xc7};
byte distMAC[6] = {0x00};
byte distIP[4] = {0xc0, 0xa8, 0x01, 0x00};
} arp;
EtherPack();
};
IMMAP *ARPRequest();
void ARPRequest(IMMAP *mapp);
void IMMAPprint(IMMAP *mapp);
void ARPBroadcastMultiThread(EtherPack arpPack, IMMAP *mapp, byte beginIndex, byte endIndex, std::atomic<int> & count);
void ARPAttack(int victim, IMMAP *mapp);
int bytencmp(const byte *b1, const byte *b2, int n);
void printHex(byte *str, int size);
void dataTransmit(int target, IMMAP *mapp);
void selectDataTransmitTarget(IMMAP *mapp);
void dataTransmitPrepare(int target, IMMAP *mapp);
#endif