POSTECH 1/17 CSED702D: Internet Traffic Monitoring and Analysis James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea

Slides:



Advertisements
Similar presentations
Datalink Access.
Advertisements

Network Performance Measurement
Lecture Materials for the John Wiley & Sons book: Cyber Security: Managing Networks, Conducting Tests, and Investigating Intrusions April 14, 2015 DRAFT1.
Snort & ACID. UTSA IS 6973 Computer Forensics SNORT.
Introduction1-1 message segment datagram frame source application transport network link physical HtHt HnHn HlHl M HtHt HnHn M HtHt M M destination application.
CSE551: Computer Network Review r Network Layers r TCP/UDP r IP.
TCPDUMP Network-Based Intrusion Detection. Description  Packet sniffing is the heart of intrusion detection and of understanding what is actually occurring.
Network Layer Packet Forwarding IS250 Spring 2010
The Network Layer Chapter 5. The IP Protocol The IPv4 (Internet Protocol) header.
1 libpcap Packet Sniffing for Security Alisa Neeman.
1 Application TCPUDP IPICMPARPRARP Physical network Application TCP/IP Protocol Suite.
Source Port # (16)Destination Port # (16) Sequence Number (32 bits) Acknowledgement Number (32 bits) Hdr Len (4) Flags (6)Window Size (16) Options (if.
Chapter 3 Review of Protocols And Packet Formats
Network Layer4-1 Network layer r transport segment from sending to receiving host r on sending side encapsulates segments into datagrams r on rcving side,
Network Layer4-1 Network layer r transport segment from sending to receiving host r on sending side encapsulates segments into datagrams r on rcving side,
POSTECH DP&NM Lab. Internet Traffic Monitoring and Analysis: Methods and Applications (1) Programming with Libpcap.
IP-UDP-RTP Computer Networking (In Chap 3, 4, 7) 건국대학교 인터넷미디어공학부 임 창 훈.
CIS 193A – Lesson12 Monitoring Tools. CIS 193A – Lesson12 Focus Question What are the common ways of specifying network packets used in tcpdump, wireshark,
Linux Networking Commands
Programming Multi-Core Processors based Embedded Systems A Hands-On Experience on Cavium Octeon based Platforms Lab Exercises.
University of Calgary – CPSC 441.  Wireshark (originally named Ethereal)is a free and open-source packet analyzer.  It is used for network troubleshooting,
4: Network Layer4a-1 IP datagram format ver length 32 bits data (variable length, typically a TCP or UDP segment) 16-bit identifier Internet checksum time.
Packet Analysis with Wireshark
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Network Layer ICMP and fragmentation.
Internet Protocol (IP)
CPSC 441 Tutorial TA: Fang Wang The content of these slides are taken from CPSC 526 TUTORIAL by Nashd Safa (Extended and partially modified)
Intrusion Detection: Snort. Basics: History Snort was developed in 1998 by Martin Roesch. It was intended to be an open-source technology, and remains.
Agostinho L S Castro Telecommunications and Multimedia Unit BPF - BSD Packet Filter.
Introduction to Networks CS587x Lecture 1 Department of Computer Science Iowa State University.
SNORT Feed the Pig Vicki Insixiengmay Jon Krieger.
Protocols 1 Objective: Build a protocol foundation for Client / Server programming in an Internet Environment Note: RFCs available from
Review the key networking concepts –TCP/IP reference model –Ethernet –Switched Ethernet –IP, ARP –TCP –DNS.
Network Programming Eddie Aronovich mail:
Networking Tutorial Special Interest Group for Software Engineering Luke Rajlich.
Project Requirements (NetFlow Generator) 정승화 분산 처리 및 네트워크 관리 연구실 포항 공과 대학교
Internet Protocol Formats. IP (V4) Packet byte 0 byte1 byte 2 byte 3 data... – up to 65 K including heading info Version IHL Serv. Type Total Length Identifcation.
Decoding an IP Header (1)
Sniffer, tcpdump, Ethereal, ntop
Network Analyzer :- Introduction to Wireshark. What is Wireshark ? Ethereal Formerly known as Ethereal GUINetwork Protocol Analyzer Wireshark is a GUI.
1 Microsoft Windows 2000 Network Infrastructure Administration Chapter 4 Monitoring Network Activity.
PLUS 내부 세미나 1/22 The Libnet Library 이병영 2004/05/06.
1 CSE 5346 Spring Network Simulator Project.
POSTECH 1/39 CSED702D: Internet Traffic Monitoring and Analysis James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea
Department of Computer Science & Engineering 5. Acknowledgments 4. Conclusions 3. Evaluation2. Contribution 1. Introduction REU 2008-Packet Sniffer Jose.
Ethereal/WireShark Tutorial Yen-Cheng Chen IM, NCNU April, 2006.
Programming Multi-Core Processors based Embedded Systems A Hands-On Experience on Cavium Octeon based Platforms Lab Exercises: Lab 4 (Network Packet Filtering)
WIRESHARK Lab#3. Computer Network Monitoring  Port Scanning  Keystroke Monitoring  Packet sniffers  takes advantage of “friendly” nature of net. 
1 COMP 431 Internet Services & Protocols The IP Internet Protocol Jasleen Kaur April 21, 2016.
Introduction to Networks
Wireshark Tutorial KUAS, Hao-Xiang Gu.
Multiplexing.
Lab 2: Packet Capture & Traffic Analysis with Wireshark
Chapter 6 Network Performance Measurement
Internet Protocol Formats
Wireshark Lab#3.
Standards Basics.
SNORT.
Internet Protocol (IP)
Ethereal/WireShark Tutorial
Wide Area Networks and Internet CT1403
Network Analyzer :- Introduction to Wireshark
Net 323 D: Networks Protocols
Network Analyzer :- Introduction to Wireshark
Internet Protocol Formats
Advanced Computer Networks
Network Architecture Models: Layered Communications
Chapter 3 Transport Layer
32 bit destination IP address
Transport Layer 9/22/2019.
Packet Sniffing and Spoofing
Presentation transcript:

