Code Monkey home page Code Monkey logo

firefox_decrypt's Introduction

Firefox Decrypt

GitHub Actions status Gitmoji badge

As of 1.0.0 Python 3.9+ is required. Python 2 is no longer supported. If you encounter a problem, try the latest release or check open issues for ongoing work.

If you definitely need to use Python 2, Firefox Decrypt 0.7.0 is your best bet, although no longer supported.

Table of contents

About

Firefox Decrypt is a tool to extract passwords from profiles of Mozilla (Fire/Water)fox™, Thunderbird®, SeaMonkey® and derivates.

It can be used to recover passwords from a profile protected by a Master Password as long as the latter is known. If a profile is not protected by a Master Password, passwords are displayed without prompt.

This tool does not try to crack or brute-force the Master Password in any way. If the Master Password is not known it will simply fail to recover any data.

It requires access to libnss3, included with most Mozilla products. The script is usually able to find a compatible library but may in some cases load an incorrect/incompatible version. If you encounter this situation please file a bug report.

Alternatively, you can install libnss3 (Debian/Ubuntu) or nss (Arch/Gentoo/…). libnss3 is part of https://developer.mozilla.org/docs/Mozilla/Projects/NSS

If you need to decode passwords from Firefox 3 or older, although not officially supported, there is a patch in this pull request.

Usage

Run:

python firefox_decrypt.py

The tool will present a numbered list of profiles. Enter the relevant number.

Then, a prompt to enter the master password for the profile:

  • if no password was set, no master password will be asked.
  • if a password was set and is known, enter it and hit key Return or Enter
  • if a password was set and is no longer known, you can not proceed

Advanced usage

If your profiles are at an unusual path, you can call the script with:

python firefox_decrypt.py /folder/containing/profiles.ini/

If you don't want to display all passwords on the screen you can use:

python firefox_decrypt.py | grep -C2 keyword

where keyword is part of the expected output (URL, username, email, password …)

You can also choose from one of the supported formats with --format:

  • human - a format displaying one record for every 3 lines
  • csv - a spreadsheet-like format. See also --csv-* options for additional control.
  • tabular - similar to csv but producing a tab-delimited (tsv) file instead.
  • json - a machine compatible format - see JSON
  • pass - a special output format that directly calls to the passwordstore.org command to export passwords (*). See also --pass-* options.

(*) pass can produce unintended consequences. Make sure to backup your password store before using this option.

Specify NSS library location

In order to decode your passwords, Firefox Decrypt uses a series of heuristics to try to locate a compatible NSS library on your system. As this approach can sometimes fail, starting with version 1.1.1 of Firefox Decrypt you can now define the NSS_LIB_PATH environment variable to manually specify the location of the library. This location will be prioritized and if no compatible library is found, the script will continue with the built-in heuristics.

# On Linux it will look for libnss3.so in /opt/nss/lib/
# On Mac it will look for libnss3.dylib
NSS_LIB_PATH=/opt/nss/lib/ python firefox_decrypt.py

# On Windows it will look for nss3.dll
set NSS_LIB_PATH=D:\NSS\lib\ && python firefox_decrypt.py

You can confirm if this was successful by running the script in high-verbosity mode (-vv) and look for the Loaded NSS message after Loading NSS:

(...) DEBUG - Loading NSS library from /opt/nss/lib/libnss3.so
(...) DEBUG - Loaded NSS library from /opt/nss/lib/libnss3.so
Non-interactive mode

A non-interactive mode which bypasses all prompts, including profile choice and master password, can be enabled with -n/--no-interactive. If you have multiple Mozilla profiles, make sure to also indicate your profile choice by passing -c/--choice N where N is the number of the profile you wish to decrypt (starting from 1).

You can list all available profiles with -l/--list (to stdout).

Your master password is read from stdin.

$ python firefox_decrypt.py --list
1 -> l1u1xh65.default
2 -> vuhdnx5b.YouTube
3 -> 1d8vcool.newdefault
4 -> ekof2ces.SEdu
5 -> 8a52xmtt.Fresh

$ read -sp "Master Password: " PASSWORD
Master Password:

$ echo $PASSWORD | python firefox_decrypt.py --no-interactive --choice 4
Website:   https://login.example.com
Username: 'john.doe'
Password: '1n53cur3'

Website:   https://example.org
Username: 'max.mustermann'
Password: 'Passwort1234'

Website:   https://github.com
Username: 'octocat'
Password: 'qJZo6FduRcHw'

[...snip...]

$ echo $PASSWORD | python firefox_decrypt.py -nc 1
Website:   https://git-scm.com
Username: 'foo'
Password: 'bar'

Website:   https://gitlab.com
Username: 'whatdoesthefoxsay'
Password: 'w00fw00f'

[...snip...]

$ # Unset Password
$ PASSWORD=
Format CSV

Passwords may be exported in CSV format using the --format flag.

python firefox_decrypt.py --format csv

Additionally, --csv-delimiter and --csv-quotechar flags can specify which characters to use as delimiters and quote characters in the CSV output.

Format Pass - Passwordstore

Stored passwords can be exported to pass (from passwordstore.org) using:

python firefox_decrypt.py --format pass

All existing passwords will be exported after the pattern web/<address>[:<port>]. If multiple credentials exist for the same website /<login> is appended. By pass convention, the password will be on the first and the username on the second line.

To prefix the username with login: for compatibility with the browserpass extension, you can use:

python firefox_decrypt.py --format pass --pass-username-prefix 'login: '

There is currently no way to selectively export passwords.

Exporting will overwrite existing passwords without warning. Ensure you have a backup or are using the pass git functionality.

Non fatal password decryption

By default, encountering a corrupted username or password will abort decryption. Since version 1.1.0 there is now --non-fatal-decryption that tolerates individual failures.

$ python firefox_decrypt.py --non-fatal-decryption
(...)
Website:   https://github.com
Username: '*** decryption failed ***'
Password: '*** decryption failed ***'

which can also be combined with any of the above --format options.

Troubleshooting

If a problem occurs, please try firefox_decrypt in high verbosity mode by calling it with:

python firefox_decrypt.py -vvv

If the output does not help you to identify the cause and a solution to the problem, file a bug report including the verbose output. Beware:

  • your profile password, as well as other passwords, may be visible in the output – so please remove any sensitive data before sharing the output.
Silencing error messages

Logging messages above warning level are included in the standard error output by default as these can be useful to troubleshoot failures. If you wish to omit this information append 2>/dev/null to your command on UNIX and 2> nul on Windows.

Windows

Both Python and Firefox must be either 32-bit or 64-bit.

If you mix architectures the code will fail. More information on issue #8.

cmd.exe is not supported due to it's poor UTF-8 support. Use Microsoft Terminal and install UTF-8 compatible fonts. Depending on the Terminal settings, the Windows version and the language of your system, you may also need to force Python to run in UTF-8 mode with PYTHONUTF8=1 python firefox_decrypt.py.

MacOS/Darwin

If you get the error described in #14 when loading libnss3, consider installing nss using Homebrew or an alternative package manager.

While not supported, you may find that DYLD_LIBRARY_PATH=. python3 firefox_decrypt.py will work in some configurations.

Testing

If you wish to run the test suite locally, chdir into tests/ and run ./run_all

If any test fails on your system, please ensure libnss is installed.

If tests continue to fail, re-run with ./run_all -v then please file a bug report including:

  • the output
  • information about your system (e.g. Linux distribution, version of libnss/firefox …).

It is much appreciated.

Contributors

All Contributors

See CONTRIBUTORS.md for a complete list of contributions

Spin-off, derived and related works


Firefox is a trademark of the Mozilla Foundation in the U.S. and other countries.

firefox_decrypt's People

Contributors

catleeball avatar criztovyl avatar dwordptr avatar edwintorok avatar eseifert avatar gounlaf avatar neffisback avatar sedrubal avatar stweil avatar thomasmerz avatar unode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

firefox_decrypt's Issues

Firefox decrypt cannot find `libnss3.so` on NixOS

The bug
On NixOS (currently latest stable), firefox decrypt cannot find libnss3.so, probably because NixOS stores libraries within its store (which is in /nix/store/), and firefox decrypt does't look for libnss3.so there.

To Reproduce

$ git clone https://github.com/unode/firefox_decrypt
[...]
$ cd firefox_decrypt
$ nix-shell -p python39
[...]
$ python firefox_decrypt.py
ERROR [...]

Logs

$ python firefox_decrypt.py
2021-06-13 11:29:49,606 - ERROR - Couldn't find or load 'libnss3.so'. This library is essential to interact with your Mozilla profile.
2021-06-13 11:29:49,606 - ERROR - If you are seeing this error please perform a system-wide search for 'libnss3.so' and file a bug report indicating any location found. Thanks!
2021-06-13 11:29:49,606 - ERROR - Alternatively you can try launching firefox_decrypt from the location where you found 'libnss3.so'. That is 'cd' or 'chdir' to that location and run firefox_decrypt from there.
2021-06-13 11:29:49,606 - ERROR - Please also include the following on any bug report. Errors seen while searching/loading NSS:
2021-06-13 11:29:49,606 - ERROR - Error when loading libnss3.so was libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /usr/lib64/libnss3.so was /usr/lib64/libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /usr/lib64/nss/libnss3.so was /usr/lib64/nss/libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /usr/lib/libnss3.so was /usr/lib/libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /usr/lib/nss/libnss3.so was /usr/lib/nss/libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /usr/local/lib/libnss3.so was /usr/local/lib/libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /usr/local/lib/nss/libnss3.so was /usr/local/lib/nss/libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /opt/local/lib/libnss3.so was /opt/local/lib/libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /opt/local/lib/nss/libnss3.so was /opt/local/lib/nss/libnss3.so: cannot open shared object file: No such file or directory
2021-06-13 11:29:49,606 - ERROR - Error when loading /home/user/.nix-profile/lib/libnss3.so was /home/user/.nix-profile/lib/libnss3.so: cannot open shared object file: No such file or directory

Technical information

  • OS: GNU/Linux 5.10.40 - NixOS 21.05 - 64bits
  • Browser: Firefox Firefox 89.0 - 64bits
  • Python: Python 3.9.4
  • firefox_decrypt: 1.0.0+git

Additional information
The actual path for libnss3.so is /nix/store/22xfq369sx8dqfxv9g1rixjaiw12j0f5-nss-3.53.1/lib/libnss3.so, but it cannot be reliably hard-coded, because 22xfq369sx8dqfxv9g1rixjaiw12j0f5 is the hash of the derivation, not of the package, which might change.

libnss3 usage is a bit crude and has memory leaks

First, thanks for the nice work! I always needed that tool but I never trusted any code. But your code is nicely understandable...so while checking the code I noticed a few bugs related to the libnss3 usage.

  1. In get_keyslot there is a strange cast required to avoid segfaults (my system is affected). I think, the reason is that the return value is not void_p but a pointer to a struct.
  2. There is a memory leak, because the SECItems are not freed.
  3. The keyslot is also not freed, which causes the NSS_Shutdown to fail always.

There seems to be no real documentation of libnss3, but attached is a class which does a more accurate handling of libnss3, feel free to use it.

nssdecoder.zip

Firefox decrypt cannot find `libnss3.dylib` on macOS

I navigated to /Applications/Firefox.app/Contents/MacOS using cd and then pasted and ran python3 firefox_decrypt.py -vvv from there. /Applications/Firefox.app/Contents/MacOS/libnss3.dylib exists but firefox_decrypt couldn't find it.

