windows guid

#include <stdio.h>  
#include <windows.h>
#define GUID_LEN 64  

int main(int argc, char* argv[])  
{  
    printf("test\n");
    char buffer[GUID_LEN] = { 0 };  
    GUID guid;
    printf("guid\n");
    if (CoCreateGuid(&guid))  
    {  
        printf("create guid error\n");
        fprintf(stderr, "create guid error\n");  
        return -1;  
    }
    _snprintf(buffer, sizeof(buffer),  
        "%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X",  
        guid.Data1, guid.Data2, guid.Data3,  
        guid.Data4[0], guid.Data4[1], guid.Data4[2],  
        guid.Data4[3], guid.Data4[4], guid.Data4[5],  
        guid.Data4[6], guid.Data4[7]);  
    printf("guid: %s\n", buffer);  
    return 0;  
}

编译方法

gcc main.c -o main.exe -lmingw32 -lole32

linux

#include <uuid/uuid.h>  

int main()  
{
    uuid_t uu;  
    int i;  
    uuid_generate( uu );  

    for(i=0;i<16;i++)  
    {  
        printf("%02X-",uu[i]);  
    }  
    printf("\n");  
    return 0;  
}

经测试windows识别码会改变,于是寻找其他资料:
https://blog.csdn.net/yanchenyu365/article/details/85061879?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163047488916780366580119%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=163047488916780366580119&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-4-85061879.pc_search_result_hbase_insert&utm_term=%E8%8E%B7%E5%8F%96%E7%A1%AC%E7%9B%98%E5%BA%8F%E5%88%97%E5%8F%B7&spm=1018.2226.3001.4187
注册表操作:https://blog.csdn.net/Tiaobaobao/article/details/100016013?ops_request_misc=&request_id=&biz_id=102&utm_term=C%E8%AF%AD%E8%A8%80%20%E6%B7%BB%E5%8A%A0%E6%B3%A8%E5%86%8C%E8%A1%A8&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-100016013.pc_search_result_hbase_insert&spm=1018.2226.3001.4187
php获取唯一识别码:https://blog.csdn.net/weixin_30466039/article/details/98265895?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163047573016780264010454%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=163047573016780264010454&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_v2~rank_v29-1-98265895.pc_search_result_hbase_insert&utm_term=php+%E8%8E%B7%E5%8F%96%E8%AF%86%E5%88%AB%E7%A0%81&spm=1018.2226.3001.4187
获取uuid命令:wmic csproduct get uuid
(这个貌似是获取主板uuid)

python获取mac地址

#!/usr/bin/python
# get ip
import subprocess
def get_ip():
    args='''ifconfig|grep 'inet addr:'|awk '{print $2}'|awk -F':' '{print $2}'|grep -v "127.0.0.1"'''
    t=subprocess.Popen(args,shell=True,stdout=subprocess.PIPE).communicate()[0]
    print(t, type(t))
    t = str(t)
    return t.split('\n')[0]

# print(get_ip())

# 获取mac唯一地址
def get_max_address():
    import uuid
    node=uuid.getnode()
    print('node:', node)
    mac=uuid.UUID(int=node).hex[-12:]
    return mac

print(get_max_address())

发表评论

邮箱地址不会被公开。 必填项已用*标注