Skip to content

Commit 29d65a6

Browse files
committed
f
1 parent 766f380 commit 29d65a6

3 files changed

Lines changed: 322 additions & 7 deletions

File tree

.github/workflows/auto_merge_approved_prs.yml

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,38 @@ jobs:
3737
- name: Check for running workflows
3838
id: check_workflows
3939
run: |
40+
gh_with_retry() {
41+
local max_attempts=5
42+
local base_sleep_seconds=2
43+
local attempt=1
44+
local stderr_file
45+
stderr_file=$(mktemp)
46+
47+
while true; do
48+
if gh "$@" 2>"$stderr_file"; then
49+
rm -f "$stderr_file"
50+
return 0
51+
fi
52+
53+
local exit_code=$?
54+
if [ "$attempt" -ge "$max_attempts" ]; then
55+
echo "gh command failed after $max_attempts attempts: gh $*" >&2
56+
cat "$stderr_file" >&2
57+
rm -f "$stderr_file"
58+
return "$exit_code"
59+
fi
60+
61+
local sleep_for=$((base_sleep_seconds * attempt))
62+
echo "gh command failed (attempt $attempt/$max_attempts): gh $*" >&2
63+
cat "$stderr_file" >&2
64+
echo "Retrying in ${sleep_for}s..." >&2
65+
sleep "$sleep_for"
66+
attempt=$((attempt + 1))
67+
done
68+
}
69+
4070
# Get all running workflows except this one
41-
running_workflows=$(gh run list --status in_progress --json workflowName,name --repo "$GITHUB_REPOSITORY" --jq '.[].name' | grep -v "Auto Merge Approved PRs" | wc -l)
71+
running_workflows=$(gh_with_retry run list --status in_progress --json workflowName,name --repo "$GITHUB_REPOSITORY" --jq '.[].name' | grep -v "Auto Merge Approved PRs" | wc -l)
4272
echo "running_workflows=$running_workflows" >> $GITHUB_OUTPUT
4373
4474
if [ "$running_workflows" -gt 0 ]; then
@@ -54,14 +84,44 @@ jobs:
5484
- name: Find and merge approved PRs
5585
if: steps.check_workflows.outputs.should_continue == 'true'
5686
run: |
87+
gh_with_retry() {
88+
local max_attempts=5
89+
local base_sleep_seconds=2
90+
local attempt=1
91+
local stderr_file
92+
stderr_file=$(mktemp)
93+
94+
while true; do
95+
if gh "$@" 2>"$stderr_file"; then
96+
rm -f "$stderr_file"
97+
return 0
98+
fi
99+
100+
local exit_code=$?
101+
if [ "$attempt" -ge "$max_attempts" ]; then
102+
echo "gh command failed after $max_attempts attempts: gh $*" >&2
103+
cat "$stderr_file" >&2
104+
rm -f "$stderr_file"
105+
return "$exit_code"
106+
fi
107+
108+
local sleep_for=$((base_sleep_seconds * attempt))
109+
echo "gh command failed (attempt $attempt/$max_attempts): gh $*" >&2
110+
cat "$stderr_file" >&2
111+
echo "Retrying in ${sleep_for}s..." >&2
112+
sleep "$sleep_for"
113+
attempt=$((attempt + 1))
114+
done
115+
}
116+
57117
authorized_user="carlospolop"
58118
max_merges=2
59119
60120
echo "Authorized user: $authorized_user"
61121
echo "Looking for PRs with exact comment 'merge' from $authorized_user..."
62122
63123
# Get all open PRs
64-
prs=$(gh pr list --state open --json number,title,url,author --repo "$GITHUB_REPOSITORY")
124+
prs=$(gh_with_retry pr list --state open --json number,title,url,author --repo "$GITHUB_REPOSITORY")
65125
66126
if [ "$prs" = "[]" ]; then
67127
echo "No open PRs found."
@@ -98,7 +158,10 @@ jobs:
98158
has_merge_comment=false
99159
if [ "$eligible_by_title" != true ]; then
100160
# Get all comments for this PR
101-
comments=$(gh pr view "$pr_number" --json comments --jq '.comments[]' --repo "$GITHUB_REPOSITORY")
161+
if ! comments=$(gh_with_retry pr view "$pr_number" --json comments --jq '.comments[]' --repo "$GITHUB_REPOSITORY"); then
162+
echo "Failed to fetch comments for PR #$pr_number after retries. Skipping PR."
163+
continue
164+
fi
102165
103166
# Print all comment authors for debugging
104167
echo "Comments in PR #$pr_number:"
@@ -123,15 +186,21 @@ jobs:
123186
echo "Attempting to merge PR #$pr_number..."
124187
125188
# Get PR details including head branch
126-
pr_details=$(gh pr view "$pr_number" --json headRefName,baseRefName --repo "$GITHUB_REPOSITORY")
189+
if ! pr_details=$(gh_with_retry pr view "$pr_number" --json headRefName,baseRefName --repo "$GITHUB_REPOSITORY"); then
190+
echo "Failed to fetch details for PR #$pr_number after retries. Skipping PR."
191+
continue
192+
fi
127193
head_branch=$(echo "$pr_details" | jq -r '.headRefName')
128194
base_branch=$(echo "$pr_details" | jq -r '.baseRefName')
129195
130196
# --- Polling for non-UNKNOWN mergeable status ---
131197
max_retries=10
132198
retry=0
133199
while true; do
134-
pr_mergeable=$(gh pr view "$pr_number" --json mergeable --jq '.mergeable' --repo "$GITHUB_REPOSITORY")
200+
if ! pr_mergeable=$(gh_with_retry pr view "$pr_number" --json mergeable --jq '.mergeable' --repo "$GITHUB_REPOSITORY"); then
201+
echo "Failed to fetch mergeable status for PR #$pr_number after retries."
202+
pr_mergeable="UNKNOWN"
203+
fi
135204
if [ "$pr_mergeable" != "UNKNOWN" ]; then
136205
break
137206
fi

