#!/usr/bin/perl
# Checks for interbase databases
# Written by Max of SecurityApex.com [Max@Wackowoh.com]
# www.SecurityApex.com
# -----------------------------------------------------------
#
# This is a perl script to scan all hosts in a file on port 
# 3050 for a possible Interbase database. If your using this 
# script, i'm sure you heard of the HUGE interbase backdoor 
# having to do with the hardcoded username & pass: 
# politically:correct
#
# Credits to my biatch Bansh33 for 1/3 of this code
#
# -----------------------------------------------------------
#
# usage: ./interbase.pl [file with hosts to check]
#
# to log the output to a file, do:
#
# ./interbase.pl [file with hosts] > interbase_logs.txt
#
# -----------------------------------------------------------

use Socket;

print "\n[Interbase Rape by Max of Security Apex]\n";
print "[         -www.SecurityApex.com-       ]\n\n";

if (!($ARGV[0])) {
  	&dienice("usage: ./interbase.pl [file with hostnames to check]\n");
}

print "Beginning scan from file: $filetoopen\n";

$filetoopen = $ARGV[0];
open(THEFILE, $filetoopen) or &dienice("Couldnt open the file. Please make sure the file exists...\n");
@thefile = <THEFILE>;
close(THEFILE);

foreach $line (@thefile) {
	chomp($line);
	&scann0rbyname("$line");
}

print "Scan complete.\n";

sub dienice() {
	($msg) = @_;
	print "$msg";
	exit;
}

sub scann0rbyname() {
	$host = "@_";
	$serverIP = inet_aton($host);
	$serverAddr = sockaddr_in(3050, $serverIP);

	socket(CLIENT, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
	gethostbyname($host) or print "No IP address for $host";
	if(!gethostbyname($host)) {
		print "Can't Resolve DNS/IP for $host";
	} else {
		if(connect(CLIENT, $serverAddr)) {
			print "Possible Interbase database found on $host:3050\n";
		} else {
			print "No Interbase database found on $host:3050\n";
		}
	}
}

# EOF [Security.Apex]