Created
April 16, 2016 23:44
-
-
Save m0rb/7cb1a589f5407e4d586a7555d4947967 to your computer and use it in GitHub Desktop.
brutely - crawl bit.ly and similar URL shortening services using brute force methodology
This file contains 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 -w | |
# Usage: brutely.pl URL <LENGTH> (length defaults to 6) | |
# Ex: ./brutely.pl https://bit.ly/1 6 | |
# 4/16/16 -- chris_commat_misentropic_commercial | |
use strict; | |
use warnings; | |
use HTTP::Tiny; | |
my $ua = HTTP::Tiny->new( { agent => "ayy/1.0", keep_alive => 1 } ); | |
my $ln = $ARGV[1]; $ln ||= 6; | |
sub bfg { | |
my @chars = ("A".."Z","a".."z",0..9) ; | |
my $out = | |
$ARGV[0] . join( "", @chars[ map { rand @chars } ( 1 .. $ln ) ] ); | |
return $out; | |
} | |
sub heed { | |
my $url = shift; | |
my $res = $ua->head($url); | |
return $res; | |
} | |
until ( my $death ) { | |
my $url = &bfg; | |
my $ret = heed($url); | |
next if ( $ret->{status} eq 404 or $ret->{url} eq $url ); | |
print "$url == $ret->{url}\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, i'm new to perl. How do I use your script?