src/network-services-pentesting/pentesting-dns.md

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,140 @@ dig google.com A @<IP>
183183

184184
![](<../images/image (146).png>)
185185

186+
### DNS Auditor checks (HackTricks tools)
187+
188+
The HackTricks Domain/DNS auditor was expanded with extra DNS/certificate checks.
189+
Use this as a quick manual reference for verification and abuse paths.
190+
191+
#### NS delegation integrity / lame delegation
192+
193+
**What it checks**
194+
- Delegated NS hostnames resolve to IPs
195+
- Delegated NSs answer authoritatively for the zone
196+
- SOA serial consistency across authoritative NSs
197+
198+
**How to check**
199+
```bash
200+
dig example.com NS +short
201+
for ns in $(dig +short example.com NS); do dig @${ns%?} example.com SOA +short; done
202+
```
203+
204+
**Impact**
205+
- Intermittent or full DNS outages
206+
- Stale records depending on which NS a resolver hits
207+
208+
**Attacker abuse**
209+
- Exploit lame/out-of-sync delegation to increase reliability of cache-poisoning windows and selective traffic disruption.
210+
211+
#### HTTPS/SVCB modern records
212+
213+
**What it checks**
214+
- Presence/absence of `HTTPS` and `SVCB` records on apex and `www`
215+
216+
**How to check**
217+
```bash
218+
dig example.com HTTPS +short
219+
dig example.com SVCB +short
220+
dig www.example.com HTTPS +short
221+
dig www.example.com SVCB +short
222+
```
223+
224+
**Impact**
225+
- Mostly hardening/operational maturity gap (less protocol steering, less explicit service binding)
226+
227+
**Attacker abuse**
228+
- Not usually direct exploitation, but can reduce defensive control over client connection behavior.
229+
230+
#### DNS EDNS + TCP fallback resilience
231+
232+
**What it checks**
233+
- Truncation handling and TCP fallback viability for large DNS/DNSSEC answers
234+
235+
**How to check**
236+
```bash
237+
dig example.com DNSKEY +dnssec +bufsize=1232
238+
dig example.com DNSKEY +dnssec +tcp
239+
```
240+
241+
**Impact**
242+
- DNSSEC breakage, intermittent resolution failures behind specific networks/firewalls
243+
244+
**Attacker abuse**
245+
- Trigger degraded availability by forcing large responses where TCP/53 is blocked or broken.
246+
247+
#### DNSSEC lifecycle (CDS/CDNSKEY + DS consistency)
248+
249+
**What it checks**
250+
- Presence of rollover signaling records (`CDS`, `CDNSKEY`)
251+
- Parent/child key-tag consistency (`DS` vs `CDS`)
252+
253+
**How to check**
254+
```bash
255+
dig example.com DS +short
256+
dig example.com CDS +short
257+
dig example.com CDNSKEY +short
258+
```
259+
260+
**Impact**
261+
- Broken key rollover -> validation failures / SERVFAIL for validating resolvers
262+
263+
**Attacker abuse**
264+
- Abuse mis-rolled states to create denial-of-service conditions for DNSSEC-validating clients.
265+
266+
#### DNSSEC negative trust validation (NXDOMAIN proofs)
267+
268+
**What it checks**
269+
- For signed zones, whether random NXDOMAIN responses are validated and carry denial-of-existence evidence
270+
271+
**How to check**
272+
```bash
273+
dig @8.8.8.8 _random-does-not-exist.example.com A +dnssec
274+
dig @8.8.8.8 _random-does-not-exist.example.com A +dnssec +multi
275+
```
276+
277+
**Impact**
278+
- Broken denial-of-existence behavior can indicate chain/signer inconsistencies
279+
280+
**Attacker abuse**
281+
- Increase probability of resolver-side failure states during targeted DNSSEC disruption attempts.
282+
283+
#### Very low TTL on critical records
284+
285+
**What it checks**
286+
- Low/very-low TTLs on `A`, `AAAA`, `MX`, `NS`
287+
288+
**How to check**
289+
```bash
290+
dig example.com A +ttlid
291+
dig example.com AAAA +ttlid
292+
dig example.com MX +ttlid
293+
dig example.com NS +ttlid
294+
```
295+
296+
**Impact**
297+
- Faster global propagation of accidental or malicious DNS changes
298+
299+
**Attacker abuse**
300+
- If attacker gets brief write access to DNS, low TTL accelerates malicious redirection rollout.
301+
302+
#### CAA policy quality + CT correlation
303+
304+
**What it checks**
305+
- `issue` / `issuewild` breadth and over-permissive CA authorization
306+
- Whether observed CT issuers are consistent with CAA intent (heuristic)
307+
308+
**How to check**
309+
```bash
310+
dig example.com CAA +short
311+
curl -s "https://crt.sh/?q=%25.example.com&output=json" | head
312+
```
313+
314+
**Impact**
315+
- Overly broad or inconsistent issuance policy increases cert abuse surface
316+
317+
**Attacker abuse**
318+
- Mis-scoped CAA can make unauthorized/abusive cert issuance easier after CA/process compromise.
319+
186320

