Skip to content

Commit

Permalink
redirect stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
zardus committed Feb 24, 2025
1 parent 4e42243 commit e73a164
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions intercepting-communication/sniff-cookie/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import socket
import string
import flask
import time
import sys
import os

from dojjail import Host, Network
Expand All @@ -15,8 +16,13 @@ flag = open("/flag").read()
parent_process = psutil.Process(os.getppid())
admin_pw = "".join(random.sample(string.ascii_letters*10, 8))

def ensure_new_file_fd(path, flags):
return os.open(path, os.O_CREAT|os.O_EXCL|os.O_WRONLY)

class ClientHost(Host):
def entrypoint(self):
sys.stderr = open("/tmp/client-stderr", "w", opener=ensure_new_file_fd)

time.sleep(2)
s = requests.Session()
assert s.post("http://10.0.0.2/login", data={"username":"admin", "password":admin_pw}).status_code == 200
Expand All @@ -29,6 +35,8 @@ class ClientHost(Host):

class ServerHost(Host):
def entrypoint(self):
sys.stderr = open("/tmp/server-stderr", "w", opener=ensure_new_file_fd)

app = flask.Flask("server")

@app.route("/login", methods=["POST"])
Expand Down

0 comments on commit e73a164

Please sign in to comment.