伪造任何存在或者不存在的域名

来源:互联网 发布:exe一机一码加密软件 编辑:程序博客网 时间:2024/06/03 12:39

伪造任何存在或者不存在的域名   

     很久之前,有人玩这东西,就是注册域名

xn--80ak6aa92e.com   ----        аррӏе.com

利用编码问题,当在浏览器里访问的时候很难区分apple真假:

浏览器里访问xn--80ak6aa92e.com 直接和apple展示的一样。


    不过下面整理的不是这个姿势,下面的姿势是针对于代码访问的,不是浏览器,不过浏览器也可以做,直接搞劫持,之前弄的LSP跳转劫持用的这个思路。

 

通常杀软和抓包工具,进行网络截取的时候检测和展示的域名都是来源于https)的head-host



    然而这个报毒或者是抓包工具显示的域名是可以修改的,而且可以修改成任意存在或者不存在的(前提是服务器端设置了接收所有域名)。

原理:

    直接TCP模拟HTTP(s),自己拼接Head头同时连接服务器的时候可以使用真实域名或者是使用,服务器IP,然后自己拼接的Head头里面个杀软和抓包工具看的就Host


    如果是要欺骗抓包工具(或大部分杀软),则TCP连接的时候可以直接用域名,否则的话就直接用服务器IP,如果想使用服务器IP但是怕暴露服务器,可以申请域名,开加速,走节点ip,亲测这个姿势可行。

下面是测试了一次连接tu*ou的。houst里给配置了一个xoxoxo...的不存在域名。



整理了代码如下。

 

RandomDomainLink.h

#pragma once #define WIN32_LEAN_AND_MEAN #include <string>#include <stdio.h>#include <sstream>#include <stdlib.h>#include <iostream>#include <windows.h>#include <winsock2.h>#include <ws2tcpip.h> #pragma comment(lib,"ws2_32.lib")#pragma warning(disable:4996) using namespace std; class CRandomDomainLink{private:static string SocketHttp(string strDomainLinkOrIp, string strPacketDate); public:CRandomDomainLink();~CRandomDomainLink();static string Http_Get(string strDomainLinkOrIp, string strDomainLink, string strWebPath, string strValue);};

RandomDomainLink.cpp

#include "stdafx.h"#include "RandomDomainLink.h" CRandomDomainLink::CRandomDomainLink(){ } CRandomDomainLink::~CRandomDomainLink(){ } string CRandomDomainLink::SocketHttp(string strDomainLinkOrIp, string strPacketDate) {WSADATA wsa = { 0 };WSAStartup(MAKEWORD(2, 2), &wsa);SOCKET  skSocket;struct sockaddr_in sdiAddress;struct hostent *htServer;skSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);sdiAddress.sin_family = AF_INET;sdiAddress.sin_port = htons(80);htServer = gethostbyname(strDomainLinkOrIp.c_str());if (htServer == NULL) {return "";}memcpy((char *)&sdiAddress.sin_addr.s_addr, (char*)htServer->h_addr, htServer->h_length);if (-1 == connect(skSocket, (struct sockaddr *)&sdiAddress, sizeof(sdiAddress))) {return "";}send(skSocket, strPacketDate.c_str(), strPacketDate.size(), 0);int nOffset = 0 ,nRc;DWORD dwCacheMemorySize = 1024 * 128;DWORD dwCacheMemorySizeAdd = 1024 * 128;DWORD dwCacheMemoryStepSize = 1024;char * pCacheByte = (char *)malloc(dwCacheMemorySize);while (nRc = recv(skSocket, pCacheByte + nOffset, dwCacheMemoryStepSize, 0)){nOffset += nRc;if (nOffset + dwCacheMemoryStepSize >= dwCacheMemorySize) {dwCacheMemorySize += dwCacheMemorySizeAdd;pCacheByte = (char*)realloc(pCacheByte, dwCacheMemorySize);}}closesocket(skSocket);pCacheByte[nOffset] = 0;string strCacheMemory = string(pCacheByte);free(pCacheByte);return strCacheMemory;} string CRandomDomainLink::Http_Get(string strDomainLinkOrIp, string strDomainLink, string strWebPath, string strValue){//GETstd::string strStream = "";strStream += "GET ";if (strWebPath == "") {strStream += "/";}strStream += strWebPath;if (strValue != "") {strStream += "?";}strStream += strValue;strStream += " HTTP/1.1\r\n";strStream += "Host: " + strDomainLink + "\r\n";strStream += "Connection:close\r\n\r\n";return SocketHttp(strDomainLinkOrIp, strStream);}

Pro_RandomDomainLink.cpp

#include "stdafx.h"#include "RandomDomainLink.h" int main(){//自定义网站,以及某些解析所有域名的服务器//成功,抓包工具显示www.xxxxxx.com  [*第二个参数填写的域名完全可以是别人的,或者是不存在的域名]string stdWebCode1 = CRandomDomainLink::Http_Get("www.xxxxxx.com", "www.xxxxxx.com", "", "");//成功,抓包工具显示www.oooooo.comstring stdWebCode2 = CRandomDomainLink::Http_Get("www.xxxxxx.com", "www.oooooo.com", "", "");//成功,抓包工具显示www.xxxxxx.comstring stdWebCode3 = CRandomDomainLink::Http_Get("ipipipipipipip", "www.xxxxxx.com", "", "");//成功,抓包工具显示www.oooooo.comstring stdWebCode4 = CRandomDomainLink::Http_Get("ipipipipipipip", "www.oooooo.com", "", ""); //别人的网站//成功,抓包工具显示www.tudou.comstring stdWebCode5 = CRandomDomainLink::Http_Get("www.t-u-d-o-u.com",  "www.t-u-d-o-u.com", "", "");//成功,抓包工具显示www.tudou.comstring stdWebCode6 = CRandomDomainLink::Http_Get("ipipipi---pipipip",  "www.t-u-d-o-u.com", "", "");//失败,服务器端应该是过滤了这个域名,不认识hosts过来不接收string stdWebCode7 = CRandomDomainLink::Http_Get("up或者t-u-d-o-u域名", "www.xxxxxxxxx.com", "", ""); //MessageBoxA(NULL , stdWebCode.c_str() ,"Hi" ,MB_OK);    return 0;}


原创粉丝点击