2021-06-22 22:09:33,899 - DEBUG - Running with encodings: stdin: utf-8, stdout: utf-8, stderr: utf-8, locale: UTF-8
2021-06-22 22:09:33,899 - DEBUG - Loading NSS library from libnss3.dylib
2021-06-22 22:09:33,899 - DEBUG - PATH is now ;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,900 - DEBUG - Loading NSS library from /usr/local/lib/nss/libnss3.dylib
2021-06-22 22:09:33,900 - DEBUG - PATH is now /usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,900 - DEBUG - Loading NSS library from /usr/local/lib/libnss3.dylib
2021-06-22 22:09:33,900 - DEBUG - PATH is now /usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,900 - DEBUG - Loading NSS library from /opt/local/lib/nss/libnss3.dylib
2021-06-22 22:09:33,900 - DEBUG - PATH is now /opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,900 - DEBUG - Loading NSS library from /sw/lib/firefox/libnss3.dylib
2021-06-22 22:09:33,901 - DEBUG - PATH is now /sw/lib/firefox;/opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,901 - DEBUG - Loading NSS library from /sw/lib/mozilla/libnss3.dylib
2021-06-22 22:09:33,901 - DEBUG - PATH is now /sw/lib/mozilla;/sw/lib/firefox;/opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,901 - DEBUG - Loading NSS library from /usr/local/opt/nss/lib/libnss3.dylib
2021-06-22 22:09:33,901 - DEBUG - PATH is now /usr/local/opt/nss/lib;/sw/lib/mozilla;/sw/lib/firefox;/opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,901 - DEBUG - Loading NSS library from /opt/pkg/lib/nss/libnss3.dylib
2021-06-22 22:09:33,901 - DEBUG - PATH is now /opt/pkg/lib/nss;/usr/local/opt/nss/lib;/sw/lib/mozilla;/sw/lib/firefox;/opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,901 - DEBUG - Loading NSS library from /Applications/Firefox.app/Contents/MacOS/libnss3.dylib
2021-06-22 22:09:33,901 - DEBUG - PATH is now /Applications/Firefox.app/Contents/MacOS;/opt/pkg/lib/nss;/usr/local/opt/nss/lib;/sw/lib/mozilla;/sw/lib/firefox;/opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,902 - DEBUG - Loading NSS library from /Applications/Thunderbird.app/Contents/MacOS/libnss3.dylib
2021-06-22 22:09:33,902 - DEBUG - PATH is now /Applications/Thunderbird.app/Contents/MacOS;/Applications/Firefox.app/Contents/MacOS;/opt/pkg/lib/nss;/usr/local/opt/nss/lib;/sw/lib/mozilla;/sw/lib/firefox;/opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,902 - DEBUG - Loading NSS library from /Applications/SeaMonkey.app/Contents/MacOS/libnss3.dylib
2021-06-22 22:09:33,902 - DEBUG - PATH is now /Applications/SeaMonkey.app/Contents/MacOS;/Applications/Thunderbird.app/Contents/MacOS;/Applications/Firefox.app/Contents/MacOS;/opt/pkg/lib/nss;/usr/local/opt/nss/lib;/sw/lib/mozilla;/sw/lib/firefox;/opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,902 - DEBUG - Loading NSS library from /Applications/Waterfox.app/Contents/MacOS/libnss3.dylib
2021-06-22 22:09:33,902 - DEBUG - PATH is now /Applications/Waterfox.app/Contents/MacOS;/Applications/SeaMonkey.app/Contents/MacOS;/Applications/Thunderbird.app/Contents/MacOS;/Applications/Firefox.app/Contents/MacOS;/opt/pkg/lib/nss;/usr/local/opt/nss/lib;/sw/lib/mozilla;/sw/lib/firefox;/opt/local/lib/nss;/usr/local/lib;/usr/local/lib/nss;;/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
2021-06-22 22:09:33,902 - ERROR - Couldn't find or load 'libnss3.dylib'. This library is essential to interact with your Mozilla profile.
2021-06-22 22:09:33,902 - ERROR - If you are seeing this error please perform a system-wide search for 'libnss3.dylib' and file a bug report indicating any location found. Thanks!
2021-06-22 22:09:33,902 - ERROR - Alternatively you can try launching firefox_decrypt from the location where you found 'libnss3.dylib'. That is 'cd' or 'chdir' to that location and run firefox_decrypt from there.
2021-06-22 22:09:33,902 - ERROR - Please also include the following on any bug report. Errors seen while searching/loading NSS:
2021-06-22 22:09:33,902 - ERROR - Error when loading libnss3.dylib was dlopen(libnss3.dylib, 6): Library not loaded: @executable_path/libmozglue.dylib
  Referenced from: /Applications/Firefox.app/Contents/MacOS/libnss3.dylib
  Reason: image not found
2021-06-22 22:09:33,902 - ERROR - Error when loading /usr/local/lib/libnss3.dylib was dlopen(/usr/local/lib/libnss3.dylib, 6): image not found
2021-06-22 22:09:33,902 - ERROR - Error when loading /Applications/Firefox.app/Contents/MacOS/libnss3.dylib was dlopen(/Applications/Firefox.app/Contents/MacOS/libnss3.dylib, 6): Library not loaded: @executable_path/libmozglue.dylib
  Referenced from: /Applications/Firefox.app/Contents/MacOS/libnss3.dylib
  Reason: image not found

Question

What file does this open too view the passwords?

Is it opening and decrypting logins.json?

Does it require the key3.db file?

Make project PEP8-compliant?

Is your feature request related to a problem? Please describe.
No, I just like standardized code :)

Describe the solution you'd like
Adjust to coding standards, that means especially to introduce line breaks at appropriate places.
Add e.g. flake8 to wercker.yml, maybe as it has been done at this example

Describe alternatives you've considered
There might be more scripts which could do a similar job

Additional context
I just tried running flake8 locally and the output was this:

