mirror of
https://github.com/weyne85/PentestGPT.git
synced 2025-10-29 16:58:59 +00:00
update information
This commit is contained in:
0
task_handle/__init__.py
Normal file
0
task_handle/__init__.py
Normal file
27
task_handle/cmd_execution.py
Normal file
27
task_handle/cmd_execution.py
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
import os
|
||||
|
||||
def execute_cmd(cmd:str) -> str:
|
||||
"""
|
||||
Execute the command in the mac terminal.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
cmd: str
|
||||
The command to be executed.
|
||||
|
||||
Returns
|
||||
----------
|
||||
output: str
|
||||
The output of the command.
|
||||
"""
|
||||
# execute the command in the mac terminal.
|
||||
# Alert!! The execution should be really careful, because it can be dangerous.
|
||||
# It is recommended to use this in a sandbox environment.
|
||||
try:
|
||||
output = os.popen(cmd).read()
|
||||
except Exception as e:
|
||||
print("Error when executing command %s in terminal:" % cmd )
|
||||
print("Error is:", e)
|
||||
return False
|
||||
return output
|
||||
Reference in New Issue
Block a user