For MITM Project

This source used Libtins


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
#include <iostream>
#include <unistd.h>
#include <string>
#include <tins/tins.h>
 
#define TIME_LAST 60
 
using namespace std;
using namespace Tins;
 
void tcpSniff(IPv4Address &);
void signalHandler(int signum) {
    clog << "Exit" << endl;
    exit(0);
}
 
int main(int argc, char *argv[])
{
    signal(SIGALRM, signalHandler);
    if(argc != 2) {
        fprintf(stderr, "[*] Usage : %s MY_IP\n", argv[0]);
        return 1;
    }
 
    IPv4Address myip;
    try {
        myip = argv[1];
    } catch(runtime_error& e) {
        fprintf(stderr, "[*] Please input ip address correctly!!\n");
        return 1;
    }
 
    tcpSniff(myip);
    return 0;
}
 
void tcpSniff(IPv4Address &myip)
{
    Sniffer tcpSniffer("wlan0");
    clog << "[*] Sniffing Started : " << endl;
    alarm(TIME_LAST);
    while(true) {
        Packet p = tcpSniffer.next_packet();
        if(p.pdu()->find_pdu<IP>() &&
           p.pdu()->find_pdu<TCP>() &&
           p.pdu()->find_pdu<TCP>()->sport() != 443 &&
           p.pdu()->find_pdu<TCP>()->dport() != 443 &&
           p.pdu()->find_pdu<TCP>()->find_pdu<RawPDU>()) {
            const IP &ip = p.pdu()->rfind_pdu<IP>();
            const TCP &tcp = p.pdu()->rfind_pdu<TCP>();
            const RawPDU& raw = tcp.rfind_pdu<RawPDU>();
            const RawPDU::payload_type& payload = raw.payload();
            string data(payload.begin(), payload.end());
 
            clog << " *** [" << ip.src_addr() << ":" << tcp.sport() << "] => [" << ip.dst_addr() << ":" << tcp.dport() << "] ***" << endl;
            clog << data << endl << endl;
        }
    }
}
cs


블로그 이미지

__미니__

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

,