.\firefox_decrypt.py:162:80: E501 line too long (80 > 79 characters) .\firefox_decrypt.py:200:80: E501 line too long (88 > 79 characters) .\firefox_decrypt.py:265:80: E501 line too long (86 > 79 characters) .\firefox_decrypt.py:266:80: E501 line too long (90 > 79 characters) .\firefox_decrypt.py:272:80: E501 line too long (80 > 79 characters) .\firefox_decrypt.py:297:80: E501 line too long (81 > 79 characters) .\firefox_decrypt.py:302:80: E501 line too long (80 > 79 characters) .\firefox_decrypt.py:323:80: E501 line too long (82 > 79 characters) .\firefox_decrypt.py:335:80: E501 line too long (103 > 79 characters) .\firefox_decrypt.py:388:80: E501 line too long (84 > 79 characters) .\firefox_decrypt.py:408:80: E501 line too long (98 > 79 characters) .\firefox_decrypt.py:440:80: E501 line too long (98 > 79 characters) .\firefox_decrypt.py:469:80: E501 line too long (92 > 79 characters) .\firefox_decrypt.py:507:80: E501 line too long (101 > 79 characters) .\firefox_decrypt.py:538:80: E501 line too long (100 > 79 characters) .\firefox_decrypt.py:539:80: E501 line too long (118 > 79 characters) .\firefox_decrypt.py:558:80: E501 line too long (95 > 79 characters) .\firefox_decrypt.py:593:80: E501 line too long (84 > 79 characters) .\firefox_decrypt.py:606:80: E501 line too long (84 > 79 characters) .\firefox_decrypt.py:623:80: E501 line too long (88 > 79 characters) .\firefox_decrypt.py:666:80: E501 line too long (88 > 79 characters) .\firefox_decrypt.py:714:80: E501 line too long (84 > 79 characters) .\firefox_decrypt.py:791:80: E501 line too long (84 > 79 characters) .\firefox_decrypt.py:818:80: E501 line too long (124 > 79 characters) .\firefox_decrypt.py:828:80: E501 line too long (112 > 79 characters) .\firefox_decrypt.py:839:80: E501 line too long (80 > 79 characters) .\firefox_decrypt.py:846:80: E501 line too long (88 > 79 characters) .\firefox_decrypt.py:850:80: E501 line too long (90 > 79 characters) .\firefox_decrypt.py:852:80: E501 line too long (96 > 79 characters) .\firefox_decrypt.py:856:80: E501 line too long (102 > 79 characters) .\firefox_decrypt.py:858:80: E501 line too long (103 > 79 characters) .\firefox_decrypt.py:860:80: E501 line too long (97 > 79 characters) .\firefox_decrypt.py:861:80: E501 line too long (83 > 79 characters) .\firefox_decrypt.py:867:80: E501 line too long (87 > 79 characters) .\firefox_decrypt.py:872:80: E501 line too long (106 > 79 characters) .\firefox_decrypt.py:876:80: E501 line too long (116 > 79 characters) .\firefox_decrypt.py:921:80: E501 line too long (90 > 79 characters) .\firefox_decrypt.py:925:80: E501 line too long (108 > 79 characters) .\firefox_decrypt.py:957:80: E501 line too long (80 > 79 characters)

TypeError: 'type' object is not subscriptable

Hi Unode and thank you very much for your work !

When first running the code, I stumble over the following issue. Would you have any hint on how to solve it ?

Traceback (most recent call last):
File "C:\Users...\firefox_decrypt.py", line 46, in
PWStore = list[dict[str, str]]
TypeError: 'type' object is not subscriptable

Thank you very much !

Encryption of the firefox passwords database

I ended up here searching a way to import passwords from an Opera exported CSV. I was able to find a lot of projects decrypting the firefox database, but any that can encrypt again it.

This feature would be very useful because you would be able to add new contents automatically (and not one by one using firefox lockwise) and the re-encrypt database.

I think it should not be so complex, just reversing the procedure used to decrypt, but I am not very expert in cryptography.

Can not export passwords from Thunderbird 60

Help us reproduce your problem
I have installed Firefox 63 and Firefox ESR 52 in parallel on Ubuntu-64 18.04 de_DE.
I have installed Thunderbird 60.

Describe the bug
I can export passwords without problem from old backup profile (~1 year) which was used with old TB version 52 and also from both FF profiles version 52-ESR and 63.
I fail to export passwords from current profile of current TB version 60.
Maybe because I have installed Firefox ESR 52 in parallel, the wrong libnss3 is fetched.

To Reproduce
Steps to reproduce the behavior:

  1. Launched firefox_decrypt with the following command-line arguments ...
    ./firefox_decrypt.py -f csv /home/ich/.thunderbird/Profiles/xxxxxxxx.default > TB_PW_2018-11-19.csv
  2. Selected the profile directly by command-line argument
  3. Typed in the master password ... yes. But I also tried with temporarily removing the master password.
  4. Something didn't work (or worked differently from expected) ...
    a) 2018-11-20 01:41:17,372 - ERROR - Master password is not correct
    b) 2018-11-20 01:41:23,367 - WARNING - Attempting decryption with no Master Password
    2018-11-20 01:41:23,374 - ERROR - Password decryption failed. Passwords protected by a Master Password!

Asking for Master Password when there is none FF 52.0

I am running Firefox 52.0 64bit on Ubuntu 16.10 and have used this with no issues in the past but not for a couple of months. Now when I run it I am prompted

Master Password for profile NameOfDefaultProfile:

But I have no master password set.

The first couple times I did it with a blank I got a segfault. I tried my system password and my mozilla password and just got a message that it was incorrect. Then for some reason it started working with a blank and now it does that with a message about attempting without a default password and works fine.

UnicodeDecodeError

C:\Users\Алиса\Desktop>C:\Users\Алиса\Desktop\firefox_decrypt.py

Traceback (most recent call last):
File "C:\Users\Lышёр\Desktop\firefox_decrypt.py", line 794, in
main()
File "C:\Users\Lышёр\Desktop\firefox_decrypt.py", line 767, in main
nss.load_profile(profile)
File "C:\Users\Lышёр\Desktop\firefox_decrypt.py", line 325, in load_profile
e = self.NSS._NSS_Init(b"sql:" + self.profile.encode("utf8"))

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 9: ordinal
not in range(128)

Thank-you

This is not a bug-report, this is a simple note to say thank-you for writing this utility and for making it available.

Having moved to a new computer using this tool allowed me to easily export the few passwords which I'd not previously migrated to the pass application.

Very handy, very useful, and worked without a problem for me.

How to import passwords

Can you clarify...
Is there a program, which is able to import the exported passwords again, like addon "Password Exporter" does on old Mozilla versions?
If not, could you provide such program in future?

Translate tests to Python

Windows has been a second class citizen where sporadic testing was done and bugs fixed based on user feedback. Tests are written in Bash so it's difficult to run them on Windows unless a cygwin environment is used.

After #28 which pointed out serious flaws related with encoding, primarily visible in non-ASCII deployments, it became clear that to properly support Windows automated testing is required.

AppVeyor stood out as a nice platform for this. AppVeyor is now setup and ready to be merged on #29, however we still need tests to be compatible with Windows.

This will also help the work on #25 which proposed the use of hypotesis, a python testing framework.

Ongoing work lives in the pytests branch.

Release please (fixing an input selection bug)

The project README.md mentions --pass-compat flat, while the latest release 0.7.0 has no such support. It would be great to keep the released version in sync with the documentation. The master branch 2a31774 didn't work on macOS: prompted two profiles for Firefox, but pressing 1 then pressing Enter simply repeated the prompt, stuck in a loop.

~/D/firefox_decrypt-master $ python firefox_decrypt.py --export-pass 
Select the Firefox profile you wish to decrypt
1 -> Profiles/nmpnntrd.default
2 -> Profiles/gtd5qo9s.dev-edition-default
1
Select the Firefox profile you wish to decrypt
1 -> Profiles/nmpnntrd.default
2 -> Profiles/gtd5qo9s.dev-edition-default
2
Select the Firefox profile you wish to decrypt
1 -> Profiles/nmpnntrd.default
2 -> Profiles/gtd5qo9s.dev-edition-default

Traceback (most recent call last):
  File "firefox_decrypt.py", line 965, in <module>
    main()
  File "firefox_decrypt.py", line 935, in main
    profile = get_profile(basepath, args.interactive, args.choice, args.list)
  File "firefox_decrypt.py", line 822, in get_profile
    section = ask_section(profiles, choice)
  File "firefox_decrypt.py", line 717, in ask_section
    choice = raw_input()
  File "<string>", line 0
    
    ^
SyntaxError: unexpected EOF while parsing

Search by url string

Is your feature request related to a problem? Please describe.
Search the password by string in the URL of the website. It is more convenable than Firefox's gui (too many clicks, it has the button to show the hidden password too...)

Describe the solution you'd like
Have an option to search by domain (url) string

Additional context
Code example:

--- firefox_decrypt.py	2020-04-30 07:43:34.973454793 +0200
+++ firefox_decrypt-s.py	2020-04-30 07:58:49.921552869 +0200
@@ -537,7 +537,7 @@
 
         return user, passw
 
