怎么知道网卡的MAC地址被手动修改了??

viciner 2003-02-28 11:12:35
我们公司本来有一个软件准备用网卡ID加密,用的是NetBios的取法,就在快发布的时候,发现手动更改MAC地址可以把这个API给骗过去,因为做的是单机版程序,所以无法通过MAC地址冲突来解决这一点,不知道哪位高人可以提供一个不被这个手动修改的MAC地址骗过的办法,或是怎么知道MAC有没有被修改,十万火急,救人啊
...全文
645 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Girl1983 2003-02-28
  • 打赏
  • 举报
回复
以下代码取得物理上的网卡地址
Private Const NCBASTAT As Long = &H33
Private Const NCBNAMSZ As Long = 16
Private Const HEAP_ZERO_MEMORY As Long = &H8
Private Const HEAP_GENERATE_EXCEPTIONS As Long = &H4
Private Const NCBRESET As Long = &H32
Private Type NET_CONTROL_BLOCK 'NCB
ncb_command As Byte
ncb_retcode As Byte
ncb_lsn As Byte
ncb_num As Byte
ncb_buffer As Long
ncb_length As Integer
ncb_callname As String * NCBNAMSZ
ncb_name As String * NCBNAMSZ
ncb_rto As Byte
ncb_sto As Byte
ncb_post As Long
ncb_lana_num As Byte
ncb_cmd_cplt As Byte
ncb_reserve(9) As Byte ' Reserved, must be 0
ncb_event As Long
End Type
Private Type ADAPTER_STATUS
adapter_address(5) As Byte
rev_major As Byte
reserved0 As Byte
adapter_type As Byte
rev_minor As Byte
duration As Integer
frmr_recv As Integer
frmr_xmit As Integer
iframe_recv_err As Integer
xmit_aborts As Integer
xmit_success As Long
recv_success As Long
iframe_xmit_err As Integer
recv_buff_unavail As Integer
t1_timeouts As Integer
ti_timeouts As Integer
Reserved1 As Long
free_ncbs As Integer
max_cfg_ncbs As Integer
max_ncbs As Integer
xmit_buf_unavail As Integer
max_dgram_size As Integer
pending_sess As Integer
max_cfg_sess As Integer
max_sess As Integer
max_sess_pkt_size As Integer
name_count As Integer
End Type
Private Type NAME_BUFFER
name As String * NCBNAMSZ
name_num As Integer
name_flags As Integer
End Type
Private Type ASTAT
adapt As ADAPTER_STATUS
NameBuff(30) As NAME_BUFFER
End Type
Private Declare Function Netbios Lib "netapi32.dll" (pncb As NET_CONTROL_BLOCK) As Byte
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Function GetProcessHeap Lib "kernel32" () As Long
Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long
Function GetMACAddress() As String
'retrieve the MAC Address for the network controller
'installed, returning a formatted string
Dim tmp As String
Dim pASTAT As Long
Dim NCB As NET_CONTROL_BLOCK
Dim AST As ASTAT
'The IBM NetBIOS 3.0 specifications defines four basic
'NetBIOS environments under the NCBRESET command. Win32
'follows the OS/2 Dynamic Link Routine (DLR) environment.
'This means that the first NCB issued by an application
'must be a NCBRESET, with the exception of NCBENUM.
'The Windows NT implementation differs from the IBM
'NetBIOS 3.0 specifications in the NCB_CALLNAME field.
NCB.ncb_command = NCBRESET
Call Netbios(NCB)
'To get the Media Access Control (MAC) address for an
'ethernet adapter programmatically, use the Netbios()
'NCBASTAT command and provide a "*" as the name in the
'NCB.ncb_CallName field (in a 16-chr string).
NCB.ncb_callname = "* "
NCB.ncb_command = NCBASTAT
'For machines with multiple network adapters you need to
'enumerate the LANA numbers and perform the NCBASTAT
'command on each. Even when you have a single network
'adapter, it is a good idea to enumerate valid LANA numbers
'first and perform the NCBASTAT on one of the valid LANA
'numbers. It is considered bad programming to hardcode the
'LANA number to 0 (see the comments section below).
NCB.ncb_lana_num = 0
NCB.ncb_length = Len(AST)
pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, NCB.ncb_length)
If pASTAT = 0 Then
Debug.Print "memory allocation failed!"
Exit Function
End If
NCB.ncb_buffer = pASTAT
Call Netbios(NCB)
CopyMemory AST, NCB.ncb_buffer, Len(AST)
tmp = Format$(Hex(AST.adapt.adapter_address(0)), "00") & " " & Format$(Hex(AST.adapt.adapter_address(1)), "00") & " " & Format$(Hex(AST.adapt.adapter_address(2)), "00") & " " & Format$(Hex(AST.adapt.adapter_address(3)), "00") & " " & Format$(Hex(AST.adapt.adapter_address(4)), "00") & " " & Format$(Hex(AST.adapt.adapter_address(5)), "00")
HeapFree GetProcessHeap(), 0, pASTAT
GetMACAddress = tmp
End Function
Private Sub Form_Load()
MsgBox "Network adapter address: " + GetMACAddress()
End Sub
mashimaro3600 2003-02-28
  • 打赏
  • 举报
