forked from KOLANICH-tools/de4dot
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtest_api.sh
More file actions
executable file
·72 lines (62 loc) · 2.23 KB
/
Copy pathtest_api.sh
File metadata and controls
executable file
·72 lines (62 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Exit on error
set -e
# Help / Usage check
if [ $# -lt 1 ]; then
echo "=========================================================================="
echo " de4dotEx HTTP Web API Test Client"
echo "=========================================================================="
echo "Usage: $0 <file_to_deobfuscate> [optional_extra_flags]"
echo ""
echo "Examples:"
echo " $0 MyProtectedApp.dll"
echo " $0 /path/to/Target.exe \"--preserve-tokens -str delegate\""
echo "=========================================================================="
exit 1
fi
INPUT_FILE="$1"
EXTRA_OPTIONS="$2"
# Verify input file exists
if [ ! -f "$INPUT_FILE" ]; then
echo "Error: File '$INPUT_FILE' not found."
exit 1
fi
# Calculate directory and output filename (appending _cleaned before the extension)
DIR=$(dirname "$INPUT_FILE")
FILENAME=$(basename "$INPUT_FILE")
EXTENSION="${FILENAME##*.}"
BASENAME="${FILENAME%.*}"
# Handle files with no extensions
if [ "$BASENAME" = "$EXTENSION" ]; then
OUTPUT_FILE="${DIR}/${BASENAME}_cleaned"
else
OUTPUT_FILE="${DIR}/${BASENAME}_cleaned.${EXTENSION}"
fi
echo "[de4dotEx] Uploading '$INPUT_FILE' to http://localhost:8080/deobfuscate..."
if [ -n "$EXTRA_OPTIONS" ]; then
echo "[de4dotEx] Applying native flags: $EXTRA_OPTIONS"
fi
# Perform HTTP POST request and capture HTTP status code
HTTP_CODE=$(curl -s -w "%{http_code}" \
-F "file=@${INPUT_FILE}" \
-F "options=${EXTRA_OPTIONS}" \
http://localhost:8080/deobfuscate \
-o "${OUTPUT_FILE}")
if [ "$HTTP_CODE" -eq 200 ]; then
echo "------------------------------------------------------------"
echo "🎉 Success! Cleaned assembly saved to:"
echo " $OUTPUT_FILE"
echo "------------------------------------------------------------"
else
echo "------------------------------------------------------------"
echo "❌ Error: Deobfuscation failed (HTTP status: ${HTTP_CODE})."
# If server returned an error payload, display it and clean up the file
if [ -f "${OUTPUT_FILE}" ]; then
echo "Server message:"
cat "${OUTPUT_FILE}"
echo ""
rm -f "${OUTPUT_FILE}"
fi
echo "------------------------------------------------------------"
exit 1
fi