The Shellcode Generation
Total Page:16
File Type:pdf, Size:1020Kb
Attack Trends Editors: Elias Levy, [email protected] Iván Arce, [email protected] The Shellcode Generation “Now, when your weapons are dulled, your ardor damped, your strength exhausted and your treasure spent, other chieftains will spring up to take advantage of your extremity. Then no man, however wise, will be able to avert the con- sequences that must ensue.” — Sun Tzu, The Art of War ttackers carry out many network security com- countermeasures. Studying exploits furnished by promises using exploitation programs, or ex- researchers or found “in the wild” on compromised systems can pro- ploits, which take advantage of bugs in software vide valuable information about the technical skills, degree of experi- running on vulnerable systems. These programs ence, and intent of the attackers who A developed or used them. Using this are often the only remaining evidence of a security compromise; information, we can implement measures to detect and prevent at- IVAN´ ARCE by analyzing them, we can assess understand how exploits work and tacks. (Note that those who use an Core Security the incident’s impact and the at- what they’re used for. exploit are not necessarily the de- Technologies tackers’ skills and intent. We can The simplest form of exploit signers or developers. This becomes build an entire taxonomy of attacks program is known as the proof-of- evident when attackers’ actions dur- by understanding these programs’ concept (POC) exploit. Its only goal is ing a network security compromise technical capabilities and their con- to demonstrate without a doubt that are not on par with the experience nection to those who develop and a security flaw exists, often by caus- and technical knowledge required to use them. ing the vulnerable program to mal- build the exploits used.) For the past decade, exploit tools function in a noticeable manner, From a functional perspective, have signaled the evolution of a such as terminating prematurely or exploits have three clearly distin- community of adversaries compris- abnormally. To prove not only that a guishable components: the attack ing numerous inexperienced and given software bug exists but also vector, exploitation technique, and unskilled “ankle biters”— that attackers could exploit it for exploitation payload. commonly referred to as script specific purposes, the writer of a kiddies—and a few experienced, POC exploit generally turns to Attack vector technically savvy attackers. Exploit what software vendors and security An attack vector is the mechanism programs are telltale signs of attack- researchers refer to as “execution of the exploit uses to make a vulnera- ers’ sophistication: if studied metic- arbitrary code on the vulnerable bility manifest. With software flaws, ulously, they can provide insight system” to demonstrate that an out- it’s the series of actions required to into current and future trends. sider can execute commands on af- reach and trigger the buggy portion fected systems. of the program. Dissecting Exploit tools are artifacts that let A software bug that illustrates this exploit code attackers fulfill their intentions be- concept is the Secure Sockets Layer Webster’s dictionary defines the verb yond simply demonstrating that a Private Communications Technol- exploit as “to use or manipulate to software flaw exists. From the ogy (SSL PCT) vulnerability discov- one’s advantage.” In the context of exploit developer’s viewpoint, an ered by Mike Down and Neel information security, we translate exploit must be able to use a given Mehta of Internet Security Systems’ this to mean taking advantage of a vulnerability to achieve a specific X-Force team (http://xforce.iss. vulnerable system in a way that sub- goal, while coping with the vulnera- net/xforce/alerts/id/168). The bug sequently affects the system’s secu- ble system’s operational characteris- is a fairly common buffer overflow rity. Recognizing that attackers use tics, including network topology, condition in the Microsoft library exploit code as a weapon, we must running environment, and security that implements the SSL protocol; 72 PUBLISHED BY THE IEEE COMPUTER SOCIETY ■ 1540-7993/04/$20.00 © 2004 IEEE ■ IEEE SECURITY & PRIVACY Attack Trends it’s used in several Microsoft software Jonathan Pincus and Brandon Baker vulnerable program by triggering packages, including the Web server provided a comprehensive account and exploiting a bug, it immedi- implementation in the Internet In- of past and current techniques for ately performs actions to achieve formation Services (IIS) package. exploiting software flaws. As the the exploit writer’s goal. This is In a detailed analysis, Core Secu- classic introduction to exploitation where the exploit payload comes in: rity Technologies’ Juliano Rizzo techniques for buffer overflow vul- the payload is the functional com- found that seven different network nerabilities, they cited AlephOne’s ponent that implements the ex- services can reach and trigger the “Smashing the Stack for Fun and ploit’s desired purpose. vulnerable code in many Windows Profit” (www.phrack.org/show.php Until recently, researchers ne- programs using an equal number of ?p=49&a=14) and DilDog’s “The glected exploit-payload analysis TCP ports (www.securityfocus. Tao of Windows Buffer Overflows” when trying to understand attackers’ com/archive/1/361836). This is (www.cultdeadcow.com/cDc_files/ intent and the quality and effective- one software bug with seven known cDc-351/). The techniques pre- ness of their tools. Yet, the appear- attack vectors. sented in those two articles are al- ance of a new breed of exploit pay- Similarly, other researchers at ready being applied to exploiting loads, coupled with repeated failure Core Security Technologies found other forms of software bugs. to stop and contain automated at- numerous attack vectors for the slew Several information security re- tacks and the increased popularity of of vulnerabilities in the Windows searchers have refined, improved, intrusion-prevention systems (IPS) OS components targeted by the and even superseded these tech- that aim to detect and prevent ex- Blaster and Sasser worms of 2003 niques since their publication nearly ploitation of software bugs, has re- and 2004 (www.corest.com/ a decade ago. The results are evident cently inspired R&D activities with common/showdoc.php?idx=393& in myriad research reports and in ex- a marked interest in using payload idxseccion=10). Like most exploits, ploits found in the wild on compro- analysis to help identify future trends however, each worm used only one mised systems. Advancements in in the ongoing struggle to conquer attack vector. exploit techniques and counter- the information security battlefield’s In response to the hardening of measures are testimony to attackers’ high ground. operating systems (decreasing the and defenders’ continuing attempts number of services exposed to at- to dull their adversaries’ weapons. Exploit tack) and security mechanisms such payload evolution as filtering firewalls and proxies (re- Exploit payload To better understand the payloads stricting connectivity), we should Once an exploit seizes control of a used in today’s exploits, let’s look at expect increasingly sophisticated ex- ploit programs to use more than one—or even all—available attack vectors. Such exploits will more ef- fectively target systems that operate under different configurations and operational environments. Exploitation technique An exploitation technique is the al- gorithm that exploits use to alter a vulnerable program’s execution flow and thus yield control to the attacker. To exploit a software bug, an attacker must not only find and use a valid attack vector but also de- vise a suitable technique for modi- fying the execution flow and run- ning the attacker’s commands on the system. In “Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns,” (IEEE Security & Privacy, July/Aug., pp. 20−27), www.computer.org/security/ ■ IEEE SECURITY & PRIVACY 73 Attack Trends some background information and system administrators and security A detailed account of a security inci- historical data points to try to ex- officials. Knowledgeable attackers dent that used this payload indicates trapolate the attackers’ intents and would have to quickly cover their that, although successful compro- assumptions. tracks and become as invisible as pos- mise of vulnerable systems can be achieved with a simple payload, the attacker must address several draw- Today the term ‘shellcode’ is backs of the exploit to remain unno- ticed on the compromised system almost synonymous for exploit payload. (see www.giac.org/practical/GSEC/ Sara_Dearing_GSEC.pdf). Add a user account sible after running an add-a-user- For many years, the easiest way for an account exploit. Shellcode attacker to access a vulnerable system Nonetheless, this naïve and sim- The next evolution in exploit pay- was to make the exploit modify the ple payload can still be found in loads, known as the shellcode, be- system’s configuration to let the at- today’s exploits—notably, some that came so prevalent by the mid ’90s tacker pose as a legitimate user. target Microsoft operating system that today the term is almost synony- On Unix systems, this was possible vulnerabilities such as the MS mous for exploit payload. by simply adding a line to the system RPC/DCOM vulnerability used by The fundamental concept is that, password file (/etc/passwd)— the 2003 Blaster worm (see www. upon seizing control of the vulnera- exploit code from the early ’90s used k-otik.com/exploits/09.20.rpcd ble program by modifying its execu- this approach to provide attackers di- com2ver1.1.c.php, for example). tion flow, the exploit immediately rect access to compromised systems. A spawns a command interpreter—a variation was to change the password Change the shell, in Unix parlance—that lets the on an existing account (typically, the system configuration attacker interactively enter com- privileged root account). Many publicly available exploits use mands to be executed on the vulner- Obviously, this simplistic pay- a simple evolution in exploit pay- able system and read back the out- load would overcome only the most load, altering vulnerable systems’ put.