当前位置:网站首页>Gethostbyname \ getaddrinfo DNS domain name IP address is not safe
Gethostbyname \ getaddrinfo DNS domain name IP address is not safe
2022-08-01 07:30:00 【金- 2006】
Step 1:
Make the target domain name point to a fake server IP in the following format:
Fake server IP address website domain name
Write in %Systemroot%\System32\Drivers\Etc\hosts file:
127.0.0.1 blog.csdn.net
Step 2:
Run the following test code and you will find that the domain name has been pointed to a fake server IP address, what harm will it cause?As a result, the software is easily cracked, and the user data is stolen after the user accesses the fake server.
Test code:
// ----Resolving domain name IP test starts----/*After the hosts file is written: 127.0.0.1 blog.csdn.com,The ip address obtained by gethostbyname \ getaddrinfo will be 127.0.0.1, which is why it is called insecure*///WSADATA wsaData;//WSAStartup(MAKEWORD(2, 2), &wsaData);struct addrinfo *result = nullptr, *curr = nullptr;struct addrinfo hints = { 0 };hints.ai_family = AF_UNSPEC;hints.ai_socktype = SOCK_STREAM;hints.ai_protocol = IPPROTO_TCP;int nRet = getaddrinfo("blog.csdn.net", "443", &hints, &result);if (0 != nRet){int nError = WSAGetLastError();CString szMSG;szMSG.Format(_T("getaddrinfo call failed, error code: %d.\r\n"), nError);Log(szMSG);return;}char chIP[16];for (curr = result; curr != nullptr; curr = curr->ai_next) {inet_ntop(AF_INET, &(((struct sockaddr_in *)(curr->ai_addr))->sin_addr), chIP, 16);Log(CString(chIP) + CString(_T("\r\n")));}freeaddrinfo(result);//WSACleanup();// ----End domain name IP test ----
边栏推荐
- 插入排序—直接插入排序和希尔排序
- 特殊的日子,值得纪念
- Golang: go static file processing
- pytest接口自动化测试框架 | 跳过测试类
- Detailed explanation of the crawler framework Scrapy
- pytest接口自动化测试框架 | 使用函数返回值的形式传入参数值
- app 自动化 打开app (二)
- R语言使用tidyquant包的tq_transmute函数计算持有某只股票的天、月、周收益率、ggplot2使用条形图可视化股票月收益率数据、使用百分比显示Y轴坐标数据、使用不同的色彩表征正负收益率
- 选择排序—直接选择排序和堆排序
- 日志导致线程Block的这些坑,你不得不防
猜你喜欢
随机推荐
Data Analysis 6
【一句话攻略】彻底理解JS中的回调(Callback)函数
好的plm软件有哪些?plm软件排行榜
05-SDRAM:仲裁
电磁兼容简明教程(6)测试项目
类似 MS Project 的项目管理工具有哪些
LeetCode240+312+394
Go supports OOP: use struct instead of class
选择排序—直接选择排序和堆排序
Golang: go static file processing
The socket option
MATLAB程序设计与应用 2.5 MATLAB运算
LevelSequence源码分析
Vim三种模式
22牛客多校1 J.Serval and Essay (启发式合并)
The use of Golang: go template engine
Srping中bean的生命周期
rhcsa 第三次
Dbeaver connect the MySQL database and error Connection refusedconnect processing
【MySQL】操作表DML相关语句