I create a Pentest tool for educational purposes, so the old version was written using python 2, then I convert it to python 3 and when I try to run the main file pxxtf.py
I got multiple errors, I correct most of them but for this one about Circular Import, I try multiple fixes from forums and StackOverFlow and nothing work with me.
When I try to run the main script :
sudo python3 pxxtf.py
I got these errors :
Traceback (most recent call last):
File "pxxtf.py", line 6, in <module>
from core.excute import main
File "/home/yezz123/Documents/PXXTF/core/excute.py", line 6, in <module>
from pxxtf import *
File "/home/yezz123/Documents/PXXTF/pxxtf.py", line 6, in <module>
from core.excute import main
ImportError: cannot import name 'main' from partially initialized module 'core.excute' (most likely due to a circular import) (/home/yezz123/Documents/PXXTF/core/excute.py)
pxxtf.py
from core.excute import main
if __name__ == "__main__":
main()
import sys
from core.excute import main
if __name__ == 'main':
sys.exit(main._main())
and this is the excute.py
import os
import sys
import core
from time import sleep, time
from pxxtf import *
from core.exploit import clean
from core.banner import banner, PXXTF
# Set color
R = '\033[31m' # Red
N = '\033[1;37m' # White
G = '\033[32m' # Green
O = '\033[0;33m' # Orange
B = '\033[1;34m' #Blue
E = '\033[0m' # End
if not os.geteuid() == 0: #Detected user root
sys.exit(
"""\033[1;91m\n[!] Pentest Tools Framework run as root!!. \n\033[1;m"""
)
if __name__ == "__main__" or clean() or banner() or PXXTF():
main()
def main():
while True:
try:
PXXTF = eval(input("Pentest>> "))
if PXXTF == 'use modules/exploits':
core.menu.exploits()
main()
elif PXXTF == 'use modules/scanners':
core.menu.scan()
main()
elif PXXTF == 'use modules/password':
core.menu.pas1()
main()
elif PXXTF == 'use modules/post':
core.menu.post()
main()
elif PXXTF == 'use modules/listener':
core.menu.listener()
main()
elif PXXTF == 'use modules/exploitdb':
core.menu.exploit_db()
main()
elif PXXTF == 'use modules/tools':
core.menu.tools()
main()
elif PXXTF == 'shell':
core.exploit.commands()
main()
elif PXXTF == 'show modules':
core.help.modules()
main()
elif PXXTF == 'ipconfig':
core.exploit.ip1()
main()
elif PXXTF == 'show options':
core.help.help()
main()
elif PXXTF == 'update':
core.exploit.update()
main()
elif PXXTF == 'about':
core.banner.info()
main()
elif PXXTF == 'credits':
core.banner.credits()
main()
elif PXXTF == 'banner':
clean(), banner(), PXXTF(), main()
elif PXXTF == 'clear':
core.menu.exploit.clean()
main()
elif PXXTF == 'exit':
core.banner.exits()
exit()
else:
print(("Wrong Command => ", PXXTF))
print(("" + N + "" + B + "[" + R + "!" + B + "] " + N +
"Please enter 'show options'"))
main()
except (KeyboardInterrupt):
print(
("\n" + R + "[*] (Ctrl + C ) Detected, Trying To Exit ...\n"))
time.sleep(2)
print(("" + G + "[*] Thank You For Using Pentest Framework =)\n"))
time.sleep(3)
exit()
The error message is saying it all: "most likely due to a circular import".
pxxtf.py
from core.excute import main
excute.py
from pxxtf import *
Remove one of the imports listed above and it should work. Either way, in Python you cannot have scripts mutually importing each other.