POSTECH 1/17 CSED702D: Internet Traffic Monitoring and Analysis James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea

POSTECH 2/17 CSED702D: Internet Traffic Monitoring and Analysis Outline  Introduction  Basic Concept of Packet Capturing  Programming with Libpcap  Libpcap based Software  Installation of Libpcap

POSTECH 3/17 CSED702D: Internet Traffic Monitoring and Analysis Introduction  Libpcap: Portable Packet Capturing Library  Operating system independent  Provide general-purpose APIs  Simple and powerful user-level library  Compatible with Unix like system  Many of commercial IDS systems utilize Libpcap to analyze packet data  Representative Programs Rely on Libpcap  TCPDump, SAINT and etc.  Other Packet Capturing Tools  SOCK_PACKET, LSF, SNOOP, SINT and etc.  Operating system dependent

POSTECH 4/17 CSED702D: Internet Traffic Monitoring and Analysis Basic Concept of Packet Capturing  Packet Capturing  Packet capturing (sniffing) does not affects to data transfer  The packet captured by libpcap is called raw packet and de- multiplexing is required to analyze the packet

POSTECH 5/17 CSED702D: Internet Traffic Monitoring and Analysis Libpcap File Format  File Extension  Normally has “.pcap” file extension  File Format  General libpcap file format Contains some global information followed by zero or more records for each packet A captured packet in a capture file does not necessarily contain all the data A captured file might contain at most first N bytes of each packet  Global Header Global Header Packet Header Packet Data Packet Header Packet Data Packet Header Packet Data …

POSTECH 6/17 CSED702D: Internet Traffic Monitoring and Analysis Device & Network Related APIs (1/2)  Device & Network Lookup for Single Device  char *pcap_lookupdev(char *errbuf) Return a pointer to a network device suitable for use with pcap_open_live() and pcap_lookupnet() Return NULL indicates an error Reference: lookupdev.c  int pcap_lookupnet( const char *device, bpf_u_int32 *netp, bpf_u_int32 *maskp, char *errbuf) Determine the network number and mask associated with the network device Return -1 indicates an error Reference: lookupnet.c

POSTECH 7/17 CSED702D: Internet Traffic Monitoring and Analysis Device & Network Related APIs (2/2)  Device & Network Lookup for Multiple Devices  int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) Constructs a list of network devices that can be opened with pcap_create() and pcap_activate() or with pcap_open_live() alldevsp: list of network devides Returns 0 on success and -1 on failure. The list of devices must be freed with pcap_freealldevs()  Structure of pcap_if_t next: if not NULL, a pointer to the next element in the list name: a pointer to a string giving a name for the device to pass to pcap_open_live() description: if not NULL, a pointer to a string giving a human-read- able description of the device addresses: a pointer to the first element of a list of addresses flags: interface flags - PCAP_IF_LOOPBACK set if the interface is a loopback interface

POSTECH 8/17 CSED702D: Internet Traffic Monitoring and Analysis Example of Device Loopup Output: DEV: eth0 NET: xx.x MASK: xxx.xxx

