在bat中使用 certutil 实现 Hex2Bin 和 Base64 加解密

certutil 是 vista 和 win7 自带自带的外部命令,实际上是用于管理证书的,但也有“歪门邪道”的用法
举个例子:

复制代码
@echo off
 
echo 48 65 6C 6C 6F 2C 57 6F 72 6C 64 21 >hex.txt
::生成 hex.txt,机器码对应的内容是 Hallo World!
 
certutil -decodehex hex.txt bin.txt
::Hex2Bin
 
certutil -encode bin.txt Encode.txt
::Base64_Encode
 
certutil -decode Encode.txt Decode.txt
::Base64_Decode
 
pause
复制代码

系统帮助如下:

复制代码
CertUtil -?
动词:
  -dump             -- 转储配置信息或文件
  -asn              -- 分析 ASN.1 文件

  -decodehex        -- 解码十六进制编码的文件
  -decode           -- 解码 Base64 编码的文件
  -encode           -- 将文件编码为 Base64

  -deny             -- 拒绝挂起的申请
  -resubmit         -- 重新提交挂起的申请
  -setattributes    -- 为挂起申请设置属性
  -setextension     -- 为挂起申请设置扩展
  -revoke           -- 吊销证书
  -isvalid          -- 显示当前证书部署

  -getconfig        -- 获取默认配置字符串
  -ping             -- Ping Active Directory 证书服务申请接口
  -pingadmin        -- Ping Active Directory 证书服务管理接口
  -CAInfo           -- 显示 CA 信息
  -ca.cert          -- 检索 CA 的证书
  -ca.chain         -- 检索 CA 的证书链
  -GetCRL           -- 获取 CRL
  -CRL              -- 发布新的 CRL [或仅增量 CRL]
  -shutdown         -- 关闭 Active Directory 证书服务

  -installCert      -- 安装证书颁发机构证书
  -renewCert        -- 续订证书颁发机构证书

  -schema           -- 转储证书架构
  -view             -- 转储证书视图
  -db               -- 转储原始数据库
  -deleterow        -- 删除服务器数据库行

  -backup           -- 备份 Active Directory 证书服务
  -backupDB         -- 备份 Active Directory 证书服务数据库
  -backupKey        -- 备份 Active Directory 证书服务证书和私钥
  -restore          -- 还原 Active Directory 证书服务
  -restoreDB        -- 还原 Active Directory 证书服务数据库
  -restoreKey       -- 还原 Active Directory 证书服务证书和私钥
  -importPFX        -- 导入证书和私钥
  -dynamicfilelist  -- 显示动态文件列表
  -databaselocations -- 显示数据库位置
  -hashfile         -- 通过文件生成并显示加密哈希

  -store            -- 转储证书存储
  -addstore         -- 将证书添加到存储
  -delstore         -- 从存储删除证书
  -verifystore      -- 验证存储中的证书
  -repairstore      -- 修复密钥关联,或者更新证书属性或密钥安全描述符
  -viewstore        -- 转储证书存储
  -viewdelstore     -- 从存储删除证书

  -dsPublish        -- 将证书或 CRL 发布到 Active Directory

  -ADTemplate       -- 显示 AD 模板
  -Template         -- 显示注册策略模板
  -TemplateCAs      -- 显示模板的 CA
  -CATemplates      -- 显示 CA 的模板
  -enrollmentServerURL -- 显示、添加或删除与 CA 关联的注册服务器 URL
  -ADCA             -- 显示 AD CA
  -CA               -- 显示注册策略 CA
  -Policy           -- 显示注册策略
  -PolicyCache      -- 显示或删除注册策略缓存项目
  -CredStore        -- 显示、添加或删除凭据存储项目
  -InstallDefaultTemplates -- 安装默认的证书模板
  -URLCache         -- 显示或删除 URL 缓存项目
  -pulse            -- 暂停自动注册事件
  -MachineInfo      -- 显示 Active Directory 计算机对象信息
  -DCInfo           -- 显示域控制器信息
  -EntInfo          -- 显示企业信息
  -TCAInfo          -- 显示 CA 信息
  -SCInfo           -- 显示智能卡信息

  -SCRoots          -- 管理智能卡根证书

  -verifykeys       -- 验证公/私钥集
  -verify           -- 验证证书,CRL 或链
  -sign             -- 重新签名 CRL 或证书

  -vroot            -- 创建/删除 Web 虚拟根和文件共享
  -vocsproot        -- 创建/删除 OCSP Web Proxy 的 Web 虚拟根
  -addEnrollmentServer -- 添加注册服务器应用程序
  -deleteEnrollmentServer -- 删除注册服务器应用程序
  -oid              -- 显示 ObjectId 或设置显示名称
  -error            -- 显示错误代码消息文本
  -getreg           -- 显示注册表值
  -setreg           -- 设置注册表值
  -delreg           -- 删除注册表值

  -ImportKMS        -- 为密钥存档导入用户密钥和证书到服务器数据库
  -ImportCert       -- 将证书文件导入数据库
  -GetKey           -- 检索存档的私钥恢复点
  -RecoverKey       -- 恢复存档的私钥
  -MergePFX         -- 合并 PFX 文件
  -ConvertEPF       -- 将 PFX 文件转换为 EPF 文件
  -?                -- 显示该用法消息


CertUtil -?              -- 显示动词列表(命名列表)
CertUtil -dump -?        -- 显示 "dump" 动词的帮助文本
CertUtil -v -?           -- 显示所有动词的所有帮助文本
复制代码

 

 

出处:http://www.bathome.net/viewthread.php?tid=31883

posted on   jack_Meng  阅读(316)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
历史上的今天:
2019-11-08 高中数学
2016-11-08 系列文章--打造自己的MVC框架
2016-11-08 C#组件系列——又一款Excel处理神器Spire.XLS,你值得拥有(二)
2016-11-08 C#组件系列——又一款Excel处理神器Spire.XLS,你值得拥有(一)
2015-11-08 JS实现——计算两日期之差
2013-11-08 C语言利用SMTP协议发送邮件
2013-11-08 C语言发送邮件

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示

喜欢请打赏

扫描二维码打赏

支付宝打赏

主题色彩