puddly / android-otp-extractor

Extracts OTP tokens from rooted Android devices
GNU General Public License v3.0
231 stars 22 forks source link

Unable to extract tokens.xml of freeOTP #12

Closed erotavlasme closed 6 years ago

erotavlasme commented 6 years ago

Hi, I would to migrate from freeOTP to andOTP. I found your script, however I'm not able to extract the file tokens.xml from the path /data/data/org.fedorahosted.freeotp/shared_prefs/. I have a rooted phone with lineageOS 14.1. Do you have any idea how to save a new backup from freeOTP? I tried to find the file tokens.xml in the memory without success. Thank you

puddly commented 6 years ago

I just tested installed the latest version of FreeOTP on Android 7.1.2 and /data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml exists for me. Does that directory exist for you? If not, where is org.fedorahosted.freeotp/shared_prefs located?

erotavlasme commented 6 years ago

I solved in not elegant way by installing termux on the device and by copy and paste the output of cat token.xml. I do not way adb does not allow me to access the file even if it has root access.

puddly commented 6 years ago

I'd still like to fix this bug. If you're interested in helping me, the exact command that is run is:

adb shell 'su -c "toybox base64 /data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml /3bb22bb739c29e435151cb38"'

The output should look like this:

user@host:~$ adb shell 'su -c "toybox base64 /data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml /3bb22bb739c29e435151cb38"'
lotsofbase64lotsofbase64lotsofbase64lotsofbase64lotsofbase64lotsofbase64lots
lotsofbase64lotsofbase64lotsofbase64lotsofbase64lotsofbase64lotsofbase64lots
lotsofbase64lotsofbase64lotsofbase64lotsofbase64lotsofbase64lotsofbase64lots
lotsofbase64lotsofb=
base64: /3bb22bb739c29e435151cb38: No such file or directory

Does this happen on your device? LineageOS 14.1 should support toybox base64.

erotavlasme commented 6 years ago

Hi, of course, I can help you. My output to the command adb shell 'su -c "toybox base64 /data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml /3bb22bb739c29e435151cb38"'

[redacted]
base64: /3bb22bb739c29e435151cb38: No such file or directory

For me it is a little bit different.

puddly commented 6 years ago

@erotavlas85 Thanks. I wouldn't post the output of any commands publicly without either randomizing or redacting the base64-encoded lines. They contain your OTP secrets and the accounts they're associated with.

The output format you posted is what the data should look like. Can you download the latest version of the script and run it in verbose mode for just FreeOTP?

python3 extract_otp_tokens.py --no-authy --no-duo --no-google-authenticator --no-microsoft-authenticator --no-steam-authenticator --verbose --verbose 2>&1 | grep -A5000 -m3 org.fedorahosted.freeotp/

With just a single TOTP token with label a and secret AAAAAAAAAAAAAAAAAAAAA, the above command gives me the following output:

