mc-17 / pspack-flask

pOOBs4 PS4 exploit for v9.0 + automatic GoldHEN
Other
62 stars 23 forks source link

Nginx Reverse Proxy #6

Closed kocane closed 2 years ago

kocane commented 2 years ago

Thanks for the work! Any idea what it would take to serve it thru a reverse proxy with nginx?

I tried with a "normal" reverse proxy but it fails in sending the file.

127.0.0.1 - - [21/Dec/2021 16:57:16] "GET /log/Starting%20RCE%20(pOObs4)... HTTP/1.0" 200 -
Sending golden hen to 127.0.0.1
[2021-12-21 16:57:38,164] ERROR in app: Exception on /log/already patched setuid! [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/opt/apps/playstation/9.00/app.py", line 29, in log
    send(request.remote_addr, 9020, "payload/goldhen_2.0b_900.bin")
  File "/opt/apps/playstation/9.00/sender.py", line 6, in send
    clientSocket.connect((ip, port))
ConnectionRefusedError: [Errno 111] Connection refused
pabloalcantara commented 2 years ago

Change this lines of app.py: 28 print(f"Sending golden hen to {request.remote_addr}") 29 send(request.remote_addr, 9020, "payload/goldhen_2.0b_900.bin")

to

28 print(f"Sending golden hen to ) 29 send("", 9020, "payload/goldhen_2.0b_900.bin")

The problem is that this script uses the IP that conects to it, as you´re behind an reverse proxy, the script sees the IP os the proxy, not of the client.

mc-17 commented 2 years ago

As @pabloalcantara says, it's due to sending the payload to the source IP - if you can confirm his fix works, then I could consider adding a check for an environment variable to work in this scenario

pabloalcantara commented 2 years ago

It works, I use the python docker container to use this solution on my server.

pabloalcantara commented 2 years ago

docker-compose.yaml:

PS4Jailbreak: image: "python:3" container_name: PS4Jailbreak ports:

/entrypoint.sh

!/bin/sh

cd /ps4/pspack-flask-main sed -i "s/{request.remote_addr}/192.168.25.176/g" app.py sed -i 's/request.remote_addr/"192.168.25.176"/g' app.py python -m pip install -r requirements.txt python app.py

kocane commented 2 years ago

It works, I use the python docker container to use this solution on my server.

Could you share your nginx config?

pabloalcantara commented 2 years ago

I use NPM (https://nginxproxymanager.com/) so I don´t have the config. But I believe that if the machine running this script can access the IP of the PS4, everything must works with the basic nginx config.

mc-17 commented 2 years ago

Do you mind testing with the dockerfile I just merged? (Obviously adding your sed commands) just to check the existing file works. Following that I'll add a check, thanks!

pabloalcantara commented 2 years ago

Yes, the build and execution works.

pabloalcantara commented 2 years ago

Sorry, it works, but still need to edit the app.py to use the PS4 Ip, as the container only sees the internal docker proxy IP, not the real IP client. I think that ambient variable will resolve this.

kocane commented 2 years ago

In my nginx config I use this, which should forward the client ip adress

proxy_set_header  Host $host;
proxy_set_header  X-Real-IP $remote_addr;
proxy_set_header  X-Forwarded-Proto https;
proxy_set_header  X-Forwarded-For $remote_addr;
proxy_set_header  X-Forwarded-Host $remote_addr;

But I think that Flask/Python ignores it, but I don't know much about it. Perhaps the replies in this discussion makes sense for you, @mc-17?

mc-17 commented 2 years ago

Thanks, hope to get to this after Christmas, I'll make a branch with the changes if you wouldn't mind just confirming it works

kocane commented 2 years ago

Thanks, hope to get to this after Christmas, I'll make a branch with the changes if you wouldn't mind just confirming it works

Thanks to you as well. I'll test it when you got something. Merry Christmas!

mc-17 commented 2 years ago

Merry Christmas!

I've dropped a branch here, if you modify Dockerfile and set the IP, does it work? https://github.com/mc-17/pspack-flask/tree/feature/reverse-proxy

kocane commented 2 years ago

@mc-17 Which IP is it that I should input in CONSOLE_IP?

pabloalcantara commented 2 years ago

The Ps4 IP address

Em seg., 27 de dez. de 2021 19:00, kocane @.***> escreveu:

@mc-17 https://github.com/mc-17 Which IP is it that I should input in CONSOLE_IP?

— Reply to this email directly, view it on GitHub https://github.com/mc-17/pspack-flask/issues/6#issuecomment-1001775649, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHBTSAFKJR2A4XUM4TTJZDUTDOZFANCNFSM5KQRSM2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

kocane commented 2 years ago

I'm a bit confused. The WAN IP of the PS4, or? I'm hosting the app on a remote server. Ideally it shouldn't be locked to a specific server.

pabloalcantara commented 2 years ago

I think this is for local Server, not remote Server.

Em qui., 30 de dez. de 2021 07:57, kocane @.***> escreveu:

I'm a bit confused. The WAN IP of the PS4, or? I'm hosting the app on a remote server. Ideally it shouldn't be locked to a specific server.

— Reply to this email directly, view it on GitHub https://github.com/mc-17/pspack-flask/issues/6#issuecomment-1002976428, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHBTSDKDKT2F4LIFKBDUU3UTQ3KHANCNFSM5KQRSM2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

mc-17 commented 2 years ago

I'm not really sure of your use case, but you said that the IP that requests the page is wrong, so I thought a reasonable environment name was CONSOLEIP. If it's meant to be a different IP then I can rename it. If a single IP is too limiting, and you know of a solution, then happy to accept PRs - I'm not a networking guy.

mc-17 commented 2 years ago

Closed due to inaction