An Encrypted Payload Protocol and Target-Side Scripting Engine

Total Page:16

File Type:pdf, Size:1020Kb

An Encrypted Payload Protocol and Target-Side Scripting Engine An Encrypted Payload Protocol and Target-Side Scripting Engine Dino A. Dai Zovi [email protected] Abstract into the remote process and then triggering the vulnera- Modern exploit payloads in commercial and open-source bility (the injection vector) in order to cause the remote penetration testing frameworks have grown much more process to execute the injected code (the payload). Tra- advanced than the traditional shellcode they replaced. ditionally, these payloads have been written in processor- These payloads permit interactive access without launch- specific assembly language, assembled, and extracted by ing a shell, network proxying, and many other rich fea- hand into reusable machine code components. These tures. Available payload frameworks have several lim- payloads were typically small and executed an operating itations, however. They make little use of encryption to system shell, causing them to be commonly referred to secure delivery and communications, especially in earlier as shellcode. Common shellcode variants included func- stage payloads. In addition, their richer features require tionality such as restoring dropped privileges, breaking a constant network connection to the penetration tester, out of chroot environments, and attaching the shell to making them unsuitable against mobile clients, such as an inbound or outbound network connection. This style laptops, PDAs, and smart phones. of payload construction was both labor and skill inten- This work introduces a first-stage exploit payload that sive. is able to securely establish an encrypted channel using With the growth of commercial penetration testing ElGamal key agreement and the RC4 stream cipher. The services and especially commercial penetration test- key agreement implementation requires only modular ing products, exploit payloads have gotten considerably exponentiation and RC4 also lends itself to an implemen- more capable and complex. These payloads have facil- tation requiring a very small amount of executable code. itated the construction of products that help less experi- This secure channel is used to send further executable enced penetration testers better demonstrate the risk pre- code and deliver a fully-featured interpreter to execute sented by exploitable security vulnerabilities. In addi- mission logic written in the high-level Lua scripting lan- tion, the increased prevalence of layered host security guage. This scripting environment permits secure code defenses require that payloads be more robust and ca- delivery as well as disconnected operation and execution pable of more complex logic. The Unix chroot sys- of penetration testing mission logic. tem call is typically used to run a network service in a restricted file system environment. Extensions includ- 1 Introduction ing FreeBSD’s jail [1] extend this model to assign a dedicated IP address to a jail. More recent devel- Although much work has gone into detecting, mitigat- opments include the Windows Integrity Mechanism in ing, and preventing their exploitation, remote code ex- Windows Vista. The Windows Integrity Mechanism is ecution vulnerabilities remain one of the most preva- a Biba Integrity Model[2] Mandatory Access Control lent and serious vulnerability classes in software today. security system used to implement Internet Explorer’s While reported remote code execution vulnerabilities in “Protected Mode” and User Account Control (UAC). common server software have gotten more rare, they are Protected Mode Internet Explorer runs as a low-integrity still highly prevalent in web browsers, office suites, me- process that prevents it from writing to anywhere except dia players, anti-virus suites, and other local application designed places on the file system or in the registry, re- software. gardless of the discretionary access control list on the Remote code execution vulnerabilities are exploited objects. Escalating privileges in these restricted permis- by injecting a small amount of executable machine code sion environments, pivoting through networked hosts, or achieving mission objectives from these restricted execu- same or other remote systems. tion environments requires complex payload logic. There are some limitations, however, with the syscall This work addresses two shortcomings of the exist- proxy’s simple server-side logic. For example, it can- ing exploit payloads found in commercial and open- not handle the fork system call. In addition, file or source penetration testing tools. The first is a lack of se- socket input and output with the read or write system cure payload delivery and communication mechanisms. calls requires transferring the buffer twice because allo- Most available systems offer partial solutions to this at cating stack space requires sending unused data in the the present time by either only supporting encryption in marshalled stack buffer. Similarly, a round-trip for each later-stage executable agents or by only supporting sim- system call can add significant latency to input/output in- ple XOR-based traffic encoding. The second area that tensive operations. Finally, all communication with the this work addresses is the applicability of existing pay- syscall proxy server is performed unencrypted. This can loads against mobile clients. Most of the existing frame- be a concern when a remote penetration tester is gaining works require a constant network connection to the com- access to sensitive hosts or files. CORE IMPACT [4], a promised target in order to carry out mission objectives. commercial penetration testing application that employs This paper introduces a target-side scripting environment syscall proxying, addresses these issues by also employ- in order to push mission-objective logic onto the target. ing more complex agents with richer network transports The secure channel established by the earlier stage pay- that perform encryption. The initial syscall proxy server load ensures that mission objective logic is not compro- can be used to deploy a more capable remote agent, but mised in transit to the target. this requires writing an executable to the remote system’s This paper is organized as follows. First, a summary hard drive. of existing advanced payload techniques and frameworks Immunity’s CANVAS [5], a competing penetration- is presented in the next section. Afterwards, Encrypted testing application, uses a custom compiler-based pay- Payload Protocol describes a system for cryptographi- load construction system called MOSDEF [6]. The cally securing exploit payload delivery and communica- MOSDEF compiler takes a subset of the C programming tion. The final stage of this payload system, a lightweight language and generates highly position-independent ma- and powerful remotely scripted agent is introduced in the chine code suitable for dynamic injection into remote section titled Target-Side Scripting. Finally, the paper processes. The remotely executed payload can make use concludes with some discussion of the security and util- of system functions or other locally compiled functions. ity of the described payload system. Loops, conditional execution paths, and function calls are all executed inside the remote compromised process 2 Related Work and only minimal necessary information is transferred to or from the remote process. This allows the payload As mentioned above, the development of commercial author to create complex payloads that can, for exam- penetration testing applications and layered host security ple, transfer an entire remote file if successful, or only a defenses have significantly increased the complexity of smaller error code if an error occurred. exploit payloads. This section describes the exploit pay- A compiler-style approach such as MOSDEF ad- load systems found in the major available commercial dresses many of the limitations of syscall proxying at and open-source penetration testing frameworks. the expense of implementation complexity. A MOS- Syscall proxying[3] is a simple and flexible technique DEF program can create multiple processes and perform for simulating remote execution. Syscall proxying im- a significant amount of work on the client without requir- plements a fat client, thin server remote procedure call ing network round-trips or data transfers. The low-level protocol based on transferring stack frames. To exe- flexibility of C also allows a MOSDEF program to per- cute a remote system call, the syscall proxy client mar- form byte-level memory manipulations easily. This is shalls the required argument register values and mem- an important capability as performing a heap metadata ory buffers into a single buffer. The syscall proxy server exploit typically corrupts the heap to the point of caus- writes this marshalled stack buffer directly to its stack ing any subsequent heap operations to crash the program. segment, pops the general register values from it, and ex- A MOSDEF program can systematically repair the heap ecutes the system call specified. After the system call before executing higher-level functions that may require returns, the server pushes all the general purpose regis- heap memory allocation. MOSDEF, however, does not ters onto the stack and transfers the stack buffer back to encrypt the data in transit or payload code. Immunity the client. This general mechanism requires very little also provides a remote access trojan called Hydrogen that server-side logic, but provides a great deal of flexibility, uses RSA and Twofish to protect communications. The allowing the remote client to open files,
Recommended publications
  • Oracle with Metasploit
    Oracle Penetration Testing Using the Metasploit Framework Chris Gates & Mario Ceballos Metasploit Project Abstract Over the years there have been tons of Oracle exploits, SQL Injection vulnerabilities, and post exploitation tricks and tools that had no order, methodology, or standardization, mainly just random .sql files. Additionally, none of the publicly available Pentest Frameworks have the ability to leverage built- in package SQL Injection vulnerabilities for privilege escalation, data extraction, or getting operating system access. In this whitepaper we will present an Oracle Pentesting Methodology and give you all the tools to break the "unbreakable" Oracle as Metasploit auxiliary modules. We've created your version and SID enumeration modules, account bruteforcing modules, ported all the public (and not so public) Oracle SQL Injection vulnerabilities into SQLI modules (with IDS evasion examples for 10g/11g), modules for OS interaction, and modules for automating some of our post exploitation tasks. The modules are currently only supported under Linux and OSX. Oracle Penetration Testing Methodology Locate a system running Oracle. Determine Oracle Version. Determine Oracle SID. Guess/Bruteforce USERNAME/PASS. Privilege Escalation via SQL Injection. Manipulate Data/Post Exploitation. Cover Tracks. Locating an Oracle System You will typically find most Oracle installations by performing port scanning in the target netblock. The Oracle listener default port is 1521 but can listen on an port generally in the 1521-1540 range. You can also discover oracle instances by scanning other common Oracle ports. Review http://www.red- database-security.com/whitepaper/oracle_default_ports.html for common Oracle ports. Generally running a service scan will NOT give you the Oracle TNS Listener version but updated fingerprints for new versions of Nmap may yield versions in some situations.
    [Show full text]
  • Cygwin User's Guide
    Cygwin User’s Guide Cygwin User’s Guide ii Copyright © Cygwin authors Permission is granted to make and distribute verbatim copies of this documentation provided the copyright notice and this per- mission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this documentation under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this documentation into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. Cygwin User’s Guide iii Contents 1 Cygwin Overview 1 1.1 What is it? . .1 1.2 Quick Start Guide for those more experienced with Windows . .1 1.3 Quick Start Guide for those more experienced with UNIX . .1 1.4 Are the Cygwin tools free software? . .2 1.5 A brief history of the Cygwin project . .2 1.6 Highlights of Cygwin Functionality . .3 1.6.1 Introduction . .3 1.6.2 Permissions and Security . .3 1.6.3 File Access . .3 1.6.4 Text Mode vs. Binary Mode . .4 1.6.5 ANSI C Library . .4 1.6.6 Process Creation . .5 1.6.6.1 Problems with process creation . .5 1.6.7 Signals . .6 1.6.8 Sockets . .6 1.6.9 Select . .7 1.7 What’s new and what changed in Cygwin . .7 1.7.1 What’s new and what changed in 3.2 .
    [Show full text]
  • Software Assurance
    Information Assurance State-of-the-Art Report Technology Analysis Center (IATAC) SOAR (SOAR) July 31, 2007 Data and Analysis Center for Software (DACS) Joint endeavor by IATAC with DACS Software Security Assurance Distribution Statement A E X C E E C L I L V E R N E Approved for public release; C S E I N N I IO DoD Data & Analysis Center for Software NF OR MAT distribution is unlimited. Information Assurance Technology Analysis Center (IATAC) Data and Analysis Center for Software (DACS) Joint endeavor by IATAC with DACS Software Security Assurance State-of-the-Art Report (SOAR) July 31, 2007 IATAC Authors: Karen Mercedes Goertzel Theodore Winograd Holly Lynne McKinley Lyndon Oh Michael Colon DACS Authors: Thomas McGibbon Elaine Fedchak Robert Vienneau Coordinating Editor: Karen Mercedes Goertzel Copy Editors: Margo Goldman Linda Billard Carolyn Quinn Creative Directors: Christina P. McNemar K. Ahnie Jenkins Art Director, Cover, and Book Design: Don Rowe Production: Brad Whitford Illustrations: Dustin Hurt Brad Whitford About the Authors Karen Mercedes Goertzel Information Assurance Technology Analysis Center (IATAC) Karen Mercedes Goertzel is a subject matter expert in software security assurance and information assurance, particularly multilevel secure systems and cross-domain information sharing. She supports the Department of Homeland Security Software Assurance Program and the National Security Agency’s Center for Assured Software, and was lead technologist for 3 years on the Defense Information Systems Agency (DISA) Application Security Program. Ms. Goertzel is currently lead author of a report on the state-of-the-art in software security assurance, and has also led in the creation of state-of-the-art reports for the Department of Defense (DoD) on information assurance and computer network defense technologies and research.
    [Show full text]
  • Metasploit Framework «Back|Track-[IT]
    Metasploit Framework www.backtrack.it «Back|Track-[IT] www.backtrack.it (c) 2009 brigante - fiocinino [email protected] [email protected] Metasploit Framework Metasploit Framework www.backtrack.it Metasploit Framework www.backtrack.it Questo documento è rivolto a tutti coloro che vogliono conoscere cos'é, come viene utilizzato e cosa comporta l' uso del “Metasploit Framework”, parte del Metasploit Project. Metasploit è più di un semplice progetto per la sicurezza informatica, è un vero è proprio insieme di strumenti, (appunto denominato Framework), che ha praticamente rivoluzionato l' intero mondo della sicurezza informatica. Come per la stragrande maggioranza della nostra documentazione verrà, anche in questo documento, dato spazio sia alla parte teorica che alla parte pratica e descrittiva, con svariati esempi e con la descrizione dettagliata alcuni nostri video, reperibili naturalmente dall' apposita sezione del nostro portale. “Che cos'é Metasploit” Metasploit Project nasce con l' intento di fornire informazioni su vulnerabilità, sviluppo di sistemi di rilevamento di intrusioni e semplificare le operazioni di penetration testing. Il sub-project più conosciuto è il Metasploit Framework, un' insieme di strumenti per lo sviluppo e l'esecuzione di exploits, di shellcodes, auxiliary, opcode noto per lo sviluppo di strumenti di elusione ed anti- rilevamento. Uno dei principali Goals del “Metasploit Project” è quello di mirare principalmente a fornire informazioni utili allo sviluppo di nuove tecniche di pentesting e di firme per
    [Show full text]
  • Metasploit Pro User Guide
    4.11 USER GUIDE Getting Started First things first. If you haven't installed Metasploit yet, check out this these instructions if you're a commercial user. Otherwise, if you already have Metasploit installed, congratulations! You've come to the right place to get started. What's Metasploit? Metasploit is a penetration testing platform that enables you to find, exploit, and validate vulnerabilities. The platform includes the Metasploit Framework and its commercial counterparts: Metasploit Pro, Express, Community, and Nexpose Ultimate. Metasploit Framework The Metasploit Framework is the foundation on which the commercial products are built. It is an open source project that provides the infrastructure, content, and tools to perform penetration tests and extensive security auditing. Thanks to the open source community and Rapid7's own hard working content team, new modules are added on a regular basis, which means that the latest exploit is available to you as soon as it's published. There are quite a few resources available online to help you learn how to use the Metasploit Framework; however, we highly recommend that you take a look at the Metasploit Framework Wiki, which is maintained by Rapid7's content team, to ensure that you have the most up to date information available. You can also use the sidebar navigation on the left to view the documentation that is available on this site; just click on the Metasploit Framework topic or search for the topic you want. Either way, if you are unable to find what you need, let us know, and we will add it to the documentation back log.
    [Show full text]
  • The Advanced Persistent Threat (Or InformaOnized Force OperaOns)
    The Advanced Persistent Threat (or Informaonized Force Operaons) Michael K. Daly November 4, 2009 What is meant by Advanced, Persistent Threat? . Increasingly sophiscated cyber aacks by hosle organizaons with the goal of: Gaining access to defense, financial and other targeted informaon from governments, corporaons and individuals. Maintaining a foothold in these environments to enable future use and control. Modifying data to disrupt performance in their targets. APT: People With Money Who Discovered That Computers Are Connected APT in the News A Broad Problem Affecng Many Naons and Industries Is this a big deal? Is it new? . Yes, this is a very big deal. If “it” is the broad noon of the, spying, social engineering and bad stuff, then No, it is definitely not new. However, it is new (~2003) that naon states are widely leveraging the Internet to operate agents across all crical infrastructures. APT acvity is leveraging the expansion of the greater system of systems I’m not in the military. Why do I care? “[APT] possess the targeting competence to identify specific users in a unit or organization based on job function or presumed access to information. [APT] can use this access for passive monitoring of network traffic for intelligence collection purposes. Instrumenting these machines in peacetime may enable attackers to prepare a reserve of compromised machines that can be used during a crisis. [APT] … possess the technical sophistication to craft and upload rootkit and covert remote access software, creating deep persistent access to the
    [Show full text]
  • Cygwin User's Guide
    Cygwin User’s Guide i Cygwin User’s Guide Cygwin User’s Guide ii Copyright © 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc. Permission is granted to make and distribute verbatim copies of this documentation provided the copyright notice and this per- mission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this documentation under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this documentation into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation. Cygwin User’s Guide iii Contents 1 Cygwin Overview 1 1.1 What is it? . .1 1.2 Quick Start Guide for those more experienced with Windows . .1 1.3 Quick Start Guide for those more experienced with UNIX . .1 1.4 Are the Cygwin tools free software? . .2 1.5 A brief history of the Cygwin project . .2 1.6 Highlights of Cygwin Functionality . .3 1.6.1 Introduction . .3 1.6.2 Permissions and Security . .3 1.6.3 File Access . .3 1.6.4 Text Mode vs. Binary Mode . .4 1.6.5 ANSI C Library . .5 1.6.6 Process Creation . .5 1.6.6.1 Problems with process creation . .5 1.6.7 Signals . .6 1.6.8 Sockets . .6 1.6.9 Select .
    [Show full text]
  • Lifecycle of the Advanced Persistent Threat
    Lifecycle of the Advanced Persistent Threat Counter Threat Unit research Table of Contents Summary .............................................................. 2 Background: Who, not what ......................................... 3 Organized .................................................................... 3 Efficient ...................................................................... 3 Tenacious .................................................................... 4 APT Lifecycle ......................................................... 5 Preparation .................................................................. 6 Initial intrusion .............................................................. 6 Primary Objective .................................................... 9 Expansion .................................................................... 9 Persistence ................................................................. 11 Search and Exfiltration .................................................... 12 Cleanup ...................................................................... 14 Conclusion .......................................................... 15 Copyright © 2012 Dell SecureWorks Page 1 Summary Advanced Persistent Threats (APT) are a serious concern in the today’s threat landscape. They represent a threat to an organization’s intellectual property, financial assets and reputation. In some cases, these threats target critical infrastructure and government suppliers, thereby threatening the victim country’s national
    [Show full text]
  • Data Thieves: the Motivations of Cyber Threat Actors and Their Use
    Testimony Data Thieves The Motivations of Cyber Threat Actors and Their Use and Monetization of Stolen Data Lillian Ablon CT-490 Testimony presented before the House Financial Services Committee, Subcommittee on Terrorism and Illicit Finance, on March 15, 2018. For more information on this publication, visit www.rand.org/pubs/testimonies/CT490.html Testimonies RAND testimonies record testimony presented or submitted by RAND associates to federal, state, or local legislative committees; government-appointed commissions and panels; and private review and oversight bodies. Published by the RAND Corporation, Santa Monica, Calif. © Copyright 2018 RAND Corporation is a registered trademark. Limited Print and Electronic Distribution Rights This document and trademark(s) contained herein are protected by law. This representation of RAND intellectual property is provided for noncommercial use only. Unauthorized posting of this publication online is prohibited. Permission is given to duplicate this document for personal use only, as long as it is unaltered and complete. Permission is required from RAND to reproduce, or reuse in another form, any of its research documents for commercial use. For information on reprint and linking permissions, please visit www.rand.org/pubs/permissions.html. www.rand.org Data Thieves: The Motivations of Cyber Threat Actors and Their Use and Monetization of Stolen Data Testimony of Lillian Ablon1 The RAND Corporation2 Before the Committee on Financial Services Subcommittee on Terrorism and Illicit Finance United States House of Representatives March 15, 2018 ood afternoon, Chairman Pearce, Ranking Member Perlmutter, and distinguished members of the subcommittee. Thank you for the invitation to testify at this important G hearing, “After the Breach: the Monetization and Illicit Use of Stolen Data.” Cybersecurity is a constant and growing challenge.
    [Show full text]
  • Effect of Payload Virus As Threatening for Internet Security
    International Journal of Modern Communication Technologies & Research (IJMCTR) ISSN: 2321-0850, Volume-2, Issue-9, September 2014 Effect of Payload Virus as Threatening For Internet Security Sana Mahmoud Eltayeb Almansour, Dr.Amin Babekir Abd elnabi Mustafa can really bypass security borders , stay in the victim devise or Abstract– Security remains at the top concerns of internet spread in the network without being noticed . usage despite this continuous effort of security engineers to make the Internet as safe as possible, the level of threats II. PAYLOAD:- continues to grow. Hackers are getting better and quicker every day, while In order to define payload it is best explained through the security programming companies do their best to stay the definition of vulnerability and exploit. A particular server, winner of the race. It is an everlasting fight against hacker and website or application is vulnerable when it can be intruders who are trying to breach the safety and privacy of compromised or overtaken by A hacker. their victim whom could be someone using the Internet. Now that we know that a particular application is vulnerable, In this paper one of the current, dangerous most effective we need to find an exploit for that vulnerability, which might method will be discussed, explaining how what is a payload, how be the piece of code, to overtake the victim's application it works, exploits, and the intrusion process, most definitely security precision needs to be taken. without prior authorization. To go further I need a tool, virus or Trojan sent along with the exploit, to be executed on the Index Terms– Payload, Hacking, Internet Security, Victim.
    [Show full text]
  • An Introduction to Computer Security: the NIST Handbook U.S
    HATl INST. OF STAND & TECH R.I.C. NIST PUBLICATIONS AlllOB SEDS3fl NIST Special Publication 800-12 An Introduction to Computer Security: The NIST Handbook U.S. DEPARTMENT OF COMMERCE Technology Administration National Institute of Standards Barbara Guttman and Edward A. Roback and Technology COMPUTER SECURITY Contingency Assurance User 1) Issues Planniii^ I&A Personnel Trairang f Access Risk Audit Planning ) Crypto \ Controls O Managen»nt U ^ J Support/-"^ Program Kiysfcal ~^Tiireats Policy & v_ Management Security Operations i QC 100 Nisr .U57 NO. 800-12 1995 The National Institute of Standards and Technology was established in 1988 by Congress to "assist industry in the development of technology . needed to improve product quality, to modernize manufacturing processes, to ensure product reliability . and to facilitate rapid commercialization ... of products based on new scientific discoveries." NIST, originally founded as the National Bureau of Standards in 1901, works to strengthen U.S. industry's competitiveness; advance science and engineering; and improve public health, safety, and the environment. One of the agency's basic functions is to develop, maintain, and retain custody of the national standards of measurement, and provide the means and methods for comparing standards used in science, engineering, manufacturing, commerce, industry, and education with the standards adopted or recognized by the Federal Government. As an agency of the U.S. Commerce Department's Technology Administration, NIST conducts basic and applied research in the physical sciences and engineering, and develops measurement techniques, test methods, standards, and related services. The Institute does generic and precompetitive work on new and advanced technologies. NIST's research facilities are located at Gaithersburg, MD 20899, and at Boulder, CO 80303.
    [Show full text]
  • WORLD WAR C : Understanding Nation-State Motives Behind Today’S Advanced Cyber Attacks
    REPORT WORLD WAR C : Understanding Nation-State Motives Behind Today’s Advanced Cyber Attacks Authors: Kenneth Geers, Darien Kindlund, Ned Moran, Rob Rachwald SECURITY REIMAGINED World War C: Understanding Nation-State Motives Behind Today’s Advanced Cyber Attacks CONTENTS Executive Summary ............................................................................................................................................................................................................................................................................................................... 3 Introduction ............................................................................................................................................................................................................................................................................................................................................... 4 A Word of Warning ................................................................................................................................................................................................................................................................................................................. 5 The FireEye Perspective ...........................................................................................................................................................................................................................................................................................
    [Show full text]