Skip to content

Instantly share code, notes, and snippets.

@tzmfreedom
Last active August 4, 2023 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tzmfreedom/fccb31493f15e8dbc2277582b5f3eb6d to your computer and use it in GitHub Desktop.
Save tzmfreedom/fccb31493f15e8dbc2277582b5f3eb6d to your computer and use it in GitHub Desktop.
decode .mylogin.cnf to extract credential.
#!/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
print $plain;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment