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



Similar documents
Scanning Tools. Scan Types. Network sweeping - Basic technique used to determine which of a range of IP addresses map to live hosts.

Writing Basic Security Tools using Python

CIT 380: Securing Computer Systems

Why use Scapy? Blue Team. Red Team. Test IDS/IPS Test Firewall Learn more about TCP/IP (down and dirty) Application response(fuzzing)

Port Scanning and Vulnerability Assessment. ECE4893 Internetwork Security Georgia Institute of Technology

Network Scanning. What is a Network scanner? Why are scanners needed? How do scanners do? Which scanner does the market provide?

An Introduction to Nmap with a Focus on Information Gathering. Ionuț Ambrosie

Port Scanning. Objectives. Introduction: Port Scanning. 1. Introduce the techniques of port scanning. 2. Use port scanning audit tools such as Nmap.

CYBER ATTACKS EXPLAINED: PACKET CRAFTING

NETWORK SECURITY WITH OPENSOURCE FIREWALL

Host Discovery with nmap

Network Security. Network Scanning

Host Fingerprinting and Firewalking With hping

Overview of Network Security The need for network security Desirable security properties Common vulnerabilities Security policy designs

Remote Network Analysis

Penetration Testing. What Is a Penetration Testing?

Network Penetration Testing and Ethical Hacking Scanning/Penetration Testing. SANS Security Sans Mentor: Daryl Fallin


Make a folder named Lab3. We will be using Unix redirection commands to create several output files in that folder.

Python Scripting with Scapy

Presented By: Holes in the Fence. Agenda. IPCCTV Attack. DDos Attack. Why Network Security is Important

Scapy. On-the-fly Packet Generation by Dienstag, 10. Januar 12

Network Security CS 192

Lecture 5: Network Attacks I. Course Admin

Nmap: Scanning the Internet

Security: Attack and Defense

Introduction. Nmap from an Ethical Hacker's View Part 1. By Kirby Tucker

Attacks and Defense. Phase 1: Reconnaissance

Linux Network Security

Introduction Présentation de scapy. Scapy. Easy Packet Handling. Etienne Maynier. Capitole du Libre 24 Novembre 2012

Introduction to Network Security Lab 2 - NMap

Firewall implementation and testing

ft6 Motivation next step: perform the tests usually tedious, error prone work aided by a tool easily repeatable enter ft6 ft6

Chapter 6 Phase 2: Scanning

Chapter 8 Security Pt 2

Some Tools for Computer Security Incident Response Team (CSIRT)

Penetration Testing 2014

1. LAB SNIFFING LAB ID: 10

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

Stop that Big Hack Attack Protecting Your Network from Hackers.

Looking for Trouble: ICMP and IP Statistics to Watch

Vulnerability Assessment and Penetration Testing

Attacking the TCP Reassembly Plane of Network Forensics Tools

A Very Incomplete Diagram of Network Attacks

Outline. Outline. Outline

Network and Services Discovery

Learn Ethical Hacking, Become a Pentester

A Study on The Information Gathering Method for Penetration Testing

Passive Network Traffic Analysis: Understanding a Network Through Passive Monitoring Kevin Timm,

Computer forensics

Assessing Network Security

Network Forensics: Detection and Analysis of Stealth Port Scanning Attack

Defending Computer Networks Lecture 7: Port Scanning. Stuart Staniford Adjunct Professor of Computer Science

SY system so that an unauthorized individual can take over an authorized session, or to disrupt service to authorized users.

Network Security. Marcus Bendtsen Institutionen för Datavetenskap (IDA) Avdelningen för Databas- och Informationsteknik (ADIT)

CS5008: Internet Computing

Firewall Testing. Cameron Kerr Telecommunications Programme University of Otago. May 16, 2005

Packet Sniffing and Spoofing Lab

Course Title: Penetration Testing: Security Analysis

Dos & DDoS Attack Signatures (note supplied by Steve Tonkovich of CAPTUS NETWORKS)

Attack Lab: Attacks on TCP/IP Protocols

PTSv2 in pills: The Best First for Beginners who want to become Penetration Testers. Self-paced, online, flexible access

Project 2: Firewall Design (Phase I)

CSCE 465 Computer & Network Security

Remote Network Analysis

How To Test For Penetration On The Cloud