-    def decrypt_passwords(self, export, output_format="human", csv_delimiter=";", csv_quotechar="|"):
+    def decrypt_passwords(self, export, output_format="human", csv_delimiter=";", csv_quotechar="|", string=''):
         """
         Decrypt requested profile using the provided password and print out all
         stored passwords.
@@ -562,6 +562,10 @@
                 csv_writer.writeheader()
 
         for url, user, passw, enctype in credentials:
+            if string != '':
+                if url.count(string) == 0:
+                    continue
+
             got_password = True
 
             # enctype informs if passwords are encrypted and protected by
@@ -920,6 +924,7 @@
                         help="Verbosity level. Warning on -vv (highest level) user input will be printed on screen")
     parser.add_argument("--version", action="version", version=__version__,
                         help="Display version of firefox_decrypt and exit")
+    parser.add_argument("-s", "--string", action='store', default='', help="Type a string to filter the resaults")
 
     args = parser.parse_args()
 
@@ -989,6 +994,7 @@
         output_format=args.format,
         csv_delimiter=args.delimiter,
         csv_quotechar=args.quotechar,
+        string=args.string,
     )
 
     if args.export_pass:

Stops part way through with error Password

I have a large number of passwords. Program gets part way through the passwords and then stops with:

2018-08-26 13:42:19,614 - ERROR - Password decryption failed. Passwords protected by a Master Password!

Note it works for a while, then the error.

Python 3.7.0 64-bit

Prompt the user and download nss3.dll from Mozilla if not found or not compatible

I put nss3.dll in the script folder and run it from a CMD shell with the script in the working directory.

image

2018-10-11 21:20:33,456 - ERROR - Problems opening 'nss3.dll' required for password decryption
2018-10-11 21:20:33,456 - ERROR - Error was [WinError 126] Unable to find the specified module.

Ps. Can't the script just download the dll from the internet if not found?

Export more fields

Is your feature request related to a problem? Please describe.
There may be problems when importing passwords from the current output. See issue #47 .

Describe the solution you'd like
Additionally export all fields, e.g.: transport prefix, comment, field name login, field name password.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
When using the addon "Password Exporter" on old versions of Mozilla there are 7 fields shown: url. login, password, transport prefix, comment, field name login, field name password.

TypeError: Incorrect padding

On openSUSE Leap 15.0 (kernel 4.12.14, python 2.7.14) I see during command

python bin/firefox_decrypt -c 1  --export-pass

a lot of Website, Username, and Password entries but then it fails suddenly with

Traceback (most recent call last):
  File "/suse/werner/bin/firefox_decrypt", line 965, in <module>
    main()
  File "/suse/werner/bin/firefox_decrypt", line 946, in main
    csv_quotechar=args.quotechar,
  File "/suse/werner/bin/firefox_decrypt", line 536, in decrypt_passwords
    user, passw = self.decode_entry(user, passw)
  File "/suse/werner/bin/firefox_decrypt", line 503, in decode_entry
    passw = self.NSS.decode(passw64)
  File "/suse/werner/bin/firefox_decrypt", line 400, in decode
    data = b64decode(data64)
  File "/usr/lib64/python2.7/base64.py", line 78, in b64decode
    raise TypeError(msg)
TypeError: Incorrect padding

I guess that as my password are autogenerated not only with characters and numbers but also with special signs, that the script is running onto CVS quote/delimeter character

error...

Win 7, 32x
Python 2.7
Firefox 60.0.1

C:\Users\Алиса>python C:\Users\Алиса\Desktop\firefox_decrypt.py -vvv

2018-05-17 21:34:34,355 - INFO - Running firefox_decrypt version: 0.7.0
2018-05-17 21:34:34,355 - DEBUG - Parsed commandline arguments: Namespace(choice
=None, delimiter=';', export_pass=False, format='human', interactive=True, list=
False, pass_cmd=u'pass', pass_compat='default', pass_prefix=u'web', profile='C:
\Users\\xc0\xeb\xe8\xf1\xe0\AppData\Roaming\Mozilla\Firefox', quotechar='"'
, tabular=False, verbose=3)
2018-05-17 21:34:34,355 - DEBUG - Skipping password store test, not exporting
2018-05-17 21:34:34,355 - DEBUG - PATH is now C:\Python27;C:\Python27\Scripts;C
:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\Windo
wsPowerShell\v1.0;C:\Program Files\Universal Extractor;C:\Program Files\Univers
al Extractor\bin;C:\Program Files\dotnet;C:\Program Files\Mozilla Firefox
2018-05-17 21:34:34,355 - DEBUG - Loading NSS library from C:\Program Files\Mozi
lla Firefox\nss3.dll
2018-05-17 21:34:34,355 - DEBUG - Reading profiles from C:\Users\Lышёр\AppData\R
oaming\Mozilla\Firefox\profiles.ini
2018-05-17 21:34:34,371 - DEBUG - Read profiles ['General', 'Profile0']
2018-05-17 21:34:34,371 - DEBUG - Profile selection matched Profiles/7xofdivo.de
fault
2018-05-17 21:34:34,371 - DEBUG - Initializing NSS with profile path 'C:\Users\L
ышёр\AppData\Roaming\Mozilla\Firefox\Profiles/7xofdivo.default'
2018-05-17 21:34:34,371 - DEBUG - Initializing NSS returned -1
2018-05-17 21:34:34,371 - ERROR - Couldn't initialize NSS, maybe 'C:\Users\Lышёр
\AppData\Roaming\Mozilla\Firefox\Profiles/7xofdivo.default' is not a valid profi
le?
2018-05-17 21:34:34,387 - DEBUG - Error during a call to NSS library, trying to
obtain error info
2018-05-17 21:34:34,387 - DEBUG - SEC_ERROR_BAD_DATABASE: security library: bad
database.

Not finding nss3 lib on mac os X

I was getting an error like this while trying to use nss3 from both Firefox and Thunderbird.

2017-03-25 21:48:28,524 - ERROR - Error was dlopen(libnss3.dylib, 6): Library not loaded: @executable_path/libmozglue.dylib
  Referenced from: /Users/joao/Applications/FirefoxDeveloperEdition.app/Contents/MacOS/libnss3.dylib
  Reason: unsafe use of @executable_path in libnss3.dylib with restricted binary

From https://bugzilla.mozilla.org/show_bug.cgi?id=578751 this is an issue that isn't going to be solved.

My final solution was to install nss from homebrew with brew install nss and adding "/usr/local/opt/nss/lib", to the paths of nss library in Darwin (around line 245).

Just opening this to inform others.

Protect

How do I protect myself against this kind of attack?

New location for libnss3.dylib

Running this on my macbook got the error

2018-08-13 09:38:29,696 - ERROR - Couldn't find or load 'libnss3.dylib'. This library is essential to interact with your Mozilla profile.
2018-08-13 09:38:29,696 - ERROR - If you are seeing this error please perform a system-wide search for 'libnss3.dylib' and file a bug report indicating any location found. Thanks!
2018-08-13 09:38:29,696 - ERROR - Alternatively you can try launching firefox_decrypt from the location where you found 'libnss3.dylib'. That is 'cd' or 'chdir' to that location and run firefox_decrypt from there.
2018-08-13 09:38:29,696 - ERROR - Please also include the following on any bug report. Errors seen while searching/loading NSS:
2018-08-13 09:38:29,697 - ERROR - Error when loading libnss3.dylib was dlopen(libnss3.dylib, 6): image not found
2018-08-13 09:38:29,697 - ERROR - Error when loading /usr/local/lib/nss/libnss3.dylib was dlopen(/usr/local/lib/nss/libnss3.dylib, 6): image not found
2018-08-13 09:38:29,698 - ERROR - Error when loading /usr/local/lib/libnss3.dylib was dlopen(/usr/local/lib/libnss3.dylib, 6): image not found
2018-08-13 09:38:29,698 - ERROR - Error when loading /opt/local/lib/nss/libnss3.dylib was dlopen(/opt/local/lib/nss/libnss3.dylib, 6): image not found
2018-08-13 09:38:29,698 - ERROR - Error when loading /sw/lib/firefox/libnss3.dylib was dlopen(/sw/lib/firefox/libnss3.dylib, 6): image not found
2018-08-13 09:38:29,698 - ERROR - Error when loading /sw/lib/mozilla/libnss3.dylib was dlopen(/sw/lib/mozilla/libnss3.dylib, 6): image not found
2018-08-13 09:38:29,698 - ERROR - Error when loading /usr/local/opt/nss/lib/libnss3.dylib was dlopen(/usr/local/opt/nss/lib/libnss3.dylib, 6): image not found
2018-08-13 09:38:29,698 - ERROR - Error when loading /opt/pkg/lib/nss/libnss3.dylib was dlopen(/opt/pkg/lib/nss/libnss3.dylib, 6): image not found

And, running a find / -name libnss3.dylib found it at:

/Applications/Firefox.app/Contents/MacOS/libnss3.dylib

I'm on macOs 10.13.6 with Firefox 61.0.1

how i can solve this Error? (Windows)

HI, I started firefox_decrypt in the following way and got this error, what can be the problem?

(py3.9) C:\Users\MyPC\Desktop\firefox_decrypt-master>python firefox_decrypt.py
2021-07-02 17:18:54,035 - WARNING - Running with unsupported encoding 'locale': cp1252 - Things are likely to fail from here onwards
Traceback (most recent call last):
File "C:\Users\MyPC\Desktop\firefox_decrypt-master\firefox_decrypt.py", line 1106, in
main()
File "C:\Users\MyPC\Desktop\firefox_decrypt-master\firefox_decrypt.py", line 1087, in main
profile = get_profile(basepath, args.interactive, args.choice, args.list)
File "C:\Users\MyPC\Desktop\firefox_decrypt-master\firefox_decrypt.py", line 858, in get_profile
profiles: ConfigParser = read_profiles(basepath)
File "C:\Users\MyPC\Desktop\firefox_decrypt-master\firefox_decrypt.py", line 842, in read_profiles
profiles.read(profileini)
File "C:\Users\MyPC\anaconda3\envs\py3.9\lib\configparser.py", line 697, in read
self._read(fp, filename)
File "C:\Users\MyPC\anaconda3\envs\py3.9\lib\configparser.py", line 1082, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
configparser.MissingSectionHeaderError: File contains no section headers.
file: 'C:\Users\MyPC\AppData\Roaming\Mozilla\Firefox\profiles.ini', line: 1
'ÿþ[\x00I\x00n\x00s\x00t\x00a\x00l\x00l\x003\x000\x008\x000\x004\x006\x00B\x000\x00A\x00F\x004\x00A\x003\x009\x00C\x00B\x00]\x00\n'

Segmentation fault [Debian Testing]

$ git describe --tags
0.5.4-3-gf6d16af
$ ./firefox_decrypt -vvvvvvvvv #  verbose overflow :D
2017-02-03 15:05:28,862 - DEBUG - Parsed commandline arguments: Namespace(choice=None, export_pass=False, list=False, no_interactive=False, profile='~/.mozilla/firefox', verbose=9)
2017-02-03 15:05:28,862 - DEBUG - Skipping password store test, not exporting
2017-02-03 15:05:28,862 - DEBUG - Loading NSS library from libnss3.so
2017-02-03 15:05:28,864 - DEBUG - Reading profiles from /home/christoph/.mozilla/firefox/profiles.ini
2017-02-03 15:05:28,865 - DEBUG - Read profiles ['General', 'Profile0', 'Profile1', 'Profile2', 'Profile3', 'Profile4']
Select the Firefox profile you wish to decrypt
1 -> 91u1xh15.[Profile 1]
2 -> vu3dnx5b.[Profile 2]
3 -> 1d8vcooi.[Profile 3]
4 -> emof2pes.[Profile 4]
5 -> 8a52xmxd.Fresh
Choice: 5                         
2017-02-03 15:05:47,516 - DEBUG - Profile selection matched 8a52xmxd.Fresh

Master Password for profile /home/christoph/.mozilla/firefox/8a52xmxd.Fresh: 
2017-02-03 15:05:53,011 - DEBUG - Initializing NSS with profile path '/home/christoph/.mozilla/firefox/8a52xmxd.Fresh'
2017-02-03 15:05:53,016 - DEBUG - Initializing NSS returned 0
2017-02-03 15:05:53,016 - DEBUG - Retrieving internal key slot
2017-02-03 15:05:53,016 - DEBUG - Internal key slot -1009786480
2017-02-03 15:05:53,017 - DEBUG - Authenticating with password '[Password]'
Segmentation fault

Removed Profile 1-4 Names & the Password from Log.

  • It's failing at Line 275 (otherwise the debug message from 276 would be printed ^^)
  • both Python 2 and 3
  • libnss3 2:3.26.2-1
  • f6d16af

Error - Passwords protected by a Master Password!

While trying to export my passwords I get an error: Error - Passwords protected by a Master Password!
I'm sure I enter correct master password. What is the culprit?

Full output:

Select the Firefox profile you wish to decrypt
1 -> bgpdiy8n.default-1373553171844
Choice: 1

Master Password for profile /home/yz/.mozilla/firefox/bgpdiy8n.default-1373553171844:
Info - Using /home/yz/.mozilla/firefox/bgpdiy8n.default-1373553171844/logins.json for credentials.
Error - Passwords protected by a Master Password!

I get the error, while running in Linux

ismi@kali:~/Downloads/firefox_decrypt-master$ sudo python firefox_decrypt.py --list

2020-04-17 23:07:16,733 - WARNING - profile.ini not found in /root/.mozilla/firefox
2020-04-17 23:07:16,733 - WARNING - Continuing and assuming '/root/.mozilla/firefox' is a profile location
2020-04-17 23:07:16,733 - ERROR - Listing single profiles not permitted.

I get this error on my current version of firefox 68.7.0.

Multiline format for pass?

Is there any way to generate a single file in the pass multiline format instead? Simply not using --pass-compat flag didn't seem to help, as it still produced a directory structure. I think this is very close to the default behavior, or may simply be achieved by redirecting from the stdout.

¿Does it work with Quantum?

I have used it in the past with success.

Now, I am using Quantum Nightly, and I get this error message on run:

2018-01-05 17:12:08,531 - ERROR - Couldn't initialize NSS, maybe '/home/mautematico/.mozilla/firefox/mauricio' is not a valid profile?

libnss3 is already installed on my Debian box

Unable to find nss3.dll on Windows (Python 64bits, Firefox 32bits)

Trying to get this to work on Windows, the script can't seem to find the nss3.dll

The path to the firefox directory for Windows in the script is:

line 186 -- firefox = r"C:\Program Files (x86)\Mozilla Firefox"

Is that 'r' supposed to be there?

Running Python 2.7 and Win10

nss.authenticate fails after first try

Originally placed as a comment in #25 by @NPacific .


Hi @unode ,

I reached your repository by looking a way to decrypt the mozilla passwords.
But the issue is i have protected my password with master password and now i have forgot the password.But know some parts of the password.
So i want to launch bruteforce attack on my file.

So what i have done was called
nss.authenticate("1")
inside a for loop to lauch bruteforce but i noticed after single call to nss.authenticate() we are not allowed to make other call.

It seems to be a lazy approach.

Can you through some light on the issue and help me way out.
So that i can get back my bunch of logins and passwords.

Unable to find a way to contact you so came here to contact

script crashes at records with "encType":0 items

Hi Renato, my logins.json contains several records with '"encType":0' items (and corresponding "encryptedPassword": item is plaintext value). It seems as 'firefox_decrypt.py' ignore encType value and try decode this value and then crashes:

Traceback (most recent call last):
  File "/home/hanzlik/firefox_decrypt.py", line 250, in <module>
    main()
  File "/home/hanzlik/firefox_decrypt.py", line 237, in main
    out = decrypt_passwords(profile, password)
  File "/home/hanzlik/firefox_decrypt.py", line 147, in decrypt_passwords
    passwd.data = cast(c_char_p(b64decode(passw)), c_void_p)
  File "/usr/lib/python2.7/base64.py", line 76, in b64decode
    raise TypeError(msg)
TypeError: Incorrect padding

Line 147 is: 'passwd.data = cast(c_char_p(b64decode(passw)), c_void_p)'

automatic enter

Hey, do you know where I can put a simulated enter Keyinput to skip Master Password with ' '

segfault on Fedora 25

LANG=C python firefox_decrypt.py -vvv /tmp/A
2017-02-07 15:51:23,167 - DEBUG - Parsed commandline arguments: Namespace(choice=None, export_pass=False, list=False, no_interactive=False, profile='/tmp/A', verbose=3)
2017-02-07 15:51:23,167 - DEBUG - Skipping password store test, not exporting
2017-02-07 15:51:23,167 - DEBUG - Loading NSS library from libnss3.so
2017-02-07 15:51:23,168 - DEBUG - Reading profiles from /tmp/A/profiles.ini
2017-02-07 15:51:23,169 - WARNING - profile.ini not found in /tmp/A
2017-02-07 15:51:23,169 - WARNING - Continuing and assuming '/tmp/A' is a profile location

Master Password for profile /tmp/A:
2017-02-07 15:51:34,030 - DEBUG - Initializing NSS with profile path '/tmp/A'
2017-02-07 15:51:34,035 - DEBUG - Initializing NSS returned 0
2017-02-07 15:51:34,035 - DEBUG - Retrieving internal key slot
2017-02-07 15:51:34,035 - DEBUG - Internal key slot -1299103056
2017-02-07 15:51:34,036 - DEBUG - Authenticating with password 'lll'
Segmentation fault (core dump)

ERROR - Passwords protected by a Master Password! It's not

I am running on Linux Deb10 with Firefox-ESR (68). I get the error when trying to decrypt one of my profiles. There is no Master Password set in Firefox. I was able to decrypt another profile successfully.

Master Password for profile 
2019-12-21 12:38:35,926 - WARNING - Attempting decryption with no Master Password
2019-12-21 12:38:35,929 - ERROR - Password decryption failed. Passwords protected by a Master Password!

I ran tests/run_all:

decrypt/tests$ ./run_all
Passed:                            33
Failed:                             0
Unexpected successes:               0
Skipped:                            0
Expected failures:                  0
Runtime:                         2.09 seconds

nss3 lib access

program terminates with error
2016-08-29 13:53:05,943 - ERROR - Problems opening 'nss3.dll' required for password decryption
2016-08-29 13:53:05,943 - ERROR - Error was [WinError 126] The specified module could not be found
seems to be a version issue as the nss3 is in FF and other dirs on the path

I have no idea what I am doing please help

I've never used python before but am trying to decrypt my email password from firefox (haven't had any luck updating my firefox profile)! I've located the enrypted password but don't know how to use python. If anybody can help I would be so grateful. I will literally pay you.

There's no way to pass Master password if "--no-interactive" enabled (Windows)

There's no way to pass Master password if "--no-interactive" enabled (Windows).

python firefox_decrypt.py -nc 2

2020-06-08 05:51:20,312 - INFO - Running firefox_decrypt version: 0.8.0+git
Traceback (most recent call last):
  File "firefox_decrypt.py", line 1010, in <module>
    main()
  File "firefox_decrypt.py", line 985, in main
    nss.authenticate(args.interactive)
  File "firefox_decrypt.py", line 498, in authenticate
    password = ask_password(self.profile, interactive)
  File "firefox_decrypt.py", line 787, in ask_password
    if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
OSError: [WinError 10038] An operation was attempted on something that is not a socket

There should be an option to allow Master password can be passed from command line argument, eg:

python firefox_decrypt.py -nc 2 --password "abc123"


  • OS/System: Windows 10 64 bit
  • Firefox 77.0.1 - 64bit
  • Python: 3.8.3 - 64 bit
  • firefox_decrypt: 0.8.0+git

NULL: Unknown code ___P 3

After upgrading from Firefox 57 to Firefox 67 I lost access to all my site logins. But the files (logins.json, key3.db and key4.db) are still there and look proper.

So I am trying to extract my credentials with this great tool, but I am getting this error:

2019-07-08 11:10:08,209 - DEBUG - Authenticating with password 'xxxx'
2019-07-08 11:10:08,209 - DEBUG - Checking user password returned 0
2019-07-08 11:10:08,210 - DEBUG - Database location: /home/user/.mozilla/firefox/kv2roq7n.default/logins.json
2019-07-08 11:10:08,210 - INFO - Using /home/user/.mozilla/firefox/kv2roq7n.default/logins.json for credentials.
2019-07-08 11:10:08,210 - INFO - Decrypting credentials
2019-07-08 11:10:08,210 - DEBUG - Reading password database in JSON format
2019-07-08 11:10:08,212 - DEBUG - Decrypting username data 'MEIEEPgAAAAAAAAAAAAAAAAAAAQwFSIKaZIevcAAwcECFUlErpS8BrMABgqFyo/UP5Q8I0eLbl5H666s9WqqxvAU5h='
2019-07-08 11:10:08,212 - DEBUG - Decryption of data returned -1
2019-07-08 11:10:08,213 - ERROR - Password decryption failed. Passwords protected by a Master Password!
2019-07-08 11:10:08,213 - DEBUG - Error during a call to NSS library, trying to obtain error info
2019-07-08 11:10:08,213 - DEBUG - NULL: Unknown code ___P 3

I tried it with older libnss3, but that does not change anything.

Thanks!

Encoding issue on Windows

When running the program without arguments or with the -f csv argument, it successfully runs. When then adding an output redirect, e.g. ... >..\example.csv, it shows the following error:

PS D:\progfiles\firefox> python C:\users\x\firefox-decrypt.py -f csv > ..\example.csv

Master Password for profile C:\Users\x\AppData\Roaming\Mozilla\Firefox\Profiles/x.default:

Traceback (most recent call last):
File "C:\users\x\firefox-decrypt.py", line 965, in
main()
File "C:\users\x\firefox-decrypt.py", line 946, in main
csv_quotechar=args.quotechar,
File "C:\users\x\firefox-decrypt.py", line 556, in decrypt_passwords
csv_writer.writerow(output)
File "C:\Program Files\Python37\lib\csv.py", line 155, in writerow
return self.writer.writerow(self._dict_to_list(rowdict))
File "C:\Program Files\Python37\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u03a7' in position 30: character maps to

The symbol \u03a7 seems to be Greek capital Chi, no idea why that is in one of my entries but whatever.

I was able to work around the bug by changing line 555 from if PY3: to if PY3 and False:, i.e. forcing it to use the encoding on line 558. The csv output now entirely consists of entries like this:

"b'https://example.com'";"b'example'";"b'password'"

Not ideal, but I can work with it. I'm only using this to run a diff between my newer Windows install and my older Linux install, copy a few passwords to the older install, and be able to uninstall Windows altogether. (I can't just move the profile because the old one has an older Firefox due to add-on incompatibility.)

Your system (please complete the following information):

  • OS/System: Windows 10 - custom locale (e.g. ISO date format) - 64bits
  • Firefox 61.0.2 64 bits
  • Python: 3.7.0 64 bits
  • firefox_decrypt: pulled from Github on 2018-09-04 21:00

logger syntax error

I'm beginning to use PASS on my Linux PC. So i wanted to test your script
I've download the latest firefox_decrypt.py and tried running python firefox_decrypt.py.
I get this syntax error with python 2:

  File "firefox_decrypt.py", line 40
    LOG: logging.Logger
       ^
SyntaxError: invalid syntax

With Python 3:

Traceback (most recent call last):
  File "firefox_decrypt.py", line 46, in <module>
    PWStore = list[dict[str, str]]
TypeError: 'type' object is not subscriptable

Can you help ? Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.