-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpseudo.cpp
99 lines (58 loc) · 1.7 KB
/
pseudo.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//pseudo-code for arp-spoofing
class ARP_packet {
char* ethersrc;
char* etherdest;
char* arpop;
...
}
sendPacket()
char* getSenderMac(){
return senderMac;
}
void receivePacket(){ // not good .. it's better not to extract code as func.
if(ehdr->ether_type == 0x0800){
ihdr = (struct ihdr *)packet0;
} else if(ehdr->ether_type == 0x86DD){
ihdr6 = (struct ihdr6 *)packet0;
} else if(ehdr->ether_type == 0x0806){
ahdr6 = (struct ahdr6 *)packet0;
}
sprintf();
}
int getSomeoneMacAddr(){
// Stage1
ARP_packet arp1 = new ARP_packet(ethersrc, etherdest, arpop, ..);
send_packet(arp1, .. );
// Stage2
receivePakcet(); // while(1) .. // get sender's Mac
}
int main(int argc, char* argv[]){
char* victimMacAddr = getSomeoneMacAddr();
char* targetMacAddr = getSomeoneMacAddr();
while(true){
// Stage3
ARP_packet arp_attack1 = new ARP_packet(ethersrc, etherdest, arpop, ..);
send_packet(arp_attack1, .. );
// Stage4
char* result = receivePacket();
// while(1) ... // get spoofed IP packet
IP_packet ip1 = new IP_packet(result, ... );
// Stage5
send_packet(ip1, ... );
// Stage6
receivePacket(); // while(1) ..
// get ARP unicast packet
// get ARP broadcast packet
// packet in order to update its arp-table
// if ARP unicast packet -> reply -> still do while
// if ARP broadcast packet -> break while -> do again
// Stage7
ARP_packet arp_unicast = new ARP_packet(ethersrc, etherdest, ..);
send_packet(arp_unicast, ... );
// Stage8
ARP_packet arp_attack2 = new ARP_packet(ethersrc, etherdest, ..);
send_packet(arp_attack2, ... );
}
}
// wireshark filter command
// arp || eth.addr == 00:0c:29:f2:41:76 || eth.addr == a0:c5:89:77:cb:03