#!/usr/bin/perl
# Read "ReadMe.txt" for ...

# Needed Files
$|++;
use Socket; use Getopt::Std;
require 'include/banner.rs';
require 'include/logger.rs';
require 'include/count.rs';
require 'nss.conf';

# Main Code [-START-]
getopts("h:l:", \%args);
&banner;
if((length($ARGV[0])) >= 40 || (length($ARGV[1])) >= 40) { print "ARGV: Line too long.\n"; exit; }
if(!defined $args{h}) {
print <<"EOT";
Usage: (perl) $0 <options> ...

Options:
-h [host file]	-> File with hosts that will be scanned
-l [log  file]	-> File where the results are saved (default: [hostfile].log)

EOT
exit;
}
if(!defined $args{l}) { $logfile = "$args{h}.log"; } else { $logfile  = $args{l}; }
$hostfile = $args{h};

# Plugins
print "Loading Plugins ...\n";
opendir(DIR, "plugin");
while($in=readdir(DIR)) {
    next if ($in=~/^[.]{1,2}/);
    next if !($in=~/\.rs$/);
    require "plugin/$in";
}
closedir(DIR);
print "Loading $hostfile ... "; $count = 0;
count("$hostfile");
foreach $cnn (@cnt) { $count++; }
if($count <= 0) { print "Nothing To Scan!\n\n"; exit; }
print "$count Host(s) Found!\n\n"; $now=1;
foreach $host (@cnt) {
    chomp($host);
    &logs("$logfile","open");
    &last($host);
    print "Scanning $host \($now of $count\)\n";
foreach $plugin (@plugins) {
    $plugin_varb = "scan_$plugin";
    if ($$plugin_varb > 0) {
    &$plugin($host);
    }
}
    $now++;
    &logs("$logfile","close");
}

print "\nEND.\n";
exit(0);

# Main Code [-END-]