Syscall Proxying   Simulating Remote Execution Maximiliano Cáceres  Caesars Palace, Las Vegas, NV, USA · July 31st, 2002.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Smashing the Stack for Fun and Profit
CS 4284 Systems Capstone Godmar Back Processes and Threads.
David Brumley Carnegie Mellon University Credit: Some slides from Ed Schwartz.
Operating System Security : David Phillips A Study of Windows Rootkits.
Countermeasures 0x610~0x Seokmyung Hong.
Review: Software Security David Brumley Carnegie Mellon University.
1 CHAPTER 8 BUFFER OVERFLOW. 2 Introduction One of the more advanced attack techniques is the buffer overflow attack Buffer Overflows occurs when software.
PC hardware and x86 3/3/08 Frans Kaashoek MIT
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
Embedded Real-time Systems The Linux kernel. The Operating System Kernel Resident in memory, privileged mode System calls offer general purpose services.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
Assembly תרגול 8 פונקציות והתקפת buffer.. Procedures (Functions) A procedure call involves passing both data and control from one part of the code to.
.NET Mobile Application Development Remote Procedure Call.
Efficient Instruction Set Randomization Using Software Dynamic Translation Michael Crane Wei Hu.
CS252: Systems Programming Ninghui Li Final Exam Review.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
6.828: PC hardware and x86 Frans Kaashoek
Chapter 6 Operating System Support. This chapter describes how middleware is supported by the operating system facilities at the nodes of a distributed.
Implementing system calls in the Y86 model Soumava Ghosh.
KGuard: Lightweight Kernel Protection against Return-to-User Attacks Authors: Vasileios P. Kemerlis Georgios Portokalidis Angelos D. Keromytis Presenter:
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Code Generation Gülfem Savrun Yeniçeri CS 142 (b) 02/26/2013.
Introduction: Exploiting Linux. Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend,
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
The ISA Level The Instruction Set Architecture (ISA) is positioned between the microarchtecture level and the operating system level.  Historically, this.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
1 CSE 451 Section 2: Interrupts, Syscalls, Virtual Machines, and Project 1.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
MICHALIS POLYCHRONAKIS(COLUMBIA UNIVERSITY,USA), KOSTAS G. ANAGNOSTAKIS(NIOMETRICS, SINGAPORE), EVANGELOS P. MARKATOS(FORTH-ICS, GREECE) ACSAC,2010 Comprehensive.
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
CNIT 127: Exploit Development Ch 3: Shellcode. Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object.
Buffer Overflow Attack Proofing of Code Binary Gopal Gupta, Parag Doshi, R. Reghuramalingam, Doug Harris The University of Texas at Dallas.
CNIT 127: Exploit Development Ch 1: Before you begin.
Operating Systems Security
Shellcode Development -Femi Oloyede -Pallavi Murudkar.
Department of Computer Science and Software Engineering
Web Services An Introduction Copyright © Curt Hill.
Lessons learned writing exploits LESSONS LEARNED WRITING EXPLOITS Gerardo Richarte  Iván Arce 
Buffer Overflows Taught by Scott Coté.-. _ _.-. / \.-. ((___)).-. / \ /.ooM \ / \.-. [ x x ].-. / \ /.ooM \ -/ \ /-----\-----/---\--\ /--/---\-----/-----\ / \-
Information Security - 2. A Stack Frame. Pushed to stack on function CALL The return address is copied to the CPU Instruction Pointer when the function.
Security Attacks Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
About Exploits Writing ABOUT EXPLOITS WRITING Gerardo Richarte 
Introduction to InfoSec – Recitation 3 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (infosec15 at modprobe.net)
ROP Exploit. ROP Return Oriented Programming (ROP): is a hacking exploit technique where you exploit buffer overflow to inject a chain of gadgets. Each.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
CSNB334 Advanced Operating Systems 3. Kernel Structure and Organization Lecturer: Abdul Rahim Ahmad.
Computer System Structures
Exploiting & Defense Day 1 Recap
Return Oriented Programming
CHAPTER 4 Methodology.
CS 3214 Computer Systems Lecture 9 Godmar Back.
Introduction to Information Security
Assembly language.
Static and dynamic analysis of binaries
C function call conventions and the stack
Operating Systems Engineering
Anton Burtsev February, 2017
Exploiting & Defense Day 2 Recap
Summary by - Bo Zhang and Shuang Guo [Date: 03/31/2014]
System Calls David Ferry CSCI 3500 – Operating Systems
Week 2: Buffer Overflow Part 1.
Week 2: Buffer Overflow Part 2.
System Calls System calls are the user API to the OS
System and Cyber Security
Return-to-libc Attacks
Presentation transcript:

