Skip to content

Commit 3bce115

Browse files
committed
Merge branch 'master' into update_HTB__Baby___Anonymous_LDAP___Password_Spray___SeBa_20250919_124219
2 parents b9d3eb0 + ea5b9fd commit 3bce115

File tree

90 files changed

+6507
-714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+6507
-714
lines changed

.github/workflows/auto_merge_approved_prs.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Auto Merge Approved PRs
22

33
on:
44
schedule:
5-
- cron: '0 */2 * * *' # Every 2 hours
5+
- cron: '0 */1 * * *' # Every 1 hour
66
workflow_dispatch: # Allow manual triggering
77

88
permissions:
@@ -15,6 +15,17 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
token: ${{ secrets.PAT_TOKEN }}
23+
24+
- name: Configure git
25+
run: |
26+
git config --global user.email "[email protected]"
27+
git config --global user.name "GitHub Action"
28+
1829
- name: Check for running workflows
1930
id: check_workflows
2031
run: |
@@ -93,6 +104,11 @@ jobs:
93104
if [ "$has_merge_comment" = true ]; then
94105
echo "Attempting to merge PR #$pr_number..."
95106
107+
# Get PR details including head branch
108+
pr_details=$(gh pr view "$pr_number" --json headRefName,baseRefName --repo "$GITHUB_REPOSITORY")
109+
head_branch=$(echo "$pr_details" | jq -r '.headRefName')
110+
base_branch=$(echo "$pr_details" | jq -r '.baseRefName')
111+
96112
# --- Polling for non-UNKNOWN mergeable status ---
97113
max_retries=10
98114
retry=0
@@ -118,6 +134,8 @@ jobs:
118134
else
119135
echo "Failed to merge PR #$pr_number: $pr_title"
120136
fi
137+
elif [ "$pr_mergeable" = "CONFLICTED" ] || [ "$pr_mergeable" = "CONFLICTING" ]; then
138+
echo "PR #$pr_number has conflicts. Skipping auto-merge so it can be resolved manually."
121139
else
122140
echo "PR #$pr_number is not mergeable (status: $pr_mergeable)"
123141
fi

.github/workflows/build_master.yml

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -35,60 +35,38 @@ jobs:
3535
- name: Build mdBook
3636
run: MDBOOK_BOOK__LANGUAGE=en mdbook build || (echo "Error logs" && cat hacktricks-preprocessor-error.log && echo "" && echo "" && echo "Debug logs" && (cat hacktricks-preprocessor.log | tail -n 20) && exit 1)
3737

38-
- name: Update searchindex in repo (purge history, keep current on HEAD)
38+
- name: Install GitHub CLI
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y gh
42+
43+
- name: Publish search index release asset
3944
shell: bash
45+
env:
46+
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
4047
run: |
4148
set -euo pipefail
4249
43-
ls -la
44-
ls -la book
45-
46-
git config --global --add safe.directory /__w/hacktricks/hacktricks
47-
git config --global user.email "[email protected]"
48-
git config --global user.name "Build master"
49-
git config pull.rebase false
50-
51-
# Ensure we're on the target branch and up to date
52-
git fetch origin
53-
git reset --hard origin/master
50+
ASSET="book/searchindex.js"
51+
TAG="searchindex-en"
52+
TITLE="Search Index (en)"
5453
55-
# Choose the file to keep at HEAD:
56-
# 1) Prefer freshly built version from book/
57-
# 2) Fallback to the file currently at HEAD (if it exists)
58-
HAS_FILE=0
59-
if [ -f "book/searchindex.js" ]; then
60-
cp "book/searchindex.js" /tmp/sidx.js
61-
HAS_FILE=1
62-
elif git cat-file -e "HEAD:searchindex.js" 2>/dev/null; then
63-
git show "HEAD:searchindex.js" > /tmp/sidx.js
64-
HAS_FILE=1
54+
if [ ! -f "$ASSET" ]; then
55+
echo "Expected $ASSET to exist after build" >&2
56+
exit 1
6557
fi
6658
67-
# Skip if there's nothing to purge AND nothing to keep
68-
if [ "$HAS_FILE" = "1" ] || git rev-list -n 1 HEAD -- "searchindex.js" >/dev/null 2>&1; then
69-
# Fail early if working tree is dirty (avoid confusing rewrites)
70-
git diff --quiet || { echo "Working tree has uncommitted changes; aborting purge." >&2; exit 1; }
71-
72-
# Install git-filter-repo and ensure it's on PATH
73-
python -m pip install --quiet --user git-filter-repo
74-
export PATH="$HOME/.local/bin:$PATH"
75-
76-
# Rewrite ONLY the current branch, dropping all historical blobs of searchindex.js
77-
git filter-repo --force --path "searchindex.js" --invert-paths --refs "$(git symbolic-ref -q HEAD)"
78-
79-
# Re-add the current version on top of rewritten history (keep it in HEAD)
80-
if [ "$HAS_FILE" = "1" ]; then
81-
mv /tmp/sidx.js "searchindex.js"
82-
git add "searchindex.js"
83-
git commit -m "Update searchindex (purged history; keep current)"
84-
else
85-
echo "No current searchindex.js to re-add after purge."
86-
fi
59+
TOKEN="${PAT_TOKEN:-${GITHUB_TOKEN:-}}"
60+
if [ -z "$TOKEN" ]; then
61+
echo "No token available for GitHub CLI" >&2
62+
exit 1
63+
fi
64+
export GH_TOKEN="$TOKEN"
8765
88-
# Safer force push (only updates if remote hasn't advanced)
89-
git push --force-with-lease
66+
if ! gh release view "$TAG" >/dev/null 2>&1; then
67+
gh release create "$TAG" "$ASSET" --title "$TITLE" --notes "Automated search index build for master" --repo "$GITHUB_REPOSITORY"
9068
else
91-
echo "Nothing to purge; skipping."
69+
gh release upload "$TAG" "$ASSET" --clobber --repo "$GITHUB_REPOSITORY"
9270
fi
9371
9472

