Advertisement
Guest User

Untitled

a guest
Nov 17th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3. error_reporting(E_ALL);
  4. $db_host = "localhost";
  5. $db_username = "root";
  6. $db_password = "*****"; //Connection works fine, hidden for security purpose
  7. $db_name = "lab";
  8. $conn = new mysqli($db_host, $db_username, $db_password, $db_name);
  9. if ($conn->connect_error) {
  10. die("Connection failed: " . $conn->connect_error);
  11. }
  12. function file_get_contents_curl($url)
  13. {
  14. $ch = curl_init();
  15.  
  16. curl_setopt($ch, CURLOPT_HEADER, 0);
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18. curl_setopt($ch, CURLOPT_URL, $url);
  19. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  20. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
  21. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  22.  
  23. $data = curl_exec($ch);
  24. curl_close($ch);
  25.  
  26. return $data;
  27. }
  28. $sql="SELECT wid FROM websites";
  29. $result=$conn->query($sql);
  30. $num_rows=$result->num_rows;
  31. $nrs=4228250625-$num_rows; //255*255*255*255, going in reverse order
  32. $url_4=$nrs%255;
  33. $nrs=$nrs/255;
  34. $url_3=$nrs%255;
  35. $nrs=$nrs/255;
  36. $url_2=$nrs%255;
  37. $nrs=$nrs/255;
  38. $url_1=$nrs%255;
  39. for($i=1;$i<=5;$i++){
  40. $url=$url_1.".".$url_2.".".$url_3.".".($url_4-$i);
  41. try{
  42. $html = file_get_contents_curl("http://".$url);
  43. $doc = new DOMDocument();
  44. @$doc->loadHTML($html);
  45. $nodes = $doc->getElementsByTagName('title');
  46.  
  47. //get and display what you need:
  48. $title = 'Undefined';
  49. try {
  50. if($nodes){
  51. $title = $nodes->item(0)->nodeValue;
  52. }
  53. }
  54. catch (Exception $e) {
  55. }
  56. $description='';
  57.  
  58. $metas = $doc->getElementsByTagName('meta');
  59.  
  60. for ($i = 0; $i < $metas->length; $i++)
  61. {
  62. $meta = $metas->item($i);
  63. if($meta->getAttribute('name') == 'description')
  64. $description = $meta->getAttribute('content');
  65. }
  66. $wtime=time();
  67. $sql="INSERT INTO websites (`url`,`title`,`description`,`wtime`) VALUES ('$url','$title','$description','$wtime')";
  68. mysqli_query($conn,$sql);
  69. }
  70. catch(Exception $e){
  71.  
  72. }
  73. }
  74.  
  75. ?>
  76.  
  77. [17-Nov-2016 06:22:09 Etc/GMT] PHP Notice: Trying to get property of non-object in /home/roboca6g/public_html/lab/scan.php on line 48
  78. [17-Nov-2016 06:22:10 Etc/GMT] PHP Notice: Trying to get property of non-object in /home/roboca6g/public_html/lab/scan.php on line 48
  79. [17-Nov-2016 06:22:11 Etc/GMT] PHP Notice: Trying to get property of non-object in /home/roboca6g/public_html/lab/scan.php on line 48
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement