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

推荐订阅源

Vercel News
Vercel News
Recorded Future
Recorded Future
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
N
News | PayPal Newsroom
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
博客园 - Franky
SecWiki News
SecWiki News
Recent Announcements
Recent Announcements
T
Troy Hunt's Blog
The Register - Security
The Register - Security
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
S
Security Affairs
博客园 - 司徒正美
S
Schneier on Security
I
InfoQ
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Forbes - Security
Forbes - Security
腾讯CDC
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
Cloudbric
Cloudbric
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
B
Blog
V
Vulnerabilities – Threatpost
C
Check Point Blog
Google DeepMind News
Google DeepMind News
Google Online Security Blog
Google Online Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
Schneier on Security
Schneier on Security
O
OpenAI News
K
Kaspersky official blog

博客园 - 赵青青

AI模型Claude的Haiku、Sonnet、Opus 怎么选? obsidian(md笔记管理)使用实践 python中可变参数与装饰器的例子 C++ lambda 表达式 3ds max的obj文件格式说明 CPython调试和性能分析 Python3类型安全type hint Python3虚拟机和对象 vs编译cpp时设置排除项 Python311新特性-特化指令specializing adaptive interpreter-typing-asyncio 最小体积拉取git仓库并保持可更新 unity .net8 suppot comming pycharm一些减少代码warning的拼写检查设置 JavaScript速查表 Python cheatsheet 速查表 DirectX9(D3D9)游戏开发:高光时刻录制和共享纹理的踩坑 FFmpeg在游戏视频录制中的应用:画质与文件大小的综合比较 c++中字符串之string和char IMGUI快速入门
与ChatGPT的对话在windows上获取mac地址
赵青青 · 2024-11-03 · via 博客园 - 赵青青

碰到编程问题可以问chatgpt,他给的结果也很容易验证是否正确,跑一下代码正确与否一目了然,比如我想获取mac地址

c++中调用winapi实现

问:使用c++调用winapi获取电脑的mac地址

chatgpt:在C++中,你可以使用Windows API的 GetAdaptersInfo 函数来获取电脑的MAC地址。以下是一个示例:

#include <iostream>
#include <windows.h>
#include <iphlpapi.h>
#include <iomanip>

#pragma comment(lib, "iphlpapi.lib")

int main() {
    IP_ADAPTER_INFO AdapterInfo[16];
    DWORD dwBufLen = sizeof(AdapterInfo);

    DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwBufLen);
    if (dwStatus != ERROR_SUCCESS) {
        std::cerr << "GetAdaptersInfo failed with error: " << dwStatus << std::endl;
        return 1;
    }

    PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;
    do {
        std::cout << "Adapter name: " << pAdapterInfo->AdapterName << std::endl;
        std::cout << "Adapter desc: " << pAdapterInfo->Description << std::endl;
        std::cout << "Adapter MAC: ";
        for (UINT i = 0; i < pAdapterInfo->AddressLength; i++) {
            if (i == (pAdapterInfo->AddressLength - 1))
                std::cout << std::setw(2) << std::setfill('0') << std::hex << (int)pAdapterInfo->Address[i];
            else
                std::cout << std::setw(2) << std::setfill('0') << std::hex << (int)pAdapterInfo->Address[i] << "-";
        }
        std::cout << std::endl;
        pAdapterInfo = pAdapterInfo->Next;
    } while(pAdapterInfo);

    return 0;
}

python中获取mac

问:使用python2获取电脑的mac地址

chatgpt:

在Python 2中,你可以使用内置的uuid模块来获取电脑的MAC地址。以下是一个示例:

import uuid

def get_mac_address():
    mac = uuid.getnode()
    return ':'.join(('%012X' % mac)[i:i+2] for i in range(0, 12, 2))

print(get_mac_address())

这段代码首先调用uuid.getnode()函数获取电脑的MAC地址,然后将其转换为常见的冒号分隔的格式。

需要注意的是,uuid.getnode()函数返回的是一个整数,所以我们需要使用字符串格式化将其转换为16进制的形式,并添加冒号。

我电脑上的网卡

比如我的电脑上有三个网卡

  1. Realtek PCIe 2.5GbE Family Controller
  2. ZTN Adapter V1
  3. TAP-Windows Adapter V9

image-20240721173620458

Realtek公司生产的一种网络接口控制器(NIC),也就是我们通常所说的网卡。这种网卡使用PCI Express(PCIe)接口连接到计算机,支持2.5Gbps的以太网连接。

零信任网络 (ZTN),IT安装的

Tap-Windows 适配器 V9 是一个虚拟网络接口。它提供了各种 VPN 客户端所需的功能,以促进 VPN 连接

虚拟网卡和物理网卡

虚拟网卡和非虚拟网卡的主要区别在于它们的实现方式和使用场景。

非虚拟网卡,也就是物理网卡,是一种硬件设备,它直接连接到计算机的主板上。物理网卡负责处理所有的网络通信,包括数据的发送和接收。例如,当你使用网线或Wi-Fi上网时,你的计算机就是通过物理网卡来连接到网络的。

虚拟网卡,顾名思义,是一种虚拟的网络接口,它是通过软件在操作系统中创建的。虚拟网卡可以模拟物理网卡的功能,但是它并不需要物理设备。虚拟网卡通常用于网络虚拟化,例如在虚拟机或容器中创建独立的网络环境,或者在VPN(虚拟专用网络)中创建安全的网络连接。

虚拟网卡和物理网卡的另一个区别是,虚拟网卡的MAC地址通常是随机生成的,而物理网卡的MAC地址是由制造商在生产时分配的,每个物理网卡的MAC地址都是唯一的。

总的来说,虚拟网卡和物理网卡都是网络接口,它们都可以用于网络通信,但是它们的实现方式和使用场景有所不同。