[python] 找寻盗号木马的踪迹。

772 3
狼毛 2023-11-3 18:44:52 | 显示全部楼层 |阅读模式
本帖最后由 狼毛 于 2023-11-3 18:56 编辑

这一段时间,我在找盗号木马的踪迹,这是我的记录及心得。请大佬绕步。

我的系统是windows11系统。找盗号木马,用的是这个命令。

netstat -p TCP -anb

最后的-b参数能显示进程名。

根据进程找可疑ip可以定位木马。。。

这段代码通过进程名获得pid.
  1. #写一段hook指定进程的程序


  2. import psutil

  3. def hook_process(process_name):
  4.     for proc in psutil.process_iter():
  5.         try:
  6.             pinfo = proc.as_dict(attrs=['pid', 'name', 'cmdline'])
  7.         except psutil.NoSuchProcess:
  8.             pass
  9.         else:
  10.             if pinfo['name'] == process_name:
  11.                 print(pinfo)
  12.                 return pinfo['pid']
  13.                
  14. if __name__ == '__main__':
  15.     pid = hook_process('SearchHost.exe')
  16.     if pid:
  17.         print('hook process success')
  18.     else:
  19.         print('hook process failed')
复制代码
我在SearchHost进程中找到了CoreMessaging.dll模块,里面的PostMessageW函数可疑。下面是我的hook代码。。。

  1. #根据进程pid钩住CoreMessaging.dll模块的PostMessagew函数


  2. from ctypes import *  
  3. from ctypes.wintypes import HWND, UINT, WPARAM, LPARAM  
  4.   
  5. # Load DLL  
  6. dll = windll.LoadLibrary("CoreMessaging.dll")  
  7.   
  8. # Get PostMessage function from DLL  
  9. PostMessage = dll.PostMessageW  
  10.   
  11. # Set argument types and return type of PostMessage  
  12. PostMessage.argtypes = [HWND, UINT, WPARAM, LPARAM]  
  13. PostMessage.restype = BOOL  # According to the documentation, PostMessage returns a BOOL  
  14.   
  15. # Create a handle to a window (HWND)  
  16. hwnd = c_int(6224)  # You should replace this with the actual window handle you want to send the message to  
  17.   
  18. # Define the message you want to send (UINT) and the parameters for the message (WPARAM and LPARAM)  
  19. message = 0x100  # You should replace this with the actual message you want to send  
  20. wparam = 0  
  21. lparam = 0  
  22.   
  23. # Call PostMessage with the given arguments  
  24. #result = PostMessage(hwnd, message, wparam, lparam)  
  25. result = PostMessage(6224, message, wparam, lparam)
  26. if result == 0:  
  27.     print("Failed to post message")  
  28. else:  
  29.     print("Message posted successfully")
复制代码
我将这两个文件发上来。同时还有相关工具。。。
来自圈子: 中国红客联盟第五战区

本帖子中包含更多资源

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

×
狼毛 2023-11-3 20:13:18 | 显示全部楼层
上面两个图是用压缩包里的string64这个文件操作的。

  1. stings64 SearchHost.exe

  2. strings64 CoreMessaging.dll
复制代码
找模块时,打开procexp64.exe文件。然后双击其中的SearchHost进程。
看他的Threads选项卡。在这里找到有关网络的dll模块和函数。

还可以用dbgview64看模块。有网络操作。

本帖子中包含更多资源

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

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

狼毛

精英红客

关注
  • 187
    主题
  • 2
    粉丝
  • 1
    关注
这家伙很懒,什么都没留下!

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2024 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 ) 本站已运行|天天打卡