回复
那你就用硬盘的ID来加密阿~~
mashimaro3600 2003-02-28
  • 打赏
  • 举报
回复
我在网上看到手动改MAC地址的都是在注册表里修改的,就是讲真正的网卡里的MAC地址可能是没有变的(好像是有的网卡可以横容易变,但有的网卡必须在dos下用自己的诊断程序才可以修改MAC地址 这些都是修改flash的内容) 但没见过有介绍咋去读网卡上信息的
viciner 2003-02-28
  • 打赏
  • 举报
回复
多谢holydiablo(鱼头)

结帐
holydiablo 2003-02-28
  • 打赏
  • 举报
回复
楼上说的好象就是楼主用的嘛,而且这种办法还有一个毛病,那就是在Win2000或是winxp中没插网线会取不到ID号,我现在都是用Iphlpapi.dll来取。
不过正象楼主说的那样,MAC地址在Windows中允许修改,这个值是存在注册表中的,在我的机器上其位置是
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0005\NetworkAddress
其中{4D36E972-E325-11CE-BFC1-08002BE10318}是一个GUID,表示网卡,0005是设备编号。
但如果没有改过那个值,则NetworkAddress键是不存在的。
鑫河自动更换电脑网卡工具是一款专业好用的实用的Mac地址修改器软件。软件并自动读取本机网卡所有列表信息,具有自动生成MAC地址,备份旧网卡MAC地址的功能,并可自动生成随机网卡MAC地址,还可以全自动扫描网卡地址,修改多处网卡地址,需要的朋友快来下载吧! 鑫河自动更换电脑网卡工具功能 一.此软件支持Win XP,Win7,Win200,Win2003等并自动读取本机网卡所有列表信息; 二.自动生成随机网卡MAC地址,软件全自动禁启用网卡; 三.可以全自动扫描网卡地址,修改多处网卡地址,不需要重启电脑,高效快速。具有自动生成网卡MAC地址,备份旧MAC地址的功能。 四.此软件可以间隔60秒换一次网卡MAC地址的特强功能,在ARP攻击越来越普遍的今天,修改网卡MAC地址也不失为一个解决办法;; 五.同时此软件也可以根据你本人的需要设置多少时间更换一次网卡MAC地址的功能; 六.更换网卡MAC地址时网络是要影响网络7秒,它的掉线时间取决你的当地宽带运营商,正常的话几秒就可以连接上; 七.此软件可手动更换网卡MAC地址信息,也可自动更换网卡MAC地址信息,用户可自行选择; 鑫河自动更换电脑网卡工具 v3.4.6.2更新日志 1.增加时间的判断功能。 2.增加在vista操作系统下的修改网卡的判断功能 3.修正一些软件bugs. 鑫河自动更换电脑网卡工具截图

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