Perl Network Scanner


SUBMITTED BY: Guest

DATE: Jan. 1, 2014, 8:15 p.m.

FORMAT: Perl

SIZE: 3.2 kB

HITS: 1520

  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use IO::Socket;
  5. system('clear');
  6. system('cls');
  7. print q{
  8. ###########################################################
  9. # ALIVE OR NOT tool v1.4 #
  10. # by perlp0pper #
  11. # #
  12. # options: #
  13. # #
  14. # 1. give host and port and check if it's alive. #
  15. # 2. give your network ip without the last number #
  16. # (e.g: 192.168.1) and a port to scan the whole #
  17. # network for alive hosts. (takes a little while) #
  18. # #
  19. # 3. same as option 2 but scans also all the ports. #
  20. # (takes a really long time) #
  21. # #
  22. ###########################################################
  23. };
  24. print "choose your option(1/2/3): ";
  25. $|=1;
  26. my $choise = <STDIN>;
  27. chomp $choise;
  28. if($choise == 1){
  29. system('cls');
  30. system('clear');
  31. print "host: ";
  32. my $host1 = <STDIN>;
  33. chomp $host1;
  34. print "port: ";
  35. my $port1 = <STDIN>;
  36. chomp $port1;
  37. print "[*] sending socket to $host1:$port1...\r";
  38. 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";
  39. }
  40. if($choise == 2){
  41. system('cls');
  42. system('clear');
  43. print "your network ip without the last number(e.g: 192.168.1): ";
  44. my $host2 = <STDIN>;
  45. chomp $host2;
  46. print "port: ";
  47. my $port2 = <STDIN>;
  48. chomp $port2;
  49. print "[*] scanning the network for alive hosts on port $port2...\n";
  50. my $i=1;
  51. for($i;$i<255;$i++){
  52. my $ip1 = inet_aton("$host2.$i");
  53. my $hostname1 = gethostbyaddr($ip1, AF_INET);
  54. print "[*] sending socket to $host2.$i:$port2 [tcp]\r";
  55. 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 ";
  56. }
  57. print "[*] scan finished\n";
  58. }
  59. if($choise == 3){
  60. system('cls');
  61. system('clear');
  62. print "your network ip without the last number(e.g: 192.168.1): ";
  63. my $host2 = <STDIN>;
  64. chomp $host2;
  65. print "[*] scanning the network for alive hosts...\n";
  66. my $i=1;
  67. my $p=1;
  68. for($i;$i<255;$i++){
  69. for($p;$p<65666;$p++){
  70. my $ip = inet_aton("$host2.$i");
  71. my $hostname = gethostbyaddr($ip, AF_INET);
  72. print "[*] sending socket to $host2.$i:$p [tcp]\r";
  73. 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";
  74. }
  75. }
  76. print "\n[*] scan finished\n";
  77. }

comments powered by Disqus