Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1177fe98f | ||
|
|
10d89d63e2 | ||
|
|
0c24400530 | ||
|
|
61e12cd0d5 | ||
|
|
db7a9c4324 |
No files matched your search
File renamed without changes.
@@ -17,3 +17,5 @@ sha256dsum SAMPLE.zip # get sha256 to look up on the site
|
|||||||
curl -X POST -H "X-ApiKey: $VIRUSTOTAL_API_KEY" -F "file=@$PWD/SAMPLE.zip" https://www.virustotal.com/api/v3/files
|
curl -X POST -H "X-ApiKey: $VIRUSTOTAL_API_KEY" -F "file=@$PWD/SAMPLE.zip" https://www.virustotal.com/api/v3/files
|
||||||
# then look up file by sha256 checksum on the site
|
# then look up file by sha256 checksum on the site
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
OUTPUT_FILE="/mnt/c/Users/human/Downloads/NORMIEDIRWTFFILEHGISTORYFUCKYOUWINDOWSFUCKYOUTOHELLANDYOUDIEWINDOWS-$(date +%s).txt"
|
||||||
|
TEST_DIR="/mnt/c/Users/human/OneDrive/Documents/Git/general-scripts-and-system-ssssssetup/customscripts"
|
||||||
|
|
||||||
|
echo -n "" > "$OUTPUT_FILE" # inuitialize fiel ig lmao
|
||||||
|
|
||||||
|
# mAWEK dildohe3aderz
|
||||||
|
# INItuialie fiel to empty, add HEASDWERS ABDDDD PRINT TO SCREEEEBN
|
||||||
|
printf "%-85s %-66s %-22s %-22s %-15s %-12s\n" "FILENAME" "SHA-256 CHECKSUM" "DATETIME CREATED" "DATETIME MODIFIED" "SIZE (BYTES)" "SIZE (HUMAN)" | tee "$OUTPUT_FILE"
|
||||||
|
|
||||||
|
for file in $TEST_DIR/*; do # loop da fuck threough fileZ in TEST_DIR
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
filename=$(basename "$file") # DELET DA PAAATH
|
||||||
|
|
||||||
|
sha256=$(sha256sum "$file" | awk '{print $1}') # CHECJKSUYMNZZZ! VUUUT DELETE DA FIEL ANMEEE
|
||||||
|
|
||||||
|
created=$(stat -c '%w' "$file" 2>/dev/null | cut -d'.' -f1) # ATTENP GET CREATUIION DARTE
|
||||||
|
if [ "$created" = "-" ] || [ -z "$created" ]; then # IF DAT FUCKS UP
|
||||||
|
created="N/A" # ajust fuckinA N/A it lmao
|
||||||
|
fi
|
||||||
|
|
||||||
|
modified=$(stat -c '%y' "$file" | cut -d'.' -f1) # MODIFIED TIMDATESTAMP
|
||||||
|
|
||||||
|
bytes=$(du -b "$file" | awk '{print $1}' | tr -d '\n') # FIEK SIZE IN BYTES BUT NUKE FILEBNANE AND NUJKE NEWLINES
|
||||||
|
|
||||||
|
human_size=$(du -h "$file" | awk '{print $1}' | tr -d '\n') # HUMNAN FIEL SIZE VBT KILL DA FIELNAME AND NUKE NWEKLINEZ
|
||||||
|
|
||||||
|
# output DILDIOFACTZ 2 FIEL AND TERMINALLL
|
||||||
|
printf "%-85s %-66s %-22s %-22s %-15s %-12s\n" "$filename" "$sha256" "$created" "$modified" "$bytes" "$human_size" | tee -a "$OUTPUT_FILE"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Report generated successfully in $OUTPUT_FILE"
|
||||||
@@ -0,0 +1,246 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#initalize globals
|
||||||
|
## prepended space to make final assembly cleaner
|
||||||
|
whitelist_find_str=' \('
|
||||||
|
blacklist_find_str=' -not \('
|
||||||
|
search_dir="$PWD"
|
||||||
|
whitelist=()
|
||||||
|
blacklist=()
|
||||||
|
ending=''
|
||||||
|
action=' -print'
|
||||||
|
|
||||||
|
help_usage () {
|
||||||
|
echo "Usage:"
|
||||||
|
echo -e '\tfind_ext.sh [-w <str whitelisted extentions>] [-b <str blacklisted extensions>] [-[-p] [-c <str path>] [-d <str path>] [-D] [-s]'
|
||||||
|
echo -e '\t\t-w - Whitelist: Match files with provided extensions'
|
||||||
|
echo -e '\t\t\texample: find_ext.sh -w "txt pdf doc"'
|
||||||
|
echo -e '\t\t-b - Blacklist: Exclude files with provided extensions'
|
||||||
|
}
|
||||||
|
|
||||||
|
# use getopts to parse options
|
||||||
|
## each letter is a flag like -p
|
||||||
|
## letter with : after is is a flag with an arg like -w "txt pdf gif"
|
||||||
|
## first : is for when no flags are added (defaults, error handling)
|
||||||
|
while getopts ":w:b:d:c:Dhps]" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
# directory - path to search in (default $PWD)
|
||||||
|
## find_ext.sh -w "txt jpg" -d /home/princesspi
|
||||||
|
d)
|
||||||
|
search_dir="${OPTARG[@]}"
|
||||||
|
|
||||||
|
if [ ! -d "$search_dir" ]; then
|
||||||
|
echo "Error: Search directory $search_dir not found" >&2
|
||||||
|
help_useage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
# silent
|
||||||
|
## find_ext -w "txt mp3" -s
|
||||||
|
s)
|
||||||
|
# show error text but silence everything else
|
||||||
|
ending=' 1>/dev/null'
|
||||||
|
;;
|
||||||
|
|
||||||
|
# whitelist - search for files ending in provided extensions
|
||||||
|
## find_ext.sh -w "txt pdf bak" -p
|
||||||
|
w)
|
||||||
|
## break whitelist str into array
|
||||||
|
IFS=' ' read -r -a whitelist <<< "${OPTARG[@]}"
|
||||||
|
|
||||||
|
### start the whitelist group
|
||||||
|
#### whitelist counter so it knows its in the first position (to not add the -o)
|
||||||
|
whitelist_counter=0
|
||||||
|
### loop through array of whitelisted exts
|
||||||
|
for ext in "${whitelist[@]}"; do
|
||||||
|
### only add -o after the first one
|
||||||
|
if [ $whitelist_counter -eq 0 ]; then
|
||||||
|
#### test if array has exactly one item
|
||||||
|
if [ ${#whitelist[@]} -eq 1 ]; then
|
||||||
|
##### Append space because its the only entry
|
||||||
|
whitelist_find_str+=" -iname \"*.${ext}\" "
|
||||||
|
else
|
||||||
|
##### no appended space on first one to make it neat with the -o's
|
||||||
|
whitelist_find_str+=" -iname \"*.${ext}\""
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
whitelist_find_str+=" -o -iname \"*.${ext}\" "
|
||||||
|
fi
|
||||||
|
|
||||||
|
### increment counter
|
||||||
|
whitelist_counter=$(($whitelist_counter + 1));
|
||||||
|
done
|
||||||
|
## finish the whitelist group
|
||||||
|
### appended space to make final assembly cleaner
|
||||||
|
whitelist_find_str+='\) '
|
||||||
|
;;
|
||||||
|
|
||||||
|
# blacklist - exclude provided extensions from search
|
||||||
|
## find_ext.sh -b "txt pdf jpg" -p
|
||||||
|
b)
|
||||||
|
# break blacklist str into array
|
||||||
|
IFS=' ' read -r -a blacklist <<< "${OPTARG[@]}"
|
||||||
|
echo ${#blacklist[@]}
|
||||||
|
# create the blacklist find section text
|
||||||
|
## start the whitelist group
|
||||||
|
## has the -not for blacklisting
|
||||||
|
## whitelist counter so it knows its in the first position (to not add the -o)
|
||||||
|
blacklist_counter=0
|
||||||
|
## loop through array of whitelisted exts
|
||||||
|
for ext in "${blacklist[@]}"; do
|
||||||
|
### test if array has exactly one item
|
||||||
|
if [ ${#blacklist[@]} -eq 1 ]; then
|
||||||
|
#### Append space because its the only entry
|
||||||
|
blacklist_find_str+=" -iname \"*.${ext}\" "
|
||||||
|
else
|
||||||
|
#### no appended space on first one to make it neat with the -o's
|
||||||
|
blacklist_find_str+=" -iname \"*.${ext}\""
|
||||||
|
fi
|
||||||
|
|
||||||
|
### increment counter
|
||||||
|
blacklist_counter=$(($whitelist_counter + 1));
|
||||||
|
done
|
||||||
|
## finish the whitelist group
|
||||||
|
### appended space to make final assembly cleaner
|
||||||
|
blacklist_find_str+=' \) '
|
||||||
|
;;
|
||||||
|
|
||||||
|
# print (default(
|
||||||
|
## find_ext.sh "jpg gif png" -p
|
||||||
|
p)
|
||||||
|
# do nothing here, just do the default print silently
|
||||||
|
# action=' -print'
|
||||||
|
;;
|
||||||
|
|
||||||
|
# delete
|
||||||
|
## find_ext.sh -w "tmp bak" -d
|
||||||
|
D)
|
||||||
|
# verify that user REALLY wants to delete
|
||||||
|
# todo: show list of files before prompting to confirm
|
||||||
|
# send warning as stderr to bypass s
|
||||||
|
echo -e "ARE YOU CERTAIN YOU WISH TO DELETE ALL MATCHING FILES RECURSIVELY IN $search_dir?\n\tPatterns:\n\t\tWhitelist: \"${whitelist[@]}\"\n\t\tBlacklist: \"${blacklist[@]}\"\n\t\tPath: $search_dir" >&2
|
||||||
|
read checkdelete
|
||||||
|
|
||||||
|
# strict case insensitive yes match, no other chars, nothing prepended or appendeed, no doubles, no mispellling
|
||||||
|
regex="^[yY]{1}[eE]{1}[sS]{1}$"
|
||||||
|
if [[ $checkdelete =~ $regex ]]; then
|
||||||
|
echo "WARNING PROCEEDING TO DELETE!"
|
||||||
|
else
|
||||||
|
echo "NOTE: DELETE CANCELLED"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
action+=' -delete'
|
||||||
|
;;
|
||||||
|
|
||||||
|
# copy
|
||||||
|
## find_ext.sh -w "txt" -c /path/somewhere
|
||||||
|
c)
|
||||||
|
action+=" -exec cp \"{}\" \"${OPTARG[@]}\" \\;"
|
||||||
|
;;
|
||||||
|
|
||||||
|
# help
|
||||||
|
## find_ext.sh -h
|
||||||
|
h)
|
||||||
|
help_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
# invalid options or flags
|
||||||
|
\?)
|
||||||
|
echo "Error: Invalid Option -$OPTARG" >&2
|
||||||
|
help_usage
|
||||||
|
exit 0;
|
||||||
|
;;
|
||||||
|
|
||||||
|
# arg requiring value not given
|
||||||
|
## like -w without the list of exts
|
||||||
|
:)
|
||||||
|
echo "Error: Option -$OPTARG requires an argument" >&2
|
||||||
|
help_usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# assemble the find command
|
||||||
|
## "$PWD" used for dir instead of . to output absolute paths
|
||||||
|
find_str="find \"$search_dir\"${whitelist_find_str}${blacklist_find_str}${action}${ending}";
|
||||||
|
echo $find_str
|
||||||
|
# bash -c "$find_str"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo -e 'Usage:\n\tfind_ext.sh <str extensions whitelist> <str extensions blacklist>\n\tfind_ext.sh "jpg mp3 png" ["doc pdf svg"]'
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
# break whitelist str into array
|
||||||
|
IFS=' ' read -r -a whitelist <<< "$1"
|
||||||
|
|
||||||
|
# create the whitelisted find section text
|
||||||
|
## start the whitelist group
|
||||||
|
## prepended space to make final assembly cleaner
|
||||||
|
whitelist_find_str=' \('
|
||||||
|
## whitelist counter so it knows its in the first position (to not add the -o)
|
||||||
|
whitelist_counter=0
|
||||||
|
## loop through array of whitelisted exts
|
||||||
|
for ext in "${whitelist[@]}"; do
|
||||||
|
### only add -o after the first one
|
||||||
|
if [ $whitelist_counter -eq 0 ]; then
|
||||||
|
#### test if array has exactly one item
|
||||||
|
if [ ${#whitelist[@]} -eq 1 ]; then
|
||||||
|
##### Append space because its the only entry
|
||||||
|
whitelist_find_str+=" -iname \"*.${ext}\" "
|
||||||
|
else
|
||||||
|
##### no appended space on first one to make it neat with the -o's
|
||||||
|
whitelist_find_str+=" -iname \"*.${ext}\""
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
whitelist_find_str+=" -o -iname \"*.${ext}\" "
|
||||||
|
fi
|
||||||
|
|
||||||
|
### increment counter
|
||||||
|
whitelist_counter=$(($whitelist_counter + 1));
|
||||||
|
done
|
||||||
|
## finish the whitelist group
|
||||||
|
### appended space to make final assembly cleaner
|
||||||
|
whitelist_find_str+='\) '
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$2" ]; then
|
||||||
|
# break blacklist str into array
|
||||||
|
IFS=' ' read -r -a blacklist <<< "$2"
|
||||||
|
|
||||||
|
# create the blacklist find section text
|
||||||
|
## start the whitelist group
|
||||||
|
## has the -not for blacklisting
|
||||||
|
## prepended space to make final assembly cleaner
|
||||||
|
blacklist_find_str=' -not \('
|
||||||
|
## whitelist counter so it knows its in the first position (to not add the -o)
|
||||||
|
blacklist_counter=0
|
||||||
|
## loop through array of whitelisted exts
|
||||||
|
for ext in "${blacklist[@]}"; do
|
||||||
|
### only add -o after the first one
|
||||||
|
if [ $blacklist_counter -eq 0 ]; then
|
||||||
|
#### test if array has exactly one item
|
||||||
|
if [ ${#blacklist[@]} -eq 1 ]; then
|
||||||
|
##### Append space because its the only entry
|
||||||
|
blacklist_find_str+=" -iname \"*.${ext}\" "
|
||||||
|
else
|
||||||
|
##### no appended space on first one to make it neat with the -o's
|
||||||
|
blacklist_find_str+=" -iname \"*.${ext}\""
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
blaclklist_find_str+=" -o -iname \"*.${ext}\" "
|
||||||
|
fi
|
||||||
|
|
||||||
|
### increment counter
|
||||||
|
blacklist_counter=$(($whitelist_counter + 1));
|
||||||
|
done
|
||||||
|
## finish the whitelist group
|
||||||
|
### appended space to make final assembly cleaner
|
||||||
|
blacklist_find_str+='\) '
|
||||||
|
fi
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
set -eo pipefail # safest to die on any error or pipe fail
|
||||||
|
temp_file=$(mktemp) # makes random temp file user has rw on, always safer to use mktemp for random temp name (unpredictable) and to avoid clobbering
|
||||||
|
if [ -z "$1" ]; then # if no arg is present, select create new, current umicros code
|
||||||
|
unix_microseconds=$(date +'%s%N') # microseconds since the unix epoch, UTC
|
||||||
|
hex_encoding="$(printf '%x' $unix_microseconds)" # printf to convert da big int to hex
|
||||||
|
echo -n "$hex_encoding" | xxd -p -r > "$temp_file" # decode hex to raw bytes with xxd, load the bytes into the temp file, must use temp file or nullbyte fuckery happenz ERROR TOWNN~ oh echo -n is to echo wothoot da appended newline
|
||||||
|
base64_encoding="$(base64 ${temp_file} | tr -d '\n')"; # base64 encode the bytes from the temp file, then remove any newlines
|
||||||
|
final_umicros_code="$(echo -n $base64_encoding | tr -d '\n' | tr '\/\+\=' '\-\.\_')" # now remove any dangling newlines and replace "/", "+", and "=" with "-", ".", and "_", respectively. just to make the code better suited to filenames
|
||||||
|
echo -n "${final_umicros_code}" # output the umicros code (no trailing newline)
|
||||||
|
# exit 0 # exit without error
|
||||||
|
else # is an argumnenbt is specified, select to decode that argument as a umicros code
|
||||||
|
umicros_code_supplied="$1" # get arg
|
||||||
|
decoded_base64=$(echo -n "$umicros_code_supplied" | tr '\-\.\_' '\/\+\=' | base64 -d | xxd -p) # replace supplied umicros code with the original base64 chars, decode the base64, then convert to hex with xxd
|
||||||
|
decoded_umicros_code_unix_microseconds=$(printf "%u" "0x${decoded_base64}") # prepend 0x and decode with printf (%u because its large and not likely to be signed)
|
||||||
|
decoded_unix_seconds="${decoded_umicros_code_unix_microseconds:0:-9}" # get the first nine chars
|
||||||
|
last_nine="${decoded_umicros_code_unix_microseconds: -9}" # get the last nine chars
|
||||||
|
date -d "@${decoded_unix_seconds}.${last_nine}" +"%Y-%m-%d %H:%M:%S.%N %Z" # date command to format the umicros code, -u to use UTC time, -d is to set the timestamp to convert, unix microseconds converted to unix seconds by being broken into first six and last six digits, decimal between them. then just the datetime format, including the TZ (%Z/UTC)
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$temp_file" # clean up temp file
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Ensure script is run as root
|
||||||
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
echo "[-] Error: This script must be run as root." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if directory argument is provided
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "[-] Usage: $0 <target_directory>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TARGET_DIR="$1"
|
||||||
|
|
||||||
|
if [ ! -d "$TARGET_DIR" ]; then
|
||||||
|
echo "[-] Error: '$TARGET_DIR' is not a valid directory." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Interactive password prompt (hidden input)
|
||||||
|
echo -n "Enter archive password for full decryption test (or press Enter to skip): "
|
||||||
|
read -s PASSWORD
|
||||||
|
echo "" # Print a newline after hidden input
|
||||||
|
|
||||||
|
echo "[*] Scanning directory recursively: $TARGET_DIR"
|
||||||
|
if [ -n "$PASSWORD" ]; then
|
||||||
|
echo "[*] Password provided: Archive full decryption & integrity test enabled."
|
||||||
|
else
|
||||||
|
echo "[*] Password skipped: Running signature, header encryption check, and SHA512 verification."
|
||||||
|
fi
|
||||||
|
echo "--------------------------------------------------"
|
||||||
|
|
||||||
|
ERROR_COUNT=0
|
||||||
|
FILE_COUNT=0
|
||||||
|
|
||||||
|
while IFS= read -r -d '' file; do
|
||||||
|
FILE_COUNT=$((FILE_COUNT + 1))
|
||||||
|
filename=$(basename "$file")
|
||||||
|
failed=0
|
||||||
|
|
||||||
|
echo "[*] Checking: $file"
|
||||||
|
|
||||||
|
# 1. Check if file ends in .7z or .sha512
|
||||||
|
if [[ "$filename" != *.7z && "$filename" != *.sha512 ]]; then
|
||||||
|
echo " [X] Failed extension check: does not end in .7z or .sha512"
|
||||||
|
failed=1
|
||||||
|
else
|
||||||
|
echo " [+] Extension check passed ($filename)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Check and enforce ownership (root:root)
|
||||||
|
owner=$(stat -c '%U:%G' "$file")
|
||||||
|
if [ "$owner" != "root:root" ]; then
|
||||||
|
echo " [!] Incorrect ownership ($owner). Fixing to root:root..."
|
||||||
|
chown root:root "$file"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo " [X] Failed to change ownership to root:root."
|
||||||
|
failed=1
|
||||||
|
else
|
||||||
|
echo " [+] Ownership corrected to root:root."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " [+] Ownership check passed (root:root)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Check and enforce permissions (600)
|
||||||
|
perms=$(stat -c '%a' "$file")
|
||||||
|
if [ "$perms" != "600" ]; then
|
||||||
|
echo " [!] Incorrect permissions ($perms). Fixing to 600..."
|
||||||
|
chmod 600 "$file"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo " [X] Failed to change permissions to 600."
|
||||||
|
failed=1
|
||||||
|
else
|
||||||
|
echo " [+] Permissions corrected to 600."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " [+] Permissions check passed (600)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. If it is a .7z file, perform verification and SHA512 management
|
||||||
|
if [[ "$filename" == *.7z ]]; then
|
||||||
|
if [ -n "$PASSWORD" ]; then
|
||||||
|
# Full decryption and integrity test using the provided password
|
||||||
|
if ! 7z t -p"$PASSWORD" "$file" >/dev/null 2>&1; then
|
||||||
|
echo " [X] Failed integrity/decryption check: Incorrect password, corrupted archive, or invalid data."
|
||||||
|
failed=1
|
||||||
|
else
|
||||||
|
echo " [+] Archive successfully decrypted and integrity verified with password."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Fallback mode: Signature check + Header encryption verification
|
||||||
|
expected_header=$'\x37\x7a\xbc\xaf\x27\x1c'
|
||||||
|
file_header=$(head -c 6 "$file")
|
||||||
|
if [ "$file_header" != "$expected_header" ]; then
|
||||||
|
echo " [X] Failed format check: Not a valid 7-zip file signature."
|
||||||
|
failed=1
|
||||||
|
else
|
||||||
|
echo " [+] Valid 7-zip file signature confirmed."
|
||||||
|
|
||||||
|
# Confirm header/filename encryption is active (-mhe=on)
|
||||||
|
if 7z l "$file" </dev/null >/dev/null 2>&1; then
|
||||||
|
echo " [X] Failed encryption check: Archive headers/filenames are NOT encrypted."
|
||||||
|
failed=1
|
||||||
|
else
|
||||||
|
echo " [+] Filename and header encryption confirmed (-mhe=on active)."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# SHA512 check / generation
|
||||||
|
sha_file="${file}.sha512"
|
||||||
|
if [ ! -f "$sha_file" ]; then
|
||||||
|
echo " [!] Missing .sha512 file. Generating..."
|
||||||
|
sha512sum "$file" > "$sha_file"
|
||||||
|
chown root:root "$sha_file"
|
||||||
|
chmod 600 "$sha_file"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo " [+] Generated and secured new SHA512 checksum file."
|
||||||
|
else
|
||||||
|
echo " [X] Failed to generate or secure SHA512 checksum file."
|
||||||
|
failed=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " [+] Found existing .sha512 file. Verifying..."
|
||||||
|
file_dir=$(dirname "$file")
|
||||||
|
base_sha=$(basename "$sha_file")
|
||||||
|
|
||||||
|
if (cd "$file_dir" && sha512sum -c "$base_sha" >/dev/null 2>&1); then
|
||||||
|
echo " [+] SHA512 hash verification passed."
|
||||||
|
else
|
||||||
|
echo " [X] FAILED: SHA512 hash verification failed!"
|
||||||
|
failed=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $failed -eq 1 ]; then
|
||||||
|
echo " [-] STATUS: FILE COMPLIANCE FAILED"
|
||||||
|
ERROR_COUNT=$((ERROR_COUNT + 1))
|
||||||
|
else
|
||||||
|
echo " [+] STATUS: OK"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
done < <(find "$TARGET_DIR" -type f -print0)
|
||||||
|
|
||||||
|
echo "--------------------------------------------------"
|
||||||
|
echo "[*] Scan complete."
|
||||||
|
echo " Total files checked: $FILE_COUNT"
|
||||||
|
echo " Files with compliance failures: $ERROR_COUNT"
|
||||||
|
|
||||||
|
if [ $ERROR_COUNT -gt 0 ]; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user