#!/usr/bin/perl
use warnings;
use strict;
use IO::Socket;
system('clear');
system('cls');
print q{
###########################################################
# ALIVE OR NOT tool v1.4 #
# by perlp0pper #
# #
# options: #
# #
# 1. give host and port and check if it's alive. #
# 2. give your network ip without the last number #
# (e.g: 192.168.1) and a port to scan the whole #
# network for alive hosts. (takes a little while) #
# #
# 3. same as option 2 but scans also all the ports. #
# (takes a really long time) #
# #
###########################################################
};
print "choose your option(1/2/3): ";
$|=1;
my $choise = <STDIN>;
chomp $choise;
if($choise == 1){
system('cls');
system('clear');
print "host: ";
my $host1 = <STDIN>;
chomp $host1;
print "port: ";
my $port1 = <STDIN>;
chomp $port1;
print "[*] sending socket to $host1:$port1...\r";
my $sock1 = new IO::Socket::INET (PeerAddr => $host1, PeerPort => $port1, Proto => 'tcp', Timeout => 1) && print "\n\a\a\a[+] [tcp] host alive\n\a\a\a";
}
if($choise == 2){
system('cls');
system('clear');
print "your network ip without the last number(e.g: 192.168.1): ";
my $host2 = <STDIN>;
chomp $host2;
print "port: ";
my $port2 = <STDIN>;
chomp $port2;
print "[*] scanning the network for alive hosts on port $port2...\n";
my $i=1;
for($i;$i<255;$i++){
my $ip1 = inet_aton("$host2.$i");
my $hostname1 = gethostbyaddr($ip1, AF_INET);
print "[*] sending socket to $host2.$i:$port2 [tcp]\r";
my $sock = new IO::Socket::INET (PeerAddr => "$host2.$i", PeerPort => $port2, Proto => 'tcp', Timeout => 1) && print "\n\a\a\a[+] [tcp] $host2.$i hostname: $hostname1\n\n\a\a\a ";
}
print "[*] scan finished\n";
}
if($choise == 3){
system('cls');
system('clear');
print "your network ip without the last number(e.g: 192.168.1): ";
my $host2 = <STDIN>;
chomp $host2;
print "[*] scanning the network for alive hosts...\n";
my $i=1;
my $p=1;
for($i;$i<255;$i++){
for($p;$p<65666;$p++){
my $ip = inet_aton("$host2.$i");
my $hostname = gethostbyaddr($ip, AF_INET);
print "[*] sending socket to $host2.$i:$p [tcp]\r";
my $sock = new IO::Socket::INET (PeerAddr => "$host2.$i", PeerPort => $p, Proto => 'tcp', Timeout => 1) && print "\n\a\a\a[+] [tcp] $host2.$i:$p hostname: $hostname\n\n\a\a\a";
}
}
print "\n[*] scan finished\n";
}