Skip to content

Instantly share code, notes, and snippets.

@joequery
Last active October 19, 2016 21:54
Show Gist options
  • Save joequery/72aea4b259c5fa8f1d5af20ae03db34c to your computer and use it in GitHub Desktop.
Save joequery/72aea4b259c5fa8f1d5af20ae03db34c to your computer and use it in GitHub Desktop.
sombra decryption
<?php
function str_rot($s, $n = 13) {
static $letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$n = (int)$n % 26;
if (!$n) return $s;
if ($n == 13) return str_rot13($s);
for ($i = 0, $l = strlen($s); $i < $l; $i++) {
$c = $s[$i];
if ($c >= 'a' && $c <= 'z') {
$s[$i] = $letters[(ord($c) - 71 + $n) % 26];
} else if ($c >= 'A' && $c <= 'Z') {
$s[$i] = $letters[(ord($c) - 39 + $n) % 26 + 26];
}
}
return $s;
}
function encrypt($password) {
$passArray = str_split($password);
$encrypted = array();
foreach($passArray as $char) {
$salt = count($encrypted);
$char1 = str_rot($char,($salt+3));
$char = base64_encode(dechex(ord($char1)*3));
if($salt % 2 == 0) $char = strrev($char);
array_push($encrypted, $char);
}
$encrypted = implode(":", $encrypted);
$encrypted = str_replace("=", "?", $encrypted);
return $encrypted;
}
function decrypt($encrypted_str) {
$encrypted = explode(":", $encrypted_str);
$encrypted = str_replace("?", "=", $encrypted);
$plaintext = "";
foreach($encrypted as $chunk) {
$salt = strlen($plaintext);
if($salt % 2 == 0) $chunk = strrev($chunk);
$char1 = chr(
hexdec(
base64_decode($chunk)
)/3
);
$char =str_rot($char1, -1*($salt+3));
$plaintext .= $char;
}
return $plaintext;
}
$dudepw = "Xy@4+Bkuqd<53uJ";
$x = encrypt($dudepw);
$d = decrypt($x);
echo $dudepw ."\n\n";
echo $d ."\n\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment