mirror of
https://gitlab.anthaathi.net/omkar/mattermost-patched-enterprise.git
synced 2026-10-06 13:03:41 +00:00
Add already-patched detection
This commit is contained in:
@@ -35,6 +35,7 @@ if [ ${#MISSING_DEPS[@]} -gt 0 ]; then
|
||||
fi
|
||||
|
||||
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')
|
||||
|
||||
# Check binary file argument exists and is writable
|
||||
if [ -z "$BINARY_FILE" ]; then
|
||||
@@ -60,6 +61,13 @@ hexdump -ve '1/1 "%.2x"' "$BINARY_FILE" > "$TEMP_FILE"
|
||||
|
||||
echo "Searching for rsa.VerifyPKCS1v15 call inside LicenseValidatorImpl.ValidateLicense()"
|
||||
|
||||
# Check if already patched
|
||||
PATCHED_COUNT=$(grep -Eo -b "$PATCHED_PATTERN" "$TEMP_FILE" 2>/dev/null | wc -l)
|
||||
if [ "$PATCHED_COUNT" -gt 0 ]; then
|
||||
echo "Binary appears to already be patched (jnz instruction found)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MATCH_COUNT=$(grep -Eo -b "$SEARCH_PATTERN" "$TEMP_FILE" | wc -l)
|
||||
if [ "$MATCH_COUNT" -gt 1 ]; then
|
||||
echo "Warning: Found $MATCH_COUNT matches for the pattern. Using the first match."
|
||||
|
||||
Reference in New Issue
Block a user