Paramore
Paramore

Reputation: 1313

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

Let's 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 just connects to myhost.com/index.php page and prints its content. In index.php file I have

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

line. Now user agent string does not contain "libwww-perl". How can I recognize perl bot and restrict it?

Upvotes: 4

Views: 445

Answers (1)

Narf
Narf

Reputation: 14752

You can't, the USER_AGENT string while being the only factor that helps you identify the client's "browser" is also basically user input. If they change it - there's nothing that you can do about it.

Upvotes: 5

Related Questions