POSTECH 9/17 CSED702D: Internet Traffic Monitoring and Analysis Initializing Packet Capturing APIs  Preparation of Packet Capturing  File descriptor == Packet capture descriptor  Packet capture descriptor: pcap_t *  pcap_t *pcap_open_live( const char *device, int snaplen, int promisc, int to_ms, char *errbuf) Parameters device: the device in which the packets are captured from snaplen: maximum number of bytes to capture promisc: true, set the interface into promiscuous mode; false, only bring packets intended for you to_ms: read timeout in milliseconds; zero, cause a read to wait forever to allow enough packets to arrive Return A packet capture descriptor to look at packets on the network Return NULL indicates an error  pcap_t *pcap_open_offline(const char *fname, char *errbuf) open a “savefile” for reading fname: the name of the file to open return a pcap_t * on success and NULL on failure

POSTECH 10/17 CSED702D: Internet Traffic Monitoring and Analysis TCP, IP, Ethernet Structures (1/4)  The path of TCP, IP and Ethernet Header  Ethernet header: /usr/include/linux/if_ether.h  IP header: /usr/include/netinet/ip.h  TCP header: /usr/include/netinet/tcp.h  Packet Format Ethernet Trailer 14 bytes Ethernet Frame IP HeaderTCP Header Application Data 20 bytes 46 ~ 1500 bytes Ethernet Header ICMP header : 8 byte UDP header : 8 byte ARP header : 28 byte

POSTECH 11/17 CSED702D: Internet Traffic Monitoring and Analysis TCP, IP, Ethernet Structures (2/4)  Ethernet Header Preamble DST. Address SRC. Address Type Payload Frame Check (CRC) 8 bytes6 bytes 2 bytesn bytes4 bytes SFDSFD Ethernet Header

POSTECH 12/17 CSED702D: Internet Traffic Monitoring and Analysis TCP, IP, Ethernet Structures (3/4)  IP Header Bit Offset 0 ~ 34 ~ 78 ~ 1516 ~ 2324 ~ 31 0Version Header Length TOSTotal Packet Length 32IdentifierFlagsFragment Offset 64Time to Live (TTL) Protocol ID Header Checksum 96Source IP Address 128Destination IP Address 160IP Header OptionsPadding

POSTECH 13/17 CSED702D: Internet Traffic Monitoring and Analysis TCP, IP, Ethernet Structures (4/4) source port # dest port # 32 bits sequence number acknowledgement number rcvr window size ptr urgent data checksum F SR PAU head len not used Options (variable length)  TCP Header

POSTECH 14/17 CSED702D: Internet Traffic Monitoring and Analysis Packet Read Related APIs  Read Packet in Loop Manner  const u_char *pcap_next(pcap_t *p, struct pcap_pkthdr *h) Read the next packet Return NULL indicates an error pcap_next.c timestamp.c  int pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user) Processes packets from a live capture or “savefile‘” until cnt packets are processed A value of -1 or 0 for cnt is equivalent to infinity callback specifies a routine to be called

POSTECH 15/17 CSED702D: Internet Traffic Monitoring and Analysis Filtering Related APIs  Filter  int pcap_compile(pcap_t *p, struct bpf_program *fp, char *str, int optimize, bpf_u_int32 netmask) Compile the str into a filter program str: filter string optimize: 1, optimization on the resulting code is performed netmask: specify network on which packets are being captured Returns 0 on success and -1 on failure  int pcap_setfilter(pcap_t *p, struct bpf_program *fp) Specify a filter program (after compiling filter) Return -1 indicates an error pcap_filter.c  Sample Source  

POSTECH 16/17 CSED702D: Internet Traffic Monitoring and Analysis How to Compile Libpcap Program?  Two Parameters  Library path (e.g., -lpcap)  Compilation flags (-I/usr/include.pcap)  Automate the Compilation  Shell Scripting Create a compile.sh in executable mode, put follows and execute compile.sh gcc -o test test.c –lpcap -I/usr/include.pcap  Makefile Create a Makefile, put follows and run make through CLI CC=gcc LIBS=-lpcap CFLAGS=-I/usr/include.pcap OBJ=test.o TARGET = test all: $(TARGET) $(TARGET): $(TARGET).c $(CC) -o $(TARGET) $(TARGET).c $(LIBS) $(CFLAGS) clean: $(RM) $(TARGET)

POSTECH 17/17 CSED702D: Internet Traffic Monitoring and Analysis Libpcap based Software  Libpcap based Software  ntop - network top A network traffic probe that shows the network usage Sort network traffic according to many protocols  snort Intrusion prevention and detection system Sniff every packet and differentiate general and intrusion by against rules  ethereal Network protocol analyzer  Wireshark A free and open-source packet analyzer Originally named Ethereal, after renamed as wireshark in May 2006, due to trade mark issues

POSTECH 18/17 CSED702D: Internet Traffic Monitoring and Analysis Q&A