or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
pwntools
src: 天下女人心 某一集
資芽北區2023 講師YuKai 洪郁凱
Outline
Before we start…
請不要觸法!
【刑法】36章——妨害電腦使用罪
【個人資料保護法】
ref
Intro
除了Crypto之外…
Intro
What is CTF
Capture the Flag
Intro
What is CTF
(jeopardy-style challenges)
Intro
What is CTF
Intro
format:FLAG{...}
Intro
format:FLAG{...}
answer:
FLAG{Ka1n_i5_G0rg30u5}
Intro
picoCTF
Crypto
密碼學 Cryptography
study of techniques for secure communication in the presence of adversarial behavior.
Crypto
凱薩密碼 Caesar
assume key = 2
Crypto 練習
給定字串跟一個key(-25~25)
根據key產生/解開結果字串
Crypto 練習
Hint:
Crypto 練習
試著加密以下字串
When key = 13, it's ROT13!
Crypto
picoCTF{...}
link
Crypto
凱薩密碼 Caesar
Weakness
Register
Use your code to solve registration problem!
Practice website
PlayFair
https://en.wikipedia.org/wiki/Playfair_cipher
PlayNice
PlayFair
將0-9,a-z隨意塞在6x6的方格內
當作加密的key
PlayFair
將要加密的英數字串全轉為小寫
並拆成兩兩一組,按照下列規則插入X
PlayFair
舉例:
happy2023
ha px py 2023
PlayFair
開始加密!
PlayFair
每組字都可能:
PlayFair
在不同行與列

各自換成同列的另個角落
ha => do
px => lu
23 => 6b
PlayFair
在同列不同行
各自換成同列右一個字
ut => xb
PlayFair
在同行不同列
各自換成同行下一個字
p1 => 1u
PlayFair
最後把各組字接起來就完成了!
doluh1wb6b
腦力激盪:怎麼把他還原呢?
PlayFair Hint
不同行不同列 => 不同行不同列
同行不同列 => 同行不同列
不同行同列 => 不同行同列
PlayFair Hint
不同行不同列 => 一樣找各自角落
同行不同列 => 往上找
不同行同列 => 往左找
PlayNice 實戰
從伺服器拿到加密用的訊息
試圖解出正確密碼並拿到Flag!
PlayNice 實戰
PlayNice 實戰
nc
連上遠端機器用的工具
nc mercury.picoctf.net 21003
pwntools recv/send
pwntools也有對應的工具幫忙收發訊息
PlayNice decryption
看扣時間!
PlayNice decryption
修改加密步驟
PlayNice decryption
得到Flag了!
RSA
超有名且泛用的加密方式
(應該只能大致講過)
RSA
RSA
為何有用?
:因數分解很難算
RSA
運作方式
不安全!
RSA
Alice負責生出公私鑰
發給其他人鎖頭
RSA
Alice用私鑰解密訊息
全世界只有Alice有私鑰能解密!
RSA
Alice如何製作公私鑰?
步驟:
RSA
RSA
加密
假設要傳送一串數字c,公鑰\((N,e)\)
加密後為\(enc=c^{e}{\bmod {N}}\)
RSA
解密
收到加密後的\(enc\)後,私鑰\((N,d)\)
還原數字\(c={enc}^{d}{\bmod {N}} = {c}^{ed}{\bmod {N}}\)
RSA
為何能解密?
\(c = {enc}^{d}{\bmod {N}} = enc=c^{ed}{\bmod {N}}\)
\(ed{\bmod {N}} = 1, ed - 1\)為N的倍數
RSA
為何能解密?
Euler定理:\(a^{c*N}{\bmod {N}} = 1\)
a跟N互質,c為任意整數
\(c^{ed}{\bmod {N}} = c * c^{hN} {\bmod {N}} = c * 1 {\bmod {N}}\)
更多正確性細節可以參考Wiki
RSA練習
link
RSA練習
flag ** 3 mod N = enc
flag ** 3 = t*N + enc
RSA練習
判斷是否為e次方的數字
Tool:
gmpy2.iroot(n, e)
其他
你們好棒!