ผู้เขียน หัวข้อ: [Perl] Backlinker  (อ่าน 237 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ Admin

  • << ผู้บัญชาการบอร์ด >>
  • Administrator
  • << Hero Member >>
  • *****
  • กระทู้: 2,666
  • ความมีน้ำใจ: +2657/-0
  • เพศ: ชาย
  • Developer ขาโหด..!!
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 10.0.648.205 Chrome 10.0.648.205
    • www.rockdevper.com
    • อีเมล์
[Perl] Backlinker
« เมื่อ: เมษายน 27, 2011, 01:18:04 PM »
I got permission from Saustin to post this, I hope you enjoy!

Saustin:
FEATURES:
- Can use practically ANY SIZE LIST!
- Tells you how much bandwith has been used!
- Allows you to set a timeout so you won't be wasting time on useless dead websites!
- Can make a noise when finished!
- Made to run (literally) FOREVER.
- NEW: Can use a proxy list! (IP:[port OR http://IP:[port] format!)
- NEW: Can allow you to kill off dead proxies by seating a timeout!
- NEW: Switches proxies so that they are evenly used!
- NEW: Checks to see if it actually is a good proxy! It doesn't just check if it connected, it will actually try to grab REAL web content!
- NEW: Tells you how long it has been running!

What to expect:
Although it might sound shitty to some, over a period of 6 hours I ran ONE bot (proxies) and it used up 60% of a 2mb list, totalling at 180 mb data sent..
My test page bumped up from 6 to 4 on google! Going to see if I caqn get one!

Glitches:
- When using proxies and the bandwith counter, sometimes it doesn't do a carriage return and it will keep posting results over and over..
Severity: Extremely minor (might just take up a tad bit of ssh bandwith)
โค๊ด: [Select]
#!/usr/bin/perl
$| = 1;
use Getopt::Long;
use Lwp::UserAgent;
use Time::Local;

$time = localtime;

my $ua = LWP::UserAgent->new;

$version = "0.3A";

print "Version $version made by Saustin (c).\nContact the developer: austinbenknowsyou@hotmail.com\nIf you use this, please thank me for creating this free tool!\n\n\n";
@website_array = ();
@completed_array = ();
@proxies = ();
GetOptions( "list=s" => \$list,
            "help" => \$help,
            "website=s" => \$website,
            "bandwith" => \$bandwith_switch,
            "timeout=i" => \$timeout,
            "bell" => \$is_bell_true,
            "proxy-list=s" => \$proxy_list,
            "no-longer-than=i" => \$no_longer_than,
            "debug" => \$debug);
if(!defined($timeout))
{
    $timeout = 10;
}
if($help == 1)
{
    print "$0 [OPTIONS]\n";
    print "Options:\n";
    print "--list  = Specify a list to use.\n";
    print "--website  = Website for you to use.\n"
    print "--bandwith = Tells you how much bandwith in kilobytes has been used so far.\n";
    print "--timeout  = Cancel dead connections, default is 10 secs.\n";
    print "--bell  = Ring a bell on the computer when finished. (Doesnt always work)\n";
    print "--proxy-list = Use a proxy list (domain/ip:port OR http://proxy:[port]/ format)\n";
    print "--no-longer-than = Specify an integer that is a timeout for proxies.\n";
    print "--help  = Displays this menu and exits.\n\n\n\n\n";
    print "Please note:\nBacklinks should be in this format:\nhttp://www.examples.com/web_dir/\{0\}\n\n\n";
    exit;
}
if(!defined($website))
{
    print "You must define a website. I suggest you look at help?\n";
    exit;
}
if(defined($proxy_list))
{
    open PROXY_LIST, "$proxy_list" or die "Error opening proxy list: $!\n";
    while(<PROXY_LIST>)
    {
        chop($_);
        if($_ =~ /http/)
        {
            push(@proxies, $_);
        }
        else
        {
            $new_proxy = "http://" . $_ . "/";
            push(@proxies, $new_proxy);
        }
    }
    foreach(@proxies)
    {
        $proxy = $_;
        $time = time;
        $ua->proxy('http', $proxy);
        $ua->timeout($timeout);
        $request = new HTTP::Request('GET', 'http://www.google.com/');
        $response = $ua->request($request);
        $content = $response->content;

        if(defined($content))
        {
            if($content =~ /google/)
            {
                if(defined($no_longer_than))
                {
        $time_new = time;
        $time_taken = $time_new - $time;
        if($time_taken > $no_longer_than)
        {
        print "Proxy took $time_taken seconds, not using...\n";
        }
        if($time_taken < $no_longer_than)
        {
        print "Proxy works! Visted google!: $proxy\n";
        push(@working_proxies, $_);
        }
                }
                else
                {
        print "Proxy works! Visited google!: $proxy\n";
        push(@working_proxies, $_);
                }
            }
            else
            {
                print "Proxy is broken: $proxy\n";
            }

    }
    $size_of_proxy_array = @working_proxies;
}
}   

if(defined($list))
{
    open FILE, "$list" or die "ERROR: Error loading $list: $!\n";
    print "List opened.\n";
    while(<FILE>)
    {
        chomp($cur_row = $_);
        push(@website_array, $cur_row);
    }
        $count = 0;
    foreach(@website_array)
    {
        $cur = $_;
        if($cur =~ /\{0\}/)
        {
            $cur =~ s/\{0\}/$website/g;
            push(@completed_array, $cur);
            $count++;
        }
        if($cur =~ /\[URL\]/)
        {
            $cur =~ s/\[URL\]/$website/g;
            push(@completed_array, $cur);
            $count++;
        }
    }
    print "Done replacing URLs. Starting to visit them..\n";
    $start_time = time;
    $completed_count = 0;
    if($bandwith_switch == 1) { $bandwith_used = 0; }

    foreach(@completed_array)
    {
        $cur_website = $_;
        $ua->timeout($timeout);
        if(defined($proxy_list))
        {
            $random_proxy = int(rand($size_of_proxy_array));
            $proxy_to_use = $working_proxies[$random_proxy];
            $ua->proxy('http', $proxy_to_use);
        }
        $req = HTTP::Request->new('GET', $cur_website);
        $response = $ua->request($req);
        $content = $response->content;
        if(defined($content))
        {
            $completed_count++;
            $time_ran = time - $start_time;
            if($bandwith_switch == 1)
            {
                $percent_done = ($completed_count / $count) * 100;
                $bandwith_used = $bandwith_used + length($content);
                if($bandwith_used > 1048576)
                {
        $cb = int($bandwith_used / 1048576);
        print "[+] Amount worked so far: $completed_count | $percent_done\% | Time: $time_ran sec | BW used: $cb\MB";
        print "\r";
                }
                else
                {
        $cb = int($bandwith_used / 1024);
        print "[+] Amount worked so far: $completed_count | $percent_done\% | Time: $time_ran sec | BW used: $cb\KB";
        print "\r";
                }

            }
            else
            {
                $percent_done = ($completed_count / $count) * 100;

                if($debug == 1)
                {
        print "[+] Amount worked so far: $completed_count | $percent_done\% | Time: $time_ran sec\n";
        print "URL: $cur_website\nPROXY: $proxy_to_use\n";
                }
                else
                {
        print "[+] Amount worked so far: $completed_count | $percent_done\% | Time: $time_ran sec";
        print "\r";
                }
            }
        }
    }
    print "\nDone with list!\n";
    if($is_bell_true == 1)
    {
        print "\a\a\a\a\a\a";
    }
    exit;
}

else
{
    print "You must specify a list... --help...\n";
    exit;
}


Ref: http://leetcoders.org/showthread.php?t=6240