Skip to content

Commit ff06c91

Browse files
committed
f
1 parent 08c2e42 commit ff06c91

File tree

3 files changed

+71
-11
lines changed

3 files changed

+71
-11
lines changed

.github/workflows/build_master.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,32 @@ jobs:
8888
RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
8989
echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
9090
91-
# Copy ONLY the .gz version to the searchindex repo (no uncompressed .js)
91+
# XOR encrypt the compressed file
92+
KEY='Prevent_Online_AVs_From_Flagging_HackTricks_Search_Gzip_As_Malicious_394h7gt8rf9u3rf9g'
93+
python3 - << 'PYTHON_SCRIPT'
94+
import sys
95+
key = sys.argv[1]
96+
input_file = sys.argv[2]
97+
output_file = sys.argv[3]
98+
99+
with open(input_file, 'rb') as f:
100+
data = f.read()
101+
102+
key_bytes = key.encode('utf-8')
103+
encrypted = bytearray(len(data))
104+
for i in range(len(data)):
105+
encrypted[i] = data[i] ^ key_bytes[i % len(key_bytes)]
106+
107+
with open(output_file, 'wb') as f:
108+
f.write(encrypted)
109+
110+
print(f"Encrypted: {len(data)} bytes")
111+
PYTHON_SCRIPT
112+
python3 - "$KEY" "${ASSET}.gz" "${ASSET}.gz.enc"
113+
114+
# Copy ONLY the encrypted .gz version to the searchindex repo (no uncompressed .js)
92115
cd /tmp/searchindex-repo
93-
cp "${GITHUB_WORKSPACE}/${ASSET}.gz" "${FILENAME}.gz"
116+
cp "${GITHUB_WORKSPACE}/${ASSET}.gz.enc" "${FILENAME}.gz"
94117

95118
# Stage all files
96119
git add -A

.github/workflows/translate_all.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,31 @@ jobs:
184184
RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
185185
echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
186186
187-
# Copy ONLY the .gz version to the searchindex repo (no uncompressed .js)
188-
cp "${ASSET}.gz" "/tmp/searchindex-repo/${FILENAME}.gz"
187+
# XOR encrypt the compressed file
188+
KEY="Prevent_Online_AVs_From_Flagging_HackTricks_Search_Gzip_As_Malicious_394h7gt8rf9u3rf9g"
189+
python3 - << 'PYTHON_SCRIPT'
190+
import sys
191+
key = sys.argv[1]
192+
input_file = sys.argv[2]
193+
output_file = sys.argv[3]
194+
195+
with open(input_file, 'rb') as f:
196+
data = f.read()
197+
198+
key_bytes = key.encode('utf-8')
199+
encrypted = bytearray(len(data))
200+
for i in range(len(data)):
201+
encrypted[i] = data[i] ^ key_bytes[i % len(key_bytes)]
202+
203+
with open(output_file, 'wb') as f:
204+
f.write(encrypted)
205+
206+
print(f"Encrypted: {len(data)} bytes")
207+
PYTHON_SCRIPT
208+
python3 - "$KEY" "${ASSET}.gz" "${ASSET}.gz.enc"
209+
210+
# Copy ONLY the encrypted .gz version to the searchindex repo (no uncompressed .js)
211+
cp "${ASSET}.gz.enc" "/tmp/searchindex-repo/${FILENAME}.gz"
189212

190213
# Commit and push with retry logic
191214
cd /tmp/searchindex-repo
@@ -224,8 +247,8 @@ jobs:
224247
git config user.name "GitHub Actions"
225248
git config user.email "[email protected]"
226249

227-
# Re-copy ONLY the .gz version (no uncompressed .js)
228-
cp "${ASSET}.gz" "${FILENAME}.gz"
250+
# Re-copy ONLY the encrypted .gz version (no uncompressed .js)
251+
cp "${ASSET}.gz.enc" "${FILENAME}.gz"
229252

230253
git add "${FILENAME}.gz"
231254
git commit -m "Update ${FILENAME}.gz from hacktricks-cloud build"

theme/ht_searcher.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,17 @@
2121
try { importScripts('https://cdn.jsdelivr.net/npm/[email protected]/elasticlunr.min.js'); }
2222
catch { importScripts(abs('/elasticlunr.min.js')); }
2323
24-
/* 2 — decompress gzip data */
24+
/* 2 — XOR decryption function */
25+
function xorDecrypt(encryptedData, key){
26+
const keyBytes = new TextEncoder().encode(key);
27+
const decrypted = new Uint8Array(encryptedData.length);
28+
for(let i = 0; i < encryptedData.length; i++){
29+
decrypted[i] = encryptedData[i] ^ keyBytes[i % keyBytes.length];
30+
}
31+
return decrypted.buffer;
32+
}
33+
34+
/* 3 — decompress gzip data */
2535
async function decompressGzip(arrayBuffer){
2636
if(typeof DecompressionStream !== 'undefined'){
2737
/* Modern browsers: use native DecompressionStream */
@@ -40,21 +50,25 @@
4050
}
4151
}
4252
43-
/* 3 — load a single index (remote → local) */
53+
/* 4 — load a single index (remote → local) */
4454
async function loadIndex(remote, local, isCloud=false){
55+
const XOR_KEY = "Prevent_Online_AVs_From_Flagging_HackTricks_Search_Gzip_As_Malicious_394h7gt8rf9u3rf9g";
4556
let rawLoaded = false;
4657
if(remote){
4758
/* Try ONLY compressed version from GitHub (remote already includes .js.gz) */
4859
try {
4960
const r = await fetch(remote,{mode:'cors'});
5061
if (r.ok) {
51-
const compressed = await r.arrayBuffer();
62+
const encryptedCompressed = await r.arrayBuffer();
63+
/* Decrypt first */
64+
const compressed = xorDecrypt(new Uint8Array(encryptedCompressed), XOR_KEY);
65+
/* Then decompress */
5266
const text = await decompressGzip(compressed);
5367
importScripts(URL.createObjectURL(new Blob([text],{type:'application/javascript'})));
5468
rawLoaded = true;
55-
console.log('Loaded compressed from GitHub:',remote);
69+
console.log('Loaded encrypted+compressed from GitHub:',remote);
5670
}
57-
} catch(e){ console.warn('compressed GitHub',remote,'failed →',e); }
71+
} catch(e){ console.warn('encrypted+compressed GitHub',remote,'failed →',e); }
5872
}
5973
/* If remote (GitHub) failed, fall back to local uncompressed file */
6074
if(!rawLoaded && local){

0 commit comments

Comments
 (0)