Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError
#1
Hi
I am new to python. I am trying to run a script called attach_range_local.py but I keep getting the following error:

Traceback (most recent call last):
File "attack_range_local.py", line 4, in <module>
from modules import logger
ImportError: cannot import name logger


If I run pip list I do see modules (1.0.0)

Thank you in advance!
Reply
#2
The error message says it cannot find logger. Have you installed a package named logger (did it appear when you ran pip list)? logger is not in the Python standard libraries. Maybe you need to install this:

https://pypi.org/project/logger/
Reply
#3
(Nov-10-2021, 08:35 PM)deanhystad Wrote: The error message says it cannot find logger. Have you installed a package named logger (did it appear when you ran pip list)? logger is not in the Python standard libraries. Maybe you need to install this:

https://pypi.org/project/logger/

Hi

Yes I installed pip install logger and pip3 install logger
Reply
#4
I didn't notice that you have the import statement wrong. It should be "import logger", not "from modules import logger". There is no module named "modules". At least I hope not. That would be confusing.
Reply
#5
I've found github repository which must be the source of the program splunk/attack_range. In the file attack_range.py, there is a line from modules import logger, but the package has a subpackage named modules and this subpackage has a submodule named logger.

The program attack_range.py cannot be run separately from the rest of the package. Follow the installation instructions.
Reply
#6
(Nov-11-2021, 07:01 AM)Gribouillis Wrote: I've found github repository which must be the source of the program splunk/attack_range. In the file attack_range.py, there is a line from modules import logger, but the package has a subpackage named modules and this subpackage has a submodule named logger.

The program attack_range.py cannot be run separately from the rest of the package. Follow the installation instructions.

I ran the requirements file and I did read the installation instructions. I have both modules and logger installed.
Reply
#7
So I found the moduels called "logger.py" in the github folder that I downloaded in the following folder path /modules/logger.py

how can I import that since that is what it's looking for?
Reply
#8
(Nov-12-2021, 03:23 PM)antmar904 Wrote: So I found the moduels called "logger.py" in the github folder that I downloaded in the following folder path /modules/logger.py