187321
### Mail to nonexistent account
188322

@@ -267,4 +401,3 @@ Entry_6:
267401
{{#include ../banners/hacktricks-training.md}}
268402

269403

270-

src/network-services-pentesting/pentesting-smtp/README.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,120 @@ _dmarc.bing.com. 3600 IN TXT "v=DMARC1; p=none; pct=100; rua=mailto:BingEmailDMA
389389
| adkim | Alignment mode for DKIM | adkim=s |
390390
| aspf | Alignment mode for SPF | aspf=r |
391391
392+
### Extra email hardening checks (HackTricks DNS/Domain auditor)
393+
394+
The HackTricks Domain/DNS auditor now includes extra SMTP/email-control checks.
395+
Use this to manually validate findings and explain impact in reports.
396+
397+
#### DMARC alignment hardening (`adkim`, `aspf`, `fo`)
398+
399+
**What it checks**
400+
- Strict alignment (`adkim=s`, `aspf=s`)
401+
- Presence of forensic policy (`fo=...`)
402+
403+
**How to check**
404+
```bash
405+
dig _dmarc.example.com TXT +short
406+
```
407+
408+
**Impact**
409+
- Relaxed alignment or missing forensic controls can reduce spoofing resistance and forensic visibility.
410+
411+
**Attacker abuse**
412+
- Attackers can craft borderline-aligned campaigns that pass weaker DMARC configurations more often.
413+
414+
#### MX STARTTLS transport security
415+
416+
**What it checks**
417+
- Whether MXs advertise `STARTTLS`
418+
- Whether STARTTLS negotiation works and certificates validate
419+
420+
**How to check**
421+
```bash
422+
dig MX example.com +short
423+
openssl s_client -starttls smtp -connect mx1.example.com:25 -servername mx1.example.com
424+
```
425+
426+
**Impact**
427+
- Missing/broken STARTTLS increases plaintext transport exposure and downgrade risk.
428+
429+
**Attacker abuse**
430+
- Active network attackers can intercept/modify SMTP traffic more easily if STARTTLS is absent or misconfigured.
431+
432+
#### MTA-STS policy consistency
433+
434+
**What it checks**
435+
- `_mta-sts` TXT exists and policy file is reachable
436+
- Policy fields (`version`, `mode`, `max_age`) are valid
437+
- `mx:` patterns actually match active MX hosts
438+
439+
**How to check**
440+
```bash
441+
dig TXT _mta-sts.example.com +short
442+
curl -i https://mta-sts.example.com/.well-known/mta-sts.txt
443+
dig MX example.com +short
444+
```
445+
446+
**Impact**
447+
- Broken or inconsistent policy gives a false sense of protection and weakens SMTP TLS enforcement.
448+
449+
**Attacker abuse**
450+
- Downgrade/MITM opportunities increase when policy hosts or MX matching are misconfigured.
451+
452+
#### TLS-RPT destination validation
453+
454+
**What it checks**
455+
- `rua=` exists and uses valid `mailto:` or `https:` destinations
456+
- Basic reachability hints of report destinations
457+
458+
**How to check**
459+
```bash
460+
dig TXT _smtp._tls.example.com +short
461+
```
462+
463+
**Impact**
464+
- Broken report sinks = no visibility into SMTP TLS failures.
465+
466+
**Attacker abuse**
467+
- TLS downgrade and delivery issues can remain unnoticed longer.
468+
469+
#### BIMI full validation (logo + VMC URL)
470+
471+
**What it checks**
472+
- `l=` logo URL reachable and actually serves SVG content
473+
- `a=` VMC URL uses HTTPS and is reachable
474+
475+
**How to check**
476+
```bash
477+
dig TXT default._bimi.example.com +short
478+
curl -I https://logo.example.com/brand.svg
479+
curl -I https://example.com/vmc.pem
480+
```
481+
482+
**Impact**
483+
- Brand-trust controls can silently fail, reducing anti-phishing posture in supporting clients.
484+
485+
**Attacker abuse**
486+
- Poorly validated BIMI deployments can be leveraged in social engineering narratives around "trusted sender" expectations.
487+
488+
#### Email service exposure / autodiscover over HTTP
489+
490+
**What it checks**
491+
- Presence of common email service subdomains (`autodiscover`, `imap`, `pop`, `smtp`, `mail`, `webmail`)
492+
- Whether autodiscover endpoint is reachable over plaintext HTTP
493+
494+
**How to check**
495+
```bash
496+
for h in autodiscover imap pop smtp mail webmail; do dig +short ${h}.example.com A; done
497+
curl -i http://autodiscover.example.com/autodiscover/autodiscover.xml
498+
```
499+
500+
**Impact**
501+
- Increases exposed attack surface and can enable weak-client/legacy downgrade paths.
502+
503+
**Attacker abuse**
504+
- Autodiscover abuse and credential-harvest workflows become easier when plaintext or weak redirects are accepted.
505+
392506
### **What about Subdomains?**
393507
394508
**From** [**here**](https://serverfault.com/questions/322949/do-spf-records-for-primary-domain-apply-to-subdomains)**.**\
@@ -630,4 +744,3 @@ Entry_8:
630744
```
631745
632746
{{#include ../../banners/hacktricks-training.md}}
633-

0 commit comments

Comments
 (0)