ss23/fortitoken-mobile-registration

Script fails with missing dependencies and "No module named 'Crypto'" error

Closed this issue · 2 comments

Problem Description:

Following the instructions, the script fails with errors regarding missing Python modules. When these modules are installed manually, the script still fails.

To Reproduce

  1. Setup virtual environment for Python as per instructions

  2. Run the script to generate a token:

$ python3 register-token.py EEAEVVEYZSERRHEM --mobile-id a432ea29c22034ca

this will result in the following error:

Traceback (most recent call last):
  File "/home/root2/register-token.py", line 1, in <module>
    from requests_pkcs12 import Pkcs12Adapter
ModuleNotFoundError: No module named 'requests_pkcs12'
  1. install the missing module:

$ pip install requests_pkcs12

  1. Re-run the script:

$ python3 register-token.py EEAEVVEYSERZREEM --mobile-id a432ea29c22034ca

  1. the script will now create a new error:
Traceback (most recent call last):
  File "/home/root2/register-token.py", line 8, in <module>
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'
  1. install this missing module as well:

$ pip install Crypto

  1. Run the script again:

$ python3 register-token.py EEAEVVEYSERZREEM --mobile-id a432ea29c22034ca

the script still terminates with the same error:

Traceback (most recent call last):
  File "/home/root2/register-token.py", line 8, in <module>
    from Crypto.Cipher import AES
ModuleNotFoundError: No module named 'Crypto'

Expected behavior:

Running “python3 register-token.py EEAEVVEYSERZREEM --mobile-id a432ea29c22034ca” should produce either a token or an error stating the server refused generating the token.

Environment:

Tested on Fedora 40, Alma Linux 9.4, Ubuntu 22.04 LTS and Ubuntu 24.04 LTS.

ss23 commented

The step in the README pip install -r requirements.txt should have installed all required modules. Did you miss that step?the requirements file is a normal text document so you can always install those modules manually if you have issues.

I think I found the issue. I did follow the README every time, but still got errors, so I checked the output of the pip installation of the requirements again, and found a warning about a the path for the script normalizer not being in the path setting. So I added it to the path and ran the installer again, and lo and behold I was able to generate tokens for my Fortinet accounts.

So it was an oversight on my part, not a bug in the script.

Thanks for the great work btw, it's really great to be able to use a regular authenticator app and no longer being chained to the mess that is the FortiToken app.