how can I import that since that is what it's looking for?
You shall not import anything,as installation say so most this be run in Docker or virtual environment local.
Docker is easiest way,if i do quick a test it work fine.
root@kali:~# docker pull splunk/attack_range
Using default tag: latest
latest: Pulling from splunk/attack_range
16ec32c2132b: Pull complete 
0433ad9bfd9f: Pull complete 
7512e89c37fe: Pull complete 
ea3ca2410962: Pull complete 
dd3f83e1f1e7: Pull complete 
4b7b9fe71a9e: Pull complete 
c2863730a779: Pull complete 
4cd8ea81cf60: Pull complete 
Digest: sha256:e7b60de47f8099555d4c4c74156263a6bb3cb079822093324493126315cd339f
Status: Downloaded newer image for splunk/attack_range:latest
docker.io/splunk/attack_range:latest
root@kali:~# docker run -it splunk/attack_range
root@958a1e92a137:/attack_range# python -V
Python 3.8.10 
root@958a1e92a137:/attack_range# python attack_range.py configure

           ________________
         |'-.--._ _________:
         |  /    |  __    __\\
         | |  _  | [\_\= [\_\
         | |.' '. \.........|
         | ( <)  ||:       :|_
          \ '._.' | :.....: |_(o
           '-\_   \ .------./
           _   \   ||.---.||  _
          / \  '-._|/\n~~\n' | \\
         (| []=.--[===[()]===[) |
         <\_/  \_______/ _.' /_/
         ///            (_/_/
         |\\            [\\
         ||:|           | I|
         |::|           | I|
         ||:|           | I|
         ||:|           : \:
         |\:|            \I|
         :/\:            ([])
         ([])             [|
          ||              |\_
         _/_\_            [ -'-.__
    snd <]   \>            \_____.>
          \__/

starting configuration for AT-ST mech walker
    
? select cloud provider  aws
The attack_range.py dos all import as eg from modules import logger
If i test import now it will work as now all is isolated in Docker environment(with own Python 3.8 version)
root@958a1e92a137:/attack_range# python     
Python 3.8.10 (default, Jun  2 2021, 10:49:15)                                                                                                                                                                                        
[GCC 9.4.0] on linux                                                                                                                                                                                                                  
Type "help", "copyright", "credits" or "license" for more information.                                                                                                                                                                
>>> from modules import logger
>>> logger.__file__                                                                                                                                                                                                                   
'/attack_range/modules/logger.py'                                                                                                                                                                                                     
>>> exit()

Not using Docker you most follow this
The virtual environment most be activate or it will not find logger.py in modules.
Gribouillis and ndc85430 like this post
Reply
#9
(Nov-12-2021, 09:09 PM)snippsat Wrote:
(Nov-12-2021, 03:23 PM)antmar904 Wrote: So I found the moduels called "logger.py" in the github folder that I downloaded in the following folder path /modules/logger.py

how can I import that since that is what it's looking for?
You shall not import anything,as installation say so most this be run in Docker or virtual environment local.
Docker is easiest way,if i do quick a test it work fine.
root@kali:~# docker pull splunk/attack_range
Using default tag: latest
latest: Pulling from splunk/attack_range
16ec32c2132b: Pull complete 
0433ad9bfd9f: Pull complete 
7512e89c37fe: Pull complete 
ea3ca2410962: Pull complete 
dd3f83e1f1e7: Pull complete 
4b7b9fe71a9e: Pull complete 
c2863730a779: Pull complete 
4cd8ea81cf60: Pull complete 
Digest: sha256:e7b60de47f8099555d4c4c74156263a6bb3cb079822093324493126315cd339f
Status: Downloaded newer image for splunk/attack_range:latest
docker.io/splunk/attack_range:latest
root@kali:~# docker run -it splunk/attack_range
root@958a1e92a137:/attack_range# python -V
Python 3.8.10 
root@958a1e92a137:/attack_range# python attack_range.py configure

           ________________
         |'-.--._ _________:
         |  /    |  __    __\\
         | |  _  | [\_\= [\_\
         | |.' '. \.........|
         | ( <)  ||:       :|_
          \ '._.' | :.....: |_(o
           '-\_   \ .------./
           _   \   ||.---.||  _
          / \  '-._|/\n~~\n' | \\
         (| []=.--[===[()]===[) |
         <\_/  \_______/ _.' /_/
         ///            (_/_/
         |\\            [\\
         ||:|           | I|
         |::|           | I|
         ||:|           | I|
         ||:|           : \:
         |\:|            \I|
         :/\:            ([])
         ([])             [|
          ||              |\_
         _/_\_            [ -'-.__
    snd <]   \>            \_____.>
          \__/

starting configuration for AT-ST mech walker
    
? select cloud provider  aws
The attack_range.py dos all import as eg from modules import logger
If i test import now it will work as now all is isolated in Docker environment(with own Python 3.8 version)
root@958a1e92a137:/attack_range# python     
Python 3.8.10 (default, Jun  2 2021, 10:49:15)                                                                                                                                                                                        
[GCC 9.4.0] on linux                                                                                                                                                                                                                  
Type "help", "copyright", "credits" or "license" for more information.                                                                                                                                                                
>>> from modules import logger
>>> logger.__file__                                                                                                                                                                                                                   
'/attack_range/modules/logger.py'                                                                                                                                                                                                     
>>> exit()

Not using Docker you most follow this
The virtual environment most be activate or it will not find logger.py in modules.

You are confusing the instance I am trying to install. There are two (1) is AWS which is called Attack Range (2) is the local installation called Attack Range Local.
Reply
#10
(Nov-13-2021, 02:08 PM)antmar904 Wrote: You are confusing the instance I am trying to install. There are two (1) is AWS which is called Attack Range (2) is the local installation called Attack Range Local.
No i am not i did link to Attack Range Local in my post.
snippsat Wrote:Not using Docker you most follow this
The virtual environment most be activate or it will not find logger.py in modules.
I did a demo with Docker and only mention that if us Attack Range Local(not tested bye me) the virtual environment most be activate.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020