I have this script, works ok:
#!/usr/bin/perl
$key = pack("H*","3cb37efae7f4f376ebbd76cd");
$str = "&4\=80CHB'";
$dec = decode($str);
print "Decoded string value: $dec\n";
sub decode{ #Sub to decode
@subvar=@_;
my $sqlstr = $subvar[0];
$cipher = unpack("u", $sqlstr);
$plain = $cipher^$key;
return substr($plain, 0, length($cipher));
}
If I alter it to get the $str variable from STDIN, it messes up all the result:
#!/usr/bin/perl
$key = pack("H*","3cb37efae7f4f376ebbd76cd");
print "Enter string to decode: ";
$str=<STDIN>;chomp $str;
$dec = decode($str);
print "Decoded string value: $dec\n";
sub decode{ #Sub to decode
@subvar=@_;
my $sqlstr = $subvar[0];
$cipher = unpack("u", $sqlstr);
$plain = $cipher^$key;
return substr($plain, 0, length($cipher));
}
First script gets it ok, result is:
Decoded string value: mentos
Second script is bad:
Decoded string value: ot&¸ÝÖóvë½vÍ
Any idea on what I do wrong? Thanks!
You original code has
which for some reason contains an escaped equals sign. It is the same as
so you need to enter
&4=80CHB'to your modified code.