forked from xcalibure2/DataBouncing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeadPool.ps1
More file actions
209 lines (165 loc) · 6.13 KB
/
deadPool.ps1
File metadata and controls
209 lines (165 loc) · 6.13 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
function Regenerate {
param (
[string]$regex,
[string]$File
)
function Find-Secret {
param (
[Parameter(Mandatory = $true)]
[string]$FilePath,
[Parameter(Mandatory = $true)]
[string]$Regex
)
# Ensure the file exists
if (-not (Test-Path $FilePath)) {
Write-Error "File not found: $FilePath"
return
}
# Initialize an array to hold matches
$MatchesFound = @()
# Read the file and process each line
Get-Content $FilePath | ForEach-Object {
if ($_ -match "$Regex\.([^\.]+)\.") {
# Add matched string in uppercase
$MatchesFound += $Matches[1].ToUpper()
}
}
# Output unique matches only
$MatchesFound | Select-Object -Unique
# Read the file and process each line
$content = Get-Content $FilePath | ForEach-Object {
$line = $_
if ($line -match "$Regex\.([^\.]+)\.") {
# Skip lines with matches
return $null
} else {
# Return lines without matches
return $line
}
}
# Output the modified content
$content | Set-Content -Path $FilePath -Force
}
function Assemble-Instructions {
param (
[string]$FilePath
)
# Reading data from the file
$data = Get-Content $FilePath
# Splitting the data into lines by newlines
$lines = $data -split "`r`n"
foreach ($line in $lines) {
if ($line -match "^j.*j$") {
$instructions = $line
break
}
}
# Remove the leading and trailing 'J'
$trimmedInstructions = $instructions.Trim('J')
# Split the string by 'G', 'H', or 'I'
$split = [regex]::Split($trimmedInstructions, '[GHI]')
$numSegs = [int]$split[0]
$hexString = $split[1]
# $hexName = $split[2]
$ext = Convert-HexToAscii $hexString
$saveName = "${regex}."
# Removing the first line (contains the total count, not needed for processing)
$lines = $lines[1..($lines.Length - 1)]
# Sorting the lines based on the number at the beginning
$sortedLines = $lines | Sort-Object { [int]($_ -replace '[GHI].*$', '') }
# Extracting and concatenating the strings without spaces
$hexContent = ($sortedLines | ForEach-Object { $_ -replace '^[0-9]+[GHI]', '' }) -join ''
$result = Convert-HexToAscii $hexContent
return $result, $ext, $saveName, $numSegs
}
function Convert-HexToAscii {
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string]$HexInput
)
process {
# Split the hex string into chunks of two characters each
$hexPairs = $HexInput -split "(..)" | Where-Object { $_ }
# Convert each hex pair to its ASCII representation
$asciiString = $hexPairs | ForEach-Object {
[char][convert]::ToInt32($_, 16)
}
# Combine the ASCII characters into a single string
return -join $asciiString
}
}
$secrets = (Find-Secret -FilePath $File -Regex $regex)
$secrets | Out-File -FilePath ./raw.txt -Encoding UTF8
$result, $ext, $saveName, $numSegs = Assemble-Instructions -FilePath ./raw.txt
# Save the decoded content to a file with the extracted extension
$result | Out-File -FilePath "$saveName$ext" -Encoding UTF8
}
function watchLogs {
param (
[string]$File = "logs.txt",
[string]$IdsFilePath = "file-IDs.txt"
)
while ($true) {
# Check if the log file exists
if (-Not (Test-Path $File)) {
Write-Host "Log file not found: $File"
return
}
# Check if the IDs file exists
if (-Not (Test-Path $IdsFilePath)) {
Write-Host "IDs file not found: $IdsFilePath"
return
}
# Read the IDs file and split it into an array
$fileContent = Get-Content $IdsFilePath
$fileIds = $fileContent -split '\r?\n'
# Read the log file
$logFileContent = Get-Content $File
# Initialize variables
$segments = $null
$fileIdFound = $false
# Search for each ID in the log file and capture the number of segments
foreach ($fileid in $fileIds) {
$pattern = "$fileid\.J(\d+)"
foreach ($line in $logFileContent) {
if ($line -match $pattern) {
$segments = $matches[1]
Write-Host "ID found: $fileid"
Write-Host "Found matching line: $line"
Write-Host "Captured number of segments: $segments"
$fileIdFound = $true
break
}
}
if ($fileIdFound) {
break
}
}
if (-not $fileIdFound) {
Write-Host "No ID found in the log file, checking again..."
Start-Sleep -Seconds 10 # Optional: Delay before next check
continue
}
# Initialize an array to keep track of found segments
$foundSegments = @()
# Check for each segment in a loop until all are found
while ($foundSegments.Count -lt $segments) {
for ($i = 1; $i -le $segments; $i++) {
if ($i -notin $foundSegments) {
$logFileContent = Get-Content $File
$segmentPattern = "$fileid\.$i"
$segmentFound = $logFileContent | Where-Object { $_ -match $segmentPattern }
if ($segmentFound) {
$foundSegments += $i
Write-Host "Segment $i found"
} else {
Write-Host "Segment $i not found, checking again..."
}
}
sleep 3
}
}
Write-Host "All $segments segments have been found for ID $fileid."
Recreate-Secrets -regex "$fileid"
}
}