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 |
'Programming' 카테고리의 다른 글
[C++] Reference In Low-level (0) | 2016.07.02 |
---|---|
[MITM] Create Repository 'WLAN-Crack' (0) | 2016.06.17 |
[Go] To Build Go Language in Visual Studio Code (0) | 2016.05.31 |
[C++] std::string 클래스 구현 (0) | 2016.05.23 |
Python List 얕은 복사, 깊은 복사 (0) | 2016.04.26 |