Asterisk Nmap

Nmap ("Network Mapper") is a free open source utility for network exploration or security auditing

This was found here



#!/usr/bin/perl
# tts-nmap.agi
# AGI Script that prompts the user for an ip address, scans the ip, and reports back to the user.
#
# Requires the Asterisk::AGI and Nmap::Parser perl modules
#
# Written by: Black Rathchet (blackratchet@blackratchet.org)
#
# http://www.oldskoolphreak.com

use Asterisk::AGI;
use Nmap::Parser;
use File::Basename;
use Digest::MD5 qw(md5_hex);

# speaks a string of text
sub speak(){
$text = $_[0];

my $hash = md5_hex($text);

my $ttsdir = "/var/lib/asterisk/sounds/tts";
my $cepoptions = "-p audio/sampling-rate=8000,audio/channels=1";

my $wavefile = "$ttsdir/tts-$hash.wav";

unless (-f $wavefile) {

open(fileOUT, ">/var/lib/asterisk/sounds/tts/say-text-$hash.txt");
print fileOUT "$text";
close(fileOUT);

my $execf="/opt/swift/bin/swift -f $ttsdir/say-text-$hash.txt -o $wavefile $cepoptions";
system($execf);

unlink("$ttsdir/say-text-$hash.txt");
}
$filename = 'tts/'.basename('tts/'.basename($wavefile,".wav"));
$AGI->stream_file($filename);
unlink("$wavefile");

}

$AGI = new Asterisk::AGI;

my %input = $AGI->ReadParse();

my $finished = 0;

&speak("Enter the eye-p address you wish to scan.");
my $ipaddr = '';
my $x = 0;

# While we don't have a complete IP address, have the user enter one
# using '#' for '.'...
while (!$finished) {
my $input = chr($AGI->wait_for_digit('5000'));
if ($input =~ /^[0-9\*\#]$/) {
if ($input =~ /^[\*\#]$/) {
$x++;
if ($x > 3) {
$finished = 1;
} else {
$ipaddr .= '.';
}

} else {
$ipaddr .= $input;
}
} else {
#must have timed out
$finished = 1;
}

if ( length($ipaddr) > 14) {
$finished = 1;
}
}

# Double check the address is valid...
if ($ipaddr !~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) {
&speak("Invalid Address: $ipaddr");
exit 0;
}

&speak("Oh ratchet... you know how to push my buttons...");

&speak("Please wait");

# Set up a new Nmap::Parser object
my $np = new Nmap::Parser;

$nmap_exe = '/usr/bin/nmap';

$np->callback(\&host_handler);

# Scan the host given.
$np->parsescan($nmap_exe,'-sT -p1-1023', $ipaddr);

# Do this after every host scanned
sub host_handler {
my $host_obj = shift; #an instance of Nmap::Parser::Host (for current)

&speak("Host Found with " . $host_obj->tcp_port_count() . " ports open");

# Make and array of all the ports.
my @ports = $host_obj->tcp_open_ports();

# For every port, speak the port number and service.
foreach $port (@ports){
&speak($host_obj->tcp_service($port)->name. " on port" . $port);
}
&speak("Scan complete... Thank you...");

exit;
}

# If a host was found, we shouldn't get here.
$AGI->exec('Festival', '"No host found"');

exit;


Nmap ("Network Mapper") is a free open source utility for network exploration or security auditing

This was found here



#!/usr/bin/perl
# tts-nmap.agi
# AGI Script that prompts the user for an ip address, scans the ip, and reports back to the user.
#
# Requires the Asterisk::AGI and Nmap::Parser perl modules
#
# Written by: Black Rathchet (blackratchet@blackratchet.org)
#
# http://www.oldskoolphreak.com

use Asterisk::AGI;
use Nmap::Parser;
use File::Basename;
use Digest::MD5 qw(md5_hex);

# speaks a string of text
sub speak(){
$text = $_[0];

my $hash = md5_hex($text);

my $ttsdir = "/var/lib/asterisk/sounds/tts";
my $cepoptions = "-p audio/sampling-rate=8000,audio/channels=1";

my $wavefile = "$ttsdir/tts-$hash.wav";

unless (-f $wavefile) {

open(fileOUT, ">/var/lib/asterisk/sounds/tts/say-text-$hash.txt");
print fileOUT "$text";
close(fileOUT);

my $execf="/opt/swift/bin/swift -f $ttsdir/say-text-$hash.txt -o $wavefile $cepoptions";
system($execf);

unlink("$ttsdir/say-text-$hash.txt");
}
$filename = 'tts/'.basename('tts/'.basename($wavefile,".wav"));
$AGI->stream_file($filename);
unlink("$wavefile");

}

$AGI = new Asterisk::AGI;

my %input = $AGI->ReadParse();

my $finished = 0;

&speak("Enter the eye-p address you wish to scan.");
my $ipaddr = '';
my $x = 0;

# While we don't have a complete IP address, have the user enter one
# using '#' for '.'...
while (!$finished) {
my $input = chr($AGI->wait_for_digit('5000'));
if ($input =~ /^[0-9\*\#]$/) {
if ($input =~ /^[\*\#]$/) {
$x++;
if ($x > 3) {
$finished = 1;
} else {
$ipaddr .= '.';
}

} else {
$ipaddr .= $input;
}
} else {
#must have timed out
$finished = 1;
}

if ( length($ipaddr) > 14) {
$finished = 1;
}
}

# Double check the address is valid...
if ($ipaddr !~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) {
&speak("Invalid Address: $ipaddr");
exit 0;
}

&speak("Oh ratchet... you know how to push my buttons...");

&speak("Please wait");

# Set up a new Nmap::Parser object
my $np = new Nmap::Parser;

$nmap_exe = '/usr/bin/nmap';

$np->callback(\&host_handler);

# Scan the host given.
$np->parsescan($nmap_exe,'-sT -p1-1023', $ipaddr);

# Do this after every host scanned
sub host_handler {
my $host_obj = shift; #an instance of Nmap::Parser::Host (for current)

&speak("Host Found with " . $host_obj->tcp_port_count() . " ports open");

# Make and array of all the ports.
my @ports = $host_obj->tcp_open_ports();

# For every port, speak the port number and service.
foreach $port (@ports){
&speak($host_obj->tcp_service($port)->name. " on port" . $port);
}
&speak("Scan complete... Thank you...");

exit;
}

# If a host was found, we shouldn't get here.
$AGI->exec('Festival', '"No host found"');

exit;


Created by: kFuQ, Last modification: Sun 02 of Oct, 2005 (14:10 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+