perl版 Webshell存活检测

时间:2024-01-11 17:13:26

原理:
检测url返回状态即可

源码:

 #!c:\\perl\\bin\\perl.exe
use warnings;
use strict;
use LWP::UserAgent;
$| = ;
print "---------------------------------------------------------\n";
print "| Webshell online check v1.0 |\n";
print "---------------------------------------------------------\n";
print "| |\n";
print '| Power by :FireC@t |'."\n";
print "| bbs:www.script-toolf.info |\n";
print "| |\n";
print "---------------------------------------------------------\n";
my $ua = LWP::UserAgent->new();
$ua->timeout();
my $ok = 'OK';
my $false = 'False';
while(){
print "---------------------------------------------------------\n";
open FILE, "<", "webshell.txt" or die "webshell file open error:$!\n";
foreach(<FILE>){
chomp;
if($_ !~ m#^http#i){$_ = 'http://'.$_;}
my $req = HTTP::Request->new(GET => "$_");
my $rep = $ua->request($req);
if($rep->status_line =~ //){
print "Yes --> $_\n";
}else{
print " No --> $_\n";
}
}
close FILE;
print "---------------------------------------------------------\n";
print "Ctrl+c to exit\nThe Next Check after 30sec please waite.....\n";
sleep();
system('cls');
#system('clear');
} print "press any key to continue";
getc();

#等有时间优化一下
#注意, 这个是用于win版本, 因为开头的#!路径, 还有就是system(‘cls’)用于WIN, 如果是linux的话
#请修改system(‘cls’)为system(‘clear’)
#再把开头的#!c:\\perl\\bin\\perl.exe修改为相应的perl路径
#
#