May 8th, 2012 by Idris

  1. Host
  2. <?php
  3.     $PREAUTH_KEY=”b1e40a2aa6bebcf3fb1c9c7ba4a97201b1e40a2aa6bebcf3fb1c9c7ba4a97201″;
  4.     $WEB_MAIL_PREAUTH_URL=”https://www.eepis-its.edu/preauth”;
  5.     $user = $_GET[”user”];
  6.     $domain=$_GET[”domain”];
  7.     $email = “{$user}@{$domain}”;
  8.     if(empty($PREAUTH_KEY)) {
  9.         die(”Need preauth key for domain “.$domain);
  10.     }
  11.     $timestamp=time()*1000;
  12.     $halo=number_format($timestamp,0,”,”);
  13.     $preauthToken=hash_hmac(”sha1″,$email.”|name|0|”.$halo,$PREAUTH_KEY);
  14.     $preauthURL = $WEB_MAIL_PREAUTH_URL.”?account=”.$email.”&by=name&timestamp=”.$halo.”&expires=0&preauth=”.$preauthToken;
  15.    header(”Location: $preauthURL”);
  16. ?>
  17. Target
  18.         if(isset($_GET[’username’]) && isset($_GET[’account’]) && isset($_GET[’timestamp’]) && isset($_GET[’preauth’])){
  19.                 $username=$_GET[’username’];
  20.                 $account=$_GET[’account’];
  21.                 $tsq=$_GET[’timestamp’];
  22.                 $preauth=$_GET[’preauth’];
  23.         $PREAUTH_KEY=”b1e40a2aa6bebcf3fb1c9c7ba4a97201b1e40a2aa6bebcf3fb1c9c7ba4a97201″;
  24.                 $timestamp=time()*1000;
  25.                 if(($timestamp-$tsq)<300){
  26.                         $preauthToken=hash_hmac(”sha1″,$account.”|name|0|”.$tsq,$PREAUTH_KEY);
  27.                         if( $preauth == $preauthToken)
  28.                                 $IsValidUser=TRUE;
  29.                 }
  30.         }

Leave a Reply