Last active
August 4, 2023 05:01
-
-
Save tzmfreedom/fccb31493f15e8dbc2277582b5f3eb6d to your computer and use it in GitHub Desktop.
decode .mylogin.cnf to extract credential.
This file contains 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 characters
#!/usr/bin/php -q | |
<?php | |
$fp = fopen("../.mylogin.cnf", "r"); | |
if (!$fp) { | |
die("Cannot open .mylogin.cnf"); | |
} | |
# read key | |
fseek($fp, 4); | |
$key = fread($fp, 20); | |
# generate real key | |
$rkey = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; | |
for ($i = 0; $i < strlen($key); $i++) { | |
$rkey[$i % 16] = ( $rkey[$i % 16] ^ $key[$i] ); | |
} | |
# for each line | |
while ($len = fread($fp, 4)) { | |
# as integer | |
$len = unpack("V", $len); | |
$len = $len[1]; | |
# decrypt | |
$crypt = fread($fp, $len); | |
$plain = openssl_decrypt($crypt, 'aes-128-ecb', $rkey, true); | |
print $plain; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment