Briefing for: Hacking Windows Internals Cesar Cerrudo Argeniss.

Slides:



Advertisements
Similar presentations
Dynamic Analysis of Windows Phone 7 apps Behrang Fouladi, SensePost.
Advertisements

Secure Operating Systems Lesson 3: OS Structures.
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.
Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
Lecture 16 Buffer Overflow modified from slides of Lawrie Brown.
Anti-Cheating Mechanisms for Computer Games Michael Rudolph Jason Cook.
Operating System Security : David Phillips A Study of Windows Rootkits.
Lecture 19 Page 1 CS 111 Online Protecting Operating Systems Resources How do we use these various tools to protect actual OS resources? Memory? Files?
Andrew Roths Fermin J. Serna MSRC Engineering and MSEC Science Microsoft Corporation.
Understand Database Security Concepts
Web Defacement Anh Nguyen May 6 th, Organization Introduction How Hackers Deface Web Pages Solutions to Web Defacement Conclusions 2.
Token Kidnapping's Revenge Cesar Cerrudo Argeniss.
INTRODUCTION OS/2 was initially designed to extend the capabilities of DOS by IBM and Microsoft Corporations. To create a single industry-standard operating.
Information Networking Security and Assurance Lab National Chung Cheng University The Ten Most Critical Web Application Security Vulnerabilities Ryan J.W.
2: OS Structures 1 Jerry Breecher OPERATING SYSTEMS STRUCTURES.
Process Processes are executing or executable instances of programs. Processes in a modern OS haveOS –management information –resources –unique process.
1 RISE: Randomization Techniques for Software Security Dawn Song CMU Joint work with Monica Chew (UC Berkeley)
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Module 6: Patches and Security Updates 1. Overview Installing Patches and Security Updates Recent patches and security updates for IIS Recent patches.
Address Obfuscation: An Efficient Approach to Combat a Broad Range of Memory Error Exploits Sandeep Bhatkar, Daniel C. DuVarney, and R. Sekar Stony Brook.
Cracking Windows Access Control Andrey Kolishchak Hack.lu 2007.
2851A_C01. Microsoft Windows XP Service Pack 2 Security Technologies Bruce Cowper IT Pro Advisor Microsoft Canada.
Microsoft October 2004 Security Bulletins Briefing for Senior IT Managers updated October 20, 2004 Marcus H. Sachs, P.E. The SANS Institute October 12,
CSE 451: Operating Systems Winter 2012 Processes Mark Zbikowski Gary Kimura.
Chapter 6 Enumeration Modified Objectives  Describe the enumeration step of security testing  Enumerate Microsoft OS targets  Enumerate NetWare.
Web Security Demystified Justin C. Klein Keane Sr. InfoSec Specialist University of Pennsylvania School of Arts and Sciences Information Security and Unix.
Hands-On Ethical Hacking and Network Defense
Computers Are Your Future Eleventh Edition Chapter 4: System Software Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall1.
Chapter 2 – Software Part A. Definition Computer is made up of two components Hardware Physical components Software Instructions for the computer Two.
Computer Security and Penetration Testing
3-Protecting Systems Dr. John P. Abraham Professor UTPA.
1 © 2004, Cisco Systems, Inc. All rights reserved. CISCO CONFIDENTIAL Using Internet Explorer 7.0 to Access Cisco Unity 5.0(1) Web Interfaces Unity 5.0(1)
Windows Vista Inside Out Chapter 22 - Monitoring System Activities with Event Viewer Last modified am.
1 CHAPTER 3 CLASSES OF ATTACK. 2 Denial of Service (DoS) Takes place when availability to resource is intentionally blocked or degraded Takes place when.
Win32 Programming Lesson 22: DLL Magic Part Deux All your base are belong to us…
CIS 450 – Network Security Chapter 7 – Buffer Overflow Attacks.
CS 4010 Hacking Samba Server Vulnerabilities. Recon Telnet headers claim the following: –Red Hat Linux release 9 (Shrike) –Kernel smp on an i686.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
2.3 InterProcess Communication (IPC)
Win32 Programming Lesson 7: Kernel Objects. Abstract  Many of the concepts we’ll look at today won’t make complete sense until you use them  However,
Security Attacks CS 795. Buffer Overflow Problem Buffer overflows can be triggered by inputs that are designed to execute code, or alter the way the program.
SAM-21 Fortress Model and Defense in Depth Some revision on Computer Architecture.
Crouching Admin, Hidden Hacker Techniques for Hiding and Detecting Traces Paula Januszkiewicz Penetration Tester, MVP: Enterprise Security, MCT iDesign.
CSE 451: Operating Systems Winter 2011 Linking, Loading and Process Startup Mark Zbikowski Gary Kimura.
Operating Systems Security
Win32 Programming Lesson 17: Memory Mapped Files (Finally, cool stuff again, all this work is getting tedious!)
Speaker: Xiaojiang Du Authors: Xiali Hei, Xiaojiang Du and Shan Lin Temple University.
Introduction Program File Authorization Security Theorem Active Code Authorization Authorization Logic Implementation considerations Conclusion.
Windows workshop 2010 Understanding Software Dependencies in Windows Roland Yap School of Computing National University of Singapore Singapore
Efficient Software-Based Fault Isolation Authors: Robert Wahbe Steven Lucco Thomas E. Anderson Susan L. Graham Presenter: Gregory Netland.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
Microsoft OS Vulnerabilities April 1, 2010 MIS 4600 – MBA © Abdou Illia.
Token Kidnapping's Revenge Cesar Cerrudo Argeniss.
Secure Coding Techniques
CMSC 345 Defensive Programming Practices from Software Engineering 6th Edition by Ian Sommerville.
Protecting Memory What is there to protect in memory?
Protecting Memory What is there to protect in memory?
Backdoor Attacks.
Protecting Memory What is there to protect in memory?
Secure Software Confidentiality Integrity Data Security Authentication
CSC 495/583 Topics of Software Security Stack Overflows (2)
Process Realization In OS
Windows Internals Brown-Bag Seminar Chapter 1 – Concepts and Tools
Computer Security CS May, 2018.
Advanced Buffer Overflow: Pointer subterfuge
Format String.
Outline Operating System Organization Operating System Examples
OPERATING SYSTEMS STRUCTURES
Understanding and Preventing Buffer Overflow Attacks in Unix
Outline Introduction Memory protection Buffer overflows
Presentation transcript:

Briefing for: Hacking Windows Internals Cesar Cerrudo Argeniss

Hacking Shared Sections  Shared Section definition  Using Shared Sections  Tools  Problems  Searching for holes  Exploitation  Microsoft vulnerabilities  Other vendors vulnerabilities  Solutions  Conclusions  References

Shared Section  Basically a Shared Section is a portion of memory shared by a process, mostly used as an IPC (Inter Process Communication) mechanism.  Shared Memory.  File Mapping.  Named or Unnamed.

Using Shared Sections  Loading binary images by OS.  Process creation.  Dll loading.  Mapping kernel mode memory into user address space !?.  Used to avoid kernel transitions.  Sharing data between processes.  GDI and GUI data, pointers !?, counters, any data.

Using Shared Sections  Creating a shared section HANDLE CreateFileMapping( HANDLE hFile, // handle to file (file mapping) //or 0xFFFFFFFF (shared memory) LPSECURITY_ATTRIBUTES lpAttributes, // security DWORD flProtect, // protection DWORD dwMaximumSizeHigh, // high-order DWORD of size DWORD dwMaximumSizeLow, // low-order DWORD of size LPCTSTR lpName // object name (named) //or NULL (unnamed) );//returns a shared section handle

Using Shared Sections  Opening an existing shared section HANDLE OpenFileMapping( DWORD dwDesiredAccess, // access mode (FILE_MAP_WRITE // FILE_MAP_READ, etc.) BOOL bInheritHandle, // inherit flag LPCTSTR lpName // shared section name );//returns a shared section handle

Using Shared Sections  Mapping a shared section LPVOID MapViewOfFile( HANDLE hFileMappingObject, // handle to created/opened // shared section DWORD dwDesiredAccess, // access mode(FILE_MAP_WRITE // FILE_MAP_READ, etc.) DWORD dwFileOffsetHigh, // high-order DWORD of offset DWORD dwFileOffsetLow, // low-order DWORD of offset SIZE_T dwNumberOfBytesToMap // number of bytes to map ); //returns a pointer to begining of shared section memory

Using Shared Sections  Ntdll.dll Native API  NtCreateSection() Creates a new section  NtOpenSection() Opens an existing section  NtMapViewOfSection() Map a section on memory  NtUnmapViewOfSection() Unmap a section from memory  NtQuerySection() Returns section size  NtExtendSection() Change section size

Using Shared Sections  Mapping unnamed Shared Sections.  Need to know shared section handle on target process.  Need permissions on target process. OpenProcess(PROCESS_DUP_HANDLE,...) DuplicateHandle(...) MapViewOfFile(...)

Using Shared Sections  Demo

Tools  Process Explorer  Shows information about processes (dlls, handles, etc.).  WinObj  Shows Object Manager Namespace information (objects info, permissions, etc.)  ListSS  Lists Shared Sections names (local and TS sessions).  DumpSS  Dumps Shared Section data.  TestSS  Overwrites Shared Section data (to detect bugs)

Problems  Input validation  Weak permissions  Synchronization

Problems  Input validation  Applications don't perform data validation before using the data.  Applications trust data on shared sections.  When applications read modified data from shared sections  They will crash.  They will perform unexpected actions.

Problems  Weak permissions  Low privileged users can access (read/write/change permissions) shared sections on high privileged processes (services).  Terminal Services (maybe Citrix) users can access (read/write/change permissions) shared sections on local logged on user processes, services and also on other user sessions.

Problems  Synchronization  Not built-in synchronization.  Synchronization must be done by processes in order to not corrupt data.  There isn't a mechanism to force processes to synchronize or to block shared section access.  Any process (with proper rights) can alter a shared section data while another process is using it.

Problems  Synchronization  Communication between Process A and B Process A Process B Process C Shared Section 2- Write data. 3- Data ready. 4- Replace data. 5- Read data. 1- Send me data.

Searching for holes  Look for shared sections using Process Explorer, WinObj or ListSS.  Attach a process using the shared section to a debugger.  Run TestSS on shared section.  Interact with process in order to make it use (read/write) the shared section.  Look at debugger for crashes :).

Searching for holes  Windows HTML Help  Demo.

Exploitation  Elevating privileges.  Reading data.  Altering data.  Shared section exploits.  Using shared sections on virus/rootkits/etc.

Exploitation  Reading data.  From high privileged processes (services).  From local logged on user processes, services and other sessions on Terminal Services.  This leads to unauthorized access to data.

Exploitation  Altering data.  On high privileged processes (services).  On local logged on user processes, services and other sessions on Terminal Services.  This leads to arbitrary code execution, unauthorized access, processes or kernel crashing (DOS).

Exploitation  Shared section exploits.  When overwriting shared section data allow us to take control of code execution.  Some shared sections start addresses are pretty static on same OS and Service Pack.  Put shellcode on shared section.  Build exploit to jump to shellcode on shared section at static location.

Exploitation  Shared section exploits.  MS COM Structured Storage Vulnerability  Weak permission on shared section.  Structures saved on shared section can be overwriten.  By overwriting these structures is possible to execute arbitrary code.  POC Exploit Demo.

Exploitation  Using shared sections on virus/rootkits/etc.  Some shared sections are used by many processes (InternatSHData used for Language Settings on W2k) others sections are used by all processes :).  Write code to shared section and the code will be instantly mapped on processes memory and also on new created processes.  Use SetThreadContext() or CreateRemoteThread() to start executing code.  Similar to WriteProcessMemory() - SetThreadContext() technique or DLL Injection.

Exploitation  Using shared sections on virus/rootkits/etc.  Some shared sections have execute access.  It would be possible to avoid WinXP sp2 NX and third party protections.

Microsoft vulnerabilities  Vulnerabilities on next Microsoft products have been reported and are being fixed:  Internet Explorer vulnerability.  Office vulnerabilities.  Windows 2k and Windows XP sp2 Kernel vulnerability.  IIS 5 vulnerabiliity.  Windows COM vulnerability.

Other vendors vulnerabilities  NOD32 antivirus vulnerability.  Norton Antivirus (old versions) vulnerability.  Veritas software vulnerabilities.  Etc.

Solutions  Set proper permissions  Set only current user (also service account if application running as service) permissions on shared sections unless another user should access them.  Use some synchronization mechanism  Remember that when working with shared sections there isn't built in synchronization.  Validate the data before using it  Data on shared sections can be easily manipulated.

Conclusions  Windows and 3rd. party applications have a bunch of Shared Section related holes.  These kind of holes will lead to new kind of attacks “SSAtacks” (Shared Section Attacks) ;)  Microsoft forgot to include a Shared Sections audit on the trustworthy computing initiative :).  Windows guts seem rotten:).

References  MSDN  Programming Applications for MS Windows - Fourth Edition  Process Explorer (  WinObj (  Rattle - Using Process Infection to Bypass Windows Software Firewalls (PHRACK #62)  Crazylord - Playing with Windows /dev/(k)mem (PHRACK #59)  mspx

Click to edit Master title style Click to edit Master subtitle style Briefing for: FIN Questions? Thanks. Contact: cesar>at dot<com Argeniss – Information Security Get vulnerability information before anyone!