Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e798818d1 | |||
| 56b08f32da | |||
| 251c9aa06c | |||
| 1dbd1ad79b | |||
| 7bd65e7d76 | |||
| 2fd8238a98 | |||
| 503e947eaf | |||
| 07a29167dd | |||
| 608e225833 | |||
| 4fea9dbccc | |||
| 4377cc6a45 | |||
| e5435d124e | |||
| 757f1775ff | |||
| dc17c77c87 | |||
| b504218205 | |||
| 776a52c3c3 | |||
| 3f03b2a0f3 | |||
| b32cae15b2 | |||
| 784b60a4e7 | |||
| 53fe4e9ed3 | |||
| b010b7ac71 | |||
| 0994e78843 | |||
| 1a61eb2034 | |||
| 29ee569bfe | |||
| 3425139b1f |
@@ -39,6 +39,7 @@ script=/tmp/install_script.sh && curl -s https://git.thecoven.info/PrincessPi/ge
|
|||||||
* `large_file_search_for_hash`
|
* `large_file_search_for_hash`
|
||||||
* `randomtoken`
|
* `randomtoken`
|
||||||
* `alfa_install_kali.sh`
|
* `alfa_install_kali.sh`
|
||||||
|
* `torsilly.sh`
|
||||||
|
|
||||||
#### monitoring
|
#### monitoring
|
||||||
* `mon-watch`
|
* `mon-watch`
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
|||||||
|
1. recursive verify error: `FAILED open or read`
|
||||||
|
2. recursive progress set to count total number of files recursively first for progress bar
|
||||||
+538
-159
@@ -1,277 +1,656 @@
|
|||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Princess Pi's Magical CHECKSUM! - Computes and verifies message digests / file checksums.
|
||||||
|
.DESCRIPTION
|
||||||
|
Computes or verifies checksums using cryptographic hash algorithms (SHA256, SHA512, SHA1, MD5, SHA384).
|
||||||
|
Supports parallel processing, recursive scanning, direct hash matching, and verification file parsing.
|
||||||
|
.NOTES
|
||||||
|
Requires PowerShell 7.0 or higher.
|
||||||
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName='Generate')]
|
[CmdletBinding(DefaultParameterSetName='Generate')]
|
||||||
param(
|
param(
|
||||||
# File(s) or wildcard pattern to compute checksum for
|
# File(s) or wildcard pattern to compute checksum for
|
||||||
[Parameter(Position = 0, ParameterSetName = 'Generate', ValueFromPipeline = $true)]
|
[Parameter(Position = 0, ParameterSetName = 'Generate', ValueFromPipeline = $true)]
|
||||||
[Parameter(Position = 0, ParameterSetName = 'Match', ValueFromPipeline = $true)]
|
[Parameter(Position = 0, ParameterSetName = 'Match', ValueFromPipeline = $true)]
|
||||||
|
[Parameter(Position = 0, ParameterSetName = 'PrincessPi', ValueFromPipeline = $false)]
|
||||||
|
[Alias('i', 'input', 'if', 'InputFile')]
|
||||||
[string[]]$FilePath,
|
[string[]]$FilePath,
|
||||||
|
|
||||||
# Output file to save generated checksums (-o mode)
|
# Custom output file (-f / -OutFile / -of)
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = 'Generate')]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Generate')]
|
||||||
[Alias('o')]
|
[Alias('f', 'of')]
|
||||||
[string]$OutFile,
|
[string]$OutFile,
|
||||||
|
|
||||||
# File containing checksums to verify (-c mode)
|
# Auto output file switch (-s / -Save / -o)
|
||||||
|
[Parameter(Mandatory = $false, ParameterSetName = 'Generate')]
|
||||||
|
[Alias('s', 'o')]
|
||||||
|
[switch]$Save,
|
||||||
|
|
||||||
|
# File containing checksums to verify (-c / -Check)
|
||||||
[Parameter(Mandatory = $false, ParameterSetName = 'Verify')]
|
[Parameter(Mandatory = $false, ParameterSetName = 'Verify')]
|
||||||
[Alias('c')]
|
[Alias('c')]
|
||||||
[string]$Check,
|
[string]$Check,
|
||||||
|
|
||||||
# Direct checksum hash string to match against (-m mode)
|
# Direct checksum hash string to match against (-m / -Match)
|
||||||
[Parameter(Mandatory = $true, ParameterSetName = 'Match')]
|
[Parameter(Mandatory = $true, ParameterSetName = 'Match')]
|
||||||
[Alias('m')]
|
[Alias('m')]
|
||||||
[string]$Match,
|
[string]$Match,
|
||||||
|
|
||||||
# Hashing algorithm to use (Defaults to SHA256)
|
# Hashing algorithm to use (Defaults to SHA256)
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[Alias('a')]
|
[Alias('a', 'algo')]
|
||||||
[ValidateSet('SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5')]
|
[ValidateSet('SHA1', 'SHA256', 'SHA384', 'SHA512', 'MD5')]
|
||||||
[string]$Algorithm,
|
[string]$Algorithm,
|
||||||
|
|
||||||
# Help flag (-h, -Help)
|
# Recursive flag (-r / -Recursive)
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[Alias('r')]
|
||||||
|
[switch]$Recursive,
|
||||||
|
|
||||||
|
# Princess Pi art flag (-pp / -PrincessPi)
|
||||||
|
[Parameter(Mandatory = $true, ParameterSetName = 'PrincessPi')]
|
||||||
|
[Alias('pp')]
|
||||||
|
[switch]$PrincessPi,
|
||||||
|
|
||||||
|
# Help flag (-h / -Help)
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[Alias('h')]
|
[Alias('h')]
|
||||||
[switch]$Help
|
[switch]$Help
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
# --- ENVIRONMENT SANITY CHECK ---
|
||||||
|
if ($PSVersionTable.PSVersion.Major -lt 7) {
|
||||||
|
Write-Error "checksum: This script requires PowerShell 7 or higher for parallel execution (-Parallel support). Current version is $($PSVersionTable.PSVersion)."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- HELPER FUNCTIONS ---
|
||||||
function Show-Help {
|
function Show-Help {
|
||||||
@'
|
@'
|
||||||
|
|
||||||
|
Princess Pi's Magical CHECKSUM!
|
||||||
|
|
||||||
NAME
|
NAME
|
||||||
checksum - Compute and verify message digests / file checksums
|
checksum - Compute and verify message digests / file checksums
|
||||||
|
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
.\checksum.ps1 [-FilePath] <string[]> [-OutFile <string>] [-Algorithm <string>]
|
.\checksum.ps1 [-FilePath] <string[]> [-s] [-f <string>] [-Algorithm <string>] [-r]
|
||||||
.\checksum.ps1 [-FilePath] <string[]> -Match <string> [-Algorithm <string>]
|
.\checksum.ps1 [-FilePath] <string[]> -Match <string> [-Algorithm <string>] [-r]
|
||||||
.\checksum.ps1 -Check <string> [-Algorithm <string>]
|
.\checksum.ps1 -Check <string> [-Algorithm <string>] [-r]
|
||||||
|
.\checksum.ps1 -PrincessPi
|
||||||
.\checksum.ps1 -Help
|
.\checksum.ps1 -Help
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
Computes or verifies checksums using various cryptographic algorithms.
|
Computes or verifies checksums using cryptographic hash algorithms (SHA256, SHA512, SHA1, MD5, SHA384).
|
||||||
Outputs hash values in standard Linux utility format (<hash> <filename>).
|
Outputs hash values in standard GNU coreutils format (<hash> <filename>).
|
||||||
|
Ignores checksum metadata files (.md5, .sha1, .sha256, .sha384, .sha512) during wildcards unless passed explicitly.
|
||||||
|
|
||||||
PARAMETERS
|
PARAMETERS
|
||||||
-FilePath <string[]>
|
-FilePath, -i, -input, -if, -InputFile <string[]>
|
||||||
Specifies the path to one or more files to hash. Accepts wildcards (*).
|
Specifies the target file(s) or wildcard pattern (*).
|
||||||
|
|
||||||
-o, -OutFile <string>
|
-s, -S, -Save, -o, -O <switch>
|
||||||
Specifies an output file to save the checksum results to, while still
|
Auto-saves checksum results. (Takes no arguments).
|
||||||
displaying the output on screen.
|
- If input filename contains a wildcard (*), saves to 'checksums.<algo>'.
|
||||||
|
- If input filename does NOT contain a wildcard, saves to '<filename>.<algo>'.
|
||||||
|
When combined with -r and *, recursively auto-generates checksums per directory.
|
||||||
|
|
||||||
-c, -Check <string>
|
-f, -F, -of, -OF, -OutFile <string>
|
||||||
Read checksums from the specified file and verify them against files on disk.
|
Saves checksum results to a specific custom filename.
|
||||||
|
Overrides the auto-naming behavior of -s if both are passed.
|
||||||
|
|
||||||
-m, -Match <string>
|
-c, -C, -Check <string>
|
||||||
Compare the computed hash of the target file(s) against a specific hash string.
|
Reads hashes from a specified checksum file and verifies target files on disk.
|
||||||
|
If -r is specified, recursively looks for and validates checksum files by name across subdirectories.
|
||||||
|
|
||||||
-a, -Algorithm <string>
|
-m, -M, -Match <string>
|
||||||
Specifies the cryptographic hash algorithm to use.
|
Compares the computed hash of target file(s) directly against a given hash string.
|
||||||
Supported values: SHA1, SHA256 (default), SHA384, SHA512, MD5.
|
|
||||||
If omitted in -c or -m mode, the algorithm is auto-detected by hash length.
|
|
||||||
|
|
||||||
-h, -Help
|
-a, -A, -Algo, -Algorithm <string>
|
||||||
Display this help message.
|
Specifies the hash algorithm to use.
|
||||||
|
Supported options: MD5, SHA1, SHA256 (default), SHA384, SHA512.
|
||||||
|
In -c or -m mode, auto-detects algorithm from hash length if omitted.
|
||||||
|
|
||||||
|
-r, -R, -Recursive <switch>
|
||||||
|
Processes target files or verification files recursively across directory structures.
|
||||||
|
|
||||||
|
-pp, -PP, -PrincessPi <switch>
|
||||||
|
Displays Princess Pi!
|
||||||
|
|
||||||
|
-h, -H, -Help <switch>
|
||||||
|
Displays this help documentation.
|
||||||
|
Also displays on any error.
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
1. Compute SHA256 checksum for a single file:
|
1. Compute SHA256 for a single file and auto-save as 'myfile.iso.sha256':
|
||||||
.\checksum.ps1 myfile.iso
|
.\checksum.ps1 myfile.iso -s
|
||||||
|
|
||||||
2. Compute checksums for all files and write to a file while showing output:
|
2. Compute SHA512 recursively and auto-save as 'checksums.sha512' in each folder:
|
||||||
.\checksum.ps1 * -o checksums.sha256
|
.\checksum.ps1 * -r -s -a SHA512
|
||||||
|
|
||||||
3. Verify a file against a explicit hash string:
|
3. Compute SHA256 checksums and save to a specific custom file:
|
||||||
.\checksum.ps1 myfile.iso -m "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
.\checksum.ps1 * -f my_hashes.txt
|
||||||
|
|
||||||
4. Verify checksums from a verification file (auto-detects algorithm):
|
4. Verify checksums against a verification file:
|
||||||
.\checksum.ps1 -c checksums.sha256
|
.\checksum.ps1 -c checksums.sha256
|
||||||
|
|
||||||
|
5. Compare file directly against an expected hash string:
|
||||||
|
.\checksum.ps1 myfile.bin -m 406653a68bd3538975656831f33f031b
|
||||||
|
|
||||||
|
Princess Pi LOVES YOU!~
|
||||||
|
https://linktr.ee/princesspi3
|
||||||
|
|
||||||
'@
|
'@
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper function to auto-detect hash algorithm based on string character length
|
function Write-ErrorWithHelp {
|
||||||
|
param([string]$ErrorMessage);
|
||||||
|
Show-Help;
|
||||||
|
Write-Host "";
|
||||||
|
Write-Error $ErrorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Show-PrincessPiArt {
|
||||||
|
$art = @'
|
||||||
|
|
||||||
|
=#= -- ##*+++++ *+
|
||||||
|
-#=#- +# -*%%= ##++++++++++# ##*********#
|
||||||
|
#==#= *** %%++%% -++# #++++++++++++*+ *#***************#
|
||||||
|
#===#= %***+%++#*%%@+++++% #++++++++++++**+++#******++********#
|
||||||
|
====+#%@*******###%=%++##++% #+++++++++++*++++++++#***====+****++#
|
||||||
|
=#=*==**#*#########%++#*+++@ *++++++++#+++++++++++#****==+******#
|
||||||
|
*#=====%####***%%++++#*+++**% ++++++++*+++++++++++++#************#*******
|
||||||
|
@****#==%####**#*+++++++#+++#**# #+++++++++++++++++++#####+*****************#
|
||||||
|
@****#######%**@+*%**#%+++++%##*** #+++++++++++++++++#+++++#****+======*****+
|
||||||
|
#****##%####@**%+*******@@+++@###**% #+++++++++++++*++++++++++****========****#
|
||||||
|
****#####%%*%*%+***@@@%%@*+++@####** *+++++++++++++++++++++#****=======****#
|
||||||
|
%***####%%**+%%*++*@=##@@%@++++%###*** ++++*+++++++++++#+**************#
|
||||||
|
@%%%@@##%%#++++++++==**@@**+++%*###**% +++++++++++#*+++++#*********####
|
||||||
|
%###%++++++++====**#++++%**##**% @% ++++#+++++++++++++**************#
|
||||||
|
%###%++++++++++++++++++%**%##**%@###@ %++++++++++++++++***=====********
|
||||||
|
###%%++++++++%++++++*%%%%###***##%##@ +++++++++++++##**************#
|
||||||
|
###%%%%+++++##+++++++#*+%###***%%%##@ ++++++++++++++%********+############%@
|
||||||
|
@%%*@*%%%%###****+*%%****++%##***%##@@@ #+++++++++++++++*********###*****#########*
|
||||||
|
#%%###***#####%**++++##**%#@@#@ ##+++++++++*###%#+***+***##*************#######
|
||||||
|
@#%%####%%####%+++++++##*######%++++++++++++++#*+++++#%###%#######*********######%
|
||||||
|
##%########@%@+++@###%*%#####@+++++++++++%**++++++++++%%%%%%########***==**###%##%
|
||||||
|
%#%###%###########@@%#%#@@##++++++++****++++********+++ %########**===*###%*#
|
||||||
|
#**##%####@@####%@######%*++++++++++++++++#++**+*#++++# ########******###% %
|
||||||
|
@#***# ###%@@##%#######@+++++++++++++++++++++%*++**++++# *########******##% @
|
||||||
|
*******% %##% =@#########++++++++++++++++++#++++*%++*#%#++# ########******##%
|
||||||
|
#@%@# %% *@#@@###*+++++++++++++++++++%+++##+++###++* ##*#####******##@
|
||||||
|
**##%*++%++++++++++++++++++++++++++++++++% +#**#####******###
|
||||||
|
##%#######*@***+#+++++++++++++++#***#++++++++++++ %**#####*******#%
|
||||||
|
*+++++$****##****++++++++##% #******#+++++++++++ %**#####*******#@
|
||||||
|
#++++++++*******- ++++++++# *******#++++++++++# @**#####*******#
|
||||||
|
#@@+++++++******- *+++++++# #******#+++++++++* **####%**==+**@
|
||||||
|
@@@@@+++ %+++++++# ******# %+++++++ %*###%***===**@ %=
|
||||||
|
@@@@@@@@@ #+++++++# =****** #++++++% *###%#***=+**% %**
|
||||||
|
@@@@@@@@@@ ++++++++# ******# #++++++# *##@%********% @*@
|
||||||
|
@@+@@@++@@+ ++++++++# ******# #++++++# @## #*********@ #***#
|
||||||
|
@@+@@++@@@++ @@@++++++* @@@%**** #@@++++% +## %#****************%
|
||||||
|
@*@**@+++# @@@@+++++ @@@@@@**# @@@@@++++# @# %#****************
|
||||||
|
+#+++++# @@@@@@+++% @@@@@@@@# @@@@@@@++ @ %##************%
|
||||||
|
#+++** @@@@@@@@@@ @@@@@@@@@ @@@@@@@@@ %###********%*
|
||||||
|
@@@@@@@@@@+ @@@@@@@@@@ =@@@@@@@@@ %%#####%%
|
||||||
|
*@@@@@@@@@@ @+*@@@@@@@= @@++@@@@@@
|
||||||
|
@++@@@@@@@@ #**@**@@@@@ *@@*#@@@@@@ -=
|
||||||
|
@%#@@@@@@@@ *#***@@@@@@ @+#+@++#@@@
|
||||||
|
#+++@++@@@@@ **********# #+++++@+@@@@
|
||||||
|
##+#+++@@@@@@ ##****#### *+#+##+++@@%%
|
||||||
|
#+++++++++++# #++++++++++#
|
||||||
|
#########*
|
||||||
|
|
||||||
|
____ ____ ____ _ _ ___ ____ ___ ___ ____ ____
|
||||||
|
( _ \( _ \(_ _)( \( )/ __)( ___)/ __)/ __) ( _ \(_ _)/\/
|
||||||
|
)___/ ) / _)(_ ) (( (__ )__) \__ \\__ \ )___/ _)(_
|
||||||
|
(__) (_)\_)(____)(_)\_)\___)(____)(___/(___/ (__) (____)
|
||||||
|
|
||||||
|
Princess Pi
|
||||||
|
https://linktr.ee/princesspi3
|
||||||
|
|
||||||
|
'@
|
||||||
|
Write-Host $art -ForegroundColor Blue;
|
||||||
|
}
|
||||||
|
|
||||||
function Get-AlgorithmFromHashLength {
|
function Get-AlgorithmFromHashLength {
|
||||||
param([string]$HashString)
|
param([string]$HashString);
|
||||||
|
|
||||||
switch ($HashString.Trim().Length) {
|
switch ($HashString.Trim().Length) {
|
||||||
32 { return 'MD5' }
|
32 { return 'MD5'; }
|
||||||
40 { return 'SHA1' }
|
40 { return 'SHA1'; }
|
||||||
64 { return 'SHA256' }
|
64 { return 'SHA256'; }
|
||||||
96 { return 'SHA384' }
|
96 { return 'SHA384'; }
|
||||||
128 { return 'SHA512' }
|
128 { return 'SHA512'; }
|
||||||
default {
|
default {
|
||||||
Write-Error "checksum: Could not auto-detect algorithm for hash length $($HashString.Length). Please specify -Algorithm."
|
Write-ErrorWithHelp "checksum: Could not auto-detect algorithm for hash length $($HashString.Length). Please specify -Algorithm.";
|
||||||
return $null
|
return $null;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
# --- MAIN EXECUTION FLOW ---
|
||||||
# Match help arguments passed either as switch (-h, -Help) or positional string ('help', 'h', '--help', etc.)
|
$helpInPath = $false;
|
||||||
$isHelpRequested = $Help.IsPresent -or (
|
if ($FilePath) {
|
||||||
$FilePath -and $FilePath.Count -eq 1 -and (
|
foreach ($p in ($FilePath)) {
|
||||||
$FilePath[0] -match '^(?i)[-/]{0,2}(h|help)$'
|
if ($p -match '^(?i)[-/]{1,2}(h|help|\?)$') {
|
||||||
)
|
$helpInPath = $true;
|
||||||
)
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($isHelpRequested) {
|
if ($Help.IsPresent -or $helpInPath) {
|
||||||
Show-Help
|
Show-Help;
|
||||||
return
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($PrincessPi.IsPresent) {
|
||||||
|
Show-PrincessPiArt;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Normalize explicit algorithm input if provided
|
|
||||||
if (-not [string]::IsNullOrWhiteSpace($Algorithm)) {
|
if (-not [string]::IsNullOrWhiteSpace($Algorithm)) {
|
||||||
$Algorithm = $Algorithm.ToUpper()
|
$Algorithm = $Algorithm.ToUpper();
|
||||||
|
}
|
||||||
|
|
||||||
|
$isWildcardGlobal = $false;
|
||||||
|
if ($FilePath) {
|
||||||
|
foreach ($p in $FilePath) {
|
||||||
|
if ($p -match '\*') { $isWildcardGlobal = $true; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$showProgress = $Recursive.IsPresent -or $isWildcardGlobal -or ($PSCmdlet.ParameterSetName -eq 'Verify');
|
||||||
|
|
||||||
|
# --- ITEM GATHERING (Generate & Match Modes) ---
|
||||||
|
if ($PSCmdlet.ParameterSetName -in @('Generate', 'Match')) {
|
||||||
|
if (-not $FilePath -or $FilePath.Count -eq 0) {
|
||||||
|
Write-ErrorWithHelp "checksum: Missing file path parameter. Use -Help for usage.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$allItems = @();
|
||||||
|
$skipExtensions = @('.md5', '.sha1', '.sha256', '.sha384', '.sha512');
|
||||||
|
|
||||||
|
foreach ($pathEntry in ($FilePath)) {
|
||||||
|
$isWildcard = ($pathEntry -match '\*');
|
||||||
|
$resolvedItems = @();
|
||||||
|
|
||||||
|
if ($Recursive) {
|
||||||
|
$resolvedItems = Get-ChildItem -Path ($pathEntry) -Recurse -File -ErrorAction 'SilentlyContinue';
|
||||||
|
} else {
|
||||||
|
if ($isWildcard -or ($pathEntry -match '\?')) {
|
||||||
|
$resolvedItems = Get-ChildItem -Path ($pathEntry) -File -ErrorAction 'SilentlyContinue';
|
||||||
|
} else {
|
||||||
|
$resolvedItems = Get-Item -Path ($pathEntry) -ErrorAction 'SilentlyContinue';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $resolvedItems) {
|
||||||
|
Write-ErrorWithHelp "checksum: $($pathEntry): No such file or directory";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$explicitFileFound = $false;
|
||||||
|
if ((-not $isWildcard) -and (Test-Path -Path ($pathEntry) -PathType 'Leaf')) {
|
||||||
|
$explicitFileFound = $true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($item in ($resolvedItems)) {
|
||||||
|
if ($item.PSIsContainer) { continue; }
|
||||||
|
|
||||||
|
if (-not $explicitFileFound) {
|
||||||
|
if ($skipExtensions -contains $item.Extension.ToLower()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$allItems += $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- DIRECT MATCH MODE (-m / -Match) ---
|
# --- DIRECT MATCH MODE (-m / -Match) ---
|
||||||
if ($PSCmdlet.ParameterSetName -eq 'Match') {
|
if ($PSCmdlet.ParameterSetName -eq 'Match') {
|
||||||
if (-not $FilePath -or $FilePath.Count -eq 0) {
|
|
||||||
Write-Error "checksum: Missing file path parameter for matching. Use -Help for usage."
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
# Auto-detect algorithm from provided -Match hash string if not explicitly given
|
|
||||||
if ([string]::IsNullOrWhiteSpace($Algorithm)) {
|
if ([string]::IsNullOrWhiteSpace($Algorithm)) {
|
||||||
$Algorithm = Get-AlgorithmFromHashLength -HashString $Match
|
$Algorithm = Get-AlgorithmFromHashLength -HashString ($Match);
|
||||||
if (-not $Algorithm) { return }
|
if (-not $Algorithm) { return; }
|
||||||
Write-Verbose "Auto-detected algorithm: $Algorithm"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$expectedHash = $Match.Trim().ToLower()
|
$expectedHash = $Match.Trim().ToLower();
|
||||||
|
$totalFiles = $allItems.Count;
|
||||||
|
$currentIndex = 0;
|
||||||
|
|
||||||
foreach ($pathEntry in $FilePath) {
|
$allItems | ForEach-Object -Parallel {
|
||||||
$resolvedItems = Get-Item -Path $pathEntry -ErrorAction SilentlyContinue
|
$item = $_
|
||||||
|
$algo = $using:Algorithm
|
||||||
|
$exp = $using:expectedHash
|
||||||
|
|
||||||
if (-not $resolvedItems) {
|
$actualHash = (Get-FileHash -Path ($item.FullName) -Algorithm ($algo)).Hash.ToLower();
|
||||||
Write-Error "checksum: $pathEntry`: No such file or directory"
|
$targetFile = Resolve-Path -Path ($item.FullName) -Relative -ErrorAction 'SilentlyContinue';
|
||||||
continue
|
if (-not $targetFile) { $targetFile = $item.Name; }
|
||||||
|
if ($targetFile.StartsWith(".\") -or $targetFile.StartsWith("./")) { $targetFile = $targetFile.Substring(2); }
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
TargetFile = $targetFile
|
||||||
|
IsMatch = ($actualHash -eq $exp)
|
||||||
|
}
|
||||||
|
} -ThrottleLimit 16 | ForEach-Object {
|
||||||
|
$currentIndex++
|
||||||
|
if ($showProgress -and $totalFiles -gt 0) {
|
||||||
|
Write-Progress -Activity "Matching Checksums ($Algorithm)" -Status "Processing file $currentIndex of $totalFiles" -PercentComplete (($currentIndex / $totalFiles) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($item in $resolvedItems) {
|
if ($_.IsMatch) {
|
||||||
if ($item.PSIsContainer) {
|
Write-Host "$($_.TargetFile): " -NoNewline;
|
||||||
Write-Error "checksum: $($item.Name)`: Is a directory"
|
Write-Host "OK" -ForegroundColor Green;
|
||||||
} else {
|
} else {
|
||||||
$actualHash = (Get-FileHash -Path $item.FullName -Algorithm $Algorithm).Hash.ToLower()
|
Write-Host "$($_.TargetFile): " -NoNewline;
|
||||||
$targetFile = Resolve-Path -Path $item.FullName -Relative
|
Write-Host "FAILED" -ForegroundColor Red;
|
||||||
if ($targetFile.StartsWith(".\")) { $targetFile = $targetFile.Substring(2) }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($actualHash -eq $expectedHash) {
|
if ($showProgress) {
|
||||||
Write-Host "${targetFile}: " -NoNewline
|
Write-Progress -Activity "Matching Checksums ($Algorithm)" -Completed;
|
||||||
Write-Host "OK" -ForegroundColor Green
|
|
||||||
} else {
|
|
||||||
Write-Host "${targetFile}: " -NoNewline
|
|
||||||
Write-Host "FAILED" -ForegroundColor Red
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# --- VERIFICATION MODE (-c / -Check) ---
|
# --- VERIFICATION MODE (-c / -Check) ---
|
||||||
elseif ($PSCmdlet.ParameterSetName -eq 'Verify') {
|
elseif ($PSCmdlet.ParameterSetName -eq 'Verify') {
|
||||||
if (-not (Test-Path -Path $Check -PathType Leaf)) {
|
$checkFiles = @();
|
||||||
Write-Error "checksum: $Check`: No such file or directory"
|
if ($Recursive) {
|
||||||
return
|
$checkFileName = Split-Path -Path ($Check) -Leaf;
|
||||||
|
$checkFiles = Get-ChildItem -Path '.\' -Filter ($checkFileName) -Recurse -File -ErrorAction 'SilentlyContinue';
|
||||||
|
} else {
|
||||||
|
if (Test-Path -Path ($Check) -PathType 'Leaf') {
|
||||||
|
$checkFiles = @(Get-Item -Path ($Check));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = Get-Content -Path $Check
|
if (-not $checkFiles -or $checkFiles.Count -eq 0) {
|
||||||
|
Write-ErrorWithHelp "checksum: $($Check): No such file or directory";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($cf in ($checkFiles)) {
|
||||||
|
$lines = Get-Content -Path ($cf.FullName);
|
||||||
|
$baseDir = $cf.DirectoryName;
|
||||||
|
|
||||||
|
$fileAlgo = $Algorithm;
|
||||||
|
if ([string]::IsNullOrWhiteSpace($fileAlgo)) {
|
||||||
|
foreach ($line in ($lines)) {
|
||||||
|
if ([string]::IsNullOrWhiteSpace($line) -or $line.StartsWith("#")) { continue; }
|
||||||
|
|
||||||
# Auto-detect algorithm based on hash length if not explicitly provided
|
|
||||||
if ([string]::IsNullOrWhiteSpace($Algorithm)) {
|
|
||||||
foreach ($line in $lines) {
|
|
||||||
if ([string]::IsNullOrWhiteSpace($line) -or $line.StartsWith("#")) { continue }
|
|
||||||
if ($line -match '^([a-fA-F0-9]+)\s+') {
|
if ($line -match '^([a-fA-F0-9]+)\s+') {
|
||||||
$Algorithm = Get-AlgorithmFromHashLength -HashString $Matches[1]
|
$fileAlgo = Get-AlgorithmFromHashLength -HashString ($Matches[1]);
|
||||||
if (-not $Algorithm) { return }
|
break;
|
||||||
Write-Verbose "Auto-detected algorithm: $Algorithm"
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
elseif ($line -match '^([a-fA-F0-9]{128}|[a-fA-F0-9]{96}|[a-fA-F0-9]{64}|[a-fA-F0-9]{40}|[a-fA-F0-9]{32})') {
|
||||||
|
$fileAlgo = Get-AlgorithmFromHashLength -HashString ($Matches[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ([string]::IsNullOrWhiteSpace($fileAlgo)) { $fileAlgo = 'SHA256'; }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Fallback if file contained no parsable hashes
|
$verifyItems = @();
|
||||||
if ([string]::IsNullOrWhiteSpace($Algorithm)) {
|
foreach ($line in ($lines)) {
|
||||||
$Algorithm = 'SHA256'
|
if ([string]::IsNullOrWhiteSpace($line) -or $line.StartsWith("#")) { continue; }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($line in $lines) {
|
$expectedHash = $null;
|
||||||
# Skip empty lines or comments
|
$targetFile = $null;
|
||||||
if ([string]::IsNullOrWhiteSpace($line) -or $line.StartsWith("#")) { continue }
|
|
||||||
|
|
||||||
# Match standard checksum output format: "<hash> [* ]<filename>"
|
|
||||||
if ($line -match '^([a-fA-F0-9]+)\s+[* ]?(.*)$') {
|
if ($line -match '^([a-fA-F0-9]+)\s+[* ]?(.*)$') {
|
||||||
$expectedHash = $Matches[1].ToLower()
|
$expectedHash = $Matches[1].ToLower();
|
||||||
# Strip leading whitespace and any leftover leading asterisk
|
$targetFile = $Matches[2].Trim().TrimStart('*');
|
||||||
$targetFile = $Matches[2].Trim().TrimStart('*')
|
}
|
||||||
|
elseif ($line -match '^([a-fA-F0-9]{128}|[a-fA-F0-9]{96}|[a-fA-F0-9]{64}|[a-fA-F0-9]{40}|[a-fA-F0-9]{32})[* ]?(.*)$') {
|
||||||
|
$expectedHash = $Matches[1].ToLower();
|
||||||
|
$targetFile = $Matches[2].Trim().TrimStart('*');
|
||||||
|
}
|
||||||
|
|
||||||
if (Test-Path -Path $targetFile -PathType Leaf) {
|
if ($expectedHash -and $targetFile) {
|
||||||
$actualHash = (Get-FileHash -Path $targetFile -Algorithm $Algorithm).Hash.ToLower()
|
$targetFullPath = Join-Path -Path ($baseDir) -ChildPath ($targetFile);
|
||||||
|
$verifyItems += [PSCustomObject]@{
|
||||||
|
ExpectedHash = $expectedHash
|
||||||
|
TargetFile = $targetFile
|
||||||
|
TargetFullPath = $targetFullPath
|
||||||
|
BaseDir = $baseDir
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($actualHash -eq $expectedHash) {
|
$totalFiles = $verifyItems.Count;
|
||||||
Write-Host "${targetFile}: " -NoNewline
|
$currentIndex = 0;
|
||||||
Write-Host "OK" -ForegroundColor Green
|
|
||||||
} else {
|
$verifyItems | ForEach-Object -Parallel {
|
||||||
Write-Host "${targetFile}: " -NoNewline
|
$item = $_
|
||||||
Write-Host "FAILED" -ForegroundColor Red
|
$algo = $using:fileAlgo
|
||||||
|
|
||||||
|
if (Test-Path -Path ($item.TargetFullPath) -PathType 'Leaf') {
|
||||||
|
$actualHash = (Get-FileHash -Path ($item.TargetFullPath) -Algorithm ($algo)).Hash.ToLower();
|
||||||
|
|
||||||
|
$displayPath = Resolve-Path -Path ($item.TargetFullPath) -Relative -ErrorAction 'SilentlyContinue';
|
||||||
|
if (-not $displayPath) { $displayPath = $item.TargetFile; }
|
||||||
|
if ($displayPath.StartsWith(".\") -or $displayPath.StartsWith("./")) { $displayPath = $displayPath.Substring(2); }
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
DisplayPath = $displayPath
|
||||||
|
Status = if ($actualHash -eq $item.ExpectedHash) { "OK" } else { "FAILED" }
|
||||||
|
IsError = $false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host "${targetFile}: " -NoNewline
|
$displayPath = $item.TargetFile;
|
||||||
Write-Host "FAILED open or read" -ForegroundColor Red
|
if ($item.BaseDir -ne (Get-Location).Path) {
|
||||||
|
$displayPath = Join-Path -Path (Resolve-Path -Path ($item.BaseDir) -Relative -ErrorAction 'SilentlyContinue') -ChildPath ($item.TargetFile);
|
||||||
|
if ($displayPath.StartsWith(".\") -or $displayPath.StartsWith("./")) { $displayPath = $displayPath.Substring(2); }
|
||||||
}
|
}
|
||||||
|
[PSCustomObject]@{
|
||||||
|
DisplayPath = $displayPath
|
||||||
|
Status = "FAILED open or read"
|
||||||
|
IsError = $true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} -ThrottleLimit 16 | ForEach-Object {
|
||||||
|
$currentIndex++
|
||||||
|
if ($totalFiles -gt 0) {
|
||||||
|
Write-Progress -Activity "Verifying Checksums ($fileAlgo)" -Status "Processing file $currentIndex of $totalFiles" -PercentComplete (($currentIndex / $totalFiles) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$($_.DisplayPath): " -NoNewline;
|
||||||
|
if ($_.IsError) {
|
||||||
|
Write-Host "$($_.Status)" -ForegroundColor Red;
|
||||||
|
} elseif ($_.Status -eq "OK") {
|
||||||
|
Write-Host "OK" -ForegroundColor Green;
|
||||||
} else {
|
} else {
|
||||||
Write-Warning "checksum: improperly formatted line: $line"
|
Write-Host "FAILED" -ForegroundColor Red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Write-Progress -Activity "Verifying Checksums ($fileAlgo)" -Completed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# --- GENERATION MODE ---
|
# --- GENERATION MODE ---
|
||||||
else {
|
else {
|
||||||
# Default to SHA256 if no algorithm was specified in generation mode
|
|
||||||
if ([string]::IsNullOrWhiteSpace($Algorithm)) {
|
if ([string]::IsNullOrWhiteSpace($Algorithm)) {
|
||||||
$Algorithm = 'SHA256'
|
$Algorithm = 'SHA256';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not $FilePath -or $FilePath.Count -eq 0) {
|
$wantCustomOut = $PSBoundParameters.ContainsKey('OutFile');
|
||||||
Write-Error "checksum: Missing file path parameter. Use -Help for usage."
|
$wantAutoOut = $Save.IsPresent;
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
# Clear/initialize output file if specified before writing hashes
|
if ($wantCustomOut -or $wantAutoOut) {
|
||||||
if (-not [string]::IsNullOrWhiteSpace($OutFile)) {
|
if ($Recursive -and $isWildcardGlobal) {
|
||||||
$null = New-Item -Path $OutFile -ItemType File -Force
|
$groupedItems = $allItems | Group-Object DirectoryName;
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($pathEntry in $FilePath) {
|
foreach ($group in ($groupedItems)) {
|
||||||
# Resolve wildcards and single file inputs
|
$dirPath = $group.Name;
|
||||||
$resolvedItems = Get-Item -Path $pathEntry -ErrorAction SilentlyContinue
|
$filesInDir = $group.Group;
|
||||||
|
|
||||||
if (-not $resolvedItems) {
|
if ($wantCustomOut) {
|
||||||
Write-Error "checksum: $pathEntry`: No such file or directory"
|
$currentOutFile = Join-Path -Path ($dirPath) -ChildPath ($OutFile);
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($item in $resolvedItems) {
|
|
||||||
# Handle directories like Linux sha256sum does
|
|
||||||
if ($item.PSIsContainer) {
|
|
||||||
Write-Error "checksum: $($item.Name)`: Is a directory"
|
|
||||||
} else {
|
} else {
|
||||||
$hash = (Get-FileHash -Path $item.FullName -Algorithm $Algorithm).Hash.ToLower()
|
$currentOutFile = Join-Path -Path ($dirPath) -ChildPath "checksums.$($Algorithm.ToLower())";
|
||||||
|
|
||||||
# Format standard relative path (stripping leading '.\')
|
|
||||||
$relativePath = Resolve-Path -Path $item.FullName -Relative
|
|
||||||
if ($relativePath.StartsWith(".\")) {
|
|
||||||
$relativePath = $relativePath.Substring(2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$outputLine = "$hash $relativePath"
|
$totalFiles = $filesInDir.Count;
|
||||||
|
$currentIndex = 0;
|
||||||
|
$linesToWrite = @();
|
||||||
|
|
||||||
# If -OutFile is provided, write line to file
|
$filesInDir | ForEach-Object -Parallel {
|
||||||
if (-not [string]::IsNullOrWhiteSpace($OutFile)) {
|
$item = $_
|
||||||
Add-Content -Path $OutFile -Value $outputLine
|
$algo = $using:Algorithm
|
||||||
|
|
||||||
|
$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($algo)).Hash.ToLower();
|
||||||
|
|
||||||
|
$relativePath = Resolve-Path -Path ($item.FullName) -Relative -ErrorAction 'SilentlyContinue';
|
||||||
|
if (-not $relativePath) { $relativePath = $item.Name; }
|
||||||
|
if ($relativePath.StartsWith(".\") -or $relativePath.StartsWith("./")) {
|
||||||
|
$relativePath = $relativePath.Substring(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output to stdout
|
[PSCustomObject]@{
|
||||||
Write-Output $outputLine
|
Item = $item
|
||||||
}
|
Hash = $hash
|
||||||
}
|
RelativePath = $relativePath
|
||||||
}
|
OutputLine = "${hash} ${relativePath}"
|
||||||
|
ItemOutFile = "$($item.FullName).$($algo.ToLower())"
|
||||||
}
|
}
|
||||||
|
} -ThrottleLimit 16 | ForEach-Object {
|
||||||
|
$currentIndex++;
|
||||||
|
if ($showProgress -and $totalFiles -gt 0) {
|
||||||
|
Write-Progress -Activity "Computing Checksums ($Algorithm)" -Status "Directory: $(Split-Path $dirPath -Leaf) [$currentIndex/$totalFiles]" -PercentComplete (($currentIndex / $totalFiles) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
end {}
|
$linesToWrite += $_.OutputLine;
|
||||||
|
Write-Output $_.OutputLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($showProgress) {
|
||||||
|
Write-Progress -Activity "Computing Checksums ($Algorithm)" -Completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-Content -Path ($currentOutFile) -Value $linesToWrite -Encoding utf8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($wantCustomOut -or ($wantAutoOut -and $isWildcardGlobal)) {
|
||||||
|
if ($wantCustomOut) {
|
||||||
|
$singleOutFile = $OutFile;
|
||||||
|
} else {
|
||||||
|
$singleOutFile = "checksums.$($Algorithm.ToLower())";
|
||||||
|
}
|
||||||
|
|
||||||
|
$totalFiles = $allItems.Count;
|
||||||
|
$currentIndex = 0;
|
||||||
|
$linesToWrite = @();
|
||||||
|
|
||||||
|
$allItems | ForEach-Object -Parallel {
|
||||||
|
$item = $_
|
||||||
|
$algo = $using:Algorithm
|
||||||
|
|
||||||
|
$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($algo)).Hash.ToLower();
|
||||||
|
|
||||||
|
$relativePath = Resolve-Path -Path ($item.FullName) -Relative -ErrorAction 'SilentlyContinue';
|
||||||
|
if (-not $relativePath) { $relativePath = $item.Name; }
|
||||||
|
if ($relativePath.StartsWith(".\") -or $relativePath.StartsWith("./")) {
|
||||||
|
$relativePath = $relativePath.Substring(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
Item = $item
|
||||||
|
Hash = $hash
|
||||||
|
RelativePath = $relativePath
|
||||||
|
OutputLine = "${hash} ${relativePath}"
|
||||||
|
ItemOutFile = "$($item.FullName).$($algo.ToLower())"
|
||||||
|
}
|
||||||
|
} -ThrottleLimit 16 | ForEach-Object {
|
||||||
|
$currentIndex++;
|
||||||
|
if ($showProgress -and $totalFiles -gt 0) {
|
||||||
|
Write-Progress -Activity "Computing Checksums ($Algorithm)" -Status "Processing file $currentIndex of $totalFiles" -PercentComplete (($currentIndex / $totalFiles) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
$linesToWrite += $_.OutputLine;
|
||||||
|
Write-Output $_.OutputLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($showProgress) {
|
||||||
|
Write-Progress -Activity "Computing Checksums ($Algorithm)" -Completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-Content -Path ($singleOutFile) -Value $linesToWrite -Encoding utf8;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$totalFiles = $allItems.Count;
|
||||||
|
$currentIndex = 0;
|
||||||
|
|
||||||
|
$allItems | ForEach-Object -Parallel {
|
||||||
|
$item = $_
|
||||||
|
$algo = $using:Algorithm
|
||||||
|
|
||||||
|
$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($algo)).Hash.ToLower();
|
||||||
|
|
||||||
|
$relativePath = Resolve-Path -Path ($item.FullName) -Relative -ErrorAction 'SilentlyContinue';
|
||||||
|
if (-not $relativePath) { $relativePath = $item.Name; }
|
||||||
|
if ($relativePath.StartsWith(".\") -or $relativePath.StartsWith("./")) {
|
||||||
|
$relativePath = $relativePath.Substring(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
Item = $item
|
||||||
|
Hash = $hash
|
||||||
|
RelativePath = $relativePath
|
||||||
|
OutputLine = "${hash} ${relativePath}"
|
||||||
|
ItemOutFile = "$($item.FullName).$($algo.ToLower())"
|
||||||
|
}
|
||||||
|
} -ThrottleLimit 16 | ForEach-Object {
|
||||||
|
$currentIndex++;
|
||||||
|
if ($showProgress -and $totalFiles -gt 0) {
|
||||||
|
Write-Progress -Activity "Computing Checksums ($Algorithm)" -Status "Processing file $currentIndex of $totalFiles" -PercentComplete (($currentIndex / $totalFiles) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output $_.OutputLine;
|
||||||
|
Set-Content -Path ($_.ItemOutFile) -Value $_.OutputLine -Encoding utf8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($showProgress) {
|
||||||
|
Write-Progress -Activity "Computing Checksums ($Algorithm)" -Completed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$totalFiles = $allItems.Count;
|
||||||
|
$currentIndex = 0;
|
||||||
|
|
||||||
|
$allItems | ForEach-Object -Parallel {
|
||||||
|
$item = $_
|
||||||
|
$algo = $using:Algorithm
|
||||||
|
|
||||||
|
$hash = (Get-FileHash -Path ($item.FullName) -Algorithm ($algo)).Hash.ToLower();
|
||||||
|
|
||||||
|
$relativePath = Resolve-Path -Path ($item.FullName) -Relative -ErrorAction 'SilentlyContinue';
|
||||||
|
if (-not $relativePath) { $relativePath = $item.Name; }
|
||||||
|
if ($relativePath.StartsWith(".\") -or $relativePath.StartsWith("./")) {
|
||||||
|
$relativePath = $relativePath.Substring(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[PSCustomObject]@{
|
||||||
|
Item = $item
|
||||||
|
Hash = $hash
|
||||||
|
RelativePath = $relativePath
|
||||||
|
OutputLine = "${hash} ${relativePath}"
|
||||||
|
ItemOutFile = "$($item.FullName).$($algo.ToLower())"
|
||||||
|
}
|
||||||
|
} -ThrottleLimit 16 | ForEach-Object {
|
||||||
|
$currentIndex++;
|
||||||
|
if ($showProgress -and $totalFiles -gt 0) {
|
||||||
|
Write-Progress -Activity "Computing Checksums ($Algorithm)" -Status "Processing file $currentIndex of $totalFiles" -PercentComplete (($currentIndex / $totalFiles) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output $_.OutputLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($showProgress) {
|
||||||
|
Write-Progress -Activity "Computing Checksums ($Algorithm)" -Completed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,23 +1,9 @@
|
|||||||
# waypoint.ps1
|
if ($args[0]) { $commit_message=($args -join " ") } # if arg0 exists, join all passed args with spaces
|
||||||
|
else { $commit_message="waypoint" } # or default to "waypoint"
|
||||||
|
|
||||||
if (-not (Test-Path -Path ".\.git" -PathType Container)) {
|
Write-Host "WAYPOINT!`n`tCommit Message: $commit_message`n"
|
||||||
Write-Host "No .git folder detected. Initializing new Git repository..." -ForegroundColor Yellow
|
# add and commit
|
||||||
git init
|
|
||||||
} else {
|
|
||||||
Write-Host "Git repository detected. Creating waypoint..." -ForegroundColor Cyan
|
|
||||||
}
|
|
||||||
|
|
||||||
# Stage all changes
|
|
||||||
git add .
|
git add .
|
||||||
|
git commit -m "$commit_message"
|
||||||
|
|
||||||
# Format the timestamp with timezone offset/ID string
|
Write-Host "`nDone :`"3"
|
||||||
$timestamp = (Get-Date).ToString("yyyy-MM-dd-HHmm") + "-" + ((Get-TimeZone).Id -creplace '[a-z\s]', '')
|
|
||||||
|
|
||||||
# Capture current git status output
|
|
||||||
$statusOutput = (git status | Out-String).Trim()
|
|
||||||
|
|
||||||
# Construct the commit message
|
|
||||||
$commitMessage = "WAYPOINT $timestamp`n`n$statusOutput"
|
|
||||||
|
|
||||||
# Execute commit
|
|
||||||
git commit -m "$commitMessage"
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
domain=kasm.h.acker.is
|
||||||
|
local_port=8443
|
||||||
|
swap_size_gib=6
|
||||||
|
sudo apt update
|
||||||
|
sudo apt dist-upgrade -y
|
||||||
|
sudo fallocate -l ${swap_size_gib}g /mnt/${swap_size_gib}GiB.swap
|
||||||
|
sudo chmod 600 /mnt/${swap_size_gib}GiB.swap
|
||||||
|
sudo mkswap /mnt/${swap_size_gib}GiB.swap
|
||||||
|
sudo swapon /mnt/${swap_size_gib}GiB.swap
|
||||||
|
echo "/mnt/${swap_size_gib}GiB.swap swap swap defaults 0 0" | sudo tee -a /etc/fstab
|
||||||
|
cd /tmp
|
||||||
|
curl -O https://kasm-static-content.s3.amazonaws.com/kasm_release_1.19.0-latest.tar.gz
|
||||||
|
tar -xf kasm_release*.tar.gz
|
||||||
|
sudo bash kasm_release/install.sh -L $local_port
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install nginx certbot python3-certbot-nginx -y
|
||||||
|
sudo certbot certonly --nginx -d $domain
|
||||||
|
sudo cat << 'EOF' > /etc/nginx/sites-available/$domain
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name $domain;
|
||||||
|
ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem;
|
||||||
|
location / {
|
||||||
|
# WebSocket Support
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
|
# Host and X headers
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
# Should match the listening port of this proxy
|
||||||
|
proxy_set_header X-Forwarded-Port 443;
|
||||||
|
|
||||||
|
# Connectivity Options
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_read_timeout 1800s;
|
||||||
|
proxy_send_timeout 1800s;
|
||||||
|
proxy_connect_timeout 1800s;
|
||||||
|
proxy_buffering off;
|
||||||
|
|
||||||
|
# Allow large requests to support file uploads to sessions
|
||||||
|
client_max_body_size 10M;
|
||||||
|
|
||||||
|
# Proxy to Kasm Workspaces running locally on $local_port using ssl
|
||||||
|
proxy_pass https://127.0.0.1:$local_port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
sudo ln -s /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/$domain
|
||||||
|
sudo nginx -t
|
||||||
|
sudo systemctl restart nginx
|
||||||
|
sudo docker restart kasm_api
|
||||||
|
sudo shutdown -r +7
|
||||||
@@ -12,7 +12,6 @@ tmpDir='/tmp/generalssss'
|
|||||||
tmp_customscripts_dir="$tmpDir/customscripts"
|
tmp_customscripts_dir="$tmpDir/customscripts"
|
||||||
finalDir='/usr/share/customscripts'
|
finalDir='/usr/share/customscripts'
|
||||||
packages="7zip apache2 argon2 avahi-daemon btop build-essential byobu cargo cifs-utils clamav cmake cowsay cracklib-runtime detox docker.io exiftool fdupes ffuf gcc-arm-none-eabi grc gzip iotop iptraf-ng jq kpartx libnss-mdns libnewlib-arm-none-eabi librust-git2+openssl-probe-dev libstdc++-arm-none-eabi-newlib locales lynx net-tools nginx openssl php polygen polygen-data procps python3 python3-scapy resolvconf restic ripgrep samba screen seclists snapd thefuck unzip wget xrdp xxd xz-utils zip kali-linux-default"
|
packages="7zip apache2 argon2 avahi-daemon btop build-essential byobu cargo cifs-utils clamav cmake cowsay cracklib-runtime detox docker.io exiftool fdupes ffuf gcc-arm-none-eabi grc gzip iotop iptraf-ng jq kpartx libnss-mdns libnewlib-arm-none-eabi librust-git2+openssl-probe-dev libstdc++-arm-none-eabi-newlib locales lynx net-tools nginx openssl php polygen polygen-data procps python3 python3-scapy resolvconf restic ripgrep samba screen seclists snapd thefuck unzip wget xrdp xxd xz-utils zip kali-linux-default"
|
||||||
# packages="grc kpartx openssl cracklib-runtime argon2 jq polygen polygen-data apache2 seclists cmake locales python3 build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib librust-git2+openssl-probe-dev cargo nginx build-essential cowsay iotop iptraf-ng btop screen byobu thefuck wget lynx zip unzip 7zip xz-utils gzip net-tools clamav php restic cifs-utils detox fdupes ripgrep avahi-daemon libnss-mdns xxd xrdp libimage-exiftool-perl kali-tools-hardware kali-tools-crypto-stego kali-tools-fuzzing kali-tools-bluetooth kali-tools-rfid kali-tools-sdr kali-tools-voip kali-tools-802-11 kali-tools-forensics samba procps snapd"
|
|
||||||
|
|
||||||
echo -e "\nSTARTING!\n\tUsing Shell $SHELL\n"
|
echo -e "\nSTARTING!\n\tUsing Shell $SHELL\n"
|
||||||
|
|
||||||
@@ -73,49 +72,48 @@ if [ ! -z "$1" ]; then
|
|||||||
# echo -e "\nhaveibeenpwned-downloader installed, skipping install\n"
|
# echo -e "\nhaveibeenpwned-downloader installed, skipping install\n"
|
||||||
# fi
|
# fi
|
||||||
# homebrew
|
# homebrew
|
||||||
# if [ ! $(which brew) ]; then
|
if [ ! $(which brew) ]; then
|
||||||
# ## install homebrew
|
## install homebrew
|
||||||
# echo -e "\nlinuxbrew not found, installing\n"
|
echo -e "\nlinuxbrew not found, installing\n"
|
||||||
# bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
# test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||||
# test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
|
||||||
# ### add to rcfile
|
### add to rcfile
|
||||||
# if ! grep -q 'linuxbrew' $rcfile; then
|
if ! grep -q 'linuxbrew' $rcfile; then
|
||||||
# # echo "adding linuxbrew to $rcfile"
|
echo "adding linuxbrew to $rcfile"
|
||||||
# # echo "# linuxbrew (homebrew/brew)" >> $rcfile
|
echo "# linuxbrew (homebrew/brew)" >> $rcfile
|
||||||
# # echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> $rcfile
|
echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> $rcfile
|
||||||
# else
|
else
|
||||||
# echo "linuxbrew already in $rcfile skipping"
|
echo "linuxbrew already in $rcfile skipping"
|
||||||
# fi
|
fi
|
||||||
#
|
|
||||||
# # source $rcfile
|
else
|
||||||
# else
|
echo -e "\nlinuxbrew installed, skipping install\n"
|
||||||
# echo -e "\nlinuxbrew installed, skipping install\n"
|
fi
|
||||||
# # source $rcfile
|
### install ponysay
|
||||||
# fi
|
if [ ! $(which ponysay) ]; then
|
||||||
# ### install ponysay
|
echo -e "\nponysay not fonud, installiing\n"
|
||||||
# if [ ! $(which ponysay) ]; then
|
brew install ponysay
|
||||||
# echo -e "\nponysay not fonud, installiing\n"
|
if ! grep 'ponysay fix' $rcfile; then
|
||||||
# brew install ponysay
|
echo "adding ponysay fix to $rcfile"
|
||||||
# if ! grep 'ponysay fix' $rcfile; then
|
echo -e "# ponysay fix\nexport PYTHONWARNINGS=ignore::SyntaxWarning" >> $rcfile
|
||||||
# # echo "adding ponysay fix to $rcfile"
|
source $rcfile
|
||||||
# # echo -e "# ponysay fix\nexport PYTHONWARNINGS=ignore::SyntaxWarning" >> $rcfile
|
else
|
||||||
# # source $rcfile
|
echo "ponysay fix already in $rcfile skipping"
|
||||||
# else
|
source $rcfile
|
||||||
# # echo "ponysay fix already in $rcfile skipping"
|
fi
|
||||||
# # source $rcfile
|
else
|
||||||
# fi
|
echo -e "\nponysay already installed, skipping\n"
|
||||||
# else
|
fi
|
||||||
# echo -e "\nponysay already installed, skipping\n"
|
|
||||||
# fi
|
|
||||||
# cargo
|
# cargo
|
||||||
|
|
||||||
## oniux
|
## oniux
|
||||||
echo -e "\nINSTALLIN TOR ONIUX\n"
|
echo -e "\nINSTALLIN TOR ONIUX\n"
|
||||||
if [ -f /usr/local/bin/oniux ]; then
|
if [ -f /usr/local/bin/oniux ]; then
|
||||||
echo -e "\nexisting oniux found, skipping\n"
|
echo -e "\nexisting oniux found, skipping\n"
|
||||||
else
|
else
|
||||||
echo -e "\nexisting oniux not found, installing\n"
|
echo -e "\nexisting oniux not found, installing\n"
|
||||||
cargo install --git https://gitlab.torproject.org/tpo/core/oniux --tag v0.6.1 oniux
|
cd /tmp && cargo install --git https://gitlab.torproject.org/tpo/core/oniux && cd - && echo -e '## Oniux/Cargo Shit\nPATH=$PATH:$HOME/.cargo/bin' >> ~/.bashrc && source ~/.bashrc && oniux curl https://canhazip.com
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -160,7 +158,7 @@ git clone $gitRepo $tmpDir --single-branch --depth 1
|
|||||||
|
|
||||||
# donut
|
# donut
|
||||||
echo -e "\nCompiling donut\n"
|
echo -e "\nCompiling donut\n"
|
||||||
gcc -o "$tmp_customscripts_dir/donut" "$tmp_customscripts_dir/donut.c" -lm # 2>/dev/null
|
gcc -o "$tmp_customscripts_dir/donut" "$tmp_customscripts_dir/donut.c" -lm 2>/dev/null
|
||||||
|
|
||||||
# put the customscripts dir into place
|
# put the customscripts dir into place
|
||||||
echo -e "\nPlacing in $finalDir\n"
|
echo -e "\nPlacing in $finalDir\n"
|
||||||
@@ -181,10 +179,10 @@ pathgrep=$?
|
|||||||
if [ $pathgrep -eq 0 ]; then
|
if [ $pathgrep -eq 0 ]; then
|
||||||
echo -e "\n$finalDir Already in \$PATH Skipping Append\n"
|
echo -e "\n$finalDir Already in \$PATH Skipping Append\n"
|
||||||
fi
|
fi
|
||||||
# else
|
else
|
||||||
# echo -e "\nAdding $finalDir to $username's \$PATH by Appending to $rcfile\n"
|
# echo -e "\nAdding $finalDir to $username's \$PATH by Appending to $rcfile\n"
|
||||||
# echo -e "\n\n# automatically added by customscripts installer\nexport PATH=\"\$PATH:$finalDir\"" >> "$rcfile"
|
# echo -e "\n\n# automatically added by customscripts installer\nexport PATH=\"\$PATH:$finalDir\"" >> "$rcfile"
|
||||||
# fi
|
fi
|
||||||
|
|
||||||
# install pishrink if not there
|
# install pishrink if not there
|
||||||
if [ ! -f /usr/local/bin/pishrink ]; then
|
if [ ! -f /usr/local/bin/pishrink ]; then
|
||||||
@@ -204,15 +202,11 @@ if [ ! -d $userhome/.local/share/blesh ]; then
|
|||||||
cd /tmp
|
cd /tmp
|
||||||
git clone --recursive --depth 1 --shallow-submodules --single-branch -b master https://github.com/akinomyoga/ble.sh.git
|
git clone --recursive --depth 1 --shallow-submodules --single-branch -b master https://github.com/akinomyoga/ble.sh.git
|
||||||
make -C ble.sh install PREFIX=~/.local
|
make -C ble.sh install PREFIX=~/.local
|
||||||
# echo '# ble.sh' >> $rcfile
|
echo '# ble.sh' >> $rcfile
|
||||||
# echo "source -- ~/.local/share/blesh/ble.sh" >> $rcfile
|
echo "source -- ~/.local/share/blesh/ble.sh" >> $rcfile
|
||||||
# source $rcfile
|
else
|
||||||
# exec "$SHELL"
|
echo -e "\nble.sh already installed, skippping\n"
|
||||||
fi
|
fi
|
||||||
# else
|
|
||||||
# echo -e "\nble.sh already installed, skippping\n"
|
|
||||||
# source $rcfile
|
|
||||||
# fi
|
|
||||||
|
|
||||||
$SHELL -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
$SHELL -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> "$rcfile"
|
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> "$rcfile"
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# usage
|
|
||||||
## curl -s https://raw.githubusercontent.com/PrincessPi3/general-scripts-and-system-ssssssetup/refs/heads/main/customscripts/python_pyenv_setup.sh | sudo "$SHELL" && source ~/.zshrc && exec "$SHELL" && pyenv install 3:latest && pyenv global 3:latest
|
|
||||||
# set -e
|
|
||||||
|
|
||||||
# set rcfile
|
|
||||||
rcfile="$HOME/.zshrc" # zsh
|
|
||||||
# rcfile="$USER/.bashrc" # bash
|
|
||||||
package_log="/home/princesspi/python_packages_removed.txt"
|
|
||||||
|
|
||||||
# check if a command exists, and if so, purge that package
|
|
||||||
# usage: check_purge_package <package_name>
|
|
||||||
check_purge_package () {
|
|
||||||
package_name=$1
|
|
||||||
|
|
||||||
# which -s $package_name 2>/dev/null 1>/dev/null # silently test for command
|
|
||||||
# package_check=$? # get return code. 0 for found, any other for not found
|
|
||||||
|
|
||||||
# if [ $package_check -eq 0 ]; then # if package is found, purge it
|
|
||||||
echo "purging $package_name"
|
|
||||||
sudo apt purge $package_name -y 2>>"$package_log" 1>>"$package_log"
|
|
||||||
echo "finished purging $package_name"
|
|
||||||
# else # otherwise skip
|
|
||||||
# echo "no $package_name installation found, skipping uninstall"
|
|
||||||
#fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# cleanup previous python installs
|
|
||||||
# check_purge_package pyenv*
|
|
||||||
# check_purge_package python3*
|
|
||||||
# check_purge_package python2*
|
|
||||||
# check_purge_package python*
|
|
||||||
# check_purge_package pip*
|
|
||||||
# check_purge_package pip3*
|
|
||||||
# check_purge_package pip2*
|
|
||||||
|
|
||||||
|
|
||||||
# cleanup
|
|
||||||
# echo "Autoremoving packages"
|
|
||||||
# sudo apt autoremove -y 2>>"$package_log" 1>>"$package_log"
|
|
||||||
# echo -e "DONE CLEARING OLD PACKAGES!\n\tRemoved packages logged to $package_log"
|
|
||||||
|
|
||||||
if [ -d $HOME/.pyenv ]; then
|
|
||||||
echo "Removing existing pyenv installation"
|
|
||||||
rm -rf $HOME/.pyenv
|
|
||||||
else
|
|
||||||
echo "No existing pyenv installation found, skipping removal"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# install pyenv
|
|
||||||
curl -fsSL https://pyenv.run | bash
|
|
||||||
## setup shell
|
|
||||||
### check for pyenv in rcfile
|
|
||||||
grep -q .pyenv $rcfile
|
|
||||||
rc_pyenv_check=$? # get retcode, 0 for found not 0 for not found
|
|
||||||
|
|
||||||
if [ $rc_pyenv_check -eq 0 ]; then # if pyenv found
|
|
||||||
echo "pyenv already set up in $rcfile, skipping add init"
|
|
||||||
else # if pyenv not found
|
|
||||||
echo "Setting up pyenv in $rcfile"
|
|
||||||
echo -e "\n# pyenv setup" >> $rcfile
|
|
||||||
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> $rcfile
|
|
||||||
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> $rcfile
|
|
||||||
echo 'eval "$(pyenv init - zsh)"' >> $rcfile
|
|
||||||
fi
|
|
||||||
## add aliases
|
|
||||||
### check for aliases in rcfile
|
|
||||||
grep -q '## python aliases' $rcfile
|
|
||||||
rc_pyalias_check=$? # get retcode, 0 for found not 0 for not found
|
|
||||||
|
|
||||||
if [ $rc_pyalias_check -eq 0 ]; then # if aliases found
|
|
||||||
echo "pyenv aliases already set up in $rcfile, skipping"
|
|
||||||
else # if aliases not found, add python shit
|
|
||||||
echo "Setting up pyenv aliases in $rcfile"
|
|
||||||
echo "## python aliases" >> $rcfile
|
|
||||||
echo 'alias py=python' >> $rcfile
|
|
||||||
echo 'alias py3=python' >> $rcfile
|
|
||||||
echo 'alias py2=python' >> $rcfile
|
|
||||||
echo 'alias python3=python' >> $rcfile
|
|
||||||
echo 'alias python2=python' >> $rcfile
|
|
||||||
echo 'alias pip3=pip' >> $rcfile
|
|
||||||
echo -e "alias pip2=pip\n" >> $rcfile
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "\n\ndone~ :3~\n\treset shell with exec \"\$SHELL\"\n"
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Usage:
|
||||||
|
## Install Tor
|
||||||
|
### sudo apt update; sudo apt install tor -y
|
||||||
|
## Edit /etc/tor/torrc
|
||||||
|
### sudo nano /etc/tor/torrc
|
||||||
|
#### Uncomment or add
|
||||||
|
##### ControlPort 9051
|
||||||
|
#### Ucomment and change to (default value is 1, change to 0)
|
||||||
|
##### CookieAuthentication 0
|
||||||
|
## Enable, Start, and Restart Tor
|
||||||
|
### sudo systemctl enable tor; sudo systemctl start tor; sleep 20; sudo systemctl restart tor
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
TARGET_URL="https://canhazip.com"
|
||||||
|
TOR_PROXY="socks5h://127.0.0.1:9050"
|
||||||
|
TOR_CONTROL_PORT=9051
|
||||||
|
DELAY=2 # Delay in seconds between requests
|
||||||
|
|
||||||
|
# Ensure you respect HIBP's API rate limits and terms of service
|
||||||
|
while true; do
|
||||||
|
echo "[+] Requesting new Tor identity..."
|
||||||
|
|
||||||
|
# Send NEWNYM signal to Tor Control Port to switch IP
|
||||||
|
echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051 > /dev/null
|
||||||
|
|
||||||
|
# Give Tor a brief moment to establish the new circuit
|
||||||
|
sleep "$DELAY"
|
||||||
|
|
||||||
|
echo "[+] Verifying current IP..."
|
||||||
|
CURRENT_IP=$(curl -s --proxy "$TOR_PROXY" https://canhazip.com)
|
||||||
|
echo "[+] Current Tor IP: $CURRENT_IP"
|
||||||
|
|
||||||
|
echo "[+] Sending request to Have I Been Pwned..."
|
||||||
|
# 'socks5h://' ensures DNS resolution happens through Tor, preventing leaks
|
||||||
|
curl -s --proxy "$TOR_PROXY" -H "hibp-api-key: YOUR_API_KEY" "$TARGET_URL"
|
||||||
|
|
||||||
|
echo -e "\n[+] Waiting for next iteration...\n"
|
||||||
|
sleep "$DELAY"
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user