-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths7aba.sh
More file actions
executable file
·427 lines (362 loc) · 15 KB
/
s7aba.sh
File metadata and controls
executable file
·427 lines (362 loc) · 15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
#!/usr/bin/env bash
#
# ███████╗███████╗██╗ ██╗ █████╗ ██████╗ █████╗
# ██╔════╝╚════██║██║ ██║██╔══██╗██╔══██╗██╔══██╗
# ███████╗ ██╔╝███████║███████║██████╔╝███████║
# ╚════██║ ██╔╝ ╚════██║██╔══██║██╔══██╗██╔══██║
# ███████║ ██║ ██║██║ ██║██████╔╝██║ ██║
# ╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝
#
# S7aba - Cloud Privilege Escalation & Post-Exploitation Framework
# Author: Ali AlEnezi (@SiteQ8)
# License: MIT
# Version: 1.0.0
#
# FOR AUTHORIZED SECURITY TESTING ONLY
# Usage of this tool for attacking targets without prior mutual consent
# is illegal. The author assumes no liability.
#
set -euo pipefail
# ─── Constants ───────────────────────────────────────────────────────────────
readonly VERSION="1.0.0"
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly MODULES_DIR="${SCRIPT_DIR}/src/modules"
readonly LIB_DIR="${SCRIPT_DIR}/src/lib"
readonly LOG_DIR="${SCRIPT_DIR}/logs"
readonly REPORT_DIR="${SCRIPT_DIR}/reports"
readonly TIMESTAMP="$(date +%Y%m%d_%H%M%S)"
# ─── Colors ──────────────────────────────────────────────────────────────────
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
readonly YELLOW='\033[1;33m'
readonly BLUE='\033[0;34m'
readonly MAGENTA='\033[0;35m'
readonly CYAN='\033[0;36m'
readonly WHITE='\033[1;37m'
readonly DIM='\033[2m'
readonly BOLD='\033[1m'
readonly RESET='\033[0m'
# ─── Global State ────────────────────────────────────────────────────────────
CLOUD_PROVIDER=""
CURRENT_USER=""
CURRENT_ROLE=""
REGION=""
VERBOSE=0
DRY_RUN=0
OUTPUT_FORMAT="text"
REPORT_FILE=""
# ─── Library Loading ─────────────────────────────────────────────────────────
source_lib() {
local lib_file="${LIB_DIR}/$1"
if [[ -f "$lib_file" ]]; then
source "$lib_file"
else
echo -e "${RED}[!] Missing library: $1${RESET}" >&2
exit 1
fi
}
source_lib "utils.sh"
source_lib "logger.sh"
source_lib "cloud_detect.sh"
# ─── Banner ──────────────────────────────────────────────────────────────────
show_banner() {
echo -e "${CYAN}"
cat << 'BANNER'
██████╗ ██████╗ █████╗ ██████╗ █████╗
██╔════╝╚════██╗██╔══██╗██╔══██╗██╔══██╗
███████╗ ██╔╝███████║██████╔╝███████║
╚════██║ ██╔╝ ╚════██║██╔══██╗██╔══██║
███████║ ██║ ██║██████╔╝██║ ██║
╚══════╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝
BANNER
echo -e "${WHITE} Cloud Privilege Escalation & Post-Exploitation${RESET}"
echo -e "${DIM} v${VERSION} | @SiteQ8 | For authorized testing only${RESET}"
echo ""
}
# ─── Help Menu ───────────────────────────────────────────────────────────────
show_help() {
show_banner
echo -e "${BOLD}USAGE${RESET}"
echo -e " ./s7aba.sh [OPTIONS] <COMMAND> [ARGS]"
echo ""
echo -e "${BOLD}COMMANDS${RESET}"
echo -e " ${GREEN}recon${RESET} Enumerate cloud environment & permissions"
echo -e " ${GREEN}privesc${RESET} Identify & exploit privilege escalation paths"
echo -e " ${GREEN}persist${RESET} Establish persistence mechanisms"
echo -e " ${GREEN}exfil${RESET} Data discovery & exfiltration techniques"
echo -e " ${GREEN}lateral${RESET} Lateral movement across cloud services"
echo -e " ${GREEN}cleanup${RESET} Remove artifacts & cover tracks"
echo -e " ${GREEN}report${RESET} Generate assessment report"
echo -e " ${GREEN}interactive${RESET} Launch interactive TUI mode"
echo ""
echo -e "${BOLD}OPTIONS${RESET}"
echo -e " ${YELLOW}-p, --provider${RESET} Target cloud (aws|azure|gcp|k8s|multi)"
echo -e " ${YELLOW}-r, --region${RESET} Target region"
echo -e " ${YELLOW}-o, --output${RESET} Output format (text|json|html|pdf)"
echo -e " ${YELLOW}-v, --verbose${RESET} Verbose output"
echo -e " ${YELLOW}-d, --dry-run${RESET} Simulate without executing"
echo -e " ${YELLOW}-h, --help${RESET} Show this help"
echo -e " ${YELLOW}--version${RESET} Show version"
echo ""
echo -e "${BOLD}EXAMPLES${RESET}"
echo -e " ${DIM}# Auto-detect cloud & enumerate permissions${RESET}"
echo -e " ./s7aba.sh recon"
echo ""
echo -e " ${DIM}# AWS privilege escalation scan${RESET}"
echo -e " ./s7aba.sh -p aws privesc"
echo ""
echo -e " ${DIM}# Kubernetes lateral movement (dry-run)${RESET}"
echo -e " ./s7aba.sh -p k8s -d lateral"
echo ""
echo -e " ${DIM}# Generate HTML report${RESET}"
echo -e " ./s7aba.sh -o html report"
echo ""
}
# ─── Version ─────────────────────────────────────────────────────────────────
show_version() {
echo -e "S7aba v${VERSION}"
}
# ─── Prerequisite Check ─────────────────────────────────────────────────────
check_prerequisites() {
local missing=()
local tools=("curl" "jq" "grep" "awk" "sed" "base64")
for tool in "${tools[@]}"; do
if ! command -v "$tool" &>/dev/null; then
missing+=("$tool")
fi
done
if [[ ${#missing[@]} -gt 0 ]]; then
log_error "Missing required tools: ${missing[*]}"
echo -e "${YELLOW}[*] Install with: sudo apt-get install ${missing[*]}${RESET}"
exit 1
fi
# Check cloud CLI tools
local cloud_tools=()
command -v aws &>/dev/null && cloud_tools+=("aws")
command -v az &>/dev/null && cloud_tools+=("azure")
command -v gcloud &>/dev/null && cloud_tools+=("gcp")
command -v kubectl &>/dev/null && cloud_tools+=("k8s")
if [[ ${#cloud_tools[@]} -eq 0 ]]; then
log_warn "No cloud CLI tools detected. Install at least one: aws-cli, azure-cli, gcloud, kubectl"
else
log_info "Detected cloud tools: ${cloud_tools[*]}"
fi
}
# ─── Init ────────────────────────────────────────────────────────────────────
init() {
mkdir -p "$LOG_DIR" "$REPORT_DIR"
REPORT_FILE="${REPORT_DIR}/s7aba_report_${TIMESTAMP}.${OUTPUT_FORMAT}"
log_init "${LOG_DIR}/s7aba_${TIMESTAMP}.log"
check_prerequisites
if [[ -z "$CLOUD_PROVIDER" ]]; then
log_info "Auto-detecting cloud environment..."
CLOUD_PROVIDER=$(detect_cloud_provider)
log_success "Detected provider: ${CLOUD_PROVIDER}"
fi
}
# ─── Command Dispatch ────────────────────────────────────────────────────────
cmd_recon() {
log_section "RECONNAISSANCE"
local module="${MODULES_DIR}/recon_${CLOUD_PROVIDER}.sh"
if [[ ! -f "$module" ]]; then
log_error "Recon module not found for provider: ${CLOUD_PROVIDER}"
exit 1
fi
source "$module"
log_step "Enumerating identity & credentials"
enum_identity
log_step "Mapping IAM permissions"
enum_permissions
log_step "Discovering services & resources"
enum_services
log_step "Checking network configuration"
enum_network
log_step "Scanning for secrets & sensitive data"
enum_secrets
log_success "Recon complete. Results saved to ${LOG_DIR}/"
}
cmd_privesc() {
log_section "PRIVILEGE ESCALATION"
local module="${MODULES_DIR}/privesc_${CLOUD_PROVIDER}.sh"
if [[ ! -f "$module" ]]; then
log_error "Privesc module not found for provider: ${CLOUD_PROVIDER}"
exit 1
fi
source "$module"
log_step "Analyzing current permissions"
analyze_permissions
log_step "Identifying escalation paths"
local paths
paths=$(find_escalation_paths)
if [[ -z "$paths" ]]; then
log_warn "No privilege escalation paths found"
return
fi
echo -e "\n${BOLD}Discovered Escalation Paths:${RESET}\n"
echo "$paths" | while IFS='|' read -r risk method description; do
local color=$GREEN
[[ "$risk" == "HIGH" ]] && color=$RED
[[ "$risk" == "MEDIUM" ]] && color=$YELLOW
echo -e " ${color}[${risk}]${RESET} ${BOLD}${method}${RESET}"
echo -e " ${DIM}${description}${RESET}"
done
if [[ $DRY_RUN -eq 0 ]]; then
echo ""
read -rp "$(echo -e "${YELLOW}[?] Attempt exploitation? [y/N]: ${RESET}")" confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
exploit_paths "$paths"
fi
else
log_info "Dry-run mode: skipping exploitation"
fi
}
cmd_persist() {
log_section "PERSISTENCE"
local module="${MODULES_DIR}/persist_${CLOUD_PROVIDER}.sh"
[[ ! -f "$module" ]] && { log_error "Module not found: persist_${CLOUD_PROVIDER}"; exit 1; }
source "$module"
log_step "Evaluating persistence techniques"
enumerate_persistence_options
log_step "Deploying persistence mechanism"
if [[ $DRY_RUN -eq 1 ]]; then
log_info "Dry-run: would deploy persistence"
else
deploy_persistence
fi
}
cmd_exfil() {
log_section "DATA EXFILTRATION"
local module="${MODULES_DIR}/exfil_${CLOUD_PROVIDER}.sh"
[[ ! -f "$module" ]] && { log_error "Module not found: exfil_${CLOUD_PROVIDER}"; exit 1; }
source "$module"
log_step "Discovering sensitive data stores"
discover_data_stores
log_step "Classifying data sensitivity"
classify_data
log_step "Evaluating exfiltration channels"
evaluate_exfil_channels
}
cmd_lateral() {
log_section "LATERAL MOVEMENT"
local module="${MODULES_DIR}/lateral_${CLOUD_PROVIDER}.sh"
[[ ! -f "$module" ]] && { log_error "Module not found: lateral_${CLOUD_PROVIDER}"; exit 1; }
source "$module"
log_step "Mapping trust relationships"
map_trust_relationships
log_step "Identifying cross-service pivots"
find_pivot_points
log_step "Enumerating reachable targets"
enumerate_targets
}
cmd_cleanup() {
log_section "CLEANUP"
local module="${MODULES_DIR}/cleanup_${CLOUD_PROVIDER}.sh"
[[ ! -f "$module" ]] && { log_error "Module not found: cleanup_${CLOUD_PROVIDER}"; exit 1; }
source "$module"
log_step "Identifying artifacts"
identify_artifacts
log_step "Removing traces"
if [[ $DRY_RUN -eq 1 ]]; then
log_info "Dry-run: would remove artifacts"
else
remove_artifacts
fi
log_success "Cleanup complete"
}
cmd_report() {
log_section "REPORT GENERATION"
log_step "Aggregating findings"
local report_module="${MODULES_DIR}/report.sh"
[[ ! -f "$report_module" ]] && { log_error "Report module not found"; exit 1; }
source "$report_module"
generate_report "$OUTPUT_FORMAT" "$REPORT_FILE"
log_success "Report saved to: ${REPORT_FILE}"
}
cmd_interactive() {
log_section "INTERACTIVE MODE"
show_banner
while true; do
echo -e "\n${CYAN}┌──(${WHITE}s7aba${CYAN})─[${GREEN}${CLOUD_PROVIDER:-unknown}${CYAN}]"
echo -ne "${CYAN}└─${WHITE}\$ ${RESET}"
read -r input
case "$input" in
recon) cmd_recon ;;
privesc) cmd_privesc ;;
persist) cmd_persist ;;
exfil) cmd_exfil ;;
lateral) cmd_lateral ;;
cleanup) cmd_cleanup ;;
report) cmd_report ;;
help|?) show_help ;;
exit|quit) echo -e "${GREEN}[+] Exiting S7aba. Stay ethical.${RESET}"; exit 0 ;;
"") continue ;;
*) echo -e "${RED}[!] Unknown command: ${input}. Type 'help' for usage.${RESET}" ;;
esac
done
}
# ─── Argument Parsing ────────────────────────────────────────────────────────
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
-p|--provider)
CLOUD_PROVIDER="$2"
shift 2
;;
-r|--region)
REGION="$2"
shift 2
;;
-o|--output)
OUTPUT_FORMAT="$2"
shift 2
;;
-v|--verbose)
VERBOSE=1
shift
;;
-d|--dry-run)
DRY_RUN=1
shift
;;
-h|--help)
show_help
exit 0
;;
--version)
show_version
exit 0
;;
recon|privesc|persist|exfil|lateral|cleanup|report|interactive)
COMMAND="$1"
shift
;;
*)
echo -e "${RED}[!] Unknown option: $1${RESET}"
show_help
exit 1
;;
esac
done
}
# ─── Main ────────────────────────────────────────────────────────────────────
main() {
local COMMAND=""
parse_args "$@"
if [[ -z "$COMMAND" ]]; then
show_help
exit 0
fi
show_banner
init
case "$COMMAND" in
recon) cmd_recon ;;
privesc) cmd_privesc ;;
persist) cmd_persist ;;
exfil) cmd_exfil ;;
lateral) cmd_lateral ;;
cleanup) cmd_cleanup ;;
report) cmd_report ;;
interactive) cmd_interactive ;;
esac
}
main "$@"