码迷,mamicode.com
首页 > 其他好文 > 详细

IT忍者神龟之获取域名用户

时间:2014-09-16 10:47:30      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:io   os   ar   art   sp   on   c   html   ad   

<%@ page contentType="text/html; charset=GBK" %>
<HTML>  
<HEAD>  
<TITLE>获取计算机名</TITLE>  
</HEAD>  
<BODY>  
<%
 String auth = request.getHeader("Authorization");
 String username = null;
  String remoteHost = null;
   String domain = null;
 if (auth == null)
 {
   response.setStatus(response.SC_UNAUTHORIZED);
   response.setHeader("WWW-Authenticate", "NTLM");
   response.flushBuffer();
   return;
 }
 if (auth.startsWith("NTLM "))
 {
   byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
   int off = 0, length, offset;
   if (msg[8] == 1)
   {
     byte z = 0;
     byte[] msg1 = {(byte)‘N‘, (byte)‘T‘, (byte)‘L‘, (byte)‘M‘, (byte)‘S‘, (byte)‘S‘, (byte)‘P‘, z,(byte)2, z, z, z, z, z, z, z,(byte)40, z, z, z, (byte)1, (byte)130, z, z,z, (byte)2, (byte)2, (byte)2, z, z, z, z, z, z, z, z, z, z, z, z};
     response.setHeader("WWW-Authenticate", "NTLM " + new sun.misc.BASE64Encoder().encodeBuffer(msg1));
     response.sendError(response.SC_UNAUTHORIZED);
     return;
   }
   else if (msg[8] == 3)
   {
     off = 30;
 
    length = msg[off+17]*256 + msg[off+16];
     offset = msg[off+19]*256 + msg[off+18];
     remoteHost = new String(msg, offset, length);
 
    length = msg[off+1]*256 + msg[off];
     offset = msg[off+3]*256 + msg[off+2];
      domain = new String(msg, offset, length);
    length = msg[off+9]*256 + msg[off+8];
     offset = msg[off+11]*256 + msg[off+10];
      username = new String(msg, offset, length);
   }
 }

 %>

alert("<%=username%>");

alert("<%=remoteHost%>");
alert("<%=domain%>");


























</script>  
</BODY>  
</HTML>

IT忍者神龟之获取域名用户

标签:io   os   ar   art   sp   on   c   html   ad   

原文地址:http://blog.csdn.net/vipyhd/article/details/39312991

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!