我创建了一个用于教育目的的 Pentest 工具,所以旧版本是使用 python 2 编写的,然后我将其转换为 python 3,当我尝试运行主文件 pxxtf.py
时出现多个错误,我更正他们中的大多数人,除了关于循环导入的这个,我尝试了来自论坛和 StackOverFlow 的多个修复程序,但没有任何效果。
当我尝试运行主脚本时:
sudo python3 pxxtf.py
我收到了这些错误:
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())
这是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()
答案 0 :(得分:0)
错误消息说明了一切:“很可能是由于循环导入”。
pxxtf.py
from core.excute import main
excute.py
from pxxtf import *
删除上面列出的导入之一,它应该可以工作。无论哪种方式,在 Python 中,您都不能让脚本相互导入。