-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sign_code_all_executables.ps1
58 lines (35 loc) · 1.33 KB
/
Sign_code_all_executables.ps1
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#Author: https://github.com/terracuda/workpow
#Welcome message
clear-host
echo ""
echo " ___________________________ "
echo "| |"
echo "| CodeSigner v1.1 |"
echo "| Author: TerraCuda |"
echo "|___________________________|"
echo ""
#Variables
$path = (Get-Item -Path ".\").FullName
$unfiles = Get-ChildItem $path -Exclude '*.ps1'
$FLTotcount = ($unfiles).count
$DateStamp = get-date
if ($FLTotcount -gt 0)
{
echo "$FLTotcount files were assigned:"
foreach($unfile in $unfiles)
{
$prefix = Get-Random -InputObject "test_cert", "tempo", "code_sign"
$num = Get-Random -Maximum 50000000 -Minimum 10000000
New-SelfSignedCertificate -Type CodeSigningCert -DnsName "$num.$prefix.com" -Subject "CN=RRR $prefix $num" -CertStoreLocation cert:\CurrentUser\My | Out-Null
$cert = (Get-ChildItem cert:\CurrentUser\my –CodeSigningCert)[-1]
$filename = ($unfile).name
Set-AuthenticodeSignature -FilePath "$filename" -Certificate $cert -IncludeChain "All" -TimeStampServer "http://timestamp.comodoca.com/authenticode"
$tprint = ($cert).thumbprint
Remove-item -Path cert:\CurrentUser\my\$tprint -Deletekey
# echo $filename
echo "--------------------------------"
}
exit
}
echo "Please prapare the unsigned executable files and put them into this folder."
exit