PDA

View Full Version : Let's get the ball rolling....


XsCode
04-15-2002, 10:51 AM
OK, no-one is posting to this forum, so let me make a suggestion. I'm learning Perl at the moment and think that it's easier lerning in groups, so... would anyone mind if I post little tutorials in here, which we could comment on and learn from each other?

Let me know what you think....:confused:

jadison
04-15-2002, 10:54 AM
Sure, XsCode! We welcome any input you can provide. :)
I'll see what I can dig up on Perl as far as tutorials and such, I have some resources I'll check out and post back here.

XsCode
04-15-2002, 11:00 AM
Well, here's my first effort...

Basically, it's an IIS (yeah yeah boo hiss:lol: ) Log parser CGI for Nimda and CodeRed, see it in action on http://www.xscode.d2g.com

I know it's not commented yet, but i'll work on it.....

###################################
#!/usr/bin/perl


use Date::Format;

my $path_to_logs = 'E:\\WINNT\\system32\\LogFiles\\W3SVC1\\';

my $file = join('',$path_to_logs,'ex',time2str("%y%m%d",time),'.log');

my $nimcount = 0;
my $redcount = 0;

open(FILE,"$file") || die 'file could not be opened';

print "Content-type: text/html\n\n";

while(<FILE>){
chomp;
if($_=~ /root.exe/i or /cmd.exe/i or /admin.dll/i)
{
$nimcount+=1;
my @tmp = split(/\s/);
push(@IPs,$tmp[1]);
}
if($_=~ /default.ida\sA+/i or /x.ida\sA+/i)
{
$redcount+=1;
my @tmp = split(/\s/);
push(@IPs,$tmp[1]);
}
}
close(FILE);

print "<html><body>";
print "<h1>Nimda attacks today: $nimcount</h1><br>";
print "<h1>CodeRed attacks today: $redcount</h1><br>";
print "<a href=\"/scripts/nimprev.cgi\">Previous days</a><br>";
print "<h3>IP\'s of today's attackers</h3>";
print &doips(@IPs);
print "<br></body></html>";

sub doips {
my @array = (@_);
my $mainret = '';

foreach $item (@array)
{
$hash{$item}+=1;
}

foreach $key (keys %hash)
{
my $ret = join(" ", $key, " ( $hash{$key} )");
$mainret = join("<br>", $mainret, $ret);
}
return $mainret;
}
########################################

Socal
04-15-2002, 3:06 PM
I really admire programming skills. With no programming background and minimal current knowledge with tinkerings on learning more, I can only look in awe at what you do with a most basic understanding of it's linear logic!

Mntsnow
04-20-2002, 10:11 PM
Xscode I get a 403 forbidden error when I click on your link

jadison
04-20-2002, 10:37 PM
-EDIT-

Just talked with XsCode, he'll be fixing it shortly.