mirror of
https://github.com/weyne85/PentestGPT.git
synced 2025-10-29 16:58:59 +00:00
27 lines
676 B
Python
27 lines
676 B
Python
|
|
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 |