- 浏览: 254914 次
- 性别:
- 来自: 西安
文章分类
- 全部博客 (91)
- hibernate (6)
- javaScript (9)
- flex (18)
- linux (3)
- vc (2)
- vs (0)
- arcgis (4)
- java (11)
- eclipse (5)
- php (3)
- arcgissde (3)
- arcgis server (5)
- myeclipse (1)
- spring (7)
- junit (1)
- ehcache (2)
- svn (2)
- SQL (7)
- webService (1)
- http://code.svnspot.com/ (0)
- spring security3 (8)
- maven (3)
- struts (2)
- tomcat (4)
- apache (1)
- vmware (0)
- mysql (2)
- android (2)
- jms (0)
- dbvisulizer (1)
- 百度地图 (2)
- openlayers (1)
最新评论
-
jobsccnu:
非常感谢,到处找这个代码呢
flex导出图片 -
li1045460568:
...
HibernateDao.java -
li1045460568:
[flash=200,200][flash=200,200][ ...
HibernateDao.java -
zz210891470:
会报这个错啊Exception in thread " ...
cxf webService简单例子 -
jie66989:
主要就是这个类了,这是前段时间学习的时候用的一部分,那个时候只 ...
HibernateDao.java
ASP获取客户端硬件信息(CPU、硬盘、主板、mac地址等)
2009-10-02 17:33 2569人阅读 评论(1) 收藏 举报
<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>
var value = "客户端硬件信息";
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");//CPU 信息
var e = new Enumerator (properties);
var p = e.item ();
var value=value+ p.SystemName + "CPU:"+ p.Name +p.ProcessorID
var properties = service.ExecQuery("SELECT * FROM Win32_DiskDrive");//硬盘序列号 信息
var e = new Enumerator (properties);
var p = e.item ();
var value=value+"HD:"+p.signature
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");//主板信息
var e = new Enumerator (properties);
var p = e.item ();
//var value=value+"BB:"+ p.Product; //在一些机器在上无法读取
document.forms[0].txtMACAddr.value=unescape(MACAddr); //MAC
document.forms[0].txtIPAddr.value=unescape(IPAddr); //IP
//document.forms[0].txtDNSName.value=unescape(sDNSName); //主机名
document.forms[0].txtDNSName.value=value; //增加的部份包括CPU硬盘主板
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="mac.asp" method="post">
<INPUT type="hidden" value="00-11-11-B4-52-EF" name="txtMACAddr" size="10">
<INPUT type="hidden" value="210.42.38.50" name="txtIPAddr">
<INPUT type="hidden" value="zhupan" name="txtDNSName">
</FORM>
</BODY>
</HTML>
注意:以上Activex控件将被阻止,
1、对于Windows XP或Windows 2003,打开IE的“工具”菜单栏,选择“Internet选项”,点击“安全”—>“受信任站点”,选择“自定义级别”,打开“安全设置”对话框,将其中“对没有标记为安全的ActiveX控件进行初始化和脚本运行”和“下载未签名的ActiveX控件”都设置为“提示”或者“启用” 。
2、vista下安装注册activex控件以及IE8的设置:
首先,要把系统的UAC关掉,或者以administrator登录(方法1:使用命令提示符激活与禁用:进入开始菜单,在“开始搜索”框中输入“cmd”,在上方出现的项目“cmd.exe”右击,在出现的快捷菜单中选择“以管理员身份运行”,之后在出现的管理权限的命令提示符框中输入“net user Administrator /Active:yes”之后,回车退出。重新启动计算机或注销计算机,你就会发现Administrator账户出现在登录画面上了。同样,当你想要禁用Windows Vista中的Administrator账户的时候,只需像上面一样操作,只不过最后在命令行中输入的是“net user Administrator /Active:no”罢了。 方法2:使用系统管理工具激活与禁用:因为vista home premium中没有“本地用户和组”这一项,所以这个方法只针对64位的vista。进入开始菜单,在右列中选中计算机,右击弹出快捷菜单,点击“管理”,找到“计算机管理(本地)”-“系统工具”-“本地用户和组”-“用户”,在右侧双击“Administrator”,在弹出的窗口中把“账户已禁用”前的钩去掉。确定后注销或重新启动计算机,同样可在启动画面上发现Administrator账户的出现。类似的,当你要再次禁用Administrator账户时,只要把那个“账户已禁用”前的钩再次勾选上就可以了。在你用administrator登录,或者用其他用户登录后,用上述方法1,运行命令行窗口,然后把ocx或者dll控件,下载到本地,拷贝到system32目录下,在命令行窗口输入regsvr32 xxxxx即可。)
其次,将你要安装控件的站点加入浏览器可信站点,并且将可信站点安全性降低,所有activex控件都要允许。或者在控制面板--程序与功能--打开或关闭windows功能中找到“安装activex控件”(大概是叫这个名字,因为同样home premium中没有这项)勾选上,可能是同样的效果。
最后,最关键的一点,如果你是IE8的用户,那么你一定要用administrator登录,或者关闭uac后,打开浏览器,工具---internet选项---高级---启用内存保护帮助减少联机攻击,这个勾勾一定要去掉,我之前的ocx控件一直是注册成功的,但是就是运行不了,找了两天的原因,才发现是他在捣鬼。
参考1:http://blog.csdn.net/KOOK_OKKO/archive/2008/05/26/2480889.aspx
参考2:http://blog.csdn.net/vkqiang/archive/2008/12/23/3588638.aspx
给政府做的,安全要求高,居然用硬盘序列号,MAC地址,CPU地址三项来绑定指定的人来操作:
<html>
<head>
<title>提取硬盘序列号</title>
<script>
function disk() {//硬盘序列号 信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_DiskDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.signature + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>
</head>
<body>
<input type="button" value="硬盘序列号" onclick="disk()">
</body>
</html>
通过javascript这种客户端脚本来获得客户端信息其他实例:
<html>
<head>
<title>javascript获得客户端硬件信息-www.web2bar.cn/</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script id=clientEventHandlersJS language=javascript>
<!--
function Button2_onclick() {//CPU 信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.DeviceID + "</td>");
document.write("<td>" + p.Name + "</td>");
document.write("<td>" + p.CpuStatus + "</td>");
document.write("<td>" + p.Availability + "</td>");
document.write("<td>" + p.Level + "</td>");
document.write("<td>" + p.ProcessorID + "</td>");
document.write("<td>" + p.SystemName + "</td>");
document.write("<td>" + p.ProcessorType + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//软盘信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_FloppyDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.DeviceID + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("<td>" + p.Manufacuturer + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//CD-ROM 信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_CDROMDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.Drive + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("<td>" + p.MediaLoaded + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//键盘信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Keyboard");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.Name + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//主板信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.HostingBoard + "</td>");
document.write("<td>" + p.Manufacturer + "</td>");
document.write("<td>" + p.PoweredOn + "</td>");
document.write("<td>" + p.Product + "</td>");
document.write("<td>" + p.SerialNumber + "</td>");
document.write("<td>" + p.Version + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
//-->
</script>
</head>
<body>
<INPUT id="Button1" type="button" value="Button" name="Button1" language=javascript onclick="return Button1_onclick()">
</body>
</html>
=================================================
其他资料:
using System;
using System.Management;
namespace HTSoft.Common.Register
{
/// <summary>
/// 计算机信息类
/// </summary>
internal class Computer
{
public string CpuID;
public string MacAddress;
public string DiskID;
public string IpAddress;
public string LoginUserName;
public string ComputerName;
public string SystemType;
public string TotalPhysicalMemory; //单位:M
private static Computer _instance;
internal static Computer Instance()
{
if (_instance == null)
_instance = new Computer();
return _instance;
}
internal Computer()
{
CpuID = GetCpuID();
MacAddress = GetMacAddress();
DiskID = GetDiskID();
IpAddress = GetIPAddress();
LoginUserName = GetUserName();
SystemType = GetSystemType();
TotalPhysicalMemory = GetTotalPhysicalMemory();
ComputerName = GetComputerName();
}
string GetCpuID()
{
try
{
//获取CPU序列号代码
string cpuInfo = " ";//cpu序列号
ManagementClass mc = new ManagementClass( "Win32_Processor ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuInfo = mo.Properties[ "ProcessorId "].Value.ToString();
}
moc = null;
mc = null;
return cpuInfo;
}
catch
{
return "unknow ";
}
finally
{
}
}
string GetMacAddress()
{
try
{
//获取网卡硬件地址
string mac = " ";
ManagementClass mc = new ManagementClass( "Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo[ "IPEnabled "] == true)
{
mac = mo[ "MacAddress "].ToString();
break;
}
}
moc = null;
mc = null;
return mac;
}
catch
{
return "unknow ";
}
finally
{
}
}
string GetIPAddress()
{
try
{
//获取IP地址
string st = " ";
ManagementClass mc = new ManagementClass( "Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo[ "IPEnabled "] == true)
{
//st=mo[ "IpAddress "].ToString();
System.Array ar;
ar = (System.Array)(mo.Properties[ "IpAddress "].Value);
st = ar.GetValue(0).ToString();
break;
}
}
moc = null;
mc = null;
return st;
}
catch
{
return "unknow ";
}
finally
{
}
}
string GetDiskID()
{
try
{
//获取硬盘ID
String HDid = " ";
ManagementClass mc = new ManagementClass( "Win32_DiskDrive ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
HDid = (string)mo.Properties[ "Model "].Value;
}
moc = null;
mc = null;
return HDid;
}
catch
{
return "unknow ";
}
finally
{
}
}
/// <summary>
/// 操作系统的登录用户名
/// </summary>
/// <returns> </returns>
string GetUserName()
{
try
{
string st = " ";
ManagementClass mc = new ManagementClass( "Win32_ComputerSystem ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
st = mo[ "UserName "].ToString();
}
moc = null;
mc = null;
return st;
}
catch
{
return "unknow ";
}
finally
{
}
}
/// <summary>
/// PC类型
/// </summary>
/// <returns> </returns>
string GetSystemType()
{
try
{
string st = " ";
ManagementClass mc = new ManagementClass( "Win32_ComputerSystem ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
st = mo[ "SystemType "].ToString();
}
moc = null;
mc = null;
return st;
}
catch
{
return "unknow ";
}
finally
{
}
}
/// <summary>
/// 物理内存
/// </summary>
/// <returns> </returns>
string GetTotalPhysicalMemory()
{
try
{
string st = " ";
ManagementClass mc = new ManagementClass( "Win32_ComputerSystem ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
st = mo[ "TotalPhysicalMemory "].ToString();
}
moc = null;
mc = null;
return st;
}
catch
{
return "unknow ";
}
finally
{
}
}
/// <summary>
/// 获取计算机名称
/// </summary>
/// <returns> </returns>
string GetComputerName()
{
try
{
return System.Environment.GetEnvironmentVariable( "ComputerName ");
}
catch
{
return "unknow ";
}
finally
{
}
}
}
}
============================
#10楼 得分:20回复于:2007-06-21 10:41:21
WMI代码如下(可以获取所有网卡的MAC地址):
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher( "root//CIMV2 ", "SELECT * FROM Win32_NetworkAdapter ");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine( "----------------------------------- ");
Console.WriteLine( "Win32_NetworkAdapter instance ");
Console.WriteLine( "----------------------------------- ");
Console.WriteLine( "MACAddress: {0} ", queryObj[ "MACAddress "]);
}
}
catch (ManagementException e)
{
MessageBox.Show( "An error occurred while querying for WMI data: " + e.Message);
}
}
}
}
============================
用javascript获取机器名和window登录名
http://blog.csdn.net/reamerit/archive/2009/05/09/4162980.aspx
代码如下:
<script language=javascript>
var WshShell =new ActiveXObject("WScript.Shell");
alert("计算机名 = "+ WshShell.ExpandEnvironmentStrings("%
COMPUTERNAME%"));
alert("登录用户名 = "+ WshShell.ExpandEnvironmentStrings("%
USERNAME%"));
</script>
<script language=javascript>
var wshNetwork = new ActiveXObject("WScript.Network");
alert("域名 = "+ wshNetwork.UserDomain);
alert("计算机名 = "+ wshNetwork.ComputerName);
alert("登录用户名 = "+ wshNetwork.UserName);
</script>
====================================
分享到:
上一篇:ASP获取和还原复选框的值(0~99多项选择)
下一篇:1、纯JS代码生成图表函数——柱图
查看评论
1楼 xzx99 2010-07-12 18:09发表 [回复]
举例,MAC.ASP获取硬件信息:
<%
Response.Write "txtDNSName=" & Request.form("txtDNSName") &"<BR>"
Response.Write "txtMACAddr=" & Request.form("txtMACAddr") &"<BR>"
Response.Write "txtIPAddr=" & Request.form("txtIPAddr") &"<BR>"
%>
**转别人的
http://blog.csdn.net/tsxnb/article/details/4627683
2009-10-02 17:33 2569人阅读 评论(1) 收藏 举报
<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>
var value = "客户端硬件信息";
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");//CPU 信息
var e = new Enumerator (properties);
var p = e.item ();
var value=value+ p.SystemName + "CPU:"+ p.Name +p.ProcessorID
var properties = service.ExecQuery("SELECT * FROM Win32_DiskDrive");//硬盘序列号 信息
var e = new Enumerator (properties);
var p = e.item ();
var value=value+"HD:"+p.signature
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");//主板信息
var e = new Enumerator (properties);
var p = e.item ();
//var value=value+"BB:"+ p.Product; //在一些机器在上无法读取
document.forms[0].txtMACAddr.value=unescape(MACAddr); //MAC
document.forms[0].txtIPAddr.value=unescape(IPAddr); //IP
//document.forms[0].txtDNSName.value=unescape(sDNSName); //主机名
document.forms[0].txtDNSName.value=value; //增加的部份包括CPU硬盘主板
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="mac.asp" method="post">
<INPUT type="hidden" value="00-11-11-B4-52-EF" name="txtMACAddr" size="10">
<INPUT type="hidden" value="210.42.38.50" name="txtIPAddr">
<INPUT type="hidden" value="zhupan" name="txtDNSName">
</FORM>
</BODY>
</HTML>
注意:以上Activex控件将被阻止,
1、对于Windows XP或Windows 2003,打开IE的“工具”菜单栏,选择“Internet选项”,点击“安全”—>“受信任站点”,选择“自定义级别”,打开“安全设置”对话框,将其中“对没有标记为安全的ActiveX控件进行初始化和脚本运行”和“下载未签名的ActiveX控件”都设置为“提示”或者“启用” 。
2、vista下安装注册activex控件以及IE8的设置:
首先,要把系统的UAC关掉,或者以administrator登录(方法1:使用命令提示符激活与禁用:进入开始菜单,在“开始搜索”框中输入“cmd”,在上方出现的项目“cmd.exe”右击,在出现的快捷菜单中选择“以管理员身份运行”,之后在出现的管理权限的命令提示符框中输入“net user Administrator /Active:yes”之后,回车退出。重新启动计算机或注销计算机,你就会发现Administrator账户出现在登录画面上了。同样,当你想要禁用Windows Vista中的Administrator账户的时候,只需像上面一样操作,只不过最后在命令行中输入的是“net user Administrator /Active:no”罢了。 方法2:使用系统管理工具激活与禁用:因为vista home premium中没有“本地用户和组”这一项,所以这个方法只针对64位的vista。进入开始菜单,在右列中选中计算机,右击弹出快捷菜单,点击“管理”,找到“计算机管理(本地)”-“系统工具”-“本地用户和组”-“用户”,在右侧双击“Administrator”,在弹出的窗口中把“账户已禁用”前的钩去掉。确定后注销或重新启动计算机,同样可在启动画面上发现Administrator账户的出现。类似的,当你要再次禁用Administrator账户时,只要把那个“账户已禁用”前的钩再次勾选上就可以了。在你用administrator登录,或者用其他用户登录后,用上述方法1,运行命令行窗口,然后把ocx或者dll控件,下载到本地,拷贝到system32目录下,在命令行窗口输入regsvr32 xxxxx即可。)
其次,将你要安装控件的站点加入浏览器可信站点,并且将可信站点安全性降低,所有activex控件都要允许。或者在控制面板--程序与功能--打开或关闭windows功能中找到“安装activex控件”(大概是叫这个名字,因为同样home premium中没有这项)勾选上,可能是同样的效果。
最后,最关键的一点,如果你是IE8的用户,那么你一定要用administrator登录,或者关闭uac后,打开浏览器,工具---internet选项---高级---启用内存保护帮助减少联机攻击,这个勾勾一定要去掉,我之前的ocx控件一直是注册成功的,但是就是运行不了,找了两天的原因,才发现是他在捣鬼。
参考1:http://blog.csdn.net/KOOK_OKKO/archive/2008/05/26/2480889.aspx
参考2:http://blog.csdn.net/vkqiang/archive/2008/12/23/3588638.aspx
给政府做的,安全要求高,居然用硬盘序列号,MAC地址,CPU地址三项来绑定指定的人来操作:
<html>
<head>
<title>提取硬盘序列号</title>
<script>
function disk() {//硬盘序列号 信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_DiskDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.signature + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>
</head>
<body>
<input type="button" value="硬盘序列号" onclick="disk()">
</body>
</html>
通过javascript这种客户端脚本来获得客户端信息其他实例:
<html>
<head>
<title>javascript获得客户端硬件信息-www.web2bar.cn/</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script id=clientEventHandlersJS language=javascript>
<!--
function Button2_onclick() {//CPU 信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Processor");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.DeviceID + "</td>");
document.write("<td>" + p.Name + "</td>");
document.write("<td>" + p.CpuStatus + "</td>");
document.write("<td>" + p.Availability + "</td>");
document.write("<td>" + p.Level + "</td>");
document.write("<td>" + p.ProcessorID + "</td>");
document.write("<td>" + p.SystemName + "</td>");
document.write("<td>" + p.ProcessorType + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//软盘信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_FloppyDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.DeviceID + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("<td>" + p.Manufacuturer + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//CD-ROM 信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_CDROMDrive");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Caption + "</td>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.Drive + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("<td>" + p.MediaLoaded + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//键盘信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_Keyboard");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.Description + "</td>");
document.write("<td>" + p.Name + "</td>");
document.write("<td>" + p.Status + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
function Button1_onclick() {//主板信息
var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("SELECT * FROM Win32_BaseBoard");
var e = new Enumerator (properties);
document.write("<table border=1>");
for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();
document.write("<tr>");
document.write("<td>" + p.HostingBoard + "</td>");
document.write("<td>" + p.Manufacturer + "</td>");
document.write("<td>" + p.PoweredOn + "</td>");
document.write("<td>" + p.Product + "</td>");
document.write("<td>" + p.SerialNumber + "</td>");
document.write("<td>" + p.Version + "</td>");
document.write("</tr>");
}
document.write("</table>");
}
//-->
</script>
</head>
<body>
<INPUT id="Button1" type="button" value="Button" name="Button1" language=javascript onclick="return Button1_onclick()">
</body>
</html>
=================================================
其他资料:
using System;
using System.Management;
namespace HTSoft.Common.Register
{
/// <summary>
/// 计算机信息类
/// </summary>
internal class Computer
{
public string CpuID;
public string MacAddress;
public string DiskID;
public string IpAddress;
public string LoginUserName;
public string ComputerName;
public string SystemType;
public string TotalPhysicalMemory; //单位:M
private static Computer _instance;
internal static Computer Instance()
{
if (_instance == null)
_instance = new Computer();
return _instance;
}
internal Computer()
{
CpuID = GetCpuID();
MacAddress = GetMacAddress();
DiskID = GetDiskID();
IpAddress = GetIPAddress();
LoginUserName = GetUserName();
SystemType = GetSystemType();
TotalPhysicalMemory = GetTotalPhysicalMemory();
ComputerName = GetComputerName();
}
string GetCpuID()
{
try
{
//获取CPU序列号代码
string cpuInfo = " ";//cpu序列号
ManagementClass mc = new ManagementClass( "Win32_Processor ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
cpuInfo = mo.Properties[ "ProcessorId "].Value.ToString();
}
moc = null;
mc = null;
return cpuInfo;
}
catch
{
return "unknow ";
}
finally
{
}
}
string GetMacAddress()
{
try
{
//获取网卡硬件地址
string mac = " ";
ManagementClass mc = new ManagementClass( "Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo[ "IPEnabled "] == true)
{
mac = mo[ "MacAddress "].ToString();
break;
}
}
moc = null;
mc = null;
return mac;
}
catch
{
return "unknow ";
}
finally
{
}
}
string GetIPAddress()
{
try
{
//获取IP地址
string st = " ";
ManagementClass mc = new ManagementClass( "Win32_NetworkAdapterConfiguration ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
if ((bool)mo[ "IPEnabled "] == true)
{
//st=mo[ "IpAddress "].ToString();
System.Array ar;
ar = (System.Array)(mo.Properties[ "IpAddress "].Value);
st = ar.GetValue(0).ToString();
break;
}
}
moc = null;
mc = null;
return st;
}
catch
{
return "unknow ";
}
finally
{
}
}
string GetDiskID()
{
try
{
//获取硬盘ID
String HDid = " ";
ManagementClass mc = new ManagementClass( "Win32_DiskDrive ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
HDid = (string)mo.Properties[ "Model "].Value;
}
moc = null;
mc = null;
return HDid;
}
catch
{
return "unknow ";
}
finally
{
}
}
/// <summary>
/// 操作系统的登录用户名
/// </summary>
/// <returns> </returns>
string GetUserName()
{
try
{
string st = " ";
ManagementClass mc = new ManagementClass( "Win32_ComputerSystem ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
st = mo[ "UserName "].ToString();
}
moc = null;
mc = null;
return st;
}
catch
{
return "unknow ";
}
finally
{
}
}
/// <summary>
/// PC类型
/// </summary>
/// <returns> </returns>
string GetSystemType()
{
try
{
string st = " ";
ManagementClass mc = new ManagementClass( "Win32_ComputerSystem ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
st = mo[ "SystemType "].ToString();
}
moc = null;
mc = null;
return st;
}
catch
{
return "unknow ";
}
finally
{
}
}
/// <summary>
/// 物理内存
/// </summary>
/// <returns> </returns>
string GetTotalPhysicalMemory()
{
try
{
string st = " ";
ManagementClass mc = new ManagementClass( "Win32_ComputerSystem ");
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
st = mo[ "TotalPhysicalMemory "].ToString();
}
moc = null;
mc = null;
return st;
}
catch
{
return "unknow ";
}
finally
{
}
}
/// <summary>
/// 获取计算机名称
/// </summary>
/// <returns> </returns>
string GetComputerName()
{
try
{
return System.Environment.GetEnvironmentVariable( "ComputerName ");
}
catch
{
return "unknow ";
}
finally
{
}
}
}
}
============================
#10楼 得分:20回复于:2007-06-21 10:41:21
WMI代码如下(可以获取所有网卡的MAC地址):
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher( "root//CIMV2 ", "SELECT * FROM Win32_NetworkAdapter ");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine( "----------------------------------- ");
Console.WriteLine( "Win32_NetworkAdapter instance ");
Console.WriteLine( "----------------------------------- ");
Console.WriteLine( "MACAddress: {0} ", queryObj[ "MACAddress "]);
}
}
catch (ManagementException e)
{
MessageBox.Show( "An error occurred while querying for WMI data: " + e.Message);
}
}
}
}
============================
用javascript获取机器名和window登录名
http://blog.csdn.net/reamerit/archive/2009/05/09/4162980.aspx
代码如下:
<script language=javascript>
var WshShell =new ActiveXObject("WScript.Shell");
alert("计算机名 = "+ WshShell.ExpandEnvironmentStrings("%
COMPUTERNAME%"));
alert("登录用户名 = "+ WshShell.ExpandEnvironmentStrings("%
USERNAME%"));
</script>
<script language=javascript>
var wshNetwork = new ActiveXObject("WScript.Network");
alert("域名 = "+ wshNetwork.UserDomain);
alert("计算机名 = "+ wshNetwork.ComputerName);
alert("登录用户名 = "+ wshNetwork.UserName);
</script>
====================================
分享到:
上一篇:ASP获取和还原复选框的值(0~99多项选择)
下一篇:1、纯JS代码生成图表函数——柱图
查看评论
1楼 xzx99 2010-07-12 18:09发表 [回复]
举例,MAC.ASP获取硬件信息:
<%
Response.Write "txtDNSName=" & Request.form("txtDNSName") &"<BR>"
Response.Write "txtMACAddr=" & Request.form("txtMACAddr") &"<BR>"
Response.Write "txtIPAddr=" & Request.form("txtIPAddr") &"<BR>"
%>
**转别人的
http://blog.csdn.net/tsxnb/article/details/4627683
发表评论
-
js容易出错的地方
2013-01-06 09:58 1009<!DOCTYPE html PUBLIC &quo ... -
spring mvc传值(json格式)
2012-11-28 14:30 6920java端: spring-servlet.xml中的部分配置 ... -
frameset应用
2012-11-22 14:13 989main.html 注意不能用body标签 <!D ... -
showModalDialog应用
2012-11-22 13:44 1190直接运行下面的页面就明白怎么用了 父页面:main.html ... -
js加载swf文件
2012-09-20 12:56 10107普通方式加载swf文件可以不引用swfobject.js ... -
js加载xml文件
2012-09-20 12:48 2150function loadXmlData(xmlfile) ... -
JavaScript面向对象指南.pdf
2012-09-18 08:25 1556javascript高级 只有2章的内容但是写的还比较好一共5 ... -
javaScript笔记2
2012-05-04 16:35 0//禁用鼠标右键 document.oncontextmenu ... -
ext学习网址
2012-04-24 22:25 841ext学习: http://www.sencha.com/b ... -
javascript面向对象
2012-04-17 17:57 0function Construt(w,h) { thi ... -
javaScript笔记
2012-04-13 08:26 0\xA9表示版权符号 sub = s ...
相关推荐
在ASP.NET Web应用程序中,获取客户端的IP地址和MAC地址是常见的需求,这通常涉及到网络编程和服务器端脚本处理。以下将详细讲解如何实现这一功能。 首先,客户端的IP地址可以通过HTTP请求头中的`REMOTE_ADDR`字段...
本资源摘要信息将详细介绍在 ASP 中获取客户端 MAC 地址的方法,该方法使用了 arp 命令来读取特定 IP 的 MAC 地址,并结合了 ASP 后门的一些技术。下面将对该方法进行详细的解释和分析。 GetMac 函数 GetMac 函数...
在给定的场景中,我们关注的是如何在ASP.NET环境中获取客户端的MAC(物理)地址。MAC地址是网络设备如计算机、路由器等在网络层的唯一标识,通常在局域网(LAN)中使用。 在ASP.NET中获取客户端MAC地址是一项挑战,...
在ASP.NET中,获取客户端MAC(Media Access Control)地址是一项常见的需求,特别是在网络管理、设备认证或者特定的安全应用场景中。MAC地址是网络设备的物理地址,用于标识连接到网络的设备。然而,由于HTTP协议的...
因此,如果你需要在ASP.NET中实现防刷票或其他基于客户端硬件标识的功能,通常需要采用其他策略,比如: 1. 使用Cookie或Session:为每个用户创建唯一的标识,并限制每个标识的投票次数。 2. 用户登录:要求用户...
### ASP.NET 获取客户端IP和MAC地址的技术解析 #### 一、引言 在现代网络环境中,获取客户端的IP地址和MAC地址是许多应用场景中的基本需求之一。例如,在网络安全监控、日志记录、地理位置追踪等方面都有着重要的...
在ASP.NET中,获取客户端和服务器端的MAC(媒体访问控制)地址以及IP地址是网络编程中的常见需求。MAC地址是设备在网络上的物理地址,而IP地址则是逻辑地址,它们一起构成了网络通信的基础。以下是对这些概念的详细...
在ASP.NET中,获取客户端的IP地址是常见的需求之一,这通常用于日志记录、安全控制或者地理位置定位等功能。 1. **通过`Page.Request.UserHostAddress`** 这是最简单直接的方式,它会返回客户端的IP地址。 ```...
在ASP.NET开发中,了解如何获取客户端的IP地址和用户名是至关重要的,这有助于实现诸如用户追踪、个性化体验以及安全控制等功能。以下是对这个主题的详细解析。 首先,让我们谈谈如何在ASP.NET中获取客户端的IP地址...
在ASP.NET开发中,获取客户端的MAC地址是一个常见的需求,特别是在需要唯一标识用户设备或进行设备绑定等场景下。MAC地址(Media Access Control Address)是网络接口控制器的物理地址,通常用于局域网中设备的唯一...
在C# ASP.NET环境中,获取客户端的网卡(MAC)地址是一项常见的需求,尤其是在网络管理和安全领域。MAC地址,即物理地址,是网络设备(如网卡)在全球范围内的唯一标识符,通常由6个2进制字节组成,转换为人类可读的...
总结来说,ASP.NET开发者可以通过HttpRequest对象获取客户端的UserAgent信息来判断操作系统和浏览器类型,但获取.NET Framework版本通常需要基于假设或者依赖客户端反馈。在实际应用中,需要结合业务需求和实际情况...
在IT领域,尤其是在网络编程中,获取客户端的硬件地址,如MAC(Media Access Control)地址,是一项常见的需求。本文将详细讲解如何使用C# ASP.NET技术实现这一功能。 首先,理解MAC地址的基本概念至关重要。MAC...
在探讨如何利用***框架获取计算机硬件信息的过程中,我们主要关注于如何通过编程方式获取CPU频率、磁盘可用空间和内存容量等硬件参数。这些信息对于了解服务器状态、监控系统性能以及进行资源分配等方面都是非常重要...
在现代软件开发中,尤其是涉及到系统安全、授权管理等场景时,获取客户端硬件信息(如硬盘序列号、网卡MAC地址)的需求十分常见。本文将详细介绍如何在C#结合ASP.NET环境下通过客户端获取这些硬件信息的方法。 ####...
web端项目通过浏览器访问的项目获取客户端mac地址及ip地址,进行登录权限校验; web端通过浏览器访问的项目增加权限; 本次项目由于对数据安全性要求较为严格,所以增加了用户在登录时对于客户端电脑的ip地址和mac...
### .NET 获取客户端主机名和IP地址 在.NET框架中,获取客户端的主机名和IP地址是一项常见的需求,尤其是在Web应用程序开发中。这通常用于跟踪用户活动、安全验证或者网络诊断等场景。本文将详细介绍几种在.NET环境...
公司的域环境内,要求获取客户端的电脑... 您可能感兴趣的文章:ASP.NET获取真正的客户端IP地址的6种方法获取客户端电脑日期时间js代码(jquery)ASP 获取腾讯IP地址的代码IP138 IP地址查询小偷实现代码asp.net 通过指定
本文将详细介绍如何在ASP.NET中获取客户端的IP地址、操作系统版本和浏览器版本。 ### 获取客户端IP地址 在ASP.NET中,获取客户端IP地址是通过`HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]`来实现...
在开发B/S架构的应用程序时,为了确保用户的身份验证准确性以及追踪管理的需求,开发者常常需要获取客户端计算机的MAC地址和IP地址等信息。传统的做法是在服务器端通过各种技术手段(如调用Win32API、执行`nbtstat`...