mirror of
https://gitlab.anthaathi.net/omkar/mattermost-patched-enterprise.git
synced 2026-10-06 13:03:41 +00:00
Add ELF binary file type validation
This commit is contained in:
@@ -16,7 +16,7 @@ cleanup() {
|
|||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
# Check for required dependencies
|
# Check for required dependencies
|
||||||
DEPENDENCIES=(hexdump xxd grep awk dd tr mktemp)
|
DEPENDENCIES=(hexdump xxd grep awk dd tr mktemp file)
|
||||||
MISSING_DEPS=()
|
MISSING_DEPS=()
|
||||||
|
|
||||||
for dep in "${DEPENDENCIES[@]}"; do
|
for dep in "${DEPENDENCIES[@]}"; do
|
||||||
@@ -51,6 +51,13 @@ if [ ! -w "$BINARY_FILE" ]; then
|
|||||||
exit 5
|
exit 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check if file is an ELF binary
|
||||||
|
FILE_TYPE=$(file -b "$BINARY_FILE" 2>/dev/null || echo "unknown")
|
||||||
|
if ! echo "$FILE_TYPE" | grep -q "ELF"; then
|
||||||
|
echo "Error: '$BINARY_FILE' does not appear to be an ELF binary (detected: $FILE_TYPE)."
|
||||||
|
exit 11
|
||||||
|
fi
|
||||||
|
|
||||||
SEARCH_PATTERN=$(echo "$PATTERN" | tr -d ' ' | tr '?' '.' | tr 'A-Z' 'a-z')
|
SEARCH_PATTERN=$(echo "$PATTERN" | tr -d ' ' | tr '?' '.' | tr 'A-Z' 'a-z')
|
||||||
PATCHED_PATTERN=$(echo "$PATTERN" | sed 's/74 53/75 53/' | tr -d ' ' | tr '?' '.' | tr 'A-Z' 'a-z')
|
PATCHED_PATTERN=$(echo "$PATTERN" | sed 's/74 53/75 53/' | tr -d ' ' | tr '?' '.' | tr 'A-Z' 'a-z')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user