#!/usr/bin/perl -w # # a perl tool to make a exploit hunters life easier. looks through source code # for possible exploits. the line found may not be an actual exploit, but it # sure does spot possible ones faster than you could by hand. you can add # functions that should be searched for yourself by editing func.db. also this # tool has the ability to tail certain variables that you may find interesting. # since sometimes you will find a possible exploit, but not able to figure out # if the variable in the function is allready declared or not, you use this # option to follow that variable and figure out if it is or not. # # $Id: audit.pl,v 0.1 2007/O2/17 08:21:00 varc Exp $ use strict; use Getopt::Long; my ( $dir, $trail ); my $options = { d => \$dir, t => \$trail }; GetOptions( $options, "d=s", "t:s" ); &usage unless $dir; find( { wanted => \&scan, no_chdir => 1 }, $dir ); sub scan ( ) { my $fi = $File::Find::name; open( FILE, "func.db") or die("Failed to open func.db - $!" ); my @func = ; close( FILE ); if ( ( $fi =~ /\.php$/i ) || ( $fi =~ /\.inc$/i ) || ( $fi =~ /\.inc.php$/i) || ( $fi =~ /\.php4$/i) ) { open( FILY, "$fi" ) or warn "Failed to open $fi - $!"; foreach my $line ( ) { foreach my $fline ( @func ) { if ( $line =~ $fline ) { my $inc = $1; if ( $inc =~ /\$/ ) { print $fi . " [" . $inc . "] " . $line; } } } } } } sub usage { print "source code auditor\n"; print "usage: perl $0 -dt\n\n"; print " -d\t\tdirectory with the source code to scan\n"; print " =t\t\tvariable to trail (optional)\n"; exit; }