搜索
查看: 24074|回复: 60

[其他] Redirect Client Blocks (引诱服转移功能屏蔽代码+成品)

  [复制链接]
发表于 2012-12-1 19:39:19 | 显示全部楼层 |阅读模式 来自 广东深圳
本帖最后由 201724 于 2012-12-1 20:00 编辑

代码+成品压缩包回复可见

原理:屏蔽引诱服的关键封包,让转移服务器的功能失效来达到屏蔽引诱服的效果



  1. //Code By 201724
  2. //Anti Redirect Server Dynamic Library Sources Code
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <memory.h>
  7. #include <stdarg.h>
  8. #include <windows.h>
  9. #include "detours.h"
  10. HMODULE gSocket_ws2;
  11. HMODULE gSocket_wsock32;
  12. BOOL bInstance=FALSE;
  13. typedef int (WINAPI * fnrecvfrom)(SOCKET s,char* buf,int len,int flags,struct sockaddr* from,int* fromlen);

  14. //origin ws2_32.dll recvfrom callback
  15. fnrecvfrom orecvfrom_ws2;
  16. //origin wsock32.dll recvfrom callback
  17. fnrecvfrom orecvfrom_wsock32;

  18. //Quake Protocol Redirect Packet Title
  19. #define S2C_REDIRECT 'L'

  20. //ws2_32.dll new recvfrom
  21. int WINAPI newrecvfrom_ws2(SOCKET s,char* buf,int len,int flags,struct sockaddr* from,int* fromlen)
  22. {
  23.         int ret = orecvfrom_ws2(s,buf,len,flags,from,fromlen);
  24.         if(ret > 0 && *(DWORD*)buf == -1) //check request packet head
  25.         {
  26.                 if(((PBYTE)buf)[4] == S2C_REDIRECT) //check Redirect Packet
  27.                 {
  28.                         //Block this packet
  29.                         WSASetLastError(WSAEWOULDBLOCK);
  30.                         return -1;
  31.                 }
  32.         }
  33.         return ret;
  34. }

  35. //wsock32.dll new recvfrom
  36. int WINAPI newrecvfrom_wsock32(SOCKET s,char* buf,int len,int flags,struct sockaddr* from,int* fromlen)
  37. {
  38.         int ret = orecvfrom_wsock32(s,buf,len,flags,from,fromlen);
  39.         if(ret > 0 && *(DWORD*)buf == -1) //check request packet head
  40.         {
  41.                 if(((PBYTE)buf)[4] == S2C_REDIRECT) //check Redirect Packet
  42.                 {
  43.                         //Block this packet
  44.                         WSASetLastError(WSAEWOULDBLOCK);
  45.                         return -1;
  46.                 }
  47.         }
  48.         return ret;
  49. }

  50. //Initialize pakcet filter
  51. void Instance()
  52. {
  53.         //load librarys and get function address
  54.         gSocket_ws2 = LoadLibrary("ws2_32.dll");
  55.         gSocket_wsock32 = LoadLibrary("wsock32.dll");
  56.         orecvfrom_ws2 = (fnrecvfrom)GetProcAddress(gSocket_ws2,"recvfrom");
  57.         orecvfrom_wsock32 = (fnrecvfrom)GetProcAddress(gSocket_wsock32,"recvfrom");
  58.        
  59.         if(orecvfrom_ws2) //check func ws2_32.dll -> recvfrom address
  60.         {
  61.                 DetourTransactionBegin();
  62.                 DetourUpdateThread(GetCurrentThread());
  63.                 DetourAttach((void**)&orecvfrom_ws2,newrecvfrom_ws2); //attach make new jump data
  64.                 DetourTransactionCommit();    //instance
  65.         }

  66.         if(orecvfrom_wsock32) //check func ws2_32.dll -> recvfrom address
  67.         {
  68.                 DetourTransactionBegin();
  69.                 DetourUpdateThread(GetCurrentThread());
  70.                 DetourAttach((void**)&orecvfrom_wsock32,newrecvfrom_wsock32); //attach make new jump data
  71.                 DetourTransactionCommit();  //instance
  72.         }

  73.         bInstance = TRUE; //set hook mark
  74. }

  75. void Deinstance()
  76. {
  77.         if(bInstance==TRUE) //check hook mark
  78.         {
  79.                 if(orecvfrom_ws2)
  80.                 {
  81.                         DetourTransactionBegin();
  82.                         DetourUpdateThread(GetCurrentThread());
  83.                         DetourDetach((void**)&orecvfrom_ws2,newrecvfrom_ws2); //detach hook
  84.                         DetourTransactionCommit();  //destory new jump data and restore
  85.                 }
  86.                 if(orecvfrom_wsock32) //check hook mark
  87.                 {
  88.                         DetourTransactionBegin();
  89.                         DetourUpdateThread(GetCurrentThread());
  90.                         DetourDetach((void**)&orecvfrom_wsock32,newrecvfrom_wsock32);  //detach hook
  91.                         DetourTransactionCommit();  //destory new jump data and restore
  92.                 }
  93.         }
  94. }

  95. //Dll Initialize
  96. BOOL WINAPI DllMain(HINSTANCE hDllHandle,DWORD nReason,LPVOID lpReserved)
  97. {
  98.         switch(nReason)
  99.         {
  100.                 case DLL_PROCESS_ATTACH:
  101.                 {
  102.                         Instance();
  103.                         break;
  104.                 }
  105.                 case DLL_PROCESS_DETACH:
  106.                 {
  107.                         Deinstance();
  108.                         break;
  109.                 }
  110.         }
  111.         return TRUE;
  112. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×

评分

参与人数 1经验 +2 点通币 +200 收起 理由
By小伟 + 2 + 200 很给力!

查看全部评分

发表于 2012-12-1 19:43:48 | 显示全部楼层 来自 山西忻州
看下:)怎么样啊 啊哈哈
回复

使用道具 举报

发表于 2012-12-1 22:06:39 | 显示全部楼层 来自 广西南宁
试试效果:victory::victory:试试效果
回复

使用道具 举报

发表于 2012-12-2 00:56:39 | 显示全部楼层 来自 广东广州
不懂怎么用...
回复

使用道具 举报

发表于 2012-12-2 09:20:12 | 显示全部楼层 来自 广东梅州
这是什么语言写的?
回复

使用道具 举报

发表于 2012-12-2 09:55:53 | 显示全部楼层 来自 天津
这是什么啊!说说怎么用啊。老大给个能弄明白的说明
回复

使用道具 举报

发表于 2012-12-2 11:11:03 | 显示全部楼层 来自 上海长宁区
回复后看看
然后下载收藏
回复

使用道具 举报

发表于 2012-12-2 11:17:25 | 显示全部楼层 来自 广东茂名
顶!!!!!!!!!!!
回复

使用道具 举报

发表于 2012-12-2 11:49:17 | 显示全部楼层 来自 河南洛阳
回复后看看
回复

使用道具 举报

发表于 2012-12-2 12:02:34 | 显示全部楼层 来自 上海
本帖最后由 hackroad 于 2012-12-2 12:03 编辑

这下浩方可以借鉴了..........
是c++的吧
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表