Advanced Protocol Fuzzing
Advanced Protocol Fuzzing
Sulley
Why we Initially Chose SPIKE
Includes “proven” fuzzing strings
Written in C
Efficiency:
Write a generic program once (e.g. for TCP, UDP or Layer 2)
Add context-based payloads to this generic program via scripting
interface ( protocol descriptions )
Very easy to use framework functions
Can be used in the scripts or in a “common C program”
Complete code under GPLv2
Get package
Unpack, ./configure, make
s_block_start("netbiosblock");
//*SMBSERVER
s_string_variable(" CKFDENECFDEFFCFGEFFCCACACACACACA");
s_binary("00");
//LOCALHOST
s_string_variable(" EMEPEDEBEMEIEPFDFECACACACACACAAA");
s_binary("00");
s_block_end("netbiosblock");
Protocol Definitions –
The Simple Approach
Sniff packets
Transform structures to prot. definition
Wireshark is your friend here ;-)
Problem here:
s_string_variable takes any string, not just those with length of six bytes
SPIKE is byte-oriented
No handling of protocol information with “odd sizes” possible
No handling of bit fields (e.g. TLVs)
One of the reasons why we later switched to Sulley
Additional functions
s_random_fuzz(), s_random_fuzz_repeat()
fuzz completely random data with fixed size
[based on POSIX rand()]
s_binary_type_and_block_size_lldp()
l2_write_data()
s_binary_selection()
s_string_variable_sized()
Overview ;-)
libnet.h
listener.h
tcpstuff.h udpstuff.h l2stuff.h dlrpc.h dlargs.h
-struct listener
-struct lldpTlv
spike.h
-struct spike
MPLS
LLDP
VTP
DTP
WLCCP (only for Sulley)
MPLS
0 1920 22 2324 31
20-Bit Label
Short information entity without further internal structure
3-Bit Experimental-Bits (e.g. for CoS)
1-Bit Bottom-of-Stack Indicator (Label Stack)
8-Bit TTL-Field (Loop Mitigation)
MPLS (header) protocol definition
Demo
LLDP
Nearly no effect
[albeit packets obviously processed]
Possible cause for VTP (non-)results
DTP Packet Format
s_block_start("Domain");
s_binary("0001"); /* Type: Domain */
s_binary_block_size_byte("Domain"); /* Domain length */
s_binary("00"); /* Domain: none */
s_block_end("Domain");
s_block_start("Status");
s_binary("0002"); /* Type: Status */
s_binary_block_size_byte("Status"); /* Status length */
s_int_variable(0, 3); /* Status - ONEBYTE */
s_block_end("Status");
s_block_start("DTPtype");
s_binary("0003"); /* Type: DTPtype */
s_binary_block_size_byte("DTPtype"); /* DTPtype length */
s_int_variable(1, 3); /* DTPtype - ONEBYTE */
s_block_end("DTPtype");
s_block_start("Neighbor");
s_binary("0004"); /* Type: Neighbor */
s_binary_block_size_byte("DTPtype"); /* Neighbor length */
s_int_variable(0, 1); /* Neighbor byte 0,1 - BINARYBIGENDIAN */
s_int_variable(0, 1); /* Neighbor byte 2,3 - BINARYBIGENDIAN */
s_int_variable(0, 1); /* Neighbor byte 4,5 - BINARYBIGENDIAN */
s_block_end("Neighbor");
Results – DTP
DTP was easy, too. But we did not see the same results… why?
Other fuzz strings
We didn’t fuzz the whole variable range, as we did in SPIKE
The Sulley ARP script
from sulley import *
s_initialize("arp")
s_binary("0xff ff ff ff ff ff")
s_binary("0x01 02 03 04 05 06")
s_binary("0x08 06")
sess.fuzz()
Another protocol definition: WLCCP
No documentation available
Wireshark gives a starting point, but as the implementation seems
incomplete and flawed (at least at layer2) there was (and is) a lot
more work to do.
The WLCCP Sulley script (excerpt ;-)
from sulley import *
s_initialize("WLCCPoUDP")
s_block_start("Payload")
s_byte(0x1c) #Version
s_bit_field(1, 2) #SAP Version
s_bit_field(0, 6) #SAP ID
s_word(0x0008) #Dest Node type
s_size("Payload", length=2, endian=">") #Length
s_bit_field(0, 2) #Subtype
s_bit_field(11, 6) #Base MsgType
s_byte(0x00) #Hops
s_byte(0x0001) #MsgID
s_bit_field(8192, 16) #Flags
s_word(0x0001) #Originator Node type
s_bit_field(0x000cce333225, 48) #Orginator MAC
s_word(0x0008) #Responder Node type
Results – WLCCP
However every now and then APs crash and need hard
resets afterwards. So far we are not able to reproduce this
behavior in a controlled manner.
Next steps:
Reverse engineer the protocol
Understand the WLCCP state machine and build different scripts for all
the states
The Code
Will this stuff be available?
http://www.ernw.de/download/snmpattack.pl
Summary