当前位置:网站首页>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测试结束----边栏推荐
猜你喜欢

Image lossless compression software which works: try completely free JPG - C image batch finishing compression reduces weight tools | latest JPG batch dressing tools download

crypto-js uses

数据机构----线性表之单向链表

爬虫框架 Scrapy 详解

app 自动化 通过工具查看app 元素 (三)

爆肝3万字,最硬核丨Mysql 知识体系、命令全集 【建议收藏 】

The BP neural network based on MATLAB voice characteristic signal classification

NIO编程

How to use Photoshop to composite star trail photos, post-processing method of night sky star trail photos

app 自动化 打开app (二)
随机推荐
Srping中bean的生命周期
R语言使用gt包和gtExtras包优雅地、漂亮地显示表格数据:gtExtras包的pad_fn函数与gt::fmt函数一起用于填充包含数值的特定列、对数据列的数值进行十进制对齐(从小数点对齐)
special day to remember
The use of Golang: go template engine
最小生成树
牛客刷SQL---2
Summary of test points about app updates in different ways
支付宝如何生成及配置公钥证书
return;代表含义
Dart exception details
如何使用Photoshop合成星轨照片,夜空星轨照片后期处理方法
NIO programming
rhcsa 第四天
POJ1287联网题解
GO错误处理方式
Dart 异常详解
crypto-js uses
Datagrip error "The specified database userpassword combination is rejected..."Solutions
上课作业(7)——#598. 取余运算(mod)
Generate pictures based on the content of the specified area and share them with a summary