|
前幾天在問答區提了一下這個問題,所有回答問題的朋友都說不可能通過php實現,碰巧我的實習負責人幫我找到了一個方法,貌似是通過NTLM來實現的,我是新手,對具體原理也知之不詳,只是自己測試了一下,很好用.
所以趕快拿出來與大家分享.這是一個法國人寫的,所以編碼中的注釋都是法語,如果有朋友很想了解某行的注釋含義,請回帖說明,我可以試著翻譯一下.
<?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){ // 確認是否使用了代理(proxy),因為ntlm驗證不能穿過代理.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 '){ // 確認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 主站蜘蛛池模板: 国产精品麻豆免费版 | 一本久久a久久精品亚洲 | 国产视频合集 | 四虎国产精品永久在线看 | 中文字幕一级毛片 | 免费国产在线观看不卡 | 久久青青草原精品国产软件 | 中文字幕精品视频在线 | 国产愉拍精品视频手机 | 看全色黄大色大片免费久久久 | 精品久久久久久无码中文字幕 | 国产午夜毛片 | 91新视频| 亚洲图片小说网 | 亚洲欧美一区二区三区国产精品 | 亚洲伊人久久大香线蕉在观 | 精品国产欧美一区二区三区成人 | 亚洲欧美综合另类图片小说区 | 99视频热| 午夜在线日韩免费精品福利 | 国产精品视频一区牛牛视频 | 国产精品欧美一区二区在线看 | 日本精品一区二区三区在线 | 久久久噜噜噜久久久 | 欧美日本韩国一区二区 | 国产盗摄精品一区二区三区 | 亚洲午夜在线观看 | 中文字幕视频一区二区 | 91精品国产综合久久久久久 | 国产免费人成在线看视频 | 亚洲一区二区三区四区视频 | 丁香婷五月 | 国产v2ba最新在线观看 | 欧美在线视频网站 | 大色虫成人午夜在线观看 | 国产成人精品实拍在线 | 在线精品国产成人综合第一页 | 国产亚洲漂亮白嫩美女在线 | 国内精品视频在线观看 | 美国人和狍xxxx视频 | 亚洲成a人片8888kkkk |