Database Reference
In-Depth Information
#!/usr/bin/perl
#Perl Audit Tool - pat.pl
#paulmwright@oraclesecurity.com
use strict;
use warnings;
tnsping_it(@ARGV);
sub tnsping_it
{
my ($TNSping);
my $subnet = shift or die "Usage: pat.pl [network] e.g. pat.pl 192.168.1. $0 date\n";
my $count=29;
my @OraResult;
while ($count < 256)
{
my $host = $subnet.$count;
my $text = " milliseconds";
#step 1 find hosts with 1521 TNS
($TNSping) = `/u01/app/oracle/product/11.2.0/db_1/bin/tnsping $host | tail -1` ;
open (MYFILE, '>>output.txt');
if ($TNSping =~ /OK/)
{
($TNSping) = $TNSping =~ /OK \((\d+)/;
($TNSping) = $TNSping.$text;
print "Oracle Host $host responds successfully in $TNSping\n" ;
#Step 2 check which version of the database the TNS is from
my ($OraVer) = `./tnscmd10gOneLine.pl version -h $host`;#11g will respond
with VSNNUM=186646784
print "The TNS version string from $host is - $OraVer\n";
print MYFILE "Oracle Host $host responds successfully in $TNSping\n";
print MYFILE "$OraVer\n";
my @OraCheck;
my $OraSID;
#Step 3 Attempt to logon to the discovered 8/9 server with default passwords
#Version 8 and 9 don't need to pass SID
if ($OraVer =~ m/( Version 8\.0| Version 9\.1| Version 9\.0)/)
{
print "Oracle Version at $host is below 9.2\n";
my ($OraSID) = `./tnscmd10gOneLine.pl status -h $host`;
if($OraSID =~ m/SERVICE_NAME=(.*?)\)/)
{
print "$1\n";
$OraSID=$1;
print "OraSID equals $OraSID\n";
}
Search WWH ::




Custom Search