那麼我做了一個簡單的腳本來發送一個數據包,我需要讀取響應,如果響應是我在尋找然後打印出來是好的,如果不打印出來是壞的,現在如果ip is vuln,那麼腳本就可以工作並打印出它的陰影。現在,如果它不是惡作劇,那麼腳本就會掛起,並且發送HEX數據的有效載荷。在Perl中沒有關閉的套接字
use IO::Socket;
use strict;
print "Connecting..\n";
my $socket = IO::Socket::INET->new(
PeerAddr => '23.113.161.164', # 38.124.108.67 <-- NON vuln ip for testing
PeerPort => 123, # 23.113.161.164 <-- This IS a vuln ip!
Proto => 'udp',
Timeout => 1);
die "Error With Sockets!: $!\n" unless $socket;
print "Connected!\n";
my $payload = "\x97\x00\x00\x00\xAA\x00\x00\x00";
my $good = "\x97\x00\x00\x00";
$socket->send($payload) or die "Nothing got sent.";
my $data;
$socket->recv($data,4);
my $response = substr($data,0,8);
$response = reverse($response);
print $response;
if ($response == "\x97\x00\x00\x00") {
print "IP IS VULN\n";
} else {
print "IP IS NOT VULN\n";
exit;
}
例錯誤:
使用非vuln IP:
[email protected]:~# perl 2.pl
Connecting..
Connected!
(這就是在那裏它被卡住)
使用vuln IP:
[email protected]:~# perl 2.pl
Connecting..
Connected!
▒IP IS VULN
(如你可以看到它確實很好)
這是腳本被卡住:
$socket->send($payload) or die "Nothing got sent.";
任何幫助將不勝感激。
總是使用'使用警告;'。你的代碼有一個主要的錯誤,這將發現。 – ikegami