InQuest / iocextract

Defanged Indicator of Compromise (IOC) Extractor.
https://inquest.readthedocs.io/projects/iocextract/
GNU General Public License v2.0
498 stars 91 forks source link

ModuleNotFoundError: No module named 'iocextract' #71

Closed ZeroDot1 closed 1 year ago

ZeroDot1 commented 1 year ago

I installed it in Arch Linux, unfortunately I only get an error message.

Steps:

sudo pipx install iocextract --force
iocextract -h
$ /usr/bin/iocextract -h
Traceback (most recent call last):
  File "/usr/bin/iocextract", line 5, in <module>
    from iocextract import main
ModuleNotFoundError: No module named 'iocextract'
ZeroDot1 commented 1 year ago

Bildschirmfoto vom 2023-06-16 09-49-52

battleoverflow commented 1 year ago

Hi, @ZeroDot1!

When importing the iocextract module, you don't need to specify the main method. The main() method is reserved for using the project as a command line interface (CLI) and is already configured without the need to import.

If you're trying to use the CLI, all you need to do is install the package from pip(x) and run the project directly from the terminal, like so:

iocextract -h

You do not need to write your own script to use the module. If you cannot locate your installation, your PATH may need to be configured for pip(x) installations.

I also noticed you installed the module using sudo. This means your script (or if you're using it as a CLI) may not be able to find the module since it's not installed for your local user.

I use a flavor of Arch Linux as one of my primary host systems and I've had no issues running this module in the past, so I don't think that would be the issue. It's most likely a local misconfiguration or permissions issue from using escalated privileges to install the module.

If you're still experiencing issues, feel free to let me know. Based on the information provided, I believe you may just need to update how you're using the module locally.

I would also recommend checking out the iocextract documentation here: https://inquest.readthedocs.io/projects/iocextract/en/latest/

If you would like to use it as a library, all you have to do is import the module. Here's an example:

import iocextract

def extract_content():
    content = \
    """
    Check out hxxps://inquest[.]net
    """

    for i in iocextract.extract_iocs(content):
        print(i)

if __name__ == '__main__':
    extract_content()
ZeroDot1 commented 1 year ago

Hi @azazelm3dj3d,

Thank you for your answer. I try to use it as a CLI, but no matter what I try it doesn't work.

$ pipx install iocextract --force
⚠️  Note: iocextract was already on your PATH at /usr/bin/iocextract
  installed package iocextract 1.15.2, installed using Python 3.11.3
  These apps are now globally available
    - iocextract
done! ✨ 🌟 ✨
$ /usr/bin/iocextract -h
Traceback (most recent call last):
  File "/usr/bin/iocextract", line 5, in <module>
    from iocextract import main
ModuleNotFoundError: No module named 'iocextract'
ZeroDot1 commented 1 year ago
$ /usr/bin/iocextract --input 's.txt' --output '1.txt' --extract-ipv6s
Traceback (most recent call last):
  File "/usr/bin/iocextract", line 5, in <module>
    from iocextract import main
ModuleNotFoundError: No module named 'iocextract'
ZeroDot1 commented 1 year ago

Hi @azazelm3dj3d,

OK, I have just solved the problem, if there are leftover files from an on iocextract old installation in the system that are not deleted during the uninstallation, this error occurs.

Solution

sudo rm -rf /usr/bin/iocextract
$ pipx install iocextract --force
ZeroDot1 commented 1 year ago

Hi @inquestlabs From now on I use your opensource project for my opensource project, very good work, thank you.

CoinBlockerLists Homepage: https://zerodot1.gitlab.io/CoinBlockerListsWeb/