Created
March 6, 2013 17:19
-
-
Save aduitsis/5101097 to your computer and use it in GitHub Desktop.
Revisions
-
aduitsis created this gist
Mar 6, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/usr/bin/perl -w use strict; use warnings; use Carp; use MIME::Base64; use Compress::Zlib; use URI; use URI::QueryParam; use XML::Canonical; print STDERR "Please paste a SAMLRequest URL, then press enter, then press Ctrl-D\n"; my $slurp = do { local $/; <STDIN> }; my $u = URI->new($slurp, 'http'); for my $key ($u->query_param) { print "$key: ", join(", ", $u->query_param($key)), "\n"; } #SAMLRequest: #RelayState: #SigAlg: http://www.w3.org/2000/09/xmldsig#rsa-sha1 #Signature: # ###print decode_base64($slurp); if( defined $u->query_param('SAMLRequest') ) { my ( $i, $status ) = inflateInit( -windowBits => -&MAX_WBITS ); if ( $status == Z_OK && $i ) { my $buffer; $$buffer = decode_base64($u->query_param('SAMLRequest')); #print $$buffer; #exit; my ( $uncompressed, $status ) = $i->inflate( $buffer ); if ( ($status != Z_OK) && ($status != Z_STREAM_END) ) { croak $i->gzerror() ; } my $canon = XML::Canonical->new(comments => 1); print "\n\n"; print $canon->canonicalize_string($uncompressed); print "\n\n"; } else { print STDERR 'SAMLRequest is missing from this URL'; } }