|
前幾天在問(wèn)答區(qū)提了一下這個(gè)問(wèn)題,所有回答問(wèn)題的朋友都說(shuō)不可能通過(guò)php實(shí)現(xiàn),碰巧我的實(shí)習(xí)負(fù)責(zé)人幫我找到了一個(gè)方法,貌似是通過(guò)NTLM來(lái)實(shí)現(xiàn)的,我是新手,對(duì)具體原理也知之不詳,只是自己測(cè)試了一下,很好用.
所以趕快拿出來(lái)與大家分享.這是一個(gè)法國(guó)人寫的,所以編碼中的注釋都是法語(yǔ),如果有朋友很想了解某行的注釋含義,請(qǐng)回帖說(shuō)明,我可以試著翻譯一下.
<?php/************************************************************************************************************************************************* php NTLM GET LOGIN * Version 0.2.1 * Copyright (c) 2004 Nicolas GOLLET ( Nicolas (dot) gollet (at) secusquad (dot) com )* Copyright (c) 2004 Flextronics Saint-Etienne** This program is free software. You can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License. ************************************************************************/session_start();$headers = apache_request_headers(); // 獲取用戶頭if (@$_SERVER['HTTP_VIA'] != NULL){ // 確認(rèn)是否使用了代理(proxy),因?yàn)閚tlm驗(yàn)證不能穿過(guò)代理.echo "Proxy bypass!";}elseif($headers['Authorization'] == NULL){ //si l'entete autorisation est inexistante如果許可頭不存在 header( "HTTP/1.0 401 Unauthorized" ); //envoi au client le mode d'identification header( "WWW-Authenticate: NTLM" ); //dans notre cas le NTLM exit; //on quitte}if(isset($headers['Authorization'])) //dans le cas d'une authorisation (identification){ if(substr($headers['Authorization'],0,5) == 'NTLM '){ // 確認(rèn)client是否在ntlm下 $chaine=$headers['Authorization']; $chaine=substr($chaine, 5); // 獲取 base64-encoded type1 信息 $chained64=base64_decode($chaine); // 解碼 base64 到 $chained64 if(ord($chained64{8}) == 1){ // |_ byte signifiant l'etape du processus d'identification (etape 3) // verification du drapeau NTLM "0xb2" ?l'offset 13 dans le message type-1-message (comp ie 5.5+) : if (ord($chained64[13]) != 178){ echo "NTLM Flag error!"; exit; } $retAuth = "NTLMSSP".chr(000).chr(002).chr(000).chr(000).chr(000).chr(000).chr(000).chr(000); $retAuth .= chr(000).chr(040).chr(000).chr(000).chr(000).chr(001).chr(130).chr(000).chr(000); $retAuth .= chr(000).chr(002).chr(002).chr(002).chr(000).chr(000).chr(000).chr(000).chr(000); $retAuth .= chr(000).chr(000).chr(000).chr(000).chr(000).chr(000).chr(000); $retAuth64 =base64_encode($retAuth); // encode en base64 $retAuth64 = trim($retAuth64); // enleve les espaces de debut et de fin header( "HTTP/1.0 401 Unauthorized" ); // envoi le nouveau header header( "WWW-Authenticate: NTLM $retAuth64" ); // avec l'identification suppl 主站蜘蛛池模板: 五月婷婷色丁香 | 中文字幕在线亚洲 | 四虎免费视频 | 欧美人与zoxxxx视频 | 亚洲成人手机在线观看 | 亚洲精品xxx | 欧美日韩国产亚洲人成 | 青草久操 | 亚洲欧美成人永久第一网站 | 国产一二三在线观看 | 五月婷婷之婷婷 | 日韩视频在线观看一区 | 久久国产精品偷 | 亚洲欧美色视频 | 日韩一级特黄 | 国产一区二区不卡视频 | 亚洲一区二区影院 | 国产专区视频在线观看 | 一区二区三区四区在线播放 | 在线观看精品视频网站www | 国产日韩91 | 一区二区精品在线观看 | 久久穴 | 国产亚洲精品激情都市 | 亚洲成人伊人网 | 中文字幕久久亚洲一区 | 中文字幕日产每天更新40 | 加勒比一本大道香蕉在线视频 | 91精品国产自产在线观看高清 | 加勒比毛片 | 国产精品欧美亚洲韩国日本 | 一二三四视频社区在线中文1 | 亚洲综合情 | 亚洲日本一区二区三区 | 精品视频在线观看一区二区三区 | 久久伊人精品热在75 | 欧美视频在线免费 | 欧美怡红院免费全视频 | 国模大胆一区二区三区 | 国产成人精视频在线观看免费 | 国产欧美激情一区二区三区-老狼 |