mirror of
https://git.disroot.org/80486DX2-66/polonium.git
synced 2024-11-08 13:42:31 +05:30
52 lines
1.1 KiB
Bash
52 lines
1.1 KiB
Bash
#!/bin/sh
|
|
|
|
set +o histexpand # Disable parsing "!" as the history expansion character
|
|
set +e # Continue script execution even if a command fails
|
|
|
|
mkdir_if_not_exists() {
|
|
[ -d "$1" ] || mkdir "$1"
|
|
}
|
|
|
|
exec_name='polonium'
|
|
exec_file="$(pwd)/bin/$exec_name"
|
|
exec_log="$(pwd)/exec.log"
|
|
|
|
corrupt() {
|
|
cp "$1" "$2" || return 1
|
|
|
|
file_name="$(pwd)/$2"
|
|
|
|
args=("-p" "60" "-t" "2" "-n" "2" "--noconfirm" "-c" "-s" "999999999")
|
|
|
|
printf -- "--- [*] $exec_name $(basename "$2") ${args[*]}\n"
|
|
|
|
"$exec_file" "$file_name" "${args[@]}" > "$exec_log" 2>&1
|
|
return $?
|
|
}
|
|
|
|
iterate_on_test_files() {
|
|
find "$1" -maxdepth 1 -type f -name 'test.*' | while IFS= read -r file; do
|
|
basename="$(basename "$file")"
|
|
corrupt "$file" "./corrupted/$basename"
|
|
if [ "$?" -ne "0" ]; then
|
|
printf "[!] Polonium failed:\n"
|
|
cat "$exec_log"
|
|
rm "$exec_log"
|
|
return 1
|
|
fi
|
|
|
|
rm "$exec_log"
|
|
return 0
|
|
done
|
|
}
|
|
|
|
cd ./test_files || exit 1
|
|
printf "[*] Generating corrupted versions of test files\n"
|
|
mkdir_if_not_exists ./corrupted/
|
|
iterate_on_test_files .
|
|
if [ "$?" -ne "0" ]; then
|
|
exit 1
|
|
fi
|
|
|
|
printf "[>] All done!\n"
|