sharoue / chinawareblock Goto Github PK
View Code? Open in Web Editor NEW国产流氓、娱乐软件和不受欢迎的软件屏蔽工具
License: MIT License
国产流氓、娱乐软件和不受欢迎的软件屏蔽工具
License: MIT License
如题
如果运行错了怎么还原呢?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography.X509Certificates;
using System.IO;
using System.Security.Cryptography;
namespace GetCertFromFolder
{
public class Program
{
public static readonly string invalidChar = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
public static void Main(string[] args)
{
string baseFolder = @"!!!SOMEPATH";
foreach (FileInfo fileInfo in new DirectoryInfo(baseFolder).EnumerateFiles("*.exe"))
{
try
{
X509Certificate cert = X509Certificate.CreateFromSignedFile(fileInfo.FullName);
string certInBase64 = ExportToPEM(cert);
string hash = cert.GetCertHashString();
string issueTo = cert.Subject.Split(new string[] { ", " }, StringSplitOptions.None).FirstOrDefault(x => x.StartsWith("CN=")).Substring(3);
string validTo = DateTime.Parse(cert.GetExpirationDateString()).ToString("yyyy-MM-dd");
string certFileName = hash + "-" + issueTo + "-" + validTo + ".cer";
File.WriteAllText(Path.Combine(baseFolder, removeInvalidCharInPath(certFileName)), certInBase64);
}
catch (CryptographicException)
{
continue;
}
}
}
private static string removeInvalidCharInPath(string path)
{
foreach (char c in invalidChar)
{
path = path.Replace(c.ToString(), "");
}
return path;
}
private static string ExportToPEM(X509Certificate cert)
{
StringBuilder builder = new StringBuilder();
builder.AppendLine("-----BEGIN CERTIFICATE-----");
builder.AppendLine(Convert.ToBase64String(cert.Export(X509ContentType.Cert), Base64FormattingOptions.InsertLineBreaks));
builder.AppendLine("-----END CERTIFICATE-----");
return builder.ToString();
}
}
}
因为某些原因,我的 win10 默认不含中文。在运行 bat 文件时候碰到了乱码。
所以能否将所有文件用英文命名,或者将所有文件以 utf8 编码?
360极速浏览器可以被安装,但是不能别卸载
现在重橙的flash已经用Adobe的证书了
在本地组策略 - Windows设置 - 软件限制策略中并不能看见用批处理封禁了的证书。
请问批处理封禁的方式是什么?我想删掉规则里已过期的证书。
英文原文:How to extract a digital signature/certificate from a signed software file/package
全家桶一键处理,无限循环 CMD 闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪闪
对百度浏览器无效,提取工具导出的证书也拉黑后也没用。
感谢作者大大,脚本很好用。
我写了一个和一键拉黑作用相反的Powershell脚本,供 @sharoue 参考。
作用是一键将当前目录(及子目录)中的*.cer证书从Disallowed中删除(如果有)。
水平有限,如有问题还请见谅
# Self-Elevating script
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
# Relaunch as an elevated process:
Start-Process powershell.exe "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs
exit
}
# For each cert in the folder, delete it from the disallowed store
$certList = Get-ChildItem -Recurse $PSScriptRoot -Filter *.cer | Where { ! $_.PSIsContainer } | Select Name,FullName,Length
foreach ($cert in $certList)
{
$certPrint = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$certPrint.Import($cert.FullName)
certutil -user -delstore "Disallowed" $certPrint.Thumbprint
}
参考资料:
我在本地虚拟机上试了下,单纯一键拉黑到不受信任的证书里面,这些安装程序还是可以运行的,需要添加到本地组策略 - Windows设置 - 软件限制策略里面进行封禁才能强力阻止其运行。
众所周知,由于百度的原因,不少人下载一些东西会跑到各种下载站上面去,使用那个P2P高速下载器,进而带来一堆奇怪的东西。所以,有没有考虑过拉黑这些下载器的证书呢?让他们根本无法运行起来。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.