Created
June 24, 2009 06:23
-
-
Save nipotan/135048 to your computer and use it in GitHub Desktop.
XXE precaution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use XML::Simple; | |
use Data::Dumper; | |
my $xml = do { local $/ = undef; <DATA> }; | |
my @entities = $xml =~ /<!ENTITY\s+(\w+)\s+.+?>/sg; | |
my $entities_re = '&(?:' . join('|', @entities) . ');'; | |
$xml =~ s/$entities_re//g; | |
my $ref = XMLin($xml); | |
warn Dumper $ref; | |
__DATA__ | |
<?xml version="1.0"?> | |
<!DOCTYPE str [ | |
<!ENTITY pass SYSTEM "/etc/passwd"> | |
]> | |
<str><data1>&pass;</data1><data2></data2></str> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment