开发者

Decoding URI related entities with Perl

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.p开发者_开发百科l?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


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";


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");'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