<% @ Page contenttype = "text/html; charset = GBK" %>
<HTML>
<Head>
<Title> obtain the computer name </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, (byte) 40, Z, (byte) 1, (byte) 130, Z, (byte) 2, (byte) 2, (byte) 2, 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 ninja turtles get domain name users