Decode this string:
Code: Select all
s1f24~Z]l8qgm8<MH8qgm8[Yf?l8j]Y\8l`ak8kljaf_8g^8l]plFFF
Hint 1: this is encrypted with a factor of 24 and a strength of 1.
Have fun
Code: Select all
s1f24~Z]l8qgm8<MH8qgm8[Yf?l8j]Y\8l`ak8kljaf_8g^8l]plFFF
s1f24Hint 1: this is encrypted with a factor of 24 and a strength of 1.
Code: Select all
import sys,string,random
str_to_encrypt = ""
str_to_decrypt = ""
strength = 1
factor = 32
# find arguments
for i in range( 0, len( sys.argv ) ):
if( sys.argv[i] == "-e" ):
str_to_encrypt = sys.argv[i+1]
i = i + 1
if( sys.argv[i] == "-d" ):
str_to_decrypt = sys.argv[i+1]
i = i + 1
if( sys.argv[i] == "-s" ):
strength = int( sys.argv[i+1] )
i = i + 1
if( sys.argv[i] == "-f" ):
if( sys.argv[i+1] == "?rand?" ):
factor = random.randint( 16, pow( 2, 32 ) )
else:
factor = int( sys.argv[i+1] )
i = i + 1
# final results
final_encrypted_str = ""
final_decrypted_str = ""
# and then do encryption
if( str_to_encrypt != "" ):
# everything automatically changes to caps
str_to_encrypt = string.upper( str_to_encrypt )
# store the strength and factor
final_encrypted_str += "s" + str( strength )
final_encrypted_str += "f" + str( factor )
final_encrypted_str += "~"
# change every letter
for i in range( 0, len( str_to_encrypt ) ):
# check for overflow
if( ( ord( str_to_encrypt[i] ) + (strength * factor) ) > 255 ):
final_encrypted_str += "_r" + str( ( ord( str_to_encrypt[i] ) + (strength * factor) ) / 255 ) + "_"
final_encrypted_str += chr( ( ord( str_to_encrypt[i] ) + (strength * factor) ) % 255 )
else:
final_encrypted_str += chr( ord( str_to_encrypt[i] ) + (strength * factor) )
# tell me
print final_encrypted_str
# do we need to decrypt?
if( str_to_decrypt != "" ):
# index variable
i = 0; s = 0; e = 0;
# check for special case
if( str_to_decrypt == "?enc?" and str_to_encrypt != "" ):
str_to_decrypt = final_encrypted_str
# everything will automatically be in the right case, so find our sig
while( 1 ):
if( str_to_decrypt[i] == 's' ):
s = i + 1
if( str_to_decrypt[i] == 'f' ):
e = i - 1
str_strength = ""
for j in range( s, e + 1 ):
str_strength += str_to_decrypt[j]
strength = int( str_strength )
s = i + 1
if( str_to_decrypt[i] == '~' ):
e = i - 1
str_factor = ""
for j in range( s, e + 1 ):
str_factor += str_to_decrypt[j]
factor = int( str_factor )
break
i = i + 1
# the end of the signature, we're about to destroy i
sigend = i + 1
# now, decrypt each character
i = sigend
while( 1 ):
# check for tell-tale patterns
if( str_to_decrypt[i] == '_' and str_to_decrypt[i+1] == 'r' ):
# handle the exceeding number...
# count of times this goes into 255
count = 0
# offset
start = i + 2
# change i accordingly
i = start
# loop, until the last _ is found
while( True ):
if( str_to_decrypt[i] == '_' ):
# temp string for the count
str_count = ""
# done, get the count
for j in range( start, i ):
str_count += str_to_decrypt[j]
# convert it
count = int( str_count )
# one more for i
i = i + 1
# we're done here
break
i = i + 1
# and now finally add the proper character to the list
final_decrypted_str += chr( ( ord( str_to_decrypt[i] ) - (strength*factor) ) % (255) )
else:
final_decrypted_str += chr( ord( str_to_decrypt[i] ) - (strength*factor) )
# one more for i
i = i + 1
# check for valid i
if( i >= len( str_to_decrypt ) ):
break
# tell me
print final_decrypted_str
Code: Select all
$inputstring = 's1f24~Z]l8qgm8<MH8qgm8[Yf?l8j]Y\8l`ak8kljaf_8g^8l]plFFF';
$test = ord('8') - ord(' ');
$inputarray = str_split($inputstring);
foreach($inputarray as $c)
{
echo chr(ord($c) - $test );
}