本文整理自网络,侵删。
function ResolveIP(HostName: string): string; {delphi把域名转换成IP}
type
tAddr = array[0..100] of PInAddr;
pAddr = ^tAddr;
var
I: Integer;
WSA: TWSAData;
PHE: PHostEnt;
P: pAddr;
begin
Result := '';
WSAStartUp($101, WSA);
try
PHE := GetHostByName(pChar(HostName));
if (PHE <> nil) then
begin
P := pAddr(PHE^.h_addr_list);
I := 0;
while (P^[I] <> nil) do
begin
Result := (inet_nToa(P^[I]^));
Inc(I);
end;
end;
except
end;
WSACleanUp;
end;
这个函数必需要Winsock单元支持,Winsock是Windows进行网络通信编程的API接口,所以记得加上
一个木马,你在配置时填入域名,如下
var
dns:phcr='www.hao828.com';
那当程序开始时就要把www.hao828.com域名解释为IP,这样木马才会访问得到客户端
建就在程序开始事件放入代码:
Host := ResolveIP(Dns);
Dns变量就是域名,Host变量是得到的IP
Host: string; //IP
Dns: string; //域名
相关阅读 >>
Delphi xe android的所有权限按照分类总结说明
Delphi win10系统通知 notificationcenter1 基本用法
更多相关阅读请进入《Delphi》频道 >>