Repo Browser

bashcards/bashcards-kali
cards/131053331811--chamber-of-permissions/assets/raw.sh
#!/usr/bin/env bash
(return 0 2>/dev/null)&&{ echo 'Do not source'; return 2; };set -euo pipefail;trap 'q' INT TERM;E=$'\033[38;5;46m';R=$'\033[0m';L(){ printf -- '-%.0s' $(seq 1 "$1"); };b(){ a=("$@");printf "${E}+";L 60;printf "+${R}\n";for l in "${a[@]}";do echo "$l"|fold -s -w 60|while IFS= read -r x;do printf "${E}|${R} %-58s ${E}|${R}\n" "$x";done;done;printf "${E}+";L 60;printf "+${R}\n";};pause(){ echo;read -n1 -s -r -p "SCAN TO CONTINUE...";};select_file(){ clear;b "SELECT TARGET FILE FOR PERMISSION CONTROL";mapfile -t files < <(find . -maxdepth 1 -type f);for i in "${!files[@]}";do printf "${E}|${R} %2s - %-53s ${E}|${R}\n" "$((i+1))" "${files[$i]}";done;printf "${E}+";L 60;printf "+${R}\n";read -r -p "ENTER NUMBER: " i;target="${files[$((i-1))]:-}";};show_status(){ clear;[ -n "${target:-}" ]&&b "FILE STATUS: $target" "Permissions, Ownership, Size, Last Modified" "Use MODIFY to simulate real admin file handling scenarios." "$(stat -c '%A %U %G %s bytes %y' "$target")";pause;};mod_menu(){ while :;do clear;b "MODIFY MODULE: PERMISSION CODES FOR $target" "1 = Add Execute for Owner (chmod u+x)" "2 = Remove Write from Group (chmod g-w)" "3 = Add Read for Others (chmod o+r)" "4 = Set to Read/Write Default (chmod 644)" "5 = Change Owner to Root (chown root)" "6 = Return to Main Menu";read -r -p "ENTER NUMBER: " o;case "$o" in 1)chmod u+x "$target";;2)chmod g-w "$target";;3)chmod o+r "$target";;4)chmod 644 "$target";;5)command -v sudo >/dev/null&&sudo chown root "$target"||chown root "$target";;6)break;;*)b "INVALID NUMBER";pause;;esac;show_status;done;};q(){ echo;echo 'bye';exit 0;};while :;do clear;b "Bash.cards INTERFACE" "MISSION: FILE PERMISSIONS" "CONTEXT: chmod (change access), chown (change owner), and permission bits (rwx)";b "SCAN MENU OPTIONS" "1 = Select File" "2 = View File Permission Status" "3 = Modify File Permissions" "4 = Exit Training Module";read -r -p '> ' x;case "$x" in [qQ])q;;1)select_file;;2)show_status;;3)mod_menu;;4)clear;b "MODULE EXITED — COMPLETE";q;;*)b "INVALID NUMBER";pause;;esac;done
NameTypeSize
auto-art.pngfile1,142,351
back-data-url.txtfile236,046
back-thumb.pngfile171,655
back.pngfile177,017
front-data-url.txtfile253,598
front-thumb.pngfile130,551
front.pngfile190,181
manifest.txtfile184
qr-payload.txtfile1,499
raw.shfile2,056