惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
L
LINUX DO - 热门话题
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
AI
AI
L
LINUX DO - 最新话题
H
Heimdal Security Blog
Hacker News: Ask HN
Hacker News: Ask HN
Webroot Blog
Webroot Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The GitHub Blog
The GitHub Blog
I
Intezer
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
S
Securelist
博客园_首页
IT之家
IT之家
Schneier on Security
Schneier on Security
博客园 - 叶小钗
罗磊的独立博客
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
W
WeLiveSecurity
The Register - Security
The Register - Security
D
DataBreaches.Net
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
腾讯CDC
Recorded Future
Recorded Future
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tailwind CSS Blog
N
News and Events Feed by Topic
Cyberwarzone
Cyberwarzone
T
Tor Project blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - ㊣鑫哥

jQuery插件---获取URL参数. 利用反射,泛型,扩展方法快速获取表单值到实体类 [原创]jQuery PreviewImg 上传预览插件 js操作frameset frame 对象 关于“Internet Explorer无法打开站点,已终止操作” JavaScript 面向对象程序设计(下)——继承与多态 JavaScript 面向对象程序设计(上)——封装[转] JS类 检测上传图片的大小,宽,高及格式检查 .net 2.0 制作 柱状图 [转]AJAX之旅 由prototype_1.3.1进入javascript殿堂-类的初探 [转]不可多得的Javascript(AJAX)开发工具 - Aptana 探究 Singleton 设计模式(构建分布式应用程序) .Net平台下开发中文语音应用程序[转] [转]在自定义Server Control中捆绑JS文件 Step by Step IE下JavaScript迁移到FireFox下的工作笔记[转] Asp.net组件开发(资料贴) 有关于JSON的一些资料 这样的UpdatePanel控件要怎么做 [转]30岁前男人应该做的16件事
asp.net如何获取客户端网卡mac地址
㊣鑫哥 · 2007-09-19 · via 博客园 - ㊣鑫哥

//添加组件System.Management
using System.Management;
using System.Runtime.InteropServices;

[DllImport("Iphlpapi.dll")]
private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip);

protected void Page_Load(object sender, EventArgs e)
{
try
{
string userip = Request.UserHostAddress;
Int32 ldest = inet_addr(userip); //目的地的ip
Int32 lhost = inet_addr(""); //本地服务器的ip
Int64 macinfo = new Int64();
Int32 len = 6;
int res = SendARP(ldest, 0, ref macinfo, ref len);
string mac_src = macinfo.ToString("X");
if (mac_src == "0")
{
if (userip == "127.0.0.1")
userinfo.Text = "正在访问Localhost!";
else
userinfo.Text = "欢迎来自IP为" + userip + "的朋友!";
return;
}
while (mac_src.Length < 12)
{
mac_src = mac_src.Insert(0, "0");
}
string mac_dest = "";
for (int i = 0; i < 11; i++)
{
if (0 == (i % 2))
mac_dest = mac_dest.Insert(0, mac_src.Substring(i, 2));
}
userinfo.Text = "欢迎来自IP为" + userip + ",MAC地址为" + mac_dest + "的朋友!";
}
catch (Exception err)
{
Response.Write(err.Message);
}
}