免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
服務(wù)器是怎么要求客戶端強(qiáng)行彈出身份驗(yàn)證窗口的

我們?cè)L問(wèn)tomcat服務(wù)器的時(shí)候如果試圖訪問(wèn)Tomcat Manager就會(huì)發(fā)現(xiàn)瀏覽器彈出一個(gè)登陸對(duì)話框,和我們平常的網(wǎng)頁(yè)對(duì)話框不同,而且查看頁(yè)面的時(shí)候查不到生成這個(gè)對(duì)話框的代碼,禁止腳本也毫無(wú)作用。手頭的資料對(duì)這個(gè)東西沒(méi)有任何介紹,它到底是怎么彈出來(lái)的呢?


用jmeter創(chuàng)建一個(gè)http request的sampler,再建一個(gè)view result tree的lisenter來(lái)看看服務(wù)器返回了些什么污七八糟的:

HTTP response headers:
HTTP/1.1 401 Unauthorized
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 08:00:00 CST
WWW-Authenticate: Basic realm="Tomcat Manager Application"
Content-Type: text/html;charset=utf-8
Content-Length: 954
Date: Thu, 30 Jun 2005 09:27:26 GMT
Server: Apache-Coyote/1.1


嘿嘿,原來(lái)是一個(gè)帶WWW-Authenticate的401錯(cuò)誤啊。自己寫(xiě)個(gè)jsp模擬一下看看怎么樣:

<%
response.addHeader("WWW-Authenticate","Basic realm=\"Tomcat Manager Application\"");
response.sendError(401,"Unauthorized");
%>

果然,一個(gè)一模一樣的登陸窗口跳出來(lái)了。不過(guò)身份驗(yàn)證的具體過(guò)程要怎么做呢?google了一下,果然看到好東西了: http://www.chinadata.cn/showContent.asp?projectID=2083



按照說(shuō)明構(gòu)造了一個(gè)jsp文件:

<%
sun.misc.BASE64Decoder decoder 
= new sun.misc.BASE64Decoder();
boolean authenticated 
= false;
String authorization 
= request.getHeader("authorization");
System.
out.println("authorization:"+authorization);
if (authorization != null{
  
if (authorization.startsWith("Basic")){
    authorization 
= authorization.substring(authorization.indexOf( )+1);
    
byte[] bytes = decoder.decodeBuffer(authorization);
    authorization 
= new String(bytes);
    String userName 
= authorization.substring(0,authorization.indexOf(:));
    String password 
= authorization.substring(authorization.indexOf(:)+1);
    System.
out.println("userName:"+userName);
    System.
out.println("password:"+password);
    authenticated 
=userName.equals("abc"&& password.equals("abc");
  }
else if (authorization.startsWith("Digest")){
    String userName 
= authorization.substring(authorization.indexOf("username="));
    userName 
= userName.substring("username=\"".length());
    userName = userName.substring(0,userName.indexOf("));
    String password 
= authorization.substring(authorization.indexOf("response="));
    password 
= password.substring("response=\"".length());
    password = password.substring(0,password.indexOf("));
    authenticated 
=userName.equals("abc"&& password.equals("3cf1135d3b8e20dd9272d06288569a56");
  }

}

if (!authenticated){
  
//   response.addHeader("WWW-Authenticate","Digest realm=\"Tomcat Manager Application\"");
  response.addHeader("WWW-Authenticate","Basic realm=\"Tomcat Manager Application\"");
  response.sendError(
401,"Unauthorized");
}
else{
  
out.println("hello abc");
}

%>



cool,和tomcat一模一樣的登陸頁(yè)面做出來(lái)了。

用戶名密碼均為abc,hard code在代碼里面了。不過(guò)還沒(méi)查到Digest方式的情況下是對(duì)哪些信息進(jìn)行MD5的

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
ServletContextListener
An OAuth 2.0 introduction for beginners – ITNEXT
TCD of tomcat
dubbox
Yii 用戶登錄驗(yàn)證
asp.net FormsAuthentication表單認(rèn)證時(shí)如何彈出Windows登錄窗口
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服