Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stealing simple HTTP Server fails #2268

Open
aviramha opened this issue Feb 26, 2024 · 0 comments
Open

Stealing simple HTTP Server fails #2268

aviramha opened this issue Feb 26, 2024 · 0 comments

Comments

@aviramha
Copy link
Member

aviramha commented Feb 26, 2024

  1. When I send a HTTP request from my laptop to http://127.0.0.1:8080/ -> All works, I get the response and my local code answering
  2. When I send a HTTP request from another POD -> My local program gets the request, but the client is hang - like the TCP Socket is waiting for an answer, and just hangs
Rebuilt URL to: http://echoserver-od1:8080/
Trying 172.20.46.129...
Connected to echoserver-od1 (172.20.46.129) port 8080 (#0)
GET / HTTP/1.1
Host: echoserver-od1:8080
User-Agent: curl/7.47.0
Accept: /
>
HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.6 Python/3.9.6
< Date: Sun, 25 Feb 2024 12:39:55 GMT
< Content-type: text/plain
<
Recv failure: Connection reset by peer
Closing connection 0
curl: (56) Recv failure: Connection reset by peer
#!/usr/bin/python3
# Create a python echo-server that listens on port 8080 and echoes back any input it receives from a client.
# The server should be able to handle multiple clients concurrently.
import http.server
import socketserver

class EchoHandler(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_headers()
        self.send_body()

    def do_POST(self):
        content_length = int(self.headers.get('Content-Length', 0))
        data = self.rfile.read(content_length)

        self.send_response(200)
        self.send_headers()
        self.send_body(data)

    def send_headers(self):
        self.send_header('Content-type', 'text/plain')
        self.end_headers()

    def send_body(self, data=None):
        if data:
            self.wfile.write(data)
        else:
            self.wfile.write(self.path.encode())

    def log_message(self, format, *args):
        # Log the request to the console
        print(f"[{self.log_date_time_string()} | {self.client_address[0]}] {self.requestline}")

def run_server():
    PORT = 8080

    with socketserver.TCPServer(("", PORT), EchoHandler) as httpd:
        print(f"Server running on port {PORT}")
        httpd.serve_forever()

if __name__ == "__main__":
    run_server()

python macOS

mirrord.json

{
  "agent": {
    "ephemeral": true,
    "privileged": true
  },
  "feature": {
    "network": {
      "incoming": "steal",
      "outgoing": true
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant