急!!!!如何取道客户机的mac地址阿!!!跪求加分阿!!
大虾们:
请问怎么样取客户的mac呢???在线等!!!!不够了在加分!!!
try {
Process process = Runtime.getRuntime().exec( "ipconfig /all ");
InputStreamReader ir = new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line;
while ((line = input.readLine()) != null)
if (line.indexOf( "Physical Address ") > 0)
{
String MACAddr = line.substring(line.indexOf( "- ") - 2);
System.out.println( "MAC address = [ " + MACAddr + "] ");
}
}
catch (java.io.IOException e)
{
System.out.println( "IOException " + e.getMessage());
}
以上代码取到的是服务器的mac而并非客户的mac,怎么样取得客户的mac呢???
急!!!!在线等!!!!一定加分!!!
[解决办法]
使用javascript
[解决办法]
很简单。用脚本。加我QQ8167898
[解决办法]
<HTML> <HEAD> <TITLE> WMI Scripting HTML </TITLE>
<META http-equiv=Content-Type content= "text/html; charset=gb2312 ">
<SCRIPT language=JScript event= "OnCompleted(hResult,pErrorObject, pAsyncContext) " for=foo>
document.forms[0].txtMACAddr.value=unescape(MACAddr);
document.forms[0].txtIPAddr.value=unescape(IPAddr);
document.forms[0].txtDNSName.value=unescape(sDNSName);
//document.formbar.submit();
</SCRIPT>
<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined " && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined ")
MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined ")
IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined ")
sDNSName = objObject.DNSHostName;
}
</SCRIPT>
<META content= "MSHTML 6.00.2800.1106 " name=GENERATOR> </HEAD>
<BODY>
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT> </OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223> </OBJECT>
<SCRIPT language=JScript>
var service = locator.ConnectServer();
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration ');
</SCRIPT>
<FORM id=formfoo name=formbar action=NICPost.asp method=post> <INPUT value=00:05:5D:0E:C7:FA name=txtMACAddr> <INPUT value=192.168.0.2 name=txtIPAddr> <INPUT value=typ name=txtDNSName> </FORM> </BODY> </HTML>
[解决办法]
学习一下。。。
[解决办法]
不错, 我试过了, 不过好象用户在进入这个页面时会提示有什么不安全的activx 如果能让用户在根本不知道的情况下查到?
[解决办法]
如果你是WINDOWS操作系统,用IPCONFIG就可以了
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.lang.String.*;
public class macaddress {
public static void main(String[] args) {
macaddress mdd = new macaddress();
String str=mdd.getMacOnWindow();
System.out.println(str);
}
public static String getMacOnWindow() {
String s = " ";
try {
String s1 = "ipconfig /all ";
Process process = Runtime.getRuntime().exec(s1);
BufferedReader bufferedreader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String nextLine;
for (String line = bufferedreader.readLine(); line != null; line = nextLine) {
nextLine = bufferedreader.readLine();
if (line.indexOf( "Physical Address ") <= 0) {
continue;
}
int i = line.indexOf( "Physical Address ") + 36;
s = line.substring(i);
break;
}
bufferedreader.close();
process.waitFor();
} catch (Exception exception) {
s = " ";
}
return s.trim();
}
}
[解决办法]
楼上, 您得到的还是服务器的IP呀, 人家要得到WEB用户的MAC
[解决办法]
public static String getMACAddress() {
String address = " ";
String os = System.getProperty( "os.name ");
if ( os != null && os.startsWith( "Windows ")) {
try {
String command = "cmd.exe /c ipconfig /all ";
Process p = Runtime.getRuntime().exec(command);
BufferedReader br =
new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (line.indexOf( "Physical Address ") > 0) {
int index = line.indexOf( ": ");
index += 2;
address = line.substring(index);
break;
}
}
br.close();
return address.trim();
}
catch (IOException e) { }
}
return address;
}
[解决办法]
JAVA得到是服务器的MAC,JS能得到用户的MAC,但你也说不要提示,这是个安全问题,除非设置用户的浏览器才能做到