-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
282 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
; https://tools.ietf.org/html/rfc6238 | ||
Totp(Secret, Digits := 6, Period := 30, Algorithm := "SHA1") | ||
{ | ||
key := Base32_Hex(Secret) | ||
if (!key) | ||
return Totp_Tip("Invalid Secret") | ||
counter := Format("{:016x}", Epoch() // Period) | ||
hmac := Crypt.Hash.HMAC(Algorithm, counter, key, "HEX") | ||
offset := hex2dec(SubStr(hmac, 0)) * 2 + 1 | ||
totp := hex2dec(SubStr(hmac, offset, 8)) & 0x7FFFFFFF | ||
return SubStr(totp, -1 * Digits + 1) | ||
} | ||
|
||
Totp_Clipboard(Totp, Period) | ||
{ | ||
static fObject := "" | ||
if IsObject(fObject) | ||
{ | ||
SetTimer % fObject, Delete | ||
fObject := "" | ||
} | ||
if (!ClipData) | ||
{ | ||
ClipData := ClipboardAll | ||
Clipboard := Totp | ||
} | ||
fObject := Func("Totp_ClipboardReset").Bind(Period) | ||
SetTimer % fObject, % 1000 | ||
} | ||
|
||
Totp_ClipboardReset(Period) | ||
{ | ||
if (A_Sec = 0 || A_Sec = Period) | ||
{ | ||
Clipboard := ClipData | ||
ClipData := "" | ||
SetTimer ,, Delete | ||
} | ||
} | ||
|
||
Totp_Parse(String, Mode) | ||
{ | ||
RegExMatch(String, "algorithm=\K\w+", algorithm) | ||
if !(algorithm ~= "i)(SHA1|SHA256|SHA512)") | ||
algorithm := "SHA1" | ||
RegExMatch(String, "digits=\K\d+", digits) | ||
digits := digits ? digits : 6 | ||
RegExMatch(String, "period=\K\d+", period) | ||
period := period ? period : 30 | ||
secret := String | ||
if (InStr(String, "otpauth://totp") = 1) | ||
{ | ||
if !RegExMatch(String, "secret=\K\w+", secret) | ||
secret := String | ||
} | ||
else if (InStr(String, "steam://") = 1) | ||
{ | ||
digits := 5 | ||
secret := SubStr(String, 9) | ||
} | ||
totp := Totp(secret, digits, period, algorithm) | ||
if (Mode = "default") | ||
{ | ||
if (INI.GENERAL.totp) | ||
Totp_Clipboard(totp, period) | ||
if (INI.GENERAL.totp = 1) | ||
Totp_Tip(totp) | ||
} | ||
return totp | ||
} | ||
|
||
Totp_Tip(Message) | ||
{ | ||
timeout := 10 | ||
if (Message ~= "^\d+$") | ||
{ | ||
mid := StrLen(Message) // 2 | ||
Message := SubStr(Message, 1, mid) " " SubStr(Message, ++mid) | ||
timeout := 30 | ||
} | ||
Tip("TOTP: " Message, timeout) | ||
} | ||
|
||
Totp_Toggle() | ||
{ | ||
if (INI.GENERAL.totp) | ||
INI.GENERAL.totp := 0 | ||
else | ||
{ | ||
Alert(0x24, "Show toast notifications?") | ||
IfMsgBox Yes | ||
INI.GENERAL.totp := 1 | ||
IfMsgBox No | ||
INI.GENERAL.totp := 2 | ||
} | ||
Menu sub1, ToggleCheck, 4& | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
UIAccess(File, Mode) | ||
{ | ||
try | ||
{ | ||
xml := ComObjCreate("Msxml2.DOMDocument") | ||
xml.async := false | ||
xml.setProperty("SelectionLanguage", "XPath") | ||
xml.setProperty("SelectionNamespaces", "xmlns:v1='urn:schemas-microsoft-com:asm.v1' xmlns:v3='urn:schemas-microsoft-com:asm.v3'") | ||
if !xml.load("res://" File "/#24/#1") | ||
throw | ||
if !node := xml.selectSingleNode("/v1:assembly/v3:trustInfo/v3:security/v3:requestedPrivileges/v3:requestedExecutionLevel") | ||
throw | ||
node.setAttribute("uiAccess", Mode ? "true" : "false") | ||
xml := RTrim(xml.xml, "`r`n") | ||
size := StrPut(xml, "UTF-8") - 1 | ||
VarSetCapacity(data, size, 0) | ||
StrPut(xml, &data, "UTF-8") | ||
if !hRes := DllCall("Kernel32\BeginUpdateResource", "Str",File, "Int",false) | ||
throw | ||
r := DllCall("Kernel32\UpdateResource", "Ptr",hRes, "Ptr",24, "Ptr",1, "UShort",0x0409, "Ptr",&data, "UInt",size) | ||
if !DllCall("Kernel32\EndUpdateResource", "Ptr",hRes, "Int",!r) && r | ||
throw | ||
return true | ||
} | ||
catch | ||
{ | ||
MsgBox 0x40010, Error, % "Couldn't update " File | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
|
||
param([string]$certName, [System.IO.FileInfo]$fileName) | ||
param([string]$certName, [System.IO.FileInfo]$fileName, [string]$clean) | ||
|
||
if (!($cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -eq "CN=$certName" })) { | ||
$cert = New-SelfSignedCertificate -CertStoreLocation cert:\LocalMachine\My -HashAlgorithm SHA256 -NotAfter (Get-Date).AddMonths(120) -Subject "$certName" -Type CodeSigning | ||
if ($clean -eq "start") { | ||
Get-ChildItem Cert:\LocalMachine\*\* | Where-Object {$_.Subject -like "CN=$certName*"} | Remove-Item | ||
} | ||
|
||
$cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Subject -like "CN=$certName*" } | ||
|
||
if (!$cert) { | ||
$cert = New-SelfSignedCertificate -CertStoreLocation cert:\LocalMachine\My -HashAlgorithm SHA256 -NotAfter (Get-Date).AddMonths(120) -Subject "CN=$certName,O=u/anonymous1184,OU=Bitwarden Auto-Type" -Type CodeSigning | ||
foreach ($i in @('TrustedPublisher', 'Root')) { | ||
$store = [System.Security.Cryptography.X509Certificates.X509Store]::new($i, 'LocalMachine') | ||
$store.Open('ReadWrite') | ||
$store.Add($cert) | ||
$store.Close() | ||
} | ||
} | ||
Set-AuthenticodeSignature -Certificate $cert -FilePath "$fileName" -HashAlgorithm SHA256 -TimeStampServer http://timestamp.sectigo.com | ||
|
||
$exitCode = 0 | ||
try { | ||
Set-AuthenticodeSignature -Certificate $cert -FilePath "$fileName" -HashAlgorithm SHA256 -TimeStampServer http://timestamp.sectigo.com | ||
} catch { | ||
Add-Type -AssemblyName PresentationCore,PresentationFramework | ||
[System.Windows.MessageBox]::Show("There was an error while trying to sign the executable.", "Error", 0, 16) | ||
$exitCode = 1 | ||
} | ||
|
||
if ($clean -eq "end") { | ||
Get-ChildItem Cert:\LocalMachine\*\* | Where-Object {$_.Subject -like "CN=$certName*"} | Remove-Item | ||
} | ||
|
||
Exit $exitCode |
Oops, something went wrong.