狠狠撸

狠狠撸Share a Scribd company logo
網站黑魔法:姆咪篇
Web Security:Basics
Splitline @ 台科資安社
2017/10/12
隨便的自我介紹。
● 我是 黃志仁 Splitline
● 四資工二甲
● 廢文社社長
● 沒有技能樹,只有技能莽原
Outline
我們要幹嘛
● 前端?後端?
● HTTP簡介
○ HTTP是啥?
○ 請求(Request)方法
● Web知識
○ Cookie
○ PHP語法的隨便介紹
● OWASP Top 10:十大漏洞基本介紹
● 好用的工具介紹
總之先來個應該不會
有趣的基礎概念介紹。
後端 ? 前端?
後端
Back End
前端
Front End
你看不到的 你看得到的
Server Client
Apache, nginx
PHP, Django, RoRs
HTML, CSS,
Javascript
所以我說,
那個HTTP到底是啥啦?
我們每次瀏覽網頁
都在做HTTP Request
我们是怎麼给网页资料的?
GET Request
舉個?
http://moodle.ntust.edu.tw/course/view.php?id=13970
Key Value
id 13970
POST Request
各種看起來有輸入框的地方,87%都是POST
觀察用Tools
● Burp Suite
● Tamper Data(Firefox Addon)
其他的
● HEAD
給我沒body的response喇
● TRACE
Apache會把整個request用純文字
傳給你(底爸個用的)
● CONNECT
proxy要處理HTTPS用的方法
● PUT
移動一個資源
● PATCH
更新部分資料
● DELETE
刪除資料
右邊這裏是RESTful API表達語義用的
POST /login/index.php HTTP/1.1rn
Host: moodle.ntust.edu.twrn
Referer: http://moodle.ntust.edu.tw/rn
Content-Type: application/x-www-form-urlencodedrn
Content-Length: 56rn
Cookie: _ga=GA1.4.69562738 (略rn
rn
username=B105XXXXX&password=p@55w0rd&rememberusername=1
Request實際上大概長這樣
POST /login/index.php HTTP/1.1rn
Host: moodle.ntust.edu.twrn
Referer: http://moodle.ntust.edu.tw/rn
Content-Type: application/x-www-form-urlencodedrn
Content-Length: 56rn
Cookie: _ga=GA1.4.69562738 (略rn
rn
username=B105XXXXX&password=p@55w0rd&rememberusername=1
Request實際上大概長這樣
Request Header
Request Method
POST /login/index.php HTTP/1.1rn
Host: moodle.ntust.edu.twrn
Referer: http://moodle.ntust.edu.tw/rn
Content-Type: application/x-www-form-urlencodedrn
Content-Length: 56rn
Cookie: _ga=GA1.4.69562738 (略rn
rn
username=B105XXXXX&password=p@55w0rd&rememberusername=1
Request實際上大概長這樣
Request Body
HTTP/1.1 200 OKrn
Date: Thu, 05 Oct 2017 18:44:14 GMTrn
Server: Apachern
Content-Length: 82rn
Content-Type: text/htmlrn
Connection: keep-alivern
rn
<html><head></head>….</html>
Response實際上大概長這樣
HTTP/1.1 200 OKrn
Date: Thu, 05 Oct 2017 18:44:14 GMTrn
Server: Apachern
Content-Length: 82rn
Content-Type: text/htmlrn
Connection: keep-alivern
rn
<html><head></head>….</html>
Response實際上大概長這樣
Status Code
HTTP/1.1 200 OKrn
Date: Thu, 05 Oct 2017 18:44:14 GMTrn
Server: Apachern
Content-Length: 82rn
Content-Type: text/htmlrn
Connection: keep-alivern
rn
<html><head></head>….</html>
Response實際上大概長這樣
Response Header
HTTP/1.1 200 OKrn
Date: Thu, 05 Oct 2017 18:44:14 GMTrn
Server: Apachern
Content-Length: 82rn
Content-Type: text/htmlrn
Connection: keep-alivern
rn
<html><head></head>….</html>
Response實際上大概長這樣
Response Body
(Content)
HTTP Status Code 伺服器想告訴你什麼?
● 2xx Success:好,可以,蚌。
● 3xx Redirection:我把東西都搬到那邊了,過去找ㄅ
● 4xx Client Error:你他媽到底在衝三小
● 5xx Server Error:我他媽到底發生了三小
然後
你可以自己試試看
$ nc www.google.com 80
GET / HTTP/1.1
Host:www.google.com
[enter]
[enter]
欸
來看看
好ㄘ的Coookies
Cookie就是
存在使用者端的小東西。
一個Cookie包含了:
● Name
● Value
● Domain
● Path
● Max-Age
● HTTP-Only Flag
来贵12一下ㄅ
順便說一下SESSION
● 使用者的Cookie存著SESSION id
● 伺服器存著SESSION id對應的詳細資料
Name Value
SESSION qwertyuiopasd
使用者的Cookies
Server的資料庫
id Data
mkwqwdvimiia ...
qwertyuiopasd username=123&gender=male
imnybehdbjsls ...
sauduahuivas ...
順便說一下SESSION
● 使用者的Cookie存著SESSION id
● 伺服器存著SESSION id對應的詳細資料
Name Value
SESSION qwertyuiopasd
使用者的Cookies
Server的資料庫
id Data
mkwqwdvimiia ...
qwertyuiopasd username=123&gender=male
imnybehdbjsls ...
sauduahuivas ...
PHP語法隨便的簡介
● echo <字串/變數>; //印出文字
● $i=1; //int i = 1; php宣告時不用宣
告型別
● $_GET、$_POST、$_COOKIE、$_SESSION
● 其他大部分都很普通,有不知道的function再Google就好
基礎大概有帶到了(吧
談談各種神奇漏洞。
OWASP Top 10
十個可愛的洞!
OWASP Top 10
十個可愛的洞!
Open Web Application Security Project
總之大guy4這樣 ● A1-Injection
● A2-Broken Authentication and Session
Management
● A3-Cross-Site Scripting (XSS)
● A4-Broken Access Control
● A5-Security Misconfiguration
● A6-Sensitive Data Exposure
● A7-Insufficient Attack Protection
● A8-Cross-Site Request Forgery (CSRF)
● A9-Using Components with Known
Vulnerabilities
● A10-Underprotected APIs
A10
Underprotected
APIs
● 在這個時代到處都要Call API
● 前端有防护,础笔滨端却没做资安蚕蚕
A9
Using
Components with
Known
Vulnerabilities
● 套件框架很好用對八
● 可是用了就不管,沒及時更新QQ
● 幫別人開後門 _(: 3
A8
Cross-Site
Request Forgery
(CSRF)
● 從另外一個domain送出request
● 搭配XSS很好用
● Demo!
A7
Insufficient Attack
Protection
● 沒有檢測、預防、應對攻擊的能力
A6
Sensitive Data
Exposure
● 不該被看到的檔案被看到了
● http://vulnerable.site/config.inc
● Google Hacking Database(GHDB)
A5
Security
Misconfiguration
● 權限、Debug模式之類的設定不好
● 可能洩漏重要資訊
● "Index of"
A4
Broken Access
Control
● 我可以做我這個user不該做到的事!
A4
Broken Access
Control
● 我可以做我這個user不該做到的事!
A4
Broken Access
Control
● 我可以做我這個user不該做到的事!
● Demo!
A3
Cross-Site
Scripting (XSS)
「<script> alert("XSS")</script>」
● Demo!
A2
Broken
Authentication
and Session
Management
● 我做了權限設置,可是其實有Bug
● Demo!
A1
Injection
● 注入攻擊
● 如果:(管理員有「」) 是成立的,
? 那麼就显示资料
A1
Injection
● 注入攻擊
● 如果:(管理員有「姆咪」) 是成立的,
? 那麼就显示资料
A1
Injection
● 注入攻擊
● 如果:(管理員有「姆咪」) 是成立的,
? 那麼就显示资料
A1
Injection
● 注入攻擊
● 如果:
(管理員有「姆咪」或是「姆咪」是「姆咪」)
是成立的,
? 那麼就显示资料
A1
Injection
● 注入攻擊
● 如果:
(管理員有「姆咪」或是「姆咪」是「姆咪」)
是成立的,
? 那麼就显示资料
A1
Injection
● 注入攻擊
● ' or ''='
● ' or 1=1#
● Demo!
最后的蚕&补尘辫;础
沒了,掰掰,謝謝大家
順帶一提,還有下次ㄛowo)/

More Related Content

網站黑魔法:姆咪篇 Web security basics <s>x</s>

Editor's Notes