--- title: Sprout Challenge tags: sprouts slideOptions: theme: solarized transition: 'fade' --- # 之芽搶票 - 誤上賊船 --- ## 搶票? - Moral - No! ---- ## 模擬搶票的概念? - 僅供學術參考 - Yes! ---- ## Sprout Challenge!!! - work.hortune.tw:9988 - 合法練習la --- ## 登入( /login ) - 怎麼用程式登入 - Server怎麼知道你是誰? ---- ## Session ```python= s = requests.Session() r = s.post('http://work.hortune.tw:9988/login', data = {"username": "hortune"}) print(r.text) # '{"cookies": {"from-my": "browser"}}' r = s.get('http://work.hortune.tw:9988') print(r.text) # '{"cookies": {}}' ``` ---- ## 原理 - 網站要怎麼知道你登入過惹? - 給你一組token,這組token就代表你自己 ---- ## 不會被偽造ㄇ? - 會r - 所以要做加密 - e.g. - 你的user id是 666666 - 那server回你的token - (666666*10000 + 1234)^123123123 - 6610983105 - 1234跟123123123是server自己保護的東西,user不會知道 ---- ## 情境 - 你有自己的token,想偽造他人的token? - False - 因為沒有123123123這個key跟1234這個nonce - 詳情去看密碼相關用書 --- ## Stage1 如何按按鈕? - 按鈕其實只是Post Request - /stage1 - /stage1_easy --- ## Stage2 如何Search Text - 觀察,對網頁parse - /stage2 - /stage2_easy --- ## Stage3 Parsing - Stage2 變形而已 - /stage3 - /stage3_easy --- ## Stage4 Iter-button - 手動parsing看看? - `.split()`? - /stage4 - /stage4_easy --- ## Deeper - 如果網頁有動畫要怎麼爬呢? - e.g. Infinite scroll - 用selenium之類的東西去實際模擬 - 把所有request仔細看一看 --- # Bye Bye
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up