Front page | perl.beginners |
Postings from December 2002
Super Newbie Q
Thread Next
From:
Alan Moote
Date:
December 8, 2002 12:08
Subject:
Super Newbie Q
Message ID:
20021208170211.67370.qmail@web40307.mail.yahoo.com
Hey gang,
As you will soon see, I am quite new to Perl. I am
trying to out put a list of IPs that are trying to
access cmd.exe on my webserver. The problem is, when
I run the script against my access_log the output is a
bunch of blank lines. Here's the script so far:
#!/usr/bin/perl -w
## Use pattern matching to find IPs that have searched
for "cmd.exe"
## Example log lines:
## 24.150.82.42 - - [08/Dec/2002:08:47:46 -0500] "GET
/c/winnt/system32/cmd.exe?/c+dir HTTP/1.0" 404 293 "-"
"-"
## 24.150.82.42 - - [08/Dec/2002:08:47:48 -0500] "GET
/d/winnt/system32/cmd.exe?/c+dir HTTP/1.0" 404 293 "-"
"-"
## 24.150.82.42 - - [08/Dec/2002:08:47:51 -0500] "GET
/scripts/..%255c../winnt/system32/cmd.exe?/c+dir
HTTP/1.0" 404 307 "-" "-"
$LogFile=$ARGV[0];
## Open the file called from command line, die with
error if not readable
open(ACCLOG, "<$LogFile") || die "Cannot open
$LogFile\n";
while(<ACCLOG>) {
/(^[0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3}\.[0-9]{1-3})*.cmd\.exe*.$/g;
print "$1\n";
}
close(ACCLOG);
It's not much, and to me, it looks right, but
obviously I am overlooking some details.
Any ideas?
Thanks,
Al
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
Thread Next
-
Super Newbie Q
by Alan Moote