Skip to content

Commit 129521a

Browse files
authored
Merge pull request #30 from h0tak88r/testing
Testing
2 parents ff0edca + 9662abc commit 129521a

87 files changed

Lines changed: 3180 additions & 756 deletions

Some content is hidden

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

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# --- Builder stage: install Go-based security tools and build AutoAR bot ---
2-
FROM golang:1.26-bookworm AS builder
2+
FROM golang:1.25-bookworm AS builder
33

44
WORKDIR /app
55

@@ -78,6 +78,7 @@ RUN curl -L https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts
7878
# Copy minimal application configuration and assets (source not required at runtime)
7979
COPY regexes/ ./regexes/
8080
COPY templates/ ./templates/
81+
COPY web/static/data/ ./web/static/data/
8182
COPY autoar.sample.yaml ./
8283
COPY env.example ./
8384

README.md

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,35 @@ Results are automatically uploaded to **Cloudflare R2 storage** and linked direc
2121
![Dashboard](image.png)
2222
---
2323

24-
## Feature Highlights
24+
## Feature Highlights
2525

2626

2727
| Category | What AutoAR Does |
2828
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
29-
| 🌐 **Subdomains** | Enumerate using 15+ sources: Subfinder, CertSpotter, SecurityTrails, Chaos, crt.sh, OTX, VirusTotal, and more |
30-
| 🔍 **Live Hosts** | Detect alive hosts using httpx with follow-redirects and status detection |
31-
| 🕳️ **DNS Takeovers** | Detect CNAME, NS, Azure/AWS cloud, DNSReaper, dangling-IP, and **CF-1016 Cloudflare dangling record** vulnerabilities |
32-
| 💥 **Nuclei Scanning** | Automated vulnerability scanning using Nuclei templates with rate limiting |
33-
| 🧠 **Zero-Days** | Smart scan configured for detected tech stacks — finds active CVEs |
34-
| ☁️ **S3 Buckets** | Enumerate and scan AWS S3 buckets for exposure and misconfig |
35-
| 🔗 **JavaScript** | Extract secrets, API endpoints, auth tokens from JS files |
36-
| 🐙 **GitHub Recon** | Org-level and repo-level scanning for secrets, dependency confusion |
37-
| 📱 **APK Auditor** | Browser-based Android analysis: DEX decompiler, manifest + cert parsing, tracker detection, MASVS mapping, and regex-driven findings with APX secret patterns. (Based on [apkauditor](https://github.com/thecybersandeep/apkauditor) by @thecybersandeep) |
38-
| 🔒 **MITM Patch** | Fetch any Android app by Package ID → auto-patch `network_security_config.xml` → re-sign → R2 download link in one click |
39-
| 📱 **IPA Auditor** | Browser-based iOS IPA analysis: plist + Mach-O inspection, binary strings extraction, and findings tab powered by 200+ regex signatures plus MASVS-style rules. (Based on [ipaauditor](https://github.com/thecybersandeep/ipaauditor) by @thecybersandeep) |
40-
| 🖥️ **ADB Auditor** | Browser-based ADB security tool: USB device inspection, app enumeration, logcat tailing, file pull, activity launching. (Based on [adbauditor](https://github.com/thecybersandeep/adbauditor) by @thecybersandeep) |
41-
| ⚙️ **Misconfigs** | 100+ service misconfiguration checks |
42-
| 🏴‍☠️ **BB Scope** | Fetch scope from HackerOne, Bugcrowd, Intigriti, YesWeHack (token), Immunefi — CLI & **dashboard Targets page** |
43-
| 🔄 **Monitoring** | Subdomain + URL change monitoring daemon with Discord alerts & DB history |
44-
| 🤖 **AI Agent** | Full AI hunt loop (CLI + Discord `/ai` & `/brain`) — powered by **z-ai/glm-4.5-air:free via OpenRouter** — zero cost required |
45-
| 📤 **R2 Storage** | Auto-upload every non-empty result file to Cloudflare R2 and print the public URL |
46-
| 🔔 **Smart Alerts** | Rich Discord notifications for zero-findings scans — no more empty files or spam |
47-
| 🖥️ **Web dashboard** | **v4.1+** — Stats, scans, domains, monitors, R2 browser, Targets, APK/IPA/ADB Auditors, MITM remote scan, CF-1016 findings |
29+
| **Subdomains** | Enumerate using 15+ sources: Subfinder, CertSpotter, SecurityTrails, Chaos, crt.sh, OTX, VirusTotal, and more |
30+
| **Live Hosts** | Detect alive hosts using httpx with follow-redirects and status detection |
31+
| **DNS Takeovers** | Detect CNAME, NS, Azure/AWS cloud, DNSReaper, dangling-IP, and **CF-1016 Cloudflare dangling record** vulnerabilities |
32+
| **Nuclei Scanning** | Automated vulnerability scanning using Nuclei templates with rate limiting |
33+
| **Zero-Days** | Smart scan configured for detected tech stacks — finds active CVEs |
34+
| **S3 Buckets** | Enumerate and scan AWS S3 buckets for exposure and misconfig |
35+
| **JavaScript** | Extract secrets, API endpoints, auth tokens from JS files |
36+
| **GitHub Recon** | Org-level and repo-level scanning for secrets, dependency confusion |
37+
| **APK Auditor** | Browser-based Android analysis: DEX decompiler, manifest + cert parsing, tracker detection, MASVS mapping, and regex-driven findings with APX secret patterns. (Based on [apkauditor](https://github.com/thecybersandeep/apkauditor) by @thecybersandeep) |
38+
| **MITM Patch** | Fetch any Android app by Package ID → auto-patch `network_security_config.xml` → re-sign → R2 download link in one click |
39+
| **IPA Auditor** | Browser-based iOS IPA analysis: plist + Mach-O inspection, binary strings extraction, and findings tab powered by 200+ regex signatures plus MASVS-style rules. (Based on [ipaauditor](https://github.com/thecybersandeep/ipaauditor) by @thecybersandeep) |
40+
| **ADB Auditor** | Browser-based ADB security tool: USB device inspection, app enumeration, logcat tailing, file pull, activity launching. (Based on [adbauditor](https://github.com/thecybersandeep/adbauditor) by @thecybersandeep) |
41+
| **Misconfigs** | 100+ service misconfiguration checks |
42+
| **BB Scope** | Fetch scope from HackerOne, Bugcrowd, Intigriti, YesWeHack (token), Immunefi — CLI & **dashboard Targets page** |
43+
| **Monitoring** | Subdomain + URL change monitoring daemon with Discord alerts & DB history |
44+
| **AI Agent** | Full AI hunt loop (CLI + Discord `/ai` & `/brain`) — powered by **z-ai/glm-4.5-air:free via OpenRouter** — zero cost required |
45+
| **R2 Storage** | Auto-upload every non-empty result file to Cloudflare R2 and print the public URL |
46+
| **Smart Alerts** | Rich Discord notifications for zero-findings scans — no more empty files or spam |
47+
| **Web dashboard** | **v4.1+** — Stats, scans, domains, monitors, R2 browser, Targets, APK/IPA/ADB Auditors, MITM remote scan, CF-1016 findings |
4848

4949

5050
---
5151

52-
## 🗂️ Complete Command Reference
52+
## Complete Command Reference
5353

5454
### Workflows (Start Here)
5555

@@ -236,8 +236,8 @@ What happens:
236236
2. *(Optional)* Patches `network_security_config.xml` to trust user-installed CAs + disables certificate pinning
237237
3. Re-signs with `uber-apk-signer` and uploads the patched APK to R2
238238
4. Shows a **download panel** in the Auditor UI with direct R2 links for:
239-
- 📦 Original APK
240-
- 🔒 MITM Patched APK (if requested)
239+
- Original APK
240+
- MITM Patched APK (if requested)
241241
5. Automatically loads the APK into the browser auditor for analysis
242242

243243
> **Scan records from APK Auditor are hidden from the main Scans dashboard** — they exist only within the Auditor context.
@@ -297,13 +297,13 @@ Options:
297297
-o <output> Save output to a file
298298
```
299299

300-
**Dashboard — 🎯 Targets page:**
300+
**Dashboard — Targets page:**
301301

302302
The web dashboard includes a dedicated **Targets** page (sidebar → Targets) that:
303303
- Shows color-coded cards for each platform with credential status
304304
- Lets you paste credentials or relies on env vars (`H1_TOKEN`, `BUGCROWD_TOKEN`, `YWH_TOKEN`, `INTIGRITI_TOKEN`)
305305
- Fetches all in-scope root domains with one click
306-
- Provides per-domain **+ Add** (saves to Domains DB) and ** Scan** (opens new scan)
306+
- Provides per-domain **+ Add** (saves to Domains DB) and **> Scan** (opens new scan)
307307
- **+ Add All** saves all domains in one bulk request
308308
- **Copy List** copies to clipboard (works on both HTTP and HTTPS)
309309

@@ -350,7 +350,7 @@ autoar status [--json]
350350

351351
---
352352

353-
## 🤖 AI-Driven Security Framework — Free for Everyone
353+
## AI-Driven Security Framework — Free for Everyone
354354

355355
As of the latest release, AutoAR's AI engine runs on `**[stepfun/step-3.5-flash:free](https://openrouter.ai/stepfun/step-3.5-flash:free)**` via [OpenRouter](https://openrouter.ai). This is a **completely free model** — no credits, no billing required.
356356

@@ -415,7 +415,7 @@ autoar both Start Discord bot + API server simultaneously
415415

416416
---
417417

418-
## 🛠️ Installation
418+
## Installation
419419

420420
### Option 1 — Docker (Primary & Recommended)
421421

@@ -475,7 +475,7 @@ go install github.com/h0tak88r/AutoAR/cmd/autoar@latest
475475
476476
---
477477
478-
## ⚙️ Configuration
478+
## Configuration
479479
480480
Copy `.env.example` to `.env` and fill in your values:
481481
@@ -558,7 +558,7 @@ H1_API_KEY=... # HackerOne
558558
INTEGRITI_API_KEY=... # Intigriti
559559
560560
# AI analysis — only ONE key is needed
561-
# Recommended: OpenRouter free tier (no credit card required)
561+
# Recommended: OpenRouter free tier (no credit card required)
562562
# Sign up at https://openrouter.ai · Uses stepfun/step-3.5-flash:free automatically
563563
OPENROUTER_API_KEY=... # Powers /ai, /brain, and `autoar agent` — completely free
564564
@@ -588,7 +588,7 @@ AUTOAR_TIMEOUT_NUCLEI=0
588588

589589
---
590590

591-
## 🚀 Quick Start (Docker)
591+
## Quick Start (Docker)
592592

593593
```bash
594594
# 1. Setup
@@ -607,7 +607,7 @@ docker compose run --rm autoar-api domain run -d example.com
607607

608608
---
609609

610-
## 📂 Results Directory Structure
610+
## Results Directory Structure
611611

612612
All scan results are saved to `./new-results/` and automatically uploaded to R2 if configured:
613613

@@ -637,13 +637,13 @@ new-results/
637637
When **R2 is enabled**, each file is uploaded immediately after writing and the URL is printed:
638638

639639
```
640-
🔗 R2 Result: new-results/example.com/subs/subdomains.txt
640+
R2 Result: new-results/example.com/subs/subdomains.txt
641641
URL: https://pub-xxxx.r2.dev/new-results/example.com/subs/subdomains.txt
642642
```
643643

644644
---
645645

646-
## 🤖 CoPaw AI Integration
646+
## CoPaw AI Integration
647647

648648
AutoAR is designed to work seamlessly with **CoPaw** AI assistant, enabling natural language control of your entire recon pipeline:
649649

@@ -657,9 +657,9 @@ See the [CoPaw AutoAR Skill documentation](/blob/main/docs/copaw-skill.md) for f
657657

658658
---
659659

660-
## 🐳 Docker & Compose Deep Dive
660+
## Docker & Compose Deep Dive
661661

662-
### 🏗️ Architecture & Internal Structure (v4.1+)
662+
### Architecture & Internal Structure (v4.1+)
663663

664664
AutoAR follows a strictly decoupled, package-based architecture designed for enterprise scaling and clean dependency management:
665665

@@ -728,7 +728,7 @@ OPENROUTER_API_KEY=...
728728

729729
---
730730

731-
## 🗄️ Database
731+
## Database
732732

733733
AutoAR supports two databases:
734734

@@ -757,7 +757,7 @@ DB_HOST=./bughunt.db
757757

758758
---
759759

760-
## 🔧 Troubleshooting
760+
## Troubleshooting
761761

762762
### No Terminal Logs?
763763

@@ -804,7 +804,7 @@ For PostgreSQL, ensure:
804804

805805
---
806806

807-
## 🏷️ GitHub release (tag → CI)
807+
## GitHub release (tag → CI)
808808

809809
Versions are defined once in `[internal/version/version.go](internal/version/version.go)` (`Version`, no `v` prefix). To publish **v4.2.0**:
810810

@@ -820,7 +820,7 @@ You need a Git remote with push access (HTTPS + token or SSH). No manual “Crea
820820

821821
---
822822

823-
## 🤝 Contributing
823+
## Contributing
824824

825825
Contributions are welcome! Please:
826826

@@ -831,21 +831,21 @@ Contributions are welcome! Please:
831831

832832
---
833833

834-
## ⚠️ Legal Disclaimer
834+
## Legal Disclaimer
835835

836836
AutoAR is intended for **authorized security testing only**. Only use it on targets where you have explicit written permission, or on bug bounty programs where the target is in-scope. Unauthorized scanning of systems you do not own is illegal.
837837

838838
The authors of AutoAR assume no liability for misuse of this tool.
839839

840840
---
841841

842-
## 📄 License
842+
## License
843843

844844
MIT License — see [LICENSE](LICENSE) for details.
845845

846846
---
847847

848848

849849

850-
Built with ❤️ for the bug bounty community · [GitHub](https://github.com/h0tak88r/AutoAR)
850+
Built with for the bug bounty community · [GitHub](https://github.com/h0tak88r/AutoAR)
851851

entrypoint

3 KB
Binary file not shown.

internal/api/api.go

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,37 @@ var (
5151
resourceLimitsOnce sync.Once
5252
)
5353

54+
// safeEnvPrefixes lists environment variable prefixes that are safe to
55+
// pass through to child processes. Everything else is stripped to
56+
// prevent leaking secrets (API keys, tokens, passwords) via the
57+
// environment.
58+
var safeEnvPrefixes = []string{
59+
"HOME=", "USER=", "LOGNAME=", "PATH=", "PWD=", "SHELL=", "TERM=", "LANG=", "LC_", "TZ=",
60+
"GOPATH=", "GOROOT=", "GOPROXY=", "GOMODCACHE=", "GOFLAGS=",
61+
"AUTOAR_", "DOCKER_", "KUBERNETES_",
62+
"SSL_CERT_FILE=", "SSL_CERT_DIR=",
63+
"HTTP_PROXY=", "HTTPS_PROXY=", "NO_PROXY=", "http_proxy=", "https_proxy=", "no_proxy=",
64+
}
65+
66+
// sanitizeEnv filters os.Environ() to only keep safe variables and appends
67+
// the given key=value pair(s). This prevents secrets from leaking into child
68+
// processes.
69+
func sanitizeEnv(parentEnv []string, extra ...string) []string {
70+
out := make([]string, 0, len(safeEnvPrefixes)+len(extra))
71+
for _, ev := range parentEnv {
72+
for _, prefix := range safeEnvPrefixes {
73+
if len(ev) >= len(prefix) && ev[:len(prefix)] == prefix {
74+
out = append(out, ev)
75+
break
76+
}
77+
}
78+
}
79+
for _, e := range extra {
80+
out = append(out, e)
81+
}
82+
return out
83+
}
84+
5485
func scanResultSizeBytes(r *ScanResult) int64 {
5586
if r == nil {
5687
return 0
@@ -470,6 +501,9 @@ func SetupAPI() *gin.Engine {
470501
r.GET("/scans", serveDashboardUI)
471502
r.GET("/scans/*filepath", serveDashboardUI)
472503

504+
// Static data files (JSON reference tables)
505+
r.GET("/static/data/*filepath", serveStaticData)
506+
473507
// Public: SPA reads these before login (no JWT).
474508
r.GET("/api/config", apiConfigHandler)
475509
r.POST("/api/settings", auth, apiUpdateSettingsHandler)
@@ -1394,9 +1428,7 @@ func executeScan(scanID string, command []string, scanType string) {
13941428
utils.SendScanNotification("start", scanID, target, scanType, "running", 0)
13951429

13961430
cmd := exec.Command(command[0], command[1:]...)
1397-
cmd.Env = append(os.Environ(),
1398-
fmt.Sprintf("AUTOAR_CURRENT_SCAN_ID=%s", scanID),
1399-
)
1431+
cmd.Env = sanitizeEnv(os.Environ(), "AUTOAR_CURRENT_SCAN_ID", scanID)
14001432
// Put the child in its own process group so that SIGTERM/SIGKILL can be
14011433
// sent to the whole tree (not just the direct child) on cancel.
14021434
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}

internal/api/local_auth.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
11
package api
22

33
import (
4+
"crypto/rand"
5+
"encoding/hex"
46
"fmt"
57
"net/http"
68
"os"
79
"strings"
10+
"sync"
811
"time"
912

1013
"github.com/gin-gonic/gin"
1114
"github.com/golang-jwt/jwt/v5"
1215
)
1316

17+
var (
18+
localAuthSecret []byte
19+
localAuthSecretOnce sync.Once
20+
)
21+
1422
// localAuthJWTSecret returns the HS256 signing secret for local JWTs.
1523
// Uses AUTOAR_JWT_SECRET; falls back to DASHBOARD_PASSWORD so a single
1624
// credential env-var is sufficient for simple setups.
25+
// If neither is set, generates a random 32-byte key that lasts for the
26+
// lifetime of the process.
1727
func localAuthJWTSecret() []byte {
1828
if s := strings.TrimSpace(os.Getenv("AUTOAR_JWT_SECRET")); s != "" {
1929
return []byte(s)
2030
}
21-
// Fallback — combined so it's hard to brute-force even with known password.
2231
pw := strings.TrimSpace(os.Getenv("DASHBOARD_PASSWORD"))
2332
if pw != "" {
2433
return []byte("autoar-local-auth-" + pw)
2534
}
26-
return []byte("autoar-local-auth-insecure-default")
35+
localAuthSecretOnce.Do(func() {
36+
key := make([]byte, 32)
37+
if _, err := rand.Read(key); err != nil {
38+
panic("failed to generate local auth secret: " + err.Error())
39+
}
40+
localAuthSecret = []byte(hex.EncodeToString(key))
41+
})
42+
return localAuthSecret
2743
}
2844

2945
// localAuthEnabled returns true when DASHBOARD_USER and DASHBOARD_PASSWORD are set.

internal/api/scan_runner.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ func RunScanInProcess(scanID, scanType, target string, fn func() error) {
189189

190190
// Give SSE clients a moment to drain, then close the bus for this scan.
191191
go func() {
192-
time.Sleep(5 * time.Second)
193-
globalLogBus.Close(scanID)
192+
select {
193+
case <-time.After(5 * time.Second):
194+
globalLogBus.Close(scanID)
195+
}
194196
}()
195197
}

internal/api/scans.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,15 @@ func CancelScanByID(id string) error {
8383
_ = scan.ExecCmd.Process.Signal(syscall.SIGTERM)
8484
}
8585
go func() {
86-
time.Sleep(2 * time.Second)
87-
if pgidErr == nil {
88-
_ = syscall.Kill(-pgid, syscall.SIGKILL)
89-
} else {
90-
_ = scan.ExecCmd.Process.Kill()
86+
timer := time.NewTimer(2 * time.Second)
87+
defer timer.Stop()
88+
select {
89+
case <-timer.C:
90+
if pgidErr == nil {
91+
_ = syscall.Kill(-pgid, syscall.SIGKILL)
92+
} else {
93+
_ = scan.ExecCmd.Process.Kill()
94+
}
9195
}
9296
}()
9397
}

0 commit comments

Comments
 (0)