Skip to content

Instantly share code, notes, and snippets.

@MrCyjaneK
Last active April 9, 2020 14:02
Show Gist options
  • Save MrCyjaneK/a5e7a82743ca8be3583ec44c489717c4 to your computer and use it in GitHub Desktop.
Save MrCyjaneK/a5e7a82743ca8be3583ec44c489717c4 to your computer and use it in GitHub Desktop.
Extract android tor static binary (latest)
#!/bin/bash
DONE=0
while true;
do
num=$SECONDS
min=0
hour=0
day=0
if((num>59));then
((sec=num%60))
((num=num/60))
if((num>59));then
((min=num%60))
((num=num/60))
if((num>23));then
((hour=num%24))
((day=num/24))
else
((hour=num))
fi
else
((min=num))
fi
else
((sec=num))
fi
timespent="$min:$sec"
echo -n -e "\r[`echo "$timespent " | head -c4`]";
if [ "$DONE" -eq "1" ];
then
  break
fi;
sleep 1
done &
BGPID=$!
trap 'kill $BGPID; exit' INT
function ok {
echo -n -e "\r[ OK ]\n"
}
function fail {
echo -n -e "\r[FAIL]\n"
DONE=1;
sleep 3
exit 1;
}
function warn {
echo -n -e "\r[WARN]\n"
}
function recho {
echo -n -e "\r[....] $@"
}
recho "Fetching version..."
VERSION=`curl "https://www.torproject.org/download/#android" -s | grep ".apk" | head -1 | xargs | cut -d " " -f 9 | sed --expression "s/-/ /g" | cut -d " " -f 3` && ok || fail
echo -n -e " If version below doesn't look valid, hit ^C now. We will continue in 5 seconds.\n"
recho "Version: $VERSION"
sleep 5 && ok || fail
rm -rf $VERSION &>/dev/null
recho "Changing locale to C.UTF-8"
export LC_ALL=C.UTF-8 && ok || warn
home=`pwd`
LOGFILE="$home/log.txt"
for i in aarch64 armv7 x86_64 x86; do
echo " ============= Arch: $i"
recho "Going home"
cd $home &>$LOGFILE && ok || fail
URL="https://dist.torproject.org/torbrowser/""$VERSION""/tor-browser-""$VERSION""-android-$i-multi.apk"
recho "Creating directory"
mkdir -p "$VERSION/TMP_$i" &>$LOGFILE && ok || fail
recho "Downloading apk..."
wget "$URL" -O "$VERSION/TMP_$i/apk.zip" &>$LOGFILE && ok || fail
recho "Going to download directory"
cd "$VERSION/TMP_$i" &>$LOGFILE && ok || fail
recho "Unzipping apk"
unzip apk.zip &>$LOGFILE && ok || fail
recho "Going to libs directory"
cd "$home"/"$VERSION"/TMP_"$i"/lib/* &>$LOGFILE && ok || fail
recho "Getting libTor.so"
cp "libTor.so" "$home/$VERSION/tor_$i" &>$LOGFILE && ok || fail
recho "Is it 'not a dynamic executable'?"
if [[ "`ldd $home/$VERSION/tor_$i | xargs`" == "not a dynamic executable" ]]
then
ok
else
warn
fi
recho "Going home (again)"
cd $home &>$LOGFILE && ok || fail
recho "Cleaning up."
rm -rf "$home/$VERSION/TMP_$i" &>$LOGFILE && ok || warn
done
echo -n -e "Logfile: $LOGFILE\n";
recho "Deleting log file in 5 seconds... hit ^C to keep";
DONE=1
sleep 5
rm "$LOGFILE" && ok || warn;
kill $BGPID
exit 0;
@MrCyjaneK
Copy link
Author

Also, this is NOT what you should use in production, (i use it), you should find a way to compile static binary (and plz send me instructions here)..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment