Skip to content

Instantly share code, notes, and snippets.

@rfc-2549
Last active July 31, 2021 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfc-2549/826043261aedaec3da0079862d6110dd to your computer and use it in GitHub Desktop.
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
#!/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