-
Notifications
You must be signed in to change notification settings - Fork 3
/
uam.php
28 lines (20 loc) · 1.08 KB
/
uam.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?
$uamsecret = 'greatsecret'; //Shared secret between chilli and uam json service
header('Content-type: application/javascript'); //Output as JavaScript
//We need 4 things
$callback = $_GET["callback"];
$username = $_GET["username"];
$password = $_GET["password"];
$challenge = $_GET["challenge"];
$pappassword = return_new_pwd($password,$challenge,$uamsecret);
print $callback."({'response':'".$pappassword."'})";
//Function to do the encryption thing of the password
function return_new_pwd($pwd,$challenge,$uamsecret){
$hex_chal = pack('H32', $challenge); //Hex the challenge
$newchal = pack('H*', md5($hex_chal.$uamsecret)); //Add it to with $uamsecret (shared between chilli an this script)
$response = md5("\0" . $pwd . $newchal); //md5 the lot
$newpwd = pack('a32', $pwd); //pack again
$md5pwd = implode ('', unpack('H32', ($newpwd ^ $newchal))); //unpack again
return $md5pwd;
}
?>