daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Jun 4th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2.  
  3. use DBI;
  4.  
  5. open(IN,"< ips2.txt") || die "Can not open file : $!";
  6.  
  7. $db ="test";
  8. $user = "root";
  9. $pass = "";
  10.  
  11. ## user hostname : This should be "localhost" but it can be diffrent too
  12. $host="localhost";
  13.  
  14. $dbh = DBI->connect("DBI:mysql:$db:$host", $user, $pass);
  15.  
  16.  
  17. #select name from countries where id = (select country from ip4_61 where b=143 && c=178)
  18.  
  19.  
  20.  
  21.  
  22. while(<IN>){
  23.         @ipParts = split('[.]', $_);
  24.  
  25.         if($_ =~ /(\d+)(\.\d+){3}/)
  26.         {
  27.                 $query = "select name from countries where id = (select country from ip4_".$ipParts[0]." where b=".$ipParts[1]." && c=".$ipParts[2].")";
  28.                 $sqlQuery  = $dbh->prepare($query)
  29.                 or die "Can't prepare $query: $dbh->errstr\n";
  30.                 $rv = $sqlQuery->execute
  31.                 or die "can't execute the query: $sqlQuery->errstr";
  32.                 while (@row= $sqlQuery->fetchrow_array())
  33.                 {
  34.                         my $tables = $row[0];
  35.                         $_ =~ s/\n/ /g;
  36.                         print "$_- $tables\n";
  37.                 }
  38.                 $rc = $sqlQuery->finish;
  39.         }
  40. }
  41. close IN;
  42.  
  43. exit(0);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top