Hacking Techniques & Intrusion Detection Ali Al-Shemery arabnix [at] gmail.

Slides:



Advertisements
Similar presentations
Overview The TCP/IP Stack. The Link Layer (L2). The Network Layer (L3). The Transport Layer (L4). Port scanning & OS/App detection techniques. Evasion.
Advertisements

Lecture Materials for the John Wiley & Sons book: Cyber Security: Managing Networks, Conducting Tests, and Investigating Intrusions April 14, 2015 DRAFT1.
COEN 252 Computer Forensics Using TCPDump / Windump for package analysis.
Hacking Techniques & Intrusion Detection Ali Al-Shemery arabnix [at] gmail.
TCP/IP Fundamentals A quick and easy way to understand TCP/IP v4.
Computer Security Fundamentals
Nmap Experiment.
NMAP Scanning Options. EC-Council NMAP  Nmap is the most popular scanning tool used on the Internet.  Cretead by Fyodar ( it.
Hands-On Ethical Hacking and Network Defense Second Edition Chapter 5 Port Scanning.
Hands-On Ethical Hacking and Network Defense Chapter 5 Port Scanning.
IP Network Scanning.
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Scanning.
Hands-On Ethical Hacking and Network Defense Chapter 5 Port Scanning Last updated
Scanning Determining if the system is alive IP Scanning Port Scanning War Dialing.
Hacking Exposed 7 Network Security Secrets & Solutions Chapter 2 Scanning 1.
System Security Scanning and Discovery Chapter 14.
Scanning February 23, 2010 MIS 4600 – MBA © Abdou Illia.
1 Anti-Hacker Tool Kit Port Scanners Chapter 6. 2 Introduction The first step in the process of hacking –Discover the services –Version label –Operation.
Information Networking Security and Assurance Lab National Chung Cheng University 1 Port Scanners.
Computer Security and Penetration Testing
ECE Prof. John A. Copeland fax Office: Klaus 3362.
CIS 193A – Lesson12 Monitoring Tools. CIS 193A – Lesson12 Focus Question What are the common ways of specifying network packets used in tcpdump, wireshark,
Penetration Testing.
Port Scanning.
1 Lab 3 Transport Layer T.A. Youngjoo Han. 2 Transport Layer  Providing logical communication b/w application processes running on different hosts 
Ana Chanaba Robert Huylo
SCSC 555 Frank Li.  Port scanning  Port-scanning tools  Ping sweeps 2.
Penetration Testing Security Analysis and Advanced Tools: Snort.
1 Reconnaissance, Network Mapping, and Vulnerability Assessment ECE4112 – Internetwork Security Georgia Institute of Technology.
Karlstad University Introduction to Vulnerability Assessment Labs Ge Zhang Dvg-C03.
Port Scanning 0x470~0x480 Presenter SangDuk Seo 1.
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Scanning.
This courseware is copyrighted © 2015 gtslearning. No part of this courseware or any training material supplied by gtslearning International Limited to.
Chapter 4 TCP/IP Overview Connecting People To Information.
Scapy. Introduction  It’s a packet manipulation tool.  It can forge or decode packets of a wide number of protocols, send them on the wire, capture.
Snort & Nmap Mike O’Connor Eric Tallman Matt Yasiejko.
MIS Week 4 Site:
1 Reconnaissance, Network Mapping, and Vulnerability Assessment ECE4112 – Internetwork Security Georgia Institute of Technology.
1 Reconnaissance, Network Mapping, and Vulnerability Assessment ECE4112 – Internetwork Security Georgia Institute of Technology.
Linux Networking and Security
Information Networking Security and Assurance Lab National Chung Cheng University 1 Port Scanners.
Chapter 2 Scanning Last modified Determining If The System Is Alive.
1 Lab 1: Reconnaissance, Network Mapping, and Vulnerability Assessment Reconnaissance Scanning Network Mapping Port Scanning OS detection Vulnerability.
Scanning & Enumeration Lab 3 Once attacker knows who to attack, and knows some of what is there (e.g. DNS servers, mail servers, etc.) the next step is.
Trinity Uses Nmap, shouldn’t you?. From “The Art of War” "... knowing your enemy 100% of the time, you will win your battle 100% of the time, knowing.
Networked Systems Survivability CERT ® Coordination Center Software Engineering Institute Carnegie Mellon University Pittsburgh, PA © 2002 Carnegie.
Advanced Packet Analysis and Troubleshooting Using Wireshark 23AF
Hands-On Ethical Hacking and Network Defense
COMP2322 Lab 1 Introduction to Wireshark Weichao Li Jan. 22, 2016.
Scanning.
or call for office visit,
Network and Port Scanning Chien-Chung Shen
Introduction to Vulnerability Assessment Labs Ge Zhang Dvg-C03.
Protection (tools).
Hands-On Ethical Hacking and Network Defense
Penetration Testing Scanning
Port Scanning James Tate II
Lab 2: Packet Capture & Traffic Analysis with Wireshark
CITA 352 Chapter 5 Port Scanning.
Intro to Ethical Hacking
Network Commands 2 Linux Ubuntu A.S.
Hping2.
or call for office visit,
Port Scanning (based on nmap tool)
CIT 480: Securing Computer Systems
Information Gathering
Intro to Ethical Hacking
Intro to Ethical Hacking
EVAPI - Enumeration Auburn Hacking club
Presentation transcript:

Hacking Techniques & Intrusion Detection Ali Al-Shemery arabnix [at] gmail

All materials is licensed under a Creative Commons “Share Alike” license. 2

# whoami Ali Al-Shemery Ph.D., MS.c., and BS.c., Jordan More than 14 years of Technical Background (mainly Linux/Unix and Infosec) Technical Instructor for more than 10 years (Infosec, and Linux Courses) Hold more than 15 well known Technical Certificates Infosec & Linux are my main Interests 3

Scanning and Fingerprinting

Outline Diving into Important Network Protocols (TCP, UDP, ICMP, ARP, etc) Nmap – Intro. Host Discovery Tracing the Route Port Scanning OS and Service Fingerprinting Learning Python in 4 Slides Packet Crafting 5

Diving into Important Network Protocols Diving into Important Network Protocols: – TCP – UDP – ICMP – ARP – HTTP – etc 6

Nmap "Network Mapper” is a free and open source utility for network discovery and security auditing. - Fyodor IMO: #1 tool in your security arsenal! Important Note: A huge difference between running Nmap as a privileged/unprivileged user! 7

Host Discovery Identifying Live Systems Also called “Network Sweep” Nmap ping sweeps: – Ping Only (-sP) – ARP Ping (-PR) – ICMP Echo Request Ping (-PE) – TCP SYN Ping (-PS) – TCP ACK Ping (-PA) – UDP Ping (-PU) DEMO 8

Assignment #1 Why do host discovery or network sweeping if we already have the target list of IP(s)? 9

Tracing the Route Nmap --traceroute option DEMO 10

Port Scanning The act of testing a remote port to know in which state it is. Common port states: – Open, – Closed, – and Filtered. DEMO 11

Port Scanning - Techniques TCP SYN or Stealth Scan (-sS) TCP Connect Scan (-sT) TCP ACK Scan UDP Scan (-sU) TCP FIN Scan (-sF) TCP NULL Scan (-sN) XMAS Scan Scan (-sX) Custom Scan (--scanflags) IP Protocol Scan (-sO) DEMO 12

OS and Service Fingerprinting Operating System Detection (-O) Service Version Detection (-sV) Or Enables OS detection and Version detection, Script scanning and Traceroute (-A) DEMO 13

Evasion Techniques Fragment Packets (-f) Specific MTU (--mtu) Using a Decoy (-D) Specify source port (--source-port) Append Random Data (--data-length) Spoof MAC Address (--spoof-mac) Send Bad Checksum (--badsum) That’s all? Nope, check the next slide. 14

IDLE Scan A completely blind port scanning technique, that attackers can use to scan a target without sending a single packet to the target from their own IP address! Nmap IDLE Scan (-sI) 15

IDLE Scan – Open Port 16

IDLE Scan – Closed Port 17

IDLE Scan – Filtered Port 18

Assignment #2 Choose One: How can we find an IDLE machine? What is Nmap’s Scripting Engine? And how can we benefit from it? 19

Learning Python in 4 Slides!!!

Python in 4 Slides (1/4) Python is an open source scripting language. Developed by Guido van Rossum in the early 1990s. Name came from TV series “Monty Python’s Flying Circus”. Python is cross platform (Linux, Windows, Mac, etc). Ideal language for scripting and rapid application development in many areas on most platforms. If you’re involved in vulnerability research, reverse engineering or penetration testing, I suggest “Python” for you. 21

Learning Python in 4 Slides (2/4) Why Python for Penetration Testers? – Simple, and easy to learn, – Free and Open Source, – powerful high-level programming language – relatively fast, – widely used, and – Portable, – Extensive Libraries, – Interpreted, Extensible, Embeddable 22

Learning Python in 4 Slides (3/4) This is an int (signed, 32bits) : 88 This is a long (signed, infinite): 88L This is a str : "bell\x07\n" or ’bell\x07\n’ (" ⇐⇒ ’) This is a tuple (immutable): (0,1,“33") This is a list (mutable): [8,4,2,"1"] This is a dict (mutable): { "one":1, "two":2 } 23

Learning Python in 4 Slides (4/4) if condition1: instruction1 instruction2 elif condition2: instruction else: instruction while condition: instruction for variable in set: instruction try: instruction except exception: instruction else: instruction lambda x,y: x+y def fact(x): if x == 0: return 1 else: return x*fact(x-1) import httplib from scapy.all import ARP from scapy.all import * import scapy.all as scapy 24

Packet Crafting

What is Packet Crafting? The art of manually generating packets to test network devices, Packets are crafted to test Firewalls, IDS, TCP/IP Stack,....,etc, Auditing network protocols looking for vulnerabilities to exploit, Find inconsistencies and poor network protocol implementations. 26

Packet Crafting – Cont. Crafting test Packets is an Art! Different tools are available to Craft Packets, BUT the process of Crafting Packets in such a way that will stress test protocols, firewalls and any other network devices for the purpose of uncovering faults, is an Art. 27

Packet Crafting Composition Packet Crafting consist of: – Packet Assembly, – Packet Editing, – Packet Re-Play, – and Packet Decoding 28

Packet Crafting Tools Best Packet Crafters: Scapy - hping3 - Netdude - tcpreplay

Packet Crafting with Scapy

Scapy Overview Scapy is a Python program that enables the user to send, sniff and dissect and forge network packets. This capability allows construction of tools that can probe, scan or attack networks. It can replace hping, arpspoof, arp-sk, arping, p0f and even some parts of Nmap, tcpdump, and tshark. 31

Scapy Overview – Cont. Scapy was created by Philippe Biondi and runs in Python: – Can be used interactively at a Python prompt – Included within Python scripts for more complex interactions Must run with root privileges to craft packets, Don’t need to be a Python Guru to use Scapy! 32

Scapy Basics - 1 Supported protocols: >>> ls() Details about a specific protocol: >>> ls(TCP) Available commands/functions: >>> lsc() 33

Scapy Basics - 2 Crafting a SYN/ACK Packet >>> pkt = IP(dst=" ") >>> pkt /= TCP(dport=80, flags="SA") Crafting ICMP Host Unreachable Packet >>> pkt = IP(dst=" ") >>> pkt /= ICMP(type=3,code=1) 34

Scapy Basics - 3 Single Line: ICMP echo request Packet >>> mypkt = IP(dst=" ") /ICMP(code=0,type=8) TCP FIN, Port 22, Random Source Port, and Random Seq# >>> mypkt = IP(dst=" ") /TCP(dport=22,sport=RandShort(),seq=RandS hort(),flags="F") 35

Sending and Receiving Packets Send packet at layer 3 >>> send(packet) Send packet at L3 and receive one response >>> resp = sr1(packet) Send packet at L3 and receive all responses >>> ans,unans = sr(packet) 36

Sending and Receiving Packets Send packet at layer 2 >>> sendp(Ether()/packet) Send packet at L2 and receive one response >>> resp = srp1(packet) Send packet at L2 and receive all responses >>> ans,unans = srp(packet) 37

Displaying Packets Get a summary of each packet: >>> pkts.summary() Get the whole packet list: >>> pkts.show() 38

Scapy Host Discovery >>> ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst =" /24"),timeout=2) >>> ans.summary(lambda(s,r): r.sprintf("Ether: %Ether.src% \t\t Host: %ARP.psrc%")) 39

