BoB 에서 교육을 받으면서 gilgil 멘토님에 소개로 알게된 라이브러리이다.
라이브러리
http://libtins.github.io/
github
https://github.com/mfontanini/libtins
설치 방법은 github에 README.md에 상세하게 나와있다.
예제 소스
- #include <iostream>
- #include <tins/tins.h>
- using namespace Tins;
- bool callback(const PDU &pdu) {
- const IP &ip = pdu.rfind_pdu<IP>(); // Find the IP layer
- const TCP &tcp = pdu.rfind_pdu<TCP>(); // Find the TCP layer
- std::cout << ip.src_addr() << ':' << tcp.sport() << " -> "
- << ip.dst_addr() << ':' << tcp.dport() << std::endl;
- return true;
- }
- int main() {
- Sniffer("eth0").sniff_loop(callback);
- }
결과 화면
쉽게 공부할 수 있을 듯 하다.
반응형
'프로그래밍 > 네트워크' 카테고리의 다른 글
[libtins] Basics을 공부하면서 (0) | 2017.01.12 |
---|