Last active
July 31, 2021 03:31
-
-
Save rfc-2549/826043261aedaec3da0079862d6110dd to your computer and use it in GitHub Desktop.
Script to check if a list of onion sites are down or not
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Script to check if a list of .onion sites is alive or not. | |
use LWP::UserAgent; | |
use File::Slurp; | |
use Term::ANSIColor; | |
use Data::Dumper; | |
use POSIX qw(strftime); | |
my $ua = LWP::UserAgent->new; | |
$ua->proxy([qw(http)] => 'socks://127.0.0.1:9050'); | |
if($ARGV[0] eq "") { | |
printf <STDERR>, "Usage: qsc <file>\n"; | |
exit; | |
} | |
my @sites = read_file($ARGV[0]); | |
my $onion_site; | |
my $errors = 0; | |
my $date = strftime '%F %H:%M:%S', localtime(); | |
printf("qsc: qorg's site checker, running in %s\n", $date); | |
foreach (@sites) { | |
chomp($onion_site = $_); | |
# Check if status code is 200 (OK) | |
my $string = "Checking $onion_site"; | |
print $string; | |
$|++; | |
if ($ua->get($onion_site)->{_rc} == 200) { | |
print "\r$string"; | |
printf colored(['bold green'], "\t [OK]", "\n"); | |
} else { | |
print "\r$string"; | |
printf colored(['bold red'], "\t [ERROR]", "\n"); | |
$errors++; | |
} | |
} | |
printf("Completed with %i sites down\n", $errors); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment