chore: add useful scripts
This commit is contained in:
parent
16673ef3c0
commit
71cf2a8dd3
2 changed files with 50 additions and 0 deletions
14
scripts/dexor_binary_file.ps1
Normal file
14
scripts/dexor_binary_file.ps1
Normal file
|
@ -0,0 +1,14 @@
|
|||
$SourceFilePath = $args[0]
|
||||
$DestinationFilePath = $args[1]
|
||||
$XorKey = [byte]$args[2]
|
||||
|
||||
# Load the binary data from the file
|
||||
$data = [System.IO.File]::ReadAllBytes($SourceFilePath)
|
||||
|
||||
# Apply the XOR operation
|
||||
for ($i = 0; $i -lt $data.Length; $i++) {
|
||||
$data[$i] = $data[$i] -bxor $XorKey
|
||||
}
|
||||
|
||||
# Write the output to the destination file
|
||||
[System.IO.File]::WriteAllBytes($DestinationFilePath, $data)
|
36
scripts/split_dat_file.ps1
Normal file
36
scripts/split_dat_file.ps1
Normal file
|
@ -0,0 +1,36 @@
|
|||
$SourceFilePath = $args[0]
|
||||
$ChunkSize = $args[1]
|
||||
$Offset = $args[2]
|
||||
|
||||
# Function to create chunk file
|
||||
function Create-ChunkFile {
|
||||
param (
|
||||
[byte[]]$ChunkData,
|
||||
[int]$ChunkNumber
|
||||
)
|
||||
|
||||
$chunkFileName = Join-Path $subDir ("{0}_{1:D5}.bin" -f [System.IO.Path]::GetFileNameWithoutExtension($SourceFilePath), $ChunkNumber)
|
||||
[System.IO.File]::WriteAllBytes($chunkFileName, $ChunkData)
|
||||
}
|
||||
|
||||
# Create subdirectory named after the source file (without extension) for chunks
|
||||
$subDir = Join-Path ([System.IO.Path]::GetDirectoryName($SourceFilePath)) ([System.IO.Path]::GetFileNameWithoutExtension($SourceFilePath))
|
||||
if (!(Test-Path -Path $subDir)) {
|
||||
New-Item -ItemType Directory -Path $subDir
|
||||
}
|
||||
|
||||
# Read the binary data from the file
|
||||
$data = [System.IO.File]::ReadAllBytes($SourceFilePath)
|
||||
$dataLength = $data.Length
|
||||
$chunkNumber = 0
|
||||
|
||||
# Adjust the start position based on the offset
|
||||
$startPosition = [Math]::Min($Offset, $dataLength)
|
||||
|
||||
# Process chunks
|
||||
for ($i = $startPosition; $i -lt $dataLength; $i += $ChunkSize) {
|
||||
$chunkEnd = [Math]::Min($i + $ChunkSize, $dataLength)
|
||||
$chunkData = $data[$i..($chunkEnd - 1)]
|
||||
Create-ChunkFile -ChunkData $chunkData -ChunkNumber $chunkNumber
|
||||
$chunkNumber++
|
||||
}
|
Loading…
Reference in a new issue