.github/workflows/translate_all.yml

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- name: Update and download scripts
6666
run: |
6767
sudo apt-get update
68-
sudo apt-get install wget -y
68+
sudo apt-get install -y wget gh
6969
mkdir scripts
7070
cd scripts
7171
wget -O get_and_save_refs.py https://raw.githubusercontent.com/HackTricks-wiki/hacktricks-cloud/master/scripts/get_and_save_refs.py
@@ -123,57 +123,35 @@ jobs:
123123
git pull
124124
MDBOOK_BOOK__LANGUAGE=$BRANCH mdbook build || (echo "Error logs" && cat hacktricks-preprocessor-error.log && echo "" && echo "" && echo "Debug logs" && (cat hacktricks-preprocessor.log | tail -n 20) && exit 1)
125125
126-
- name: Update searchindex.js in repo (purge history, keep current on HEAD)
126+
- name: Publish search index release asset
127127
shell: bash
128+
env:
129+
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
128130
run: |
129131
set -euo pipefail
130132
131-
# Be explicit about workspace trust (avoids "dubious ownership")
132-
git config --global --add safe.directory "$GITHUB_WORKSPACE"
133+
ASSET="book/searchindex.js"
134+
TAG="searchindex-${BRANCH}"
135+
TITLE="Search Index (${BRANCH})"
133136
134-
git checkout "$BRANCH"
135-
git fetch origin "$BRANCH" --quiet
136-
git pull --ff-only
137-
138-
# Choose the file to keep at HEAD:
139-
# 1) Prefer freshly built version from book/
140-
# 2) Fallback to the file currently at HEAD (if it exists)
141-
HAS_FILE=0
142-
if [ -f "book/searchindex.js" ]; then
143-
cp "book/searchindex.js" /tmp/sidx.js
144-
HAS_FILE=1
145-
elif git cat-file -e "HEAD:searchindex.js" 2>/dev/null; then
146-
git show "HEAD:searchindex.js" > /tmp/sidx.js
147-
HAS_FILE=1
137+
if [ ! -f "$ASSET" ]; then
138+
echo "Expected $ASSET to exist after build" >&2
139+
exit 1
148140
fi
149141
150-
# Skip if there's nothing to purge AND nothing to keep
151-
if [ "$HAS_FILE" = "1" ] || git rev-list -n 1 "$BRANCH" -- "searchindex.js" >/dev/null 2>&1; then
152-
# **Fail early if working tree is dirty** (prevents confusing filter results)
153-
git diff --quiet || { echo "Working tree has uncommitted changes; aborting purge." >&2; exit 1; }
154-
155-
# Make sure git-filter-repo is callable via `git filter-repo`
156-
python -m pip install --quiet --user git-filter-repo
157-
export PATH="$HOME/.local/bin:$PATH"
158-
159-
# Rewrite ONLY this branch, dropping all historical blobs of searchindex.js
160-
git filter-repo --force --path "searchindex.js" --invert-paths --refs "refs/heads/$BRANCH"
161-
162-
# Re-add the current version on top of rewritten history (keep it in HEAD)
163-
if [ "$HAS_FILE" = "1" ]; then
164-
mv /tmp/sidx.js "searchindex.js"
165-
git add "searchindex.js"
166-
git commit -m "Update searchindex (purged history; keep current)"
167-
else
168-
echo "No current searchindex.js to re-add after purge."
169-
fi
142+
TOKEN="${PAT_TOKEN:-${GITHUB_TOKEN:-}}"
143+
if [ -z "$TOKEN" ]; then
144+
echo "No token available for GitHub CLI" >&2
145+
exit 1
146+
fi
147+
export GH_TOKEN="$TOKEN"
170148
171-
# **Safer force push** (prevents clobbering unexpected remote updates)
172-
git push --force-with-lease origin "$BRANCH"
149+
if ! gh release view "$TAG" >/dev/null 2>&1; then
150+
gh release create "$TAG" "$ASSET" --title "$TITLE" --notes "Automated search index build for $BRANCH" --repo "$GITHUB_REPOSITORY"
173151
else
174-
echo "Nothing to purge; skipping."
152+
gh release upload "$TAG" "$ASSET" --clobber --repo "$GITHUB_REPOSITORY"
175153
fi
176-
154+
177155
# Login in AWs
178156
- name: Configure AWS credentials using OIDC
179157
uses: aws-actions/configure-aws-credentials@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ book
1111
book/*
1212
hacktricks-preprocessor.log
1313
hacktricks-preprocessor-error.log
14+
searchindex.js

hacktricks-preprocessor.py

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
logger.addHandler(handler2)
1818

1919

20-
def findtitle(search ,obj, key, path=(),):
20+
def findtitle(search, obj, key, path=()):
2121
# logger.debug(f"Looking for {search} in {path}")
2222
if isinstance(obj, dict) and key in obj and obj[key] == search:
2323
return obj, path
@@ -54,26 +54,42 @@ def ref(matchobj):
5454
if href.endswith("/"):
5555
href = href+"README.md" # Fix if ref points to a folder
5656
if "#" in href:
57-
chapter, _path = findtitle(href.split("#")[0], book, "source_path")
58-
title = " ".join(href.split("#")[1].split("-")).title()
59-
logger.debug(f'Ref has # using title: {title}')
57+
result = findtitle(href.split("#")[0], book, "source_path")
58+
if result is not None:
59+
chapter, _path = result
60+
title = " ".join(href.split("#")[1].split("-")).title()
61+
logger.debug(f'Ref has # using title: {title}')
62+
else:
63+
raise Exception(f"Chapter not found for path: {href.split('#')[0]}")
6064
else:
61-
chapter, _path = findtitle(href, book, "source_path")
62-
logger.debug(f'Recursive title search result: {chapter["name"]}')
63-
title = chapter['name']
65+
result = findtitle(href, book, "source_path")
66+
if result is not None:
67+
chapter, _path = result
68+
logger.debug(f'Recursive title search result: {chapter["name"]}')
69+
title = chapter['name']
70+
else:
71+
raise Exception(f"Chapter not found for path: {href}")
6472
except Exception as e:
6573
dir = path.dirname(current_chapter['source_path'])
6674
rel_path = path.normpath(path.join(dir,href))
6775
try:
6876
logger.debug(f'Not found chapter title from: {href} -- trying with relative path {rel_path}')
6977
if "#" in href:
70-
chapter, _path = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
71-
title = " ".join(href.split("#")[1].split("-")).title()
72-
logger.debug(f'Ref has # using title: {title}')
78+
result = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
79+
if result is not None:
80+
chapter, _path = result
81+
title = " ".join(href.split("#")[1].split("-")).title()
82+
logger.debug(f'Ref has # using title: {title}')
83+
else:
84+
raise Exception(f"Chapter not found for relative path: {path.normpath(path.join(dir,href.split('#')[0]))}")
7385
else:
74-
chapter, _path = findtitle(path.normpath(path.join(dir,href.split('#')[0])), book, "source_path")
75-
title = chapter["name"]
76-
logger.debug(f'Recursive title search result: {chapter["name"]}')
86+
result = findtitle(path.normpath(path.join(dir,href)), book, "source_path")
87+
if result is not None:
88+
chapter, _path = result
89+
title = chapter["name"]
90+
logger.debug(f'Recursive title search result: {chapter["name"]}')
91+
else:
92+
raise Exception(f"Chapter not found for relative path: {path.normpath(path.join(dir,href))}")
7793
except Exception as e:
7894
logger.debug(e)
7995
logger.error(f'Error getting chapter title: {rel_path}')

0 commit comments

Comments
 (0)