[2018-07-08 16:17:57,248]    DEBUG [adb_read_file:172] Reading file /data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml
[2018-07-08 16:17:57,251]    DEBUG [adb_fast_run:143] Running ['adb', 'shell', 'su -c "su -c "toybox base64 /data/data/org.fedorahosted.freeotp/shared_prefs/tokens.xml; ls /3bb22bb739c29e435151cb38']
[2018-07-08 16:17:57,467]    DEBUG [adb_fast_run:146] Read: b'PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0ndXRmLTgnIHN0YW5kYWxvbmU9J3llcycgPz4K\n'
[2018-07-08 16:17:57,472]    DEBUG [adb_fast_run:146] Read: b'PG1hcD4KICAgIDxzdHJpbmcgbmFtZT0iYTphIj57JnF1b3Q7YWxnbyZxdW90OzomcXVvdDtTSEEx\n'
[2018-07-08 16:17:57,472]    DEBUG [adb_fast_run:146] Read: b'JnF1b3Q7LCZxdW90O2NvdW50ZXImcXVvdDs6MCwmcXVvdDtkaWdpdHMmcXVvdDs6NiwmcXVvdDtp\n'
[2018-07-08 16:17:57,473]    DEBUG [adb_fast_run:146] Read: b'c3N1ZXJFeHQmcXVvdDs6JnF1b3Q7YSZxdW90OywmcXVvdDtsYWJlbCZxdW90OzomcXVvdDthJnF1\n'
[2018-07-08 16:17:57,473]    DEBUG [adb_fast_run:146] Read: b'b3Q7LCZxdW90O3BlcmlvZCZxdW90OzozMCwmcXVvdDtzZWNyZXQmcXVvdDs6WzAsMCwwLDAsMCww\n'
[2018-07-08 16:17:57,473]    DEBUG [adb_fast_run:146] Read: b'LDAsMCwwLDAsMCwwLDBdLCZxdW90O3R5cGUmcXVvdDs6JnF1b3Q7VE9UUCZxdW90O308L3N0cmlu\n'
[2018-07-08 16:17:57,473]    DEBUG [adb_fast_run:146] Read: b'Zz4KICAgIDxzdHJpbmcgbmFtZT0idG9rZW5PcmRlciI+WyZxdW90O2E6YSZxdW90O108L3N0cmlu\n'
[2018-07-08 16:17:57,473]    DEBUG [adb_fast_run:146] Read: b'Zz4KPC9tYXA+Cg==\n'
[2018-07-08 16:17:57,493]    DEBUG [adb_fast_run:146] Read: b'ls: /3bb22bb739c29e435151cb38: No such file or directory\n'
otpauth://totp/a?algorithm=SHA1&digits=6&issuer=a&period=30&secret=AAAAAAAAAAAAAAAAAAAAA
erotavlasme commented 6 years ago

@puddly of course, it was randomized. No, for me the command python3 extract_otp_tokens.py --no-authy --no-duo --no-google-authenticator --no-microsoft-authenticator --no-steam-authenticator --verbose --verbose 2>&1 | grep -A5000 -m3 org.fedorahosted.freeotp/ gives empty output. I'm using python 3.5.2.

puddly commented 6 years ago

This script uses features only available in Python 3.6 or later so at least something should happen if the script doesn't immediately fail with a syntax error.

Is any output at all produced if you run the script as above but without filtering the output with grep?

I appreciate the help, this is probably a problem other people will run into.

erotavlasme commented 6 years ago

Ok, this is the output:

python3 extract_otp_tokens.py --no-authy --no-duo --no-google-authenticator --no-microsoft-authenticator --no-steam-authenticator --verbose --verbose 2>&1
  File "extract_otp_tokens.py", line 60
    name = f'{self.issuer}: {self.name}'
puddly commented 6 years ago

Right. The script cannot run with Python 3.5, it's too old. You need to use Python 3.6 or later.

erotavlasme commented 6 years ago

I installed python 3.6.

