Hari-Nagarajan / fairgame

Tool to help us buy hard to find items.
GNU General Public License v3.0
2.44k stars 804 forks source link

AttributeError: function/symbol 'SHA256_init' not found in library #558

Open jlehenbauer opened 3 years ago

jlehenbauer commented 3 years ago

Describe the bug Failure when encrypting user credentials.

To Reproduce Running on Raspberry Pi 3 B+. All dependencies are installed in pipenv. Run python app.py amazon and enter credentials as usual. Crash occurs when encrypting credentials.

Expected behavior Expect script to encrypt credentials and continue to opening chrome.

Error log

2021-03-10 13:04:22|0.6.0|INFO|Create a password for the credential file
Credential file password: ****
Verify credential file password: ****
Traceback (most recent call last):
  File "app.py", line 55, in <module>
    cli.main()
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/modbros/fairgame/cli/cli.py", line 71, in decorator
    func(*args, **kwargs)
  File "/home/modbros/fairgame/cli/cli.py", line 236, in amazon
    amzn_obj = Amazon(
  File "/home/modbros/fairgame/stores/amazon.py", line 146, in __init__
    amazon_config = global_config.get_amazon_config(encryption_pass)
  File "/home/modbros/fairgame/common/globalconfig.py", line 67, in get_amazon_config
    amazon_config["username"], amazon_config["password"] = get_credentials(
  File "/home/modbros/fairgame/common/globalconfig.py", line 48, in get_credentials
    create_encrypted_config(credential, credentials_file)
  File "/home/modbros/fairgame/utils/encryption.py", line 74, in create_encrypted_config
    result = encrypt(payload, cpass)
  File "/home/modbros/fairgame/utils/encryption.py", line 36, in encrypt
    key = scrypt(password, salt, key_len=32, N=2 ** 20, r=8, p=1)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Protocol/KDF.py", line 385, in scrypt
    stage_1 = PBKDF2(password, salt, p * 128 * r, 1, prf=prf_hmac_sha256)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Protocol/KDF.py", line 162, in PBKDF2
    s = [ prf(password, salt + struct.pack(">I", i)) ] * 2
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Protocol/KDF.py", line 383, in <lambda>
    prf_hmac_sha256 = lambda p, s: HMAC.new(p, s, SHA256).digest()
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Hash/HMAC.py", line 213, in new
    return HMAC(key, msg, digestmod)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Hash/HMAC.py", line 86, in __init__
    self._inner = digestmod.new(key_0_ipad)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Hash/SHA256.py", line 158, in new
    return SHA256Hash().new(data)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Hash/SHA256.py", line 73, in __init__
    result = _raw_sha256_lib.SHA256_init(state.address_of())
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/cffi/api.py", line 912, in __getattr__
    make_accessor(name)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/cffi/api.py", line 908, in make_accessor
    accessors[name](name)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/cffi/api.py", line 838, in accessor_function
    value = backendlib.load_function(BType, name)
AttributeError: function/symbol 'SHA256_init' not found in library '/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Util/../Hash/_SHA256.cpython-38-arm-linux-gnueabihf.so': /home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Util/../Hash/_SHA256.cpython-38-arm-linux-gnueabihf.so: undefined symbol: SHA256_init

Desktop (please complete the following information):

Additional context Found a source and a source that mention using -lcrypto before the call that needs it in bash.

jlehenbauer commented 3 years ago

Fwiw, I transferred a working credentials file from a Windows machine and got the same message with a much shorter traceback:

2021-03-10 19:06:36|0.6.0|INFO|Reading credentials from: config/amazon_credentials.json
Credential file password: **************
2021-03-10 19:06:40|0.6.0|ERROR|function/symbol 'SHA256_init' not found in library '/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Util/../Hash/_SHA256.cpython-38-arm-linux-gnueabihf.so': /home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/Crypto/Util/../Hash/_SHA256.cpython-38-arm-linux-gnueabihf.so: undefined symbol: SHA256_init
2021-03-10 19:06:40|0.6.0|ERROR|Failed to decrypt the credential file. If you have forgotten the password, delete config/amazon_credentials.json and rerun the bot
Traceback (most recent call last):
  File "app.py", line 55, in <module>
    cli.main()
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/modbros/.local/share/virtualenvs/fairgame-4xLAZWgg/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/modbros/fairgame/cli/cli.py", line 71, in decorator
    func(*args, **kwargs)
  File "/home/modbros/fairgame/cli/cli.py", line 236, in amazon
    amzn_obj = Amazon(
  File "/home/modbros/fairgame/stores/amazon.py", line 146, in __init__
    amazon_config = global_config.get_amazon_config(encryption_pass)
  File "/home/modbros/fairgame/common/globalconfig.py", line 67, in get_amazon_config
    amazon_config["username"], amazon_config["password"] = get_credentials(
  File "/home/modbros/fairgame/common/globalconfig.py", line 43, in get_credentials
    return credential["username"], credential["password"]
TypeError: 'NoneType' object is not subscriptable
DakkJaniels commented 3 years ago

Both of the references you provided are for linking in C++. I don't think that is relevant here. It sounds like you have an installation problem - did you follow all the directions for Raspberry Pi in the readme? If you did, maybe you are still missing some library (OpenSSL?) and you need to install it.

jlehenbauer commented 3 years ago

I know, but they're the only thing I could find related to the issue. It seemed to be something associated with calling the lcrypto portion of the credential encryption.

I'm pretty positive I installed all the correct dependencies. Doing a fresh install on a RPi4 just to see.