-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeobfuscator.sh
executable file
·56 lines (36 loc) · 1.07 KB
/
deobfuscator.sh
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
DIR=app_JADX/sources/
#remove previously created obfuscation map filee
rm obfuscation_map.txt
#creates obfuscation map from the decompiled java files
for i in $(find $DIR -name '*.java' -print);
do
filename=`basename $i`
obfuscatedName=`echo "${filename%.*}"`
sourceName=`grep "compiled from" $i | cut -d ' ' -f4`
if [[ ! -z $sourceName && ${obfuscatedName::1} == "C" ]]
then
targetPath=`echo $i | sed -e "s/${obfuscatedName}/${sourceName}/g"`
mv $i $targetPath
echo $i
echo $targetPath
if [ $? -eq 0 ]
then
sourceName=${sourceName%%.*}
echo $obfuscatedName $sourceName >> obfuscation_map.txt
fi
fi
done
#creates the sed replace func with the help of obfuscation map
sedCmd=""
while read -r obfuscatedName sourceName; do
echo "$obfuscatedName" "$sourceName"
sedCmd=$sedCmd" -e 's:${obfuscatedName}:${sourceName}:g' "
done < obfuscation_map.txt
sedCmd="sed -i '' ${sedCmd} "
#run the replace script for all the java files
for i in $(find $DIR -name '*.java' -print);
do
echo $i
cmd=$sedCmd$i
eval $cmd
done