puddly / android-otp-extractor

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

Reading Google Authenticator accounts broken since 70f51be #28

Closed FloThinksPi closed 5 years ago

FloThinksPi commented 5 years ago

The commit 455c45f4e7d3812e37f80cc0f11e7194596cfbee broke google authenticator extraction for me:

./extract_otp_tokens.py --show-qr
[2019-02-26 13:29:41,343]     INFO [<module>:561] Testing if your phone uses toybox...
[2019-02-26 13:29:41,566]     INFO [<module>:576] It does!
[2019-02-26 13:29:41,566]     INFO [<module>:583] Checking for root by listing the contents of $ANDROID_DATA/data. You might have to grant ADB temporary root access.
[2019-02-26 13:29:41,729]     INFO [<module>:589] Checking if files can be properly read by reading $ANDROID_ROOT/build.prop
[2019-02-26 13:29:41,880]     INFO [<module>:610] Reading AndOTP accounts
[2019-02-26 13:29:42,012]     INFO [<module>:615] Found 0 accounts (0 new)
[2019-02-26 13:29:42,012]     INFO [<module>:610] Reading Authy accounts
[2019-02-26 13:29:42,291]     INFO [<module>:615] Found 0 accounts (0 new)
[2019-02-26 13:29:42,291]     INFO [<module>:610] Reading Duo accounts
[2019-02-26 13:29:42,424]     INFO [<module>:615] Found 0 accounts (0 new)
[2019-02-26 13:29:42,424]     INFO [<module>:610] Reading FreeOTP accounts
[2019-02-26 13:29:42,562]     INFO [<module>:615] Found 0 accounts (0 new)
[2019-02-26 13:29:42,562]     INFO [<module>:610] Reading Google Authenticator accounts
Traceback (most recent call last):
  File "./extract_otp_tokens.py", line 611, in <module>
    new = list(function(adb, args.data))
  File "./extract_otp_tokens.py", line 322, in read_google_authenticator_accounts
    with open_remote_sqlite_database(adb, data_root/'com.google.android.apps.authenticator2/databases/databases') as connection:
  File "/usr/lib64/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "./extract_otp_tokens.py", line 255, in open_remote_sqlite_database
    connection = sqlite3.connect(temp_dir/database.name)
TypeError: argument 1 must be str, not PosixPath

When checking out an earlier commit, everything works except the bugs this commit fixed.

puddly commented 5 years ago

Wrapping temp_dir/database.name in a call to str() will fix it, though I'm not sure why it didn't break for me. What Python version are you running?

FloThinksPi commented 5 years ago

I was running Python 3.6.7, but anyway got it working :)

puddly commented 5 years ago

@FloThinksPi my fault, Python 3.7 fixed this bug but I didn't bother to test with Python 3.6. Thanks for the bug report.