Created
December 31, 2023 00:55
-
-
Save geeknik/a74ce04d99dbd77720f5d235fb535586 to your computer and use it in GitHub Desktop.
Vulnerable Bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
create_secure_file() { | |
local filename=$1 | |
local dir="/secure_dir" | |
if [[ ! -d "$dir" ]]; then | |
mkdir "$dir" | |
chmod 700 "$dir" | |
fi | |
local tmpfile="${dir}/$(basename "$filename").tmp" | |
touch "$tmpfile" | |
chmod 644 "$tmpfile" | |
echo "Secure Content: $(date)" > "$tmpfile" | |
chmod 600 "$tmpfile" | |
mv "$tmpfile" "${dir}/${filename}" | |
echo "Secure file '${dir}/${filename}' created successfully." | |
} | |
echo -n "Enter the name of the secure file you want to create: " | |
read FILENAME | |
create_secure_file "$FILENAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment