在vb6中使用Mac ID进行程序安全 [英] Program security using mac id in vb6

查看:72
本文介绍了在vb6中使用Mac ID进行程序安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



尝试在安装某些程序时获取识别/读取mac id的代码,并在将来运行该程序时获取系统以验证mac id的信息.如果将程序文件复制到其他系统,则它不应运行.该程序支持可能的所有操作系统和配置.

在此先感谢

Hi,

Trying to get code to identify/read mac id while installing a certain program and the system to validate the mac id when the program is run in future. If the program files are copied to different system then it should not run. This program to support possible all operating systems and configurations.

Thanks in advance

推荐答案

坏主意.
1.诚实的用户升级网卡:您的程序停止运行.
2.恶意用户设置虚拟PC,安装程序,保存映像,将其上传到Web并与足够聪明的人共享您的应用程序,以安装虚拟PC.

如果要进行软件权限管理或激活,则需要更复杂的解决方案.如果您打算出售软件,请考虑商业解决方案.我不会提供任何链接,因为没有人向我支付任何百分比,但是使用Google谷歌搜索应该会有所帮助.

JM2B,

Pablo.
Bad idea.
1. A honest user upgrades a network card: your program stops working.
2. A evil user sets up a virtual PC, installs your program, saves the image, uploads it to the Web and shares your app with whoever is smart enough to install a virtual PC.

If you want software rights management, or activation, you need a more complex solution. If you''re planning to sell your software, consider a commercial solution. I won''t provide any links, since nobody is paying me any percentages, but googling a bit should help.

JM2B,

Pablo.


来自MSDN Q118623 HOWTO:获取以太网适配器的MAC地址


From MSDN Q118623 HOWTO: Get the MAC Address for an Ethernet Adapter


Option Explicit
' net config workstation

' from NB30.h

'#define NCBNAMSZ        16    /* absolute length of a net name           */
'#define MAX_LANA       254    /* lana's in range 0 to MAX_LANA inclusive */
'#define NCBENUM         0x37            /* NCB ENUMERATE LANA NUMBERS         */

Private Const NCBNAMSZ = 16
Private Const MAX_LANA = 254

Private Const NCBRESET = &H32
Private Const NCBASTAT = &H33
Private Const NCBENUM = &H37

Private Type NCB
    ncb_command As Byte ' APIViewer defines this incorrectly as Integer
    ncb_retcode As Byte ' APIViewer defines this incorrectly as Integer
    ncb_lsn As Byte ' APIViewer defines this incorrectly as Integer
    ncb_num As Byte ' APIViewer defines this incorrectly as Integer
    ncb_buffer As Long ' APIViewer defines this incorrectly as String
    ncb_length As Integer
    ncb_callname As String * NCBNAMSZ
    ncb_name As String * NCBNAMSZ
    ncb_rto As Byte ' APIViewer defines this incorrectly as Integer
    ncb_sto As Byte ' APIViewer defines this incorrectly as Integer
    ncb_post As Long
    ncb_lana_num As Byte ' APIViewer defines this incorrectly as Integer
    ncb_cmd_cplt As Byte  ' APIViewer defines this incorrectly as Integer
    ncb_reserve(0 To 9) As Byte ' Reserved, must be 0, ' APIViewer defines this incorrectly as (10)
    ncb_event As Long
End Type

Private Type LANA_ENUM
        Length As Integer
        Lana(0 To MAX_LANA) As Integer
End Type

'#define NRC_GOODRET     0x00    /* good return                                */
Private Const NRC_GOODRET = 0

Private Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As Byte

Private Type ADAPTER_STATUS
    adapter_address(0 To 5) As Byte             'As String * 6
    rev_major As Byte           ' APIViewer defines this incorrectly as Integer
    reserved0 As Byte           ' APIViewer defines this incorrectly as Integer
    adapter_type As Byte         ' APIViewer defines this incorrectly as Integer
    rev_minor As Byte           ' APIViewer defines this incorrectly as Integer
    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        ' ?? 30 or 0 to 29 aod
End Type

   

' From MSDN Q118623 HOWTO: Get the MAC Address for an Ethernet Adapter

Public Function LANA_List() As Variant
    Dim NCB As NCB
    Dim LANA_ENUM As LANA_ENUM

'      Ncb.ncb_command = NCBENUM;
    NCB.ncb_command = NCBENUM
    
'      Ncb.ncb_buffer = (UCHAR *)&lenum;
    NCB.ncb_buffer = VarPtr(LANA_ENUM)
'      Ncb.ncb_length = sizeof(lenum);
    NCB.ncb_length = Len(LANA_ENUM)
    
'      uRetCode = Netbios( &Ncb );
    Dim Ret As Byte
    Ret = Netbios(NCB)
    If Ret <> NRC_GOODRET Then
        Err.Raise 5, , "LANA_lst: Error from Netbios, return code = " & Ret
    End If
    
    ' copy array to a nice variant array. VB Style
    If LANA_ENUM.Length > 0 Then
        ReDim List(LANA_ENUM.Length - 1)
    
        Dim Index As Long
        For Index = 0 To LANA_ENUM.Length - 1
           List(Index) = LANA_ENUM.Lana(Index)
        Next Index
        LANA_List = List
    Else
        LANA_List = Array()
    End If
End Function


Public Function MacAddress(ByVal LANA_Number_IN As Long) As String
    Dim NCB As NCB
    Dim Ret As Byte
    
    NCB.ncb_command = NCBRESET
    Ret = Netbios(NCB)
    If Ret <> NRC_GOODRET Then
        Err.Raise 5, , "MacAddress: Error from Netbios, return code = " & Ret
    End If
    
    NCB.ncb_command = NCBASTAT
    NCB.ncb_lana_num = LANA_Number_IN
    NCB.ncb_callname = "*"
    Debug.Assert NCB.ncb_callname = "*               "
    
    Dim ASTAT As ASTAT
    NCB.ncb_length = Len(ASTAT)
    Debug.Assert NCB.ncb_length = 680
    NCB.ncb_buffer = VarPtr(ASTAT)
    Ret = Netbios(NCB)
    If Ret <> NRC_GOODRET Then
        Err.Raise 5, , "MacAddress: Error from Netbios, return code = " & Ret
    End If
    
    ' this should be returned as an array of bytes someday
    MacAddress = Hex(ASTAT.adapt.adapter_address(0)) & " " & _
           Hex(ASTAT.adapt.adapter_address(1)) _
           & " " & Hex(ASTAT.adapt.adapter_address(2)) & " " _
           & Hex(ASTAT.adapt.adapter_address(3)) _
           & " " & Hex(ASTAT.adapt.adapter_address(4)) & " " _
           & Hex(ASTAT.adapt.adapter_address(5))
    'Debug.Print MacAddress
End Function


Sub main()
    Dim Lana As Variant
    
    ' this will return multiple LANA when connected to a dial up connection & a NIC
    For Each Lana In LANA_List
        Debug.Print Lana, MacAddress(Lana)
    Next Lana
End Sub


这篇关于在vb6中使用Mac ID进行程序安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