当前位置:网站首页>gethostbyname \ getaddrinfo 解析域名IP地址不安全的原因
gethostbyname \ getaddrinfo 解析域名IP地址不安全的原因
2022-08-01 07:18:00 【kim-2006】
第 1 步:
使目标域名指向假的服务器IP,格式如下:
假服务器IP地址 网站域名
在 %Systemroot%\System32\Drivers\Etc\hosts 文件中写入:
127.0.0.1 blog.csdn.net
第 2 步:
运行以下测试代码就会发现域名已被指向假的服务器IP地址, 会造成什么危害呢?导致软件轻易被破解,用户访问假的服务器后,导致用户数据被盗窃。
测试代码:
// ----解析域名IP测试开始----
/*
在 hosts 文件写入: 127.0.0.1 blog.csdn.com 后,
gethostbyname \ getaddrinfo 获得的 ip 地址将是 127.0.0.1, 这就是所谓的不安全的原因
*/
//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 调用失败, 错误代码: %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();
// ----解析域名IP测试结束----
边栏推荐
- R语言使用tidyquant包的tq_transmute函数计算持有某只股票的天、月、周收益率、ggplot2使用条形图可视化股票月收益率数据、使用百分比显示Y轴坐标数据、使用不同的色彩表征正负收益率
- pytest接口自动化测试框架 | parametrize叠加使用
- Offer brush questions - 1
- 我的创作纪念日
- LabVIEW RT中的用户界面更新速度
- Detailed explanation of the crawler framework Scrapy
- 【HDLBits 刷题】Circuits(1)Combinational Logic
- 「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面
- Three aspects of Ali: How to solve the problem of MQ message loss, duplication and backlog?
- 05-SDRAM:仲裁
猜你喜欢
Image lossless compression software which works: try completely free JPG - C image batch finishing compression reduces weight tools | latest JPG batch dressing tools download
I have three degrees, and I have five faces. I was "confessed" by the interviewer, and I got an offer of 33*15.
Datagrip error "The specified database userpassword combination is rejected..."Solutions
七夕来袭——属于程序员的浪漫
图片无损压缩软件哪个好用:试试完全免费的JPG-C 图片批量修整压缩减肥工具吧 | 最新jpg批量修整工具下载
Introduction to the basic principles, implementation and problem solving of crawler
特别数的和
MVVM project development (commodity management system 1)
「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面
Self-made a remote control software - VeryControl
随机推荐
三维坐标系距离
crypto-js uses
【一句话攻略】彻底理解JS中的回调(Callback)函数
Motion analysis and parameter optimization of crank-slider mechanism
企业员工人事管理系统(数据库课设)
Golang:go开启web服务
从底层结构开始学习FPGA(6)----分布式RAM(DRAM,Distributed RAM)
信息系统项目管理师必背核心考点(五十六)配置控制委员会(CCB)的工作
最小生成树
「面经分享」西北大学 | 字节 生活服务 | 一面二面三面 HR 面
More than 2022 cattle guest school game 4 yue
C语言学习概览(三)
响应式织梦模板园林景观类网站
The use of Golang: go template engine
并发编程13-JUC之CountDownLatch
对于升级go1.18的goland问题
datagrip 报错 “The specified database userpassword combination is rejected...”的解决方法
POJ1251丛林之路题解
MySQL row locks and gap locks
插入排序—直接插入排序和希尔排序