python3.6 extract_otp_tokens.py --no-authy --no-duo --no-google-authenticator --no-microsoft-authenticator --no-steam-authenticator --verbose --verbose 2>&1 
[2018-07-11 22:16:08,017]     INFO [<module>:495] Checking for root by listing the contents of $ANDROID_DATA/data. **You might have to grant ADB temporary root access.**
[2018-07-11 22:16:08,017]    DEBUG [adb_list_dir:167] Listing directory $ANDROID_DATA/data
[2018-07-11 22:16:08,019]    DEBUG [adb_fast_run:143] Running ['adb', 'shell', 'su -c "ls -1 \'$ANDROID_DATA/data\'"; ls /3bb22bb739c29e435151cb38']
[2018-07-11 22:16:08,192]    DEBUG [adb_fast_run:146] Read: b'android\r\n'
[2018-07-11 22:16:08,193]    DEBUG [adb_fast_run:146] Read: b'android.ext.shared\r\n'
[2018-07-11 22:16:08,193]    DEBUG [adb_fast_run:146] Read: b'at.bitfire.davdroid\r\n'
[2018-07-11 22:16:08,194]    DEBUG [adb_fast_run:146] Read: b'aws.apps.networkInfoIi\r\n'
[2018-07-11 22:16:08,195]    DEBUG [adb_fast_run:146] Read: b'be.brunoparmentier.wifikeyshare\r\n'
[2018-07-11 22:16:08,196]    DEBUG [adb_fast_run:146] Read: b'ch.protonmail.android\r\n'
[2018-07-11 22:16:08,197]    DEBUG [adb_fast_run:146] Read: b'cm.aptoide.pt\r\n'
[2018-07-11 22:16:08,198]    DEBUG [adb_fast_run:146] Read: b'com.airvisual\r\n'
[2018-07-11 22:16:08,200]    DEBUG [adb_fast_run:146] Read: b'com.amaze.filemanager\r\n'
[2018-07-11 22:16:08,201]    DEBUG [adb_fast_run:146] Read: b'com.android.backupconfirm\r\n'
[2018-07-11 22:16:08,202]    DEBUG [adb_fast_run:146] Read: b'com.android.bluetooth\r\n'
[2018-07-11 22:16:08,203]    DEBUG [adb_fast_run:146] Read: b'com.android.bluetoothmidiservice\r\n'
[2018-07-11 22:16:08,204]    DEBUG [adb_fast_run:146] Read: b'com.android.bookmarkprovider\r\n'
[2018-07-11 22:16:08,204]    DEBUG [adb_fast_run:146] Read: b'com.android.calculator2\r\n'
[2018-07-11 22:16:08,204]    DEBUG [adb_fast_run:146] Read: b'com.android.calendar\r\n'
[2018-07-11 22:16:08,204]    DEBUG [adb_fast_run:146] Read: b'com.android.calllogbackup\r\n'
[2018-07-11 22:16:08,204]    DEBUG [adb_fast_run:146] Read: b'com.android.captiveportallogin\r\n'
[2018-07-11 22:16:08,204]    DEBUG [adb_fast_run:146] Read: b'com.android.carrierconfig\r\n'
[2018-07-11 22:16:08,204]    DEBUG [adb_fast_run:146] Read: b'com.android.cellbroadcastreceiver\r\n'
[2018-07-11 22:16:08,206]    DEBUG [adb_fast_run:146] Read: b'com.android.certinstaller\r\n'
[2018-07-11 22:16:08,206]    DEBUG [adb_fast_run:146] Read: b'com.android.contacts\r\n'
[2018-07-11 22:16:08,206]    DEBUG [adb_fast_run:146] Read: b'com.android.cts.ctsshim\r\n'
[2018-07-11 22:16:08,206]    DEBUG [adb_fast_run:146] Read: b'com.android.cts.priv.ctsshim\r\n'
[2018-07-11 22:16:08,206]    DEBUG [adb_fast_run:146] Read: b'com.android.defcontainer\r\n'
[2018-07-11 22:16:08,206]    DEBUG [adb_fast_run:146] Read: b'com.android.deskclock\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.development\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.dialer\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.documentsui\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.dreams.basic\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.dreams.phototable\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.egg\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.email\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.emergency\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.exchange\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.externalstorage\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.gallery3d\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.htmlviewer\r\n'
[2018-07-11 22:16:08,207]    DEBUG [adb_fast_run:146] Read: b'com.android.inputdevices\r\n'
[2018-07-11 22:16:08,208]    DEBUG [adb_fast_run:146] Read: b'com.android.inputmethod.latin\r\n'
[2018-07-11 22:16:08,208]    DEBUG [adb_fast_run:146] Read: b'com.android.keychain\r\n'
[2018-07-11 22:16:08,208]    DEBUG [adb_fast_run:146] Read: b'com.android.location.fused\r\n'
[2018-07-11 22:16:08,208]    DEBUG [adb_fast_run:146] Read: b'com.android.managedprovisioning\r\n'
[2018-07-11 22:16:08,208]    DEBUG [adb_fast_run:146] Read: b'com.android.messaging\r\n'
[2018-07-11 22:16:08,209]    DEBUG [adb_fast_run:146] Read: b'com.android.mms.service\r\n'
[2018-07-11 22:16:08,209]    DEBUG [adb_fast_run:146] Read: b'com.android.mtp\r\n'
[2018-07-11 22:16:08,209]    DEBUG [adb_fast_run:146] Read: b'com.android.packageinstaller\r\n'
[2018-07-11 22:16:08,209]    DEBUG [adb_fast_run:146] Read: b'com.android.pacprocessor\r\n'
[2018-07-11 22:16:08,209]    DEBUG [adb_fast_run:146] Read: b'com.android.phone\r\n'
[2018-07-11 22:16:08,210]    DEBUG [adb_fast_run:146] Read: b'com.android.printservice.recommendation\r\n'
[2018-07-11 22:16:08,210]    DEBUG [adb_fast_run:146] Read: b'com.android.printspooler\r\n'
[2018-07-11 22:16:08,210]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.blockednumber\r\n'
[2018-07-11 22:16:08,210]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.calendar\r\n'
[2018-07-11 22:16:08,210]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.contacts\r\n'
[2018-07-11 22:16:08,211]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.downloads\r\n'
[2018-07-11 22:16:08,211]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.downloads.ui\r\n'
[2018-07-11 22:16:08,211]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.media\r\n'
[2018-07-11 22:16:08,211]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.settings\r\n'
[2018-07-11 22:16:08,211]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.telephony\r\n'
[2018-07-11 22:16:08,212]    DEBUG [adb_fast_run:146] Read: b'com.android.providers.userdictionary\r\n'
[2018-07-11 22:16:08,212]    DEBUG [adb_fast_run:146] Read: b'com.android.provision\r\n'
[2018-07-11 22:16:08,212]    DEBUG [adb_fast_run:146] Read: b'com.android.proxyhandler\r\n'
[2018-07-11 22:16:08,212]    DEBUG [adb_fast_run:146] Read: b'com.android.server.telecom\r\n'
[2018-07-11 22:16:08,212]    DEBUG [adb_fast_run:146] Read: b'com.android.settings\r\n'
[2018-07-11 22:16:08,212]    DEBUG [adb_fast_run:146] Read: b'com.android.sharedstoragebackup\r\n'
[2018-07-11 22:16:08,213]    DEBUG [adb_fast_run:146] Read: b'com.android.shell\r\n'
[2018-07-11 22:16:08,214]    DEBUG [adb_fast_run:146] Read: b'com.android.smspush\r\n'
[2018-07-11 22:16:08,214]    DEBUG [adb_fast_run:146] Read: b'com.android.statementservice\r\n'
[2018-07-11 22:16:08,214]    DEBUG [adb_fast_run:146] Read: b'com.android.stk\r\n'
[2018-07-11 22:16:08,214]    DEBUG [adb_fast_run:146] Read: b'com.android.storagemanager\r\n'
[2018-07-11 22:16:08,214]    DEBUG [adb_fast_run:146] Read: b'com.android.systemui\r\n'
[2018-07-11 22:16:08,214]    DEBUG [adb_fast_run:146] Read: b'com.android.terminal\r\n'
[2018-07-11 22:16:08,216]    DEBUG [adb_fast_run:146] Read: b'com.android.vending\r\n'
[2018-07-11 22:16:08,216]    DEBUG [adb_fast_run:146] Read: b'com.android.vpndialogs\r\n'
[2018-07-11 22:16:08,216]    DEBUG [adb_fast_run:146] Read: b'com.android.wallpaper.livepicker\r\n'
[2018-07-11 22:16:08,216]    DEBUG [adb_fast_run:146] Read: b'com.android.wallpaperbackup\r\n'
[2018-07-11 22:16:08,216]    DEBUG [adb_fast_run:146] Read: b'com.android.wallpapercropper\r\n'
[2018-07-11 22:16:08,216]    DEBUG [adb_fast_run:146] Read: b'com.android.wallpaperpicker\r\n'
[2018-07-11 22:16:08,216]    DEBUG [adb_fast_run:146] Read: b'com.android.webview\r\n'
[2018-07-11 22:16:08,216]    DEBUG [adb_fast_run:146] Read: b'com.apkpure.aegon\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.applagapp.elm327identifier\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.atmotube.app\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.b44t.messenger\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.brave.browser\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.bubblesoft.android.bubbleupnp\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.couchsurfing.mobile.android\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.cyanogenmod.eleven\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.cyanogenmod.lockclock\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.cyanogenmod.samsungservicemode\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.cyanogenmod.settings.device\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.cyanogenmod.setupwizard\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.cyanogenmod.trebuchet\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.finalwire.aida64\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.fsck.k9\r\n'
[2018-07-11 22:16:08,219]    DEBUG [adb_fast_run:146] Read: b'com.ghisler.android.TotalCommander\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.github.yeriomin.yalpstore\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.backuptransport\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.configupdater\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.ext.services\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.ext.shared\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.feedback\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.gms\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.gms.setup\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.gsf\r\n'
[2018-07-11 22:16:08,220]    DEBUG [adb_fast_run:146] Read: b'com.google.android.onetimeinitializer\r\n'
[2018-07-11 22:16:08,221]    DEBUG [adb_fast_run:146] Read: b'com.google.android.partnersetup\r\n'
[2018-07-11 22:16:08,221]    DEBUG [adb_fast_run:146] Read: b'com.google.android.setupwizard\r\n'
[2018-07-11 22:16:08,221]    DEBUG [adb_fast_run:146] Read: b'com.google.android.syncadapters.calendar\r\n'
[2018-07-11 22:16:08,221]    DEBUG [adb_fast_run:146] Read: b'com.google.android.syncadapters.contacts\r\n'
[2018-07-11 22:16:08,221]    DEBUG [adb_fast_run:146] Read: b'com.google.android.tts\r\n'
[2018-07-11 22:16:08,222]    DEBUG [adb_fast_run:146] Read: b'com.joshbegley.dronestream\r\n'
[2018-07-11 22:16:08,223]    DEBUG [adb_fast_run:146] Read: b'com.kajda.fuelio\r\n'
[2018-07-11 22:16:08,223]    DEBUG [adb_fast_run:146] Read: b'com.lmsc\r\n'
[2018-07-11 22:16:08,223]    DEBUG [adb_fast_run:146] Read: b'com.lyonbros.turtl\r\n'
[2018-07-11 22:16:08,224]    DEBUG [adb_fast_run:146] Read: b'com.maralexbar.wifikeyview\r\n'
[2018-07-11 22:16:08,224]    DEBUG [adb_fast_run:146] Read: b'com.nextcloud.client\r\n'
[2018-07-11 22:16:08,224]    DEBUG [adb_fast_run:146] Read: b'com.nperf.tester\r\n'
[2018-07-11 22:16:08,224]    DEBUG [adb_fast_run:146] Read: b'com.protonvpn.android\r\n'
[2018-07-11 22:16:08,224]    DEBUG [adb_fast_run:146] Read: b'com.qrcodereader\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.rebtel.android\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.revolut.revolut\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.staircase3.opensignal\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.svox.pico\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.termux\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.vrem.wifianalyzer\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.wire\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.wireguard.android\r\n'
[2018-07-11 22:16:08,225]    DEBUG [adb_fast_run:146] Read: b'com.wordreference\r\n'
[2018-07-11 22:16:08,226]    DEBUG [adb_fast_run:146] Read: b'cyanogenmod.platform\r\n'
[2018-07-11 22:16:08,226]    DEBUG [adb_fast_run:146] Read: b'cz.eutopia.snooperstopper\r\n'
[2018-07-11 22:16:08,226]    DEBUG [adb_fast_run:146] Read: b'cz.yetanotherview.webcamviewer.app\r\n'
[2018-07-11 22:16:08,226]    DEBUG [adb_fast_run:146] Read: b'de.onyxbits.listmyapps\r\n'
[2018-07-11 22:16:08,226]    DEBUG [adb_fast_run:146] Read: b'de.reimardoeffinger.quickdic\r\n'
[2018-07-11 22:16:08,226]    DEBUG [adb_fast_run:146] Read: b'eu.faircode.netguard\r\n'
[2018-07-11 22:16:08,226]    DEBUG [adb_fast_run:146] Read: b'im.vector.alpha\r\n'
[2018-07-11 22:16:08,226]    DEBUG [adb_fast_run:146] Read: b'info.guardianproject.orfox\r\n'
[2018-07-11 22:16:08,227]    DEBUG [adb_fast_run:146] Read: b'io.coinmarketapp.app\r\n'
[2018-07-11 22:16:08,227]    DEBUG [adb_fast_run:146] Read: b'io.github.droidapps.pdfreader\r\n'
[2018-07-11 22:16:08,228]    DEBUG [adb_fast_run:146] Read: b'me.twrp.twrpapp\r\n'
[2018-07-11 22:16:08,228]    DEBUG [adb_fast_run:146] Read: b'mega.privacy.android.app\r\n'
[2018-07-11 22:16:08,228]    DEBUG [adb_fast_run:146] Read: b'mobi.goldendict.android.free\r\n'
[2018-07-11 22:16:08,228]    DEBUG [adb_fast_run:146] Read: b'net.osmand.parkingPlugin\r\n'
[2018-07-11 22:16:08,228]    DEBUG [adb_fast_run:146] Read: b'net.osmand.plus\r\n'
[2018-07-11 22:16:08,228]    DEBUG [adb_fast_run:146] Read: b'net.osmand.srtmPlugin.paid\r\n'
[2018-07-11 22:16:08,228]    DEBUG [adb_fast_run:146] Read: b'net.reichholf.dreamdroid\r\n'
[2018-07-11 22:16:08,228]    DEBUG [adb_fast_run:146] Read: b'net.sourceforge.opencamera\r\n'
[2018-07-11 22:16:08,229]    DEBUG [adb_fast_run:146] Read: b'org.adaway\r\n'
[2018-07-11 22:16:08,229]    DEBUG [adb_fast_run:146] Read: b'org.cryptomator.beta\r\n'
[2018-07-11 22:16:08,229]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.audiofx\r\n'
[2018-07-11 22:16:08,229]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.cmaudio.service\r\n'
[2018-07-11 22:16:08,229]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.cmparts\r\n'
[2018-07-11 22:16:08,229]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.cmsettings\r\n'
[2018-07-11 22:16:08,230]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.gello.browser\r\n'
[2018-07-11 22:16:08,231]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.profiles\r\n'
[2018-07-11 22:16:08,231]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.snap\r\n'
[2018-07-11 22:16:08,231]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.weather.provider\r\n'
[2018-07-11 22:16:08,231]    DEBUG [adb_fast_run:146] Read: b'org.cyanogenmod.weatherservice\r\n'
[2018-07-11 22:16:08,231]    DEBUG [adb_fast_run:146] Read: b'org.dmfs.tasks\r\n'
[2018-07-11 22:16:08,231]    DEBUG [adb_fast_run:146] Read: b'org.documentfoundation.libreoffice\r\n'
[2018-07-11 22:16:08,232]    DEBUG [adb_fast_run:146] Read: b'org.eobdfacile.android\r\n'
[2018-07-11 22:16:08,232]    DEBUG [adb_fast_run:146] Read: b'org.fdroid.fdroid\r\n'
[2018-07-11 22:16:08,232]    DEBUG [adb_fast_run:146] Read: b'org.fedorahosted.freeotp\r\n'
[2018-07-11 22:16:08,232]    DEBUG [adb_fast_run:146] Read: b'org.havenapp.main\r\n'
[2018-07-11 22:16:08,232]    DEBUG [adb_fast_run:146] Read: b'org.horaapps.leafpic\r\n'
[2018-07-11 22:16:08,232]    DEBUG [adb_fast_run:146] Read: b'org.joa.zipperplus7v2\r\n'
[2018-07-11 22:16:08,232]    DEBUG [adb_fast_run:146] Read: b'org.lineageos.jelly\r\n'
[2018-07-11 22:16:08,233]    DEBUG [adb_fast_run:146] Read: b'org.lineageos.recorder\r\n'
[2018-07-11 22:16:08,233]    DEBUG [adb_fast_run:146] Read: b'org.lineageos.updater\r\n'
[2018-07-11 22:16:08,233]    DEBUG [adb_fast_run:146] Read: b'org.mozilla.firefox\r\n'
[2018-07-11 22:16:08,233]    DEBUG [adb_fast_run:146] Read: b'org.opengapps.app\r\n'
[2018-07-11 22:16:08,233]    DEBUG [adb_fast_run:146] Read: b'org.petero.droidfish\r\n'
[2018-07-11 22:16:08,233]    DEBUG [adb_fast_run:146] Read: b'org.prowl.torquefree\r\n'
[2018-07-11 22:16:08,233]    DEBUG [adb_fast_run:146] Read: b'org.schabi.newpipe\r\n'
[2018-07-11 22:16:08,233]    DEBUG [adb_fast_run:146] Read: b'org.scid.android\r\n'
[2018-07-11 22:16:08,234]    DEBUG [adb_fast_run:146] Read: b'org.shadowice.flocke.andotp\r\n'
[2018-07-11 22:16:08,234]    DEBUG [adb_fast_run:146] Read: b'org.sufficientlysecure.ical\r\n'
[2018-07-11 22:16:08,234]    DEBUG [adb_fast_run:146] Read: b'org.thoughtcrime.securesms\r\n'
[2018-07-11 22:16:08,235]    DEBUG [adb_fast_run:146] Read: b'org.thunderdog.challegram\r\n'
[2018-07-11 22:16:08,235]    DEBUG [adb_fast_run:146] Read: b'org.torproject.android\r\n'
[2018-07-11 22:16:08,235]    DEBUG [adb_fast_run:146] Read: b'org.videolan.vlc\r\n'
[2018-07-11 22:16:08,235]    DEBUG [adb_fast_run:146] Read: b'ru.meefik.busybox\r\n'
[2018-07-11 22:16:08,235]    DEBUG [adb_fast_run:146] Read: b'ws.xsoh.etar\r\n'
[2018-07-11 22:16:08,272]    DEBUG [adb_fast_run:146] Read: b'ls: /3bb22bb739c29e435151cb38: No such file or directory\n'
[2018-07-11 22:16:08,275]    DEBUG [<module>:501] Checking if files can be properly read by reading /system/build.prop
[2018-07-11 22:16:08,275]    DEBUG [adb_read_file:174] Reading file /system/build.prop
[2018-07-11 22:16:08,277]    DEBUG [adb_fast_run:143] Running ['adb', 'shell', 'su -c "su -c "toybox base64 /system/build.prop; ls /3bb22bb739c29e435151cb38']
[2018-07-11 22:16:08,385]    DEBUG [adb_fast_run:146] Read: b'Unknown id: base64\r\n'
[2018-07-11 22:16:08,414]    DEBUG [adb_fast_run:146] Read: b'ls: /3bb22bb739c29e435151cb38: No such file or directory\n'
Traceback (most recent call last):
  File "extract_otp_tokens.py", line 503, in <module>
    if not adb_read_file('/system/build.prop'):
  File "extract_otp_tokens.py", line 178, in adb_read_file
    return BytesIO(base64.b64decode(b''.join(lines)))
  File "/usr/lib/python3.6/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

File not found. I enabled root for adb and apps, but it seems that does not work.

puddly commented 6 years ago

Thank you. The problem probably stems from an overlooked typo (fixed in ed296363adf940a533bee39f921beae970acbf25) and the resulting quoting issues. Some versions of ADB seem to handle it better than others. I'm surprised it didn't cause any problems sooner.

ghost commented 5 years ago

If you don't have rooted phone and your OTP .apk is a debug app(compiled as debug .apk?), you can access tokens.xml via adb shell run-as org.fedorahosted.freeotp (assuming USB debugging is enabled, of course) freeotp-android example output: https://github.com/xftroxgpx/freeotp-android/issues/1#issuecomment-452037667