如果证书本身未安装在工作站上但仅用于签署该特定文件,是否可以以某种方式以编程方式导出文件的数字证书主题?
我需要以某种方式从文件中提取该信息并检查它是否正确。最好使用Python/CMD/PowerShell
编辑:
抱歉缺少详细信息。
我目前正在使用这个 python 脚本(我修改为在 Python 3.6 上运行):http://www.zedwood.com/article/python-openssl-x509-parse-certificate来解析我从中提取的 .cer 文件我找到的带有这个小工具的原始可执行文件(我还对其进行了修改以与 Python 3 一起使用): https: //blog.didierstevens.com/programs/disitool/但只有在我将其从 DER 编码的二进制文件转换之后使用 Windows certutil 转换为 base-64。
不过,disitool 脚本的问题在于,它使用 pefile python 模块从可执行文件本身中剪切了一个“签名”字节数组,这使得提取的 .cer 文件无效,正如我在尝试执行操作时不断收到的 python 错误一样使用 OpenSSL.crypto 模块加载证书:
[('asn1 encoding routines', 'asn1_check_tlen', 'wrong tag'), ('asn1 encoding routines', 'asn1_item_embed_d2i', 'nested asn1 error'), ('asn1 encoding routines', 'asn1_template_noexp_d2i', 'nested asn1 error'), ('PEM routines', 'PEM_ASN1_read_bio', 'ASN1 lib')]
Run Code Online (Sandbox Code Playgroud)
但是解析一个好的提取证书(使用我上面发布的第一个脚本)是有效的,正如您在此处看到的:
所以,我想我只需要一种从可执行文件中提取证书的方法。或者,如果您发现我的解决方案太复杂,如果您知道如何从证书的主题字段中获取“Redmond”文本,我非常愿意接受想法:)
powershell python certificate command-line digital-signature
我尝试通过网上搜索仅在一个窗口中打开多个Powershell实例,但没有令人满意的解决方案。任何人都可以告诉命令在一个窗口中打开多个实例吗?
我在 win server 2008 R2 标准中使用 Cisco AnyConnect 安全移动客户端,我想每天晚上 10:00 使用脚本运行它,并在完成一些事务后在晚上 10:30 将其关闭。如何使用 cmd 自动运行 Cisco AnyConnect 安全移动客户端 VPN...
提前致谢!!!
如何卸载模块以使 Get-Module 不再报告已找到该模块?
> Get-Module -list -Name Pester
ModuleType Version Name
---------- ------- ----
Script 3.4.0 Pester
> Uninstall-Module -Name Pester
PackageManagement\Uninstall-Package : No match was found for the specified search criteria and module names 'Pester'.
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Powershell 更改我的环境,以便时间以 24 小时格式显示,无需 AM/PM。
这就是我所做的:
$culture = get-culture
$culture.DateTimeFormat.ShortTimePattern = 'HH:mm'
$culture.DateTimeFormat.pmDesignator = ''
set-culture $culture
Run Code Online (Sandbox Code Playgroud)
这消除了 AM/PM 指示符,但仍显示 0..12 范围内的小时,而不是预期的 0..23 范围内的小时。那么我需要做什么才能以 24 小时格式显示时间呢?
我正在编写一个用于查看恶意软件的 powershell 解释器。我有一些文本不知道如何解析。它看起来像一个管道,但管道后面的内容对我来说没有意义,并且我正在修改的解释器不会处理。相关说法如下。
start-process($env:APPDATA+ '\mef.vbs')|I`E`X
Run Code Online (Sandbox Code Playgroud)
我得到了启动过程部分。这只是我不理解的管道。`E 可能是转义的反引号,但 `X 不在我见过的任何文档中。此外,它看起来不像是处理“start-process”输出的命令。那么,什么是“|I`E`X”?
在 Win10 系统上,我想执行以下命令(取自工作快捷方式文件):
"C:\Path with spaces\application.exe" U=<username> S=serverName
Run Code Online (Sandbox Code Playgroud)
在 CMD 中,以下命令打开应用程序没有任何问题:
"C:\Path with spaces\application.exe" "U=<username>" "S=serverName"
Run Code Online (Sandbox Code Playgroud)
然而,在PowerShell中,我尝试了各种组合(例如,包括使用Start-Process,cmd /c到目前为止它一直对我有用),但它们都失败了。这可能很简单,但我无法让它发挥作用。正确的记号是什么?
我知道这看起来像是一个重复的问题,但我已经尝试过这些解决方案,但它们对我不起作用。
我们需要使用我们的域帐户运行脚本,但也要提升执行它的权限。这在大多数设备上都不是问题,因为快捷方式以管理员身份运行并提示我们输入凭据。但是,如果用户是本地管理员,则不会提示我们输入凭据(只是提示是/否 UAC)。
我很困惑为什么这不起作用:
# Get identity of script user
$identity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
# Elevate the script if not already
if ($identity.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host -F Green 'ELEVATED'
} else {
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"& '$PSCommandPath'`""
Exit
}
# Ensure the script has domain privileges
if ($identity.IsInRole('[domain]\[admin group]')) {
Write-Host -F Green 'DOMAIN ADMIN'
} else {
Start-Process PowerShell -Verb RunAsUser "-NoProfile -ExecutionPolicy Bypass -Command `"& '$PSCommandPath'`""
Pause # required, otherwise the Exit below closes the …Run Code Online (Sandbox Code Playgroud) 我尝试根据这个官方说明自定义Powershell。我Install-Module oh-my-posh -Scope CurrentUser成功了。做事Import-Module oh-my-posh没有任何回报。运行时Set-Theme Paradox会出现通常的错误“Set-Theme”不是命令行开关的名称等。
我使用Powershell 7.1.2
可能是什么原因?我可以检查什么?我不知道 PowerShell。
我正在寻找一种在导出 WSL2 发行版时压缩它的方法,并尝试通过管道传递由 to 生成的 tar 文件wsl,7z但大约一个小时后,它只产生 CPU 负载,并且该7z过程甚至没有根据到任务管理器:
wsl --export myDistro - | 7z a -tgzip myDistro.tar.gz -si
Run Code Online (Sandbox Code Playgroud)
7z并且sample.tar.gz创建时没有任何问题:
Get-Content -Path sample.tar -Raw | 7z a -tgzip sample.tar.gz -si
Run Code Online (Sandbox Code Playgroud)
wsl --export myDistro .\myDistro.tar
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?如何将导出的 WSL2 发行版压缩为 gzip 存档而不将 tar 文件存储在磁盘上,以及如何通过管道导入它wsl --import?
正如 @DanielB 注意到的,PowerShell 不会按原样通过管道传输数据(请参阅此处和此处),但是命名管道呢?
wsl无法处理命名管道:
$ New-Object System.IO.Pipes.NamedPipeServerStream("\\.\pipe\wsl-exp-imp"); wsl --export experimentinGentoo '\\.\pipe\wsl-exp-imp' …Run Code Online (Sandbox Code Playgroud)powershell ×10
windows ×2
backticks ×1
batch ×1
certificate ×1
command-line ×1
elevated ×1
i18n ×1
networking ×1
pipelining ×1
python ×1
themes ×1
vpn ×1
windows-10 ×1
wsl2 ×1