FIREWALLS. Firewall: isolates organization s internal net from larger Internet, allowing some packets to pass, blocking others

IxLoad-Attack: Network Security Testing

Penetration Testing SIP Services

SECURITY TOOLS SOFTWARE IN AN OPEN SOURCE ENVIRONMENT. Napoleon Alexandru SIRETEANU *

Information Security. Training

Session Hijacking Exploiting TCP, UDP and HTTP Sessions

Chapter 8 Network Security

1! Network forensics

Nmap Cookbook The fat-free guide to network scanning

Firewalls. Ola Flygt Växjö University, Sweden Firewall Design Principles

Network Packet Analysis and Scapy Introduction

Keywords Vulnerability Scanner, Vulnerability assessment, computer security, host security, network security, detecting security flaws, port scanning.

Tools for penetration tests 1. Carlo U. Nicola, HT FHNW With extracts from documents of : Google; Wireshark; nmap; Nessus.

How To Hack A Nmap Port Scan With A 10 Second Delay On A Network With A Network On A Windows Server (For A Freebie) On A Linux Computer (For Freebie). For A Free Download) On An Ipnet (For

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

Northwestern University MSIT 458 Information Security

Attack and Defense Techniques

OLD VULNERABILITIES IN NEW PROTOCOLS? HEADACHES ABOUT IPV6 FRAGMENTS

TESTING OUR SECURITY DEFENCES

ACHILLES CERTIFICATION. SIS Module SLS 1508

Algorithms and Techniques Used for Auto-discovery of Network Topology, Assets and Services

Distributed Systems Security

Malicious Network Traffic Analysis

Guide to Network Defense and Countermeasures Third Edition. Chapter 2 TCP/IP

The Nexpose Expert System

Internet Security and Acceleration Server 2000 with Service Pack 1 Audit. An analysis by Foundstone, Inc.

During your session you will have access to the following lab configuration. CLIENT1 (Windows XP Workstation) /24

How do I get to

Vulnerability Assessment and Penetration Testing. CC Faculty ALTTC, Ghaziabad

Penetration Testing. NTS330 Unit 1 Penetration V1.0. February 20, Juan Ortega. Juan Ortega, juaorteg@uat.edu. 1 Juan Ortega, juaorteg@uat.

Packet Sniffers Submitted in partial fulfillment of the requirement for the award of degree Of MCA

Lab 7: Introduction to Pen Testing (NMAP)

Firewalls. configuring a sophisticated GNU/Linux firewall involves understanding

testing your IPv6-firewall with ft6

Transcription:

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

All materials is licensed under a Creative Commons Share Alike license. http://creativecommons.org/licenses/by-sa/3.0/ 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 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 try: instruction except exception: instruction else: instruction def fact(x): if x == 0: return 1 else: return x*fact(x-1) while condition: instruction instruction for variable in set: instruction lambda x,y: x+y import httplib from scapy.all import ARP from scapy.all import * import scapy.all as scapy 24

Packet Crafting

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 - http://www.secdev.org/projects/scapy/ hping3 - http://www.hping.org/ Netdude - http://netdude.sourceforge.net/ tcpreplay - http://tcpreplay.synfin.net/trac/ 29

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="192.168.122.101") >>> pkt /= TCP(dport=80, flags="sa") Crafting ICMP Host Unreachable Packet >>> pkt = IP(dst="192.168.122.101") >>> pkt /= ICMP(type=3,code=1) 34

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

Sending and Receiving Packets @L3 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 @L2 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 ="192.168.122.0/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="192.168.122.101") /TCP(dport=90,flags="S")) >>> a,u = sr(ip(dst="192.168.122.101") /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, http://www.scs.ryerson.ca/~zereneh/cn8822/packetcrafting.pdf [2] Mike Poor, Packet Craft for Defense-in-Depth, http://www.inguardians.com/research/docs/packetfoo.pdf [3] SecTools.Org: Top 125 Network Security Tools, http://sectools.org/tag/packet-crafters/ [4] Scapy Documentation, http://www.secdev.org/projects/scapy/doc/ [5] Python, http://www.python.org/ [6] Python tools for penetration testers, http://www.dirkloss.de/python-tools.htm [7] Nmap Book Online, http://nmap.org/book/ 50