Scapy the packet 途中01

33
SCAPY - 2016.10.09 1

Transcript of Scapy the packet 途中01

Page 1: Scapy the packet 途中01

SCAPY - 2016.10.09

1

Page 2: Scapy the packet 途中01

SCAPY

2

Page 3: Scapy the packet 途中01

SCAPY

SCAPY

▸ Python ⭐

▸ 2011 Release

👉

▸ HP secdev.org

👉Python2

▸ Python3

👉

▸ PhilippeBiondi

👉

3

Page 4: Scapy the packet 途中01

SCAPY

SCAPY

4

▸ Scapy Wireshark/pcap

Page 5: Scapy the packet 途中01

SCAPY

SCAPY

5

Wireshark

hping3

ASIC

openflow

send socket socket 👉

recv sniff 1pkt dissector dissect 👉

Scapy L5 👉 L7 👉 👉

Page 6: Scapy the packet 途中01

SCAPY

SCAPY

6

▸ Scapy

1. Scapy Field

2. Scapy Packet

3. Scapy bind

‣ Scapy GPLv2

scapy/modules

load_module("<module name>")

scapy/contrib

load_contrib("<proto name>")

Page 7: Scapy the packet 途中01

SCAPY & PROTOCOL

7

Page 8: Scapy the packet 途中01

SCAPY

▸ Packet - scapy.packet.Packet

IP TCP

Field

https://github.com/phaethon/scapy/blob/master/scapy/packet.py ▸ Field - scapy.fields.Field

IP

Field

https://github.com/phaethon/scapy/blob/master/scapy/fields.py

8SCAPY

Packet

Field Field

Page 9: Scapy the packet 途中01

▸ Transmission Control Protocol [https://www.ietf.org/rfc/rfc793.txt] Scapy Field

Scapy TCP Padding

Scapy TCP data Payload

9SCAPY

SCAPY TCP / RFC TCP

Page 10: Scapy the packet 途中01

▸ Packet

MUST

fields_desc :

list Field

Building :

fields_desc Field

Padding CheckSum Build Payload

Dissecting :

Wireshark (Dissector) Dissection Payload

Binding :

Building Dissecting Payload

MAY

Show/Display :

PACKET CLASS

10

SCAPY

Page 11: Scapy the packet 途中01

FIELD CLASS

11SCAPY

▸ Field i2m h2i

m: ( )

b"¥x00¥x01¥x02...." ※Python2 str Python3 bytes

i: ( ) Python

str,bytes,int,long,

h: ( ) Scapy

named flag, enum,...

repr: ++( )

repr()

‣ Field

Field

Page 12: Scapy the packet 途中01

▸ bytes(pkt) Packet.build()

▸ Field struct.pack

▸ Padding

▸ Binding Payload Building

BUILDING

12SCAPY

Page 13: Scapy the packet 途中01

▸ Ether(“xxxxxx”)

(L2 RadioTap)

payload

▸ L2 conf.l2types

▸ Binding Payload Dissecting

DISSECTING

13SCAPY

Page 14: Scapy the packet 途中01

▸ Building Dissecting

▸ bind_layers()

▸ Scapy

▸ Packet.guess_payload_class()

BINDING

14SCAPY

Page 15: Scapy the packet 途中01

IP

15

Page 16: Scapy the packet 途中01

BINDING

16

DISSECTING

BUILDING

SCAPY

Page 17: Scapy the packet 途中01

OK?

17

Page 18: Scapy the packet 途中01

CHALLENGE!

18

Page 19: Scapy the packet 途中01

👉 Chap.6 ADDING NEW PROTOCOLS

CHALLENGE!

19SCAPY

Page 20: Scapy the packet 途中01

20SCAPY

CHAP.6 ADDING NEW PROTOCOLS

Page 21: Scapy the packet 途中01

21SCAPY

CHAP.6 ADDING NEW PROTOCOLS

Page 22: Scapy the packet 途中01

22SCAPY

CHAP.6 ADDING NEW PROTOCOLS

Page 23: Scapy the packet 途中01

▸ Packet

▸ 1

23SCAPY

SIMPLE EXAMPLE!?

2

Page 24: Scapy the packet 途中01

▸ OSI 7

▸ Padding 7

▸ 3

24SCAPY

SIMPLE EXAMPLE

Page 25: Scapy the packet 途中01

25

Page 26: Scapy the packet 途中01

▸ RFC

▸ Scapy

26SCAPY

Page 27: Scapy the packet 途中01

27SCAPY

Page 28: Scapy the packet 途中01

HTCPCP

28SCAPY

Page 29: Scapy the packet 途中01

HTCPCP

HYPER TEXT COFFEE POT CONTROL PROTOCOL

29

Page 30: Scapy the packet 途中01

SCAPY

HTCPCP

▸ REST

▸ IoT

30

Page 31: Scapy the packet 途中01

31

Page 32: Scapy the packet 途中01

▸ py2K

latest: http://github.com/secdev/scapy ▸ (py3K )

latest: https://github.com/phaethon/scapy ▸

http://www.dirk-loss.de/scapy-doc/Scapy.pdf ▸

http://packetlife.net/media/library/36/scapy.pdf

32SCAPY

Page 33: Scapy the packet 途中01

ENJOY

33SCAPY