Scapy Port Scanning TCP SYN Scanner >>> sr1(IP(dst=" ") /TCP(dport=90,flags="S")) >>> a,u = sr(IP(dst=" ") /TCP(dport=(80,100),flags="S")) >>> a.summary(lambda(s,r): r.sprintf("Port: %TCP.sport% \t\t Flags: %TCP.flags%")) 40

Scapy Sniffing - 1 Scapy has powerful capabilities to capture and analyze packets. Configure the network interface to sniff packets from: >>> conf.iface="eth0“ Configure the scapy sniffer to sniff only 20 packets >>> pkts=sniff(count=20) 41

Scapy Sniffing - 2 Sniff packets and stop after a defined time: >>> pkts=sniff(count=100,timeout=60) Sniff only packets based on a filter: >>> pkts = sniff(count=100,filter="tcp port 80") 42

Scapy Sniffing - 3 >>> pkts = sniff(count=10,prn=lambda x:x.sprintf("SrcIP={IP:%IP.src% -> DestIP=%IP.dst%} | Payload={Raw:%Raw.load%\n}")) What is that doing ??? 43

Exporting Packets Sometimes it is very useful to save the captured packets in a PCAP file for future work: >>> wrpcap(“file1.cap", pkts) Dumping packets in HEX format: >>> hexdump(pkts) Dump a single packet in HEX format: >>> hexdump(pkts[2]) Convert a packet to hex string: >>> str(pkts[2]) Exporting to Base64 encoded packets: >>> export_object(pkts) 44

Importing Packets To import from a PCAP file: >>> pkts = rdpcap(“file1.cap") Or use the scapy sniffer but with the offline argument: >>> pkts2 = sniff(offline="file1.cap") 45

Create your own tools >>> def handler(packet): hexdump(packet.payload) >>> sniff(count=20, prn=handler) >>> def handler2(packet): sendp(packet) >>> sniff(count=20, prn=handler2) 46

Create your own tools – 2 arpping.py listpacket.py arppoisonor.py 47

Assignment #3 Create your own tools Choose any two: [1] Create a TCP ACK Port Scanner [2] Create a TCP Replay Tool [3] Create a UDP Ping Tool [4] Create a Sniffer that filters based on user input 48

SUMMARY Diving into Important Network Protocols (TCP, UDP, ICMP, HTTP, etc) Sweep Networks to discover hosts Scan systems to discover open ports Fingerprint OS’s and services Craft your own packets using Scapy 49

References [1] William Zereneh, [2] Mike Poor, Packet Craft for Defense-in-Depth, [3] SecTools.Org: Top 125 Network Security Tools, [4] Scapy Documentation, [5] Python, [6] Python tools for penetration testers, loss.de/python-tools.htm [7] Nmap Book Online, 50