iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 18
1
Security

Web Security 魔法使攻略系列 第 18

Web Security 魔法使攻略─Command injection

正文

談談 Command Injection 之前
要先談談 command 是什麼,所謂 command 就是命令 !(被揍

認識一下 Linux 指令

Unix 目的 範例
exit 關閉視窗 exit
cd 進入目錄 cd ..
mkdir 建立目錄 mkdir hello
pwd 顯示目前目錄 pwd
env 顯示目前環境變數 env
setenv 設定環境變數 setenv l ls
date 顯示時間 date
mv 移動,重新命名檔案 mv .test .new.cp
man 指令查詢 man ls
rm 刪除檔案 rm test.txt
cat/more 顯示檔案內容 more .test
ls 顯示檔案 ls
lp 列印檔案 lp .test
cp 複製檔案 cp .test newfile

再來認識一下管道

pipe | : 用來處理前面一個指令回傳來的正確資料(standard output)
ex. ls | grep ctf

一些用來連續下達指令ㄉ連接詞

用來連續下達指令 意義 範例
分號 ; 不考慮兩個指令相關性直接連續執行 sync; shutdown -h now
` `
&& 前者執行,後者才執行;前者失敗,後者也不執行 ls /tmp/aaa && touch /tmp/aaa/bbb

弱點

command injection

  • 多半在於網站直接可以呼叫系統的命玲
  • 比如說 ping 之類的 ....
<?php
print("<p> ping server ");
$ping=$_GET['ping'];
system("ping $ping");
?>

剛剛我們教了連接詞
如果我們在 ping 這個參數底下放

  • 127.0.0.1 | ls
  • 127.0.0.1 ; ls
  • 1 || ls
  • 127.0.0.1 && ls

假設這個網站沒有進行防護,就很容易被惡意攻擊的人取得系統權限。


上一篇
Web Security 魔法使攻略─CSP bypasss
下一篇
Web Security 魔法使攻略─Local File Inclusion
系列文
Web Security 魔法使攻略30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言