Syscall Proxying   Simulating Remote Execution Maximiliano Cáceres  Caesars Palace, Las Vegas, NV, USA · July 31st, 2002

Syscall Proxying   Simulating Remote Execution Agenda  General Concepts Agenda  Syscall Proxying  A first implementation  Optimizing for size  The real world: applications

Syscall Proxying   Simulating Remote Execution General Concepts

Syscall Proxying   Simulating Remote Execution A Process Interacts with Resources Process Operating System A file in diskThe screen A networking card

Syscall Proxying   Simulating Remote Execution Syscalls  System calls (aka “syscalls”)  Operating system services  Lowest layer of communication between a user mode process and the kernel

Syscall Proxying   Simulating Remote Execution  The UNIX Way  Homogeneous mechanism for calling any syscall by number  Arguments passed through the stack or registers  Minimum number of system services  Direct mapping between syscall and libc wrapper The System Services Layer  The Windows Way  Native API undocumented and unsupported  High number of system level services (about 1000)  Win32 API calls implement a lot of functionality around these services

Syscall Proxying   Simulating Remote Execution Our Windows “Syscalls”  Keep things simple  ANY function in ANY dynamic library available to a user mode process

Syscall Proxying   Simulating Remote Execution Syscall Proxying

Syscall Proxying   Simulating Remote Execution The Process “Context”  A process uses resources to accomplish a goal  These resources define a “context” on which the process runs  The specific resource instances  The kind of access to these resources

Syscall Proxying   Simulating Remote Execution A process reading data from a file

Syscall Proxying   Simulating Remote Execution  Syscall stub / client  Nexus between process and system services  Converts syscall argument to a common format (marshaling)  Sends requests to the syscall server  Marshals return values Two Layers  Syscall server  Handles requests from the syscall client  Converts arguments in request to native convention  Calls the specified syscall  Sends back a response to the client

Syscall Proxying   Simulating Remote Execution A process reading data from a file, using these two layers

Syscall Proxying   Simulating Remote Execution Separating Client from Server Reader Process Remote system services Syscall stubSyscall server Network layerNetwork linkNetwork layer

Syscall Proxying   Simulating Remote Execution Syscall Proxying in Action

Syscall Proxying   Simulating Remote Execution  Separating client from server  The process accesses remote resources (a file)  The process uses the privileges of the remote server  The process doesn’t now anything about remote execution  No modifications on the original program  Same inner logic Changing Context

Syscall Proxying   Simulating Remote Execution A first implementation

Syscall Proxying   Simulating Remote Execution Implementing Syscall Proxying  The RPC Model  Client / server  Remote calls are handled by both a client stub and a server stub  Perfect match!

Syscall Proxying   Simulating Remote Execution The RPC Model

Syscall Proxying   Simulating Remote Execution Benefits and Shortcomings of the RPC Model  Benefits  Interoperability between different platforms  Almost any procedure call can be converted to RPC  Shortcomings  Both client and server symmetrically duplicate data conversion to a common data interchange format

Syscall Proxying   Simulating Remote Execution Optimizing for size

Syscall Proxying   Simulating Remote Execution The UNIX Syscall Mechanism  Homogeneous way of passing arguments  Integers  Pointers to integers  Pointers to buffers  Pointers to structs  Simple calling mechanism  Software interrupt  Trap  Far call

Syscall Proxying   Simulating Remote Execution Fat Client, Thin Server  Client code directly converts from the client system’s calling convention to the server’s (no intermediate common format)  The server takes advantage of the generic mechanism for calling syscalls  The client is completely dependent on the server’s platform

Syscall Proxying   Simulating Remote Execution Marshaling Arguments  Client code creates a request representing the stack state in the server just before invoking the syscall  Integers are trivially packed  Pointers to buffers or structures are relocated inside the same request buffer using the server’s stack pointer

Syscall Proxying   Simulating Remote Execution Marshaling arguments for open()

Syscall Proxying   Simulating Remote Execution Linux syscalls  Invoking a syscall in Linux  Load EAX with syscall number  Load arguments in EBX, ECX, EDX, ESI and EDI (syscalls with more than 5 arguments push the rest on the stack)  Call software interrupt 0x80 (int $0x80)  Return value in EAX

Syscall Proxying   Simulating Remote Execution Debugging open() Breakpoint 1, 0x08050f60 in __libc_open () (gdb) x/20i $eip : push %ebx 0x8050f61 : mov 0x10(%esp,1),%edx 0x8050f65 : mov 0xc(%esp,1),%ecx 0x8050f69 : mov 0x8(%esp,1),%ebx 0x8050f6d : mov $0x5,%eax 0x8050f72 : int $0x80 0x8050f74 : pop %ebx 0x8050f75 : cmp $0xfffff001,%eax 0x8050f7a : jae 0x8056f50 0x8050f80 : ret

Syscall Proxying   Simulating Remote Execution A simple Linux server  Pseudocode for a simple linux server channel = set_up_communication() channel.send(ESP) while channel.has_data() do request = channel.read() copy request in stack pop registers int 0x80 push eax channel.send(stack)

Syscall Proxying   Simulating Remote Execution A simple syscall server in Linux (1)  Read request straight into the stack read_request: movfd, %ebx mov buflen, %edx movl$3,%eax # __NR_read mov%esp,%ecx # buff int$0x80

Syscall Proxying   Simulating Remote Execution A simple syscall server in Linux (2)  Invoke the desired syscall do_request: pop %eax pop %ebx pop %ecx pop %edx pop %esi pop %edi int $0x80  The request previously stored in ESP is the stack needed by the syscall PLUS buffers

Syscall Proxying   Simulating Remote Execution A simple syscall server in Linux (3)  Coding a simple syscall server for Linux can be done  It takes about a hundred bytes long (without optimizing)

Syscall Proxying   Simulating Remote Execution What about Windows?  Windows “syscalls”  “… any function in any dynamic library available to a user mode process.”  Common mechanism

Syscall Proxying   Simulating Remote Execution The Windows Syscall Server (1)  Windows server  Call any function in its process address space (already loaded)  In particular  Call LoadLibrary to load a new DLL  Call GetProcAddress to obtain the address of a specific function

Syscall Proxying   Simulating Remote Execution The Windows Syscall Server (2)  Pseudocode for a sample Windows server channel = set_up_communication() channel.send(ESP) channel.send(address of LoadLibrary) channel.send(address of GetProcAddress) while channel.has_data() do request = channel.read() copy request in stack pop ebx call [ebx] push eax channel.send(stack)

Syscall Proxying   Simulating Remote Execution The Real World: applications

Syscall Proxying   Simulating Remote Execution Exploiting Code Injection Vulnerabilities  Allow an attacker to execute arbitrary code in the target system  Buffer overflows  User supplied format strings  Attack method  Injection: attack specific  Payload: what to execute once control is gained  Shell code: code that spawns a shell

Syscall Proxying   Simulating Remote Execution The Privilege Escalation Phase  Successful attack against a host.  Use the compromised host as vantage point (“pivoting”)  Attacker profile switch: from external to internal  Exploit webs of trust  Possibly more privileged position in the target system’s network  To be able to “pivot”, the auditor needs his tools available at the vantage point

Syscall Proxying   Simulating Remote Execution Redefining the word “shellcode”  Supply “thin” syscall server as attack payload  Benefits  Transparent pivoting  “Local” privilege escalation  No shell? Who cares!

Syscall Proxying   Simulating Remote Execution Conclusions

Syscall Proxying   Simulating Remote Execution Conclusions  Powerful technique when staging attacks against code injection vulnerabilities  Turns the compromised host into a new attack vantage point  Useful when shell code customization is needed  Framework for developing new penetration testing tools  Raises the value of the tools

Syscall Proxying   Simulating Remote Execution Questions?

Syscall Proxying   Simulating Remote Execution Thank You!  Maximiliano Cáceres 

Syscall Proxying   Simulating Remote Execution CORE SECURITY TECHNOLOGIES · Offices Worldwide Rua do Rócio 288 | 7º andar Vila Olímpia | São Paulo | SP CEP | Brazil Tel: (55 11) Fax: (55 11) Florida 141 | 2º cuerpo | 7º piso (C1005AAC) Buenos Aires Tel/Fax: (54 11) 4878-CORE (2673) Headquarters 44 Wall Street | 12th Floor New York, NY | USA Ph: (212) Fax: (212)