Jump to content
Old threads will finally start getting archived ×

Recommended Posts

The below code is taken from my perl forums code.  The code decloaks a formsession string sent as a hidden form element.

 

It works fine to verify the form in Perl, but when I try to convert it to PHP I get errors conflicting outputs which are coming from the two lines below:

 

$key = hex($hexkey);

(PERL)

 

$key = dechex($hexkey);

(PHP)

or

$key = bin2hex($hexkey);

(PHP)

 

The Perl line above gives a different result to the PHP line(s).

 

I have managed to convert down to this line from the top.

 

Any help in figuring out why the perls HEX command varies from the PHP DECHEX command would be great!  Also any pointers in converting from there downwards!  (I know perls LENGTH is PHP STRLEN, and can sort the for loop).

 

Thanks in advance for any help!

 

 

$input = $_POST["formsession"];

if ($input !~ /\A[0-9A-F]+\Z/) {return $input; } # probably a non cloacked ID as it contains non hex code

$input =~ s~0$~~;
$hexkey = substr($input,length($input)-2,2);
$key = hex($hexkey);
for($n=0; $n < length($input)-2; $n += 2) {
$dec = substr($input, $n, 2);
$ascii = hex($dec) ^ $key; # xor it to reverse it
$ascii = chr($ascii);
$user .= $ascii;
return $user;

Link to comment
https://forums.phpfreaks.com/topic/154875-perl-to-php-conversion-help/
Share on other sites

The input is something like this

"6D5F470C7844490C785E4D48495F60494F585E454F454D422C"

 

It is a couple of the boards systemwide variables cloaked into hex code.  (that is hex code isn't it?).

 

The code above should decloak this into binary which would reveal the systemwide variables.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.