Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
better regex, ignore binary files, faster
Browse files Browse the repository at this point in the history
  • Loading branch information
s0md3v authored Nov 12, 2019
1 parent 6b473c4 commit ec94989
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions diggy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ $end"""

if [ $1 ]
then
:
:
else
printf "Usage: ./apk.sh <path to apk file>\n"
exit
printf "Usage: ./apk.sh <path to apk file>\n"
exit
fi

apk=$1
Expand All @@ -41,68 +41,64 @@ fi
if type "apktool" > /dev/null; then
:
else
printf "$bad Diggy requires 'apktool' to be installed."
exit
printf "$bad Diggy requires 'apktool' to be installed."
exit
fi

if [ -e $decom ]
then
printf $"$info Looks like this apk has been decompiled already.\n"
printf $"$info Looks like this apk has been decompiled already.\n"
printf "$que"
read -p " Decompile over the existing copy? [Y/n] " choice
read -p " Decompile over the existing copy? [y/N] " choice
if [ choice == "y" ]
then
rm -r $decom
rm -r $decom
else
:
:
fi
else
:
fi

if [ -e $links ]
then
printf $"$info Looks like links have been already extracted from this apk.\n"
printf "$que"
read -p " Rewrite the previous result? [Y/n] " choice
printf $"$info Looks like links have been already extracted from this apk.\n"
printf "$que"
read -p " Rewrite the previous result? [y/N] " choice
if [ choice == "y" ]
then
rm $links
rm $links
else
:
:
fi
else
:
fi

extract () {
k=$(apktool d $apk -o $decom -q)
}

grabby () {
matches=$( grep -r "['\"]http.*//.*['\"]\|['\"]/.*['\"]" $decom )
k=$(apktool d $apk -o $decom -fq)
}

regxy () {
for x in $matches
do
final=$(grep -o "['\"]http.*//.*['\"]\|['\"]/.*['\"]" <<< $x)
final=${final//$"\""/}
if [ "$final" == "/" ] || [ "$final" == "" ] || [ "$final" == "\"http\"" ] || [ "$final" == "\"https\"" ]
then
:
else
echo "$final" >> "$links"
fi
done
matches=$(grep -ProhI "[\"'\`](https?://|/)[\w\.-/]+[\"'\`]")
for final in $matches
do
final=${final//$"\""/}
final=${final//$"'"/}
if [ $(echo "$final" | grep "http://schemas.android.com") ] || [ "$final" == "/" ] || [ "$final" == "" ] || [ "$final" == "\"http\"" ] || [ "$final" == "\"https\"" ]
then
:
else
echo "$final" >> "$links"
fi
done
awk '!x[$1]++' $links
}


printf $"$run Decompiling the apk\n"
extract
printf $"$run Extracting endpoints\n"
grabby
regxy
printf $"$info Endpoints saved in: $links\n"
exit

0 comments on commit ec94989

Please sign in to comment.