How to restrict perl bots through php when perl changes useragent name

Say we have the following perl script

use LWP; use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->agent('NokiaN97i/SymbianOS/9.1 Series60/3.0'); my $response = $ua->get('http://myhost.com'); if ($response->is_success) print $response->decoded_content; else die $response->status_line; 

which simply connects to myhost.com/index.php and prints its contents. In the index.php file, I have

  file_put_contents('agent.txt', $_SERVER['HTTP_USER_AGENT'], FILE_APPEND); 

lines. The user agent string now does not contain "libwww-perl". How can I recognize a perl bot and restrict it?

+4
source share
1 answer

You cannot, the USER_AGENT line, being the only factor that helps you identify the client "browser", is also mostly user input. If they change it, there is nothing you can do about it.

+5
source

Source: https://habr.com/ru/post/1447940/


All Articles