【发布时间】:2023-02-17 02:54:48
【问题描述】:
你好,我尝试在目录外运行这个克隆的应用程序,但它不起作用:
https://github.com/laramies/theHarvester
我在 /opt/ 文件夹中克隆了这个应用程序并将 chmod -x 添加到主题我尝试通过这个命令运行它们:
python3 /opt/theHarvester/theHarvester.py
它给我这个错误:
File "/opt/theHarvester/theHarvester.py", line 5, in <module>
from theHarvester import __main__
File "/opt/theHarvester/theHarvester/__main__.py", line 4, in <module>
from theHarvester.discovery import dnssearch, takeover, shodansearch
File "/opt/theHarvester/theHarvester/discovery/takeover.py", line 1, in <module>
from theHarvester.lib.core import *
File "/opt/theHarvester/theHarvester/lib/core.py", line 238, in <module>
class AsyncFetcher:
File "/opt/theHarvester/theHarvester/lib/core.py", line 239, in AsyncFetcher
proxy_list = Core.proxy_list()
File "/opt/theHarvester/theHarvester/lib/core.py", line 103, in proxy_list
with open('proxies.yaml', 'r') as proxy_file:
FileNotFoundError: [Errno 2] No such file or directory: 'proxies.yaml'`
但是当我使用这个命令时:
cd /opt/theHarvester/ python3 theHarvester.py
它运作良好。
【问题讨论】:
-
cd /opt/theHarvester/基本上将您的工作目录更改为theHarvester.py文件的位置,并且它能够在其中检测到proxies.yaml。当您使用python3 /opt/theHarvester/theHarvester.py运行它时,您的 working_directory 不同并且proxies.yaml可能不存在于其中。 -
谢谢,但是我该如何解决呢?我需要在一行中运行这个脚本。
-
cd /opt/theHarvester/; python3 theHarvester.py -
在你的 python 脚本中,而不是将文件引用为
proxies.yaml,你可以定义它的绝对路径,使用脚本本身的绝对路径使用__file__。基本上,file = os.path.join(os.path.dirname(__file__), 'proxies.yaml')