views:

177

answers:

2

I may not even be referring to this the proper way so my apologies in advance. Our server logs are constantly showing us an encoded style of attack. An example is below....

http://somecompany.com/script.pl?var=%20%D1%EB........ (etc etc)

I am familiar with encoding and decoding HTML entities using Perl (using HTML::Entities) but I am not even sure how to refer to this style of decoding. I'd love to be able to write a script to decode these URI encodings (?). Is there a module that anyone knows of that can point me in the right direction?

Nikki

+5  A: 

Use the URI::Escape module to escape and unescape URI-encoded strings.

Example:

use strict;
use warnings;

use URI::Escape;

my $uri = "http://somecompany.com/script.pl?var=%20%D1%EB";
my $decoded = uri_unescape( $uri );
print $decoded, "\n";
friedo
+6  A: 

There are online resources such as http://www.albionresearch.com/misc/urlencode.php for doing quick encoding/decoding of a string.

Programmatically, you can do this:

use URI::Escape;
my $str  = uri_unescape("%20%D1%EB");
print $str . "\n";

or simply:

perl -MURI::Escape -wle'print uri_unescape("%20%D1%EB");'
Ether