@toRi

できたてほやほやのエンジニアです。インフラ、セキュリティ系です。ふんわり命がけ(´・ω・)

「オンライン・フォレンジックLT大会-Emotet編」のメモ

初めに

株式会社イエラエセキュリティさん主催の「オンライン・フォレンジックLT大会」に参加しました。

「オンライン・フォレンジックLT大会 – Emotetの巻」開催のお知らせ|株式会社イエラエセキュリティ - ハッカーによる脆弱性診断

Emotet感染端末のフォレンジックについて、勉強になることがたくさんあったので、(お見苦しいところがあるかもしれませんが)私のメモを共有したいと思います。私自身も初心者なので、初心者向けのメモになっています。

調査の流れ

outlookの調査

  • ostファイルを調べる

ファイルシステム上でwordを探す

コンテンツの有効化の痕跡を探す

  • マクロを有効にしたものだと レジストリが規定のものになっている

  • レジストリキーでマクロに関するキーがある

  • 防止するためにVBAのマクロを無効化がおすすめ

動的解析

  • マクロはalt+F11

  • パワーシェルのスクリプトが入ってたりする

WMI確認

パワーシェル確認

  • イベントログ ID600、4104でスクリプト見れる

  • base64があったりする

  • パワーシェルのコマンド履歴が保存されている場所が確認できたりする

プログラム実行履歴

  • Prefetchで実行されたファイルを見る

  • USNジャーナルでマルウェアに特徴的な自分をコピーして削除している、みたいな様子を探したりする

  • 自動実行があるところ見る CurentVersion¥Run

追加マルウェアの感染有無を確認

  • メール情報の窃取の有無を確認

  • MAPIあたりを Prefetchなど確認する

その他

  • emocheckを使う

  • 脆弱性情報をみたり、オンラインのサンドボックス使ってもいいね

  • バラマキとかはAny runやVTで見てもいいね

実行履歴(アーティファクト)で調査

UserAssist(NTUSER.DAT

  • プログラム実行日時、回数、ファイルパスがわかる

  • ROT13されている

Prefetch

  • プログラム最終実行日時、実行ファイルパス、参照ファイルパス(起動に必要なファイルなど)、実行ファイルのボリュームシリアルの情報を持つ

  • ハッシュ値はプログラムのパスから計算される、異なるパスから実行するとハッシュ値も異なる

  • WinPrefetchViewなどのツールがある

AppCompatCache(ShimCache)

Amcache.hve

  • 実行されたプログラムの情報がわかる

  • ファイルパス、サイズ、タイムスタンプ、SHAハッシュ値の情報を持つ

MUICache

  • 実行したアプリケーションを確認できる

イベントログ

  • SysmonがインストールされているとID1で詳細を確認できるが、インストールされていることはあまりない

調査観点など

  • メールの添付ファイル開封有無  

    • メールを開くとキャッシュが作成されている
  • wordコンテンツの有効化の実行有無

  • WMIを使用してパワーシェル起動しているか

  • Emotetをダウンロードして実行しているか

  • 二次感染の有無

最後に

Emotetの調査の流れや観点を学べ、とても勉強になるセミナーでした。イエラエセキュリティさんのスピーカーみなさん、ありがとうございました! 次回も参加したいです。

【DFIR】VirtualBox上でSANSSIFT使ってみた。

環境が変わるごとにツールをインストールするのが面倒になってきたので、
DFIR系ディストリビューション使ってみたいと思い、SANSSIFTを入れることにしました。
しかし、日本語でインストール方法などを書いているページがなかったので、
この先インストールするだれかのために、SANSSIFTの使い方を書いてみることにしました。


SANSSIFTを選んだ理由
・かっこいいから
・私の先輩が使っているのを借りたとき、とても便利だった
・HolidayHackChallenge(年末から年明けにかけて行われる物語系CTFみたいなもの)が面白くてSANSのファンになったから
・SANSの研修受けたいから、、

…早速本題です!

必要なもの
VirtualBox
・SANSのアカウント
・SIFT VM ?(仮想imageファイルのようなもの)

です。VirtualBoxはPCにインストールされている前提で進めます。

まず、以下のサイトからSIFT VMをダウンロードします。
ダウンロードはSANSユーザのみです。
ダウンロードしようとすると、ユーザ・パスワードを聞かれるので、その際にSANSのアカウントを作成しましょう。(無料です)
SIFT Workstation Download


アカウント登録が終わったら先ほどの画面のここをクリックし、
f:id:loveeeeeebird:20200412223558j:plain


SIFT-Workstation.ovaの方をダウンロードします。
f:id:loveeeeeebird:20200412223625p:plain

ダウンロードが終わったら、VirtualBoxのファイル→仮想アプライアンスのインポートを開き、
f:id:loveeeeeebird:20200412223656p:plain


先ほどダウンロードしたファイルを選び、次へ。
f:id:loveeeeeebird:20200412223856p:plain

特に何も変えず、インポートをします。
f:id:loveeeeeebird:20200412223819p:plain

VMという仮想マシンができます。
f:id:loveeeeeebird:20200412223750p:plain

VMを起動し、以下の情報でログインします。
Login = sansforensics
Password = forensics
するとそこにはSANSSIFTが!!
f:id:loveeeeeebird:20200412223949p:plain

マニュアルがデスクトップに散りばめられています。(英語ですが、、)


試しにRegistryParsingをしてみます。(このツール自分で入れようとするとプラグインやらなんやらでめんどくさいから入っているのありがたい)
f:id:loveeeeeebird:20200412224035p:plain

説明通りパースすると、、できました!

ちゃんと指定したファイルもできてました。
f:id:loveeeeeebird:20200412224100p:plain

これからも英語のマニュアルを読みながら、どんどん使っていきたいです。

picoCTF2018 blaise's cipher - Points: 200

問題

My buddy Blaise told me he learned about this cool cipher invented by a guy also named Blaise! Can you figure out what it says? Connect with nc 2018shell.picoctf.com 18981.

ヒント

There are tools that make this easy. 
This cipher was NOT invented by Pascal

解き方

nc 2018shell.picoctf.com にアクセスしてみると暗号化された文がでてきました。

Encrypted message: Yse lncsz bplr-izcarpnzjo dkxnroueius zf g uzlefwpnfmeznn cousex bls ltcmaqltki my Rjzn Hfetoxea Gqmexyt axtfnj 1467 fyd axpd g rptgq nivmpr jndc zt dwoynh hjewkjy cousex fwpnfmezx. Llhjcto'x dyyypm uswy ybttimpd gqahggpty fqtkw debjcar bzrjx, lnj xhizhsey bprk nydohltki my cwttosr tnj wezypr uk ehk hzrxjdpusoitl llvmlbky tn zmp cousexypxz. Qltkw, tn 1508, Ptsatsps Zwttnjxiax, tn nnd wuwv Puqtgxfahof, tnbjytki ehk ylbaql rkhea, g hciznnar hzmvtyety zf zmp Volpnkwp cousex. Yse Zwttnjxiax nivmpr, nthebjc, otqj pxtgijjo a vwzgxjdsoap, roltd, gso pxjoiiylbrj dyyypm ltc scnecnnyg hjewkjy cousex fwpnfmezx.

Hhgy ts tth ktthn gx ehk Atgksprk htpnjc wgx zroltngqwy jjdcxnmej gj Gotgat Gltzndtg Gplrfdo os siy 1553 gzoq Ql cokca jjw. Sol. Riualn Hfetoxea Hjwlgxz. Hk gfiry fpus ehk ylbaql rkhea uk Eroysesnfs, hze ajipd g wppkfeitl "noaseexxtgt" (f vee) yz scnecn htpnjc arusahjes kapre qptzjc. Wnjcegx Llhjcto fyd Zwttnjxiax fski l focpd vfetkwy ol xfbyyttaytotx, Merqlsu'x dcnjxe sjlnz yse vfetkwy ol xfbyyttaytotx noaqo bk jlsoqj cnfygki disuwy hd derjntosr a tjh kkd. Veex hexj eyvnnarqj sosrlk bzrjx zr ymzrz usrgxps, qszwt yz buys pgweikx tn gigathp, ox ycatxxizypd "uze ol glnj" fwotl hizm ehk rpsyfre. Hjwlgxz's sjehui ehax cewztrki dtxtyg yjnuxney ltc otqj tnj vee. Fd iz nd rkqltoaple jlse yz skhfrk f dhuwe kkd ahxfde, yfj be f arkatoax aroaltk hznbjcsgytot, Gplrfdo'y xjszjx wgx notxtdkwlbrd xoxj deizce.

Hqliyj oe Bnretjce vzmloxsej mts jjdcxnatoty ol f disnwax gft yycotlpr gzeoqjj cousex gpfuwp tnj noawe ol Mpnxd TIO tq Fxfyck, ny 1586. Lgypr, os ehk 19ys ckseuxd, ehk nyvkseius zf Hjwlgxz's inahkw hay rtsgyerogftki eo Bnretjce. Jfgij Plht ny hox moup Ehk Hzdkgcegppry qlmkseej yse sndazycihzeius my yfjitl ehgy siyyzre mld "olyoxjo tnnd isuzrzfyt itytxnmuznzn gso itxeegi yasjo a xjrrkxdibj lnj jwesjytgwj cousex kzr nnx [Volpnkwp] tntfgn mp hgi yozmtnm yz du bttn ne". pohzCZK{g1gt3w3_n1pn3wd_ax3s7_maj_095glcih}

Ehk Atgksprk htpnjc ggnyej f cevzeaznzn ltc bknyg kcnevytotfwle xerusr. Nuypd gzehuw lnj rltnjxaznnigs Nhgwwey Qftcnogk Izdmxzn (Rjhiy Hlrxtwl) ifwlki ehk Atgksprk htpnjc utgcegplbrj tn nnd 1868 pojne "Zmp Arusahje Cousex" ny a imtljwpn'y rlggetnk. Ny 1917, Sinpnznqii Fxexnnat ipsiwtbki ehk Atgksprk htpnjc ay "nxpuxdihqp ol ycatxwaznzn". Zmts xjauzfeius hay szt jjdexapd. Imlrrjd Bggmamj ts qszwt yz hgap bxtvet f gaxnlnz tq tnj nivmpr gx paxqj ay 1854; mzwkapr, nj oijs'e pagwiym siy bzrq. Plsoxvi kseixjwy hwzkk yse inahkw lnj ufbrndhki ehk ypcnstqaj tn zmp 19tn hpnzzcy. Kapn hjqoxj ehox, ehuzrh, ytxe yptlrjo cxdatgsllexes itflj tncgxtotfwle gcegp ehk htpnjc it yse 16zm netyfre.

Hcyvyzgxfahoh dloip raqp uyjo ay f narhflgytot ftd hd ehk Xhiyx Lrsd mezbpet 1914 fyd 1940. Zmp Volpnkwp cousex nd soralk jyoals tu gp a lnplj htpnjc il ne iy zdej ny cusuutheius hizm nivmpr jndky. Yse Ityfkiprgyp Szfeey tq Asjciif, qox jiasuwe, axpd g gcayx nivmpr jndk zt tmvqpmkse tnj Gimjyexj nivmpr jzcitl ehk Fxexnnat Htvoq Hax. Yse Ityfkiprghj's sjdsglps cjce lfc fxtx skhcez fyd zmp Utnzn xjrurfcle hcaippd zmpix rpsyfrey. Ysruzrhuze tnj hax, yse Ityfkiprgyp lkfoexxsiv ucisfcird cernpd auzn zmcek ppy vmcayjd, "Mgsnhkxeex Gwulk", "Nosuwezj Giiyzre" fyd, gx ehk blr ifxe zt l crtde, "Itxe Xjerogftoty".

Goqmexy Gexslm zwtej yz rkulix yse hwzkks nivmpr (iwpaznyg zmp Vkwyas–Atgksprk htpnjc it 1918), gft, tt xazypr cmlt nj oij, yse inahkw hay xeirq gursprggwe zt nreueatfwyynd. Vkwyas'x hoxp, socjgex, jgetyfarqj lki eo zmp otj-eisj aaj, f ehktceznnarqj utgcegplbrj nivmpr.

この文を暗号化したというBlaiseさんについて調べてみます。
Vigenere暗号を発明した方みたいです。

Vigenere暗号を復号するために以下のサイトを使いました。(便利すぎる)

https://www.guballa.de/vigenere-solver

先ほどの暗号を復号すると、以下のように暗号についての文とフラグがでてきました。

Zccltetyy bemnpgy: The first well-documented description of a polyalphabetic cipher was formulated by Leon Battista Alberti around 1467 and used a metal cipher disc to switch between cipher alphabets. Alberti's system only switched alphabets after several words, and switches were indicated by writing the letter of the corresponding alphabet in the ciphertext. Later, in 1508, Johannes Trithemius, in his work Poligraphia, invented the tabula recta, a critical component of the Vigenere cipher. The Trithemius cipher, however, only provided a progressive, rigid, and predictable system for switching between cipher alphabets.

What is now known as the Vigenere cipher was originally described by Giovan Battista Bellaso in his 1553 book La cifra del. Sig. Giovan Battista Bellaso. He built upon the tabula recta of Trithemius, but added a repeating "countersign" (a key) to switch cipher alphabets every letter. Whereas Alberti and Trithemius used a fixed pattern of substitutions, Bellaso's scheme meant the pattern of substitutions could be easily changed simply by selecting a new key. Keys were typically single words or short phrases, known to both parties in advance, or transmitted "out of band" along with the message. Bellaso's method thus required strong security for only the key. As it is relatively easy to secure a short key phrase, say by a previous private conversation, Bellaso's system was considerably more secure.

Blaise de Vigenere published his description of a similar but stronger autokey cipher before the court of Henry III of France, in 1586. Later, in the 19th century, the invention of Bellaso's cipher was misattributed to Vigenere. David Kahn in his book The Codebreakers lamented the misattribution by saying that history had "ignored this important contribution and instead named a regressive and elementary cipher for him [Vigenere] though he had nothing to do with it". picoCTF{v1gn3r3_c1ph3rs_ar3n7_bad_095baccc}

The Vigenere cipher gained a reputation for being exceptionally strong. Noted author and mathematician Charles Lutwidge Dodgson (Lewis Carroll) called the Vigenere cipher unbreakable in his 1868 piece "The Alphabet Cipher" in a children's magazine. In 1917, Scientific American described the Vigenere cipher as "impossible of translation". This reputation was not deserved. Charles Babbage is known to have broken a variant of the cipher as early as 1854; however, he didn't publish his work. Kasiski entirely broke the cipher and published the technique in the 19th century. Even before this, though, some skilled cryptanalysts could occasionally break the cipher in the 16th century.

Cryptographic slide rule used as a calculation aid by the Swiss Army between 1914 and 1940. The Vigenere cipher is simple enough to be a field cipher if it is used in conjunction with cipher disks. The Confederate States of America, for example, used a brass cipher disk to implement the Vigenere cipher during the American Civil War. The Confederacy's messages were far from secret and the Union regularly cracked their messages. Throughout the war, the Confederate leadership primarily relied upon three key phrases, "Manchester Bluff", "Complete Victory" and, as the war came to a close, "Come Retribution".

Gilbert Vernam tried to repair the broken cipher (creating the Vernam–Vigenere cipher in 1918), but, no matter what he did, the cipher was still vulnerable to cryptanalysis. Vernam's work, however, eventually led to the one-time pad, a theoretically unbreakable cipher.

picoCTF2018 hex editor - Points: 150

問題

This cat has a secret to teach you. You can also find the file in /problems/hex-editor_2_c1a99aee8d919f6e42697662d798f0ff on the shell server.

解き方

とりあえず、ncコマンドを実行してみます。

$ nc 2018shell.picoctf.com 18581
-------------------------------------------------------------------------------
syeoqbwp knqn vp myhq libo - phfpwvwhwvye_svaknqp_bqn_pyigbfin_sxvioexiea
-------------------------------------------------------------------------------
pwbwnim, aihza fhsc zhiivobe sbzn lqyz wkn pwbvqknbx, fnbqveo b fyji yl
ibwknq ye jkvsk b zvqqyq bex b qbuyq ibm sqyppnx. b mniiyj xqnppveooyje,
heovqxinx, jbp phpwbvenx onewim fnkvex kvz ye wkn zvix zyqeveo bvq. kn
knix wkn fyji biylw bex vewyenx:

-vewqyvfy bx biwbqn xnv.

kbiwnx, kn annqnx xyje wkn xbqc jvexveo pwbvqp bex sbiinx yhw sybqpnim:

-syzn ha, cvesk! syzn ha, myh lnbqlhi dnphvw!
(省略)

ROTかなと思って全部ためしてみたのですが、解読不可能でした。

ncコマンドを送信するごとに別々な暗号が表示されます。???

ここでWeb上のWriteupを読みました。 どうやら a=b みたいに文字を置き換えて復号する問題らしいです。 それをしてくれるサイトがこちらだそうです。 https://www.quipqiup.com/

このサイトを使って復号していきます。

-------------------------------------------------------------------------------
ixutjale snjn we cxzj dyat - ezqelwlzlwxu_iwmsnje_ajn_exybaqyn_ikwytukyum
-------------------------------------------------------------------------------
elalnyc, myzvm qzig vzyywtau iavn djxv lsn elawjsnak, qnajwut a qxfy xd
yalsnj xu fswis a vwjjxj auk a jarxj yac ijxeenk. a cnyyxf kjneewuttxfu,
zutwjkynk, fae ezelawunk tnulyc qnswuk swv xu lsn vwyk vxjuwut awj. sn
snyk lsn qxfy ayxdl auk wulxunk:

-wuljxwqx ak aylajn knw.

saylnk, sn mnnjnk kxfu lsn kajg fwukwut elawje auk iayynk xzl ixajenyc:

-ixvn zm, gwuis! ixvn zm, cxz dnajdzy pnezwl!

exynvuyc sn iavn dxjfajk auk vxzulnk lsn jxzuk tzujnel. sn daink aqxzl
auk qyneenk tjabnyc lsjwin lsn lxfnj, lsn ezjjxzukwut yauk auk lsn
afagwut vxzulawue. lsnu, ialiswut ewtsl xd elnmsnu knkayze, sn qnul
lxfajke swv auk vakn jamwk ijxeene wu lsn awj, tzjtywut wu swe lsjxal
auk esagwut swe snak. elnmsnu knkayze, kwemynaenk auk eynnmc, ynaunk
swe ajve xu lsn lxm xd lsn elawjiaen auk yxxgnk ixykyc al lsn esagwut
tzjtywut dain lsal qyneenk swv, nhzwun wu wle ynutls, auk al lsn ywtsl
zulxuezjnk sawj, tjawunk auk sznk ywgn mayn xag.

qzig vzyywtau mnnmnk au wuelaul zuknj lsn vwjjxj auk lsnu ixbnjnk lsn
qxfy evajlyc.

-qaig lx qajjaige! sn eawk elnjuyc.

sn akknk wu a mjnaisnje lxun:

-dxj lswe, x knajyc qnyxbnk, we lsn tnuzwun isjwelwun: qxkc auk exzy
auk qyxxk auk xzue. eyxf vzewi, mynaen. eszl cxzj ncne, tnule. xun
vxvnul. a ywllyn ljxzqyn aqxzl lsxen fswln ixjmzeiyne. ewynuin, ayy.

sn mnnjnk ewknface zm auk tabn a yxut eyxf fswelyn xd iayy, lsnu mazenk
afswyn wu jaml allnulwxu, swe nbnu fswln lnnls tywelnuwut snjn auk lsnjn
fwls txyk mxwule. isjcexelxvxe. lfx eljxut esjwyy fswelyne auefnjnk
lsjxzts lsn iayv.

-lsauge, xyk isam, sn ijwnk qjwegyc. lsal fwyy kx uwinyc. efwlis xdd
lsn izjjnul, fwyy cxz?

sn egwmmnk xdd lsn tzujnel auk yxxgnk tjabnyc al swe falisnj, talsnjwut
aqxzl swe ynte lsn yxxen dxyke xd swe txfu. lsn myzvm esakxfnk dain auk
ezyynu xbay pxfy jniayynk a mjnyaln, maljxu xd ajle wu lsn vwkkyn atne.
a mynaeaul evwyn qjxgn hzwnlyc xbnj swe ywme.

こちらを何度か試しながら文字を置き換えました。

we=is c=y x=o z=u i=r i=c ように置き換えたら、、、

quipqiup is a fast and automated cryptogram solver by Edwin Olson. It can solve simple substitution ciphers often found in newspapers, including puzzles like cryptoquips (in which word boundaries are preserved) and patristocrats (inwhi chwor dboun darie saren t).
Puzzle: 
-------------------------------------------------------------------------------
ixutjale snjn we cxzj dyat - ezqelwlzlwxu_iwmsnje_ajn_exybaqyn_ikwytukyum
-------------------------------------------------------------------------------
elalnyc, myzvm qzig vzyywtau iavn djxv lsn elawjsnak, qnajwut a qxfy xd
yalsnj xu fswis a vwjjxj auk a jarxj yac ijxeenk. a cnyyxf kjneewuttxfu,
zutwjkynk, fae ezelawunk tnulyc qnswuk swv xu lsn vwyk vxjuwut awj. sn
snyk lsn qxfy ayxdl auk wulxunk:

-wuljxwqx ak aylajn knw.

saylnk, sn mnnjnk kxfu lsn kajg fwukwut elawje auk iayynk xzl ixajenyc:

-ixvn zm, gwuis! ixvn zm, cxz dnajdzy pnezwl!

exynvuyc sn iavn dxjfajk auk vxzulnk lsn jxzuk tzujnel. sn daink aqxzl
auk qyneenk tjabnyc lsjwin lsn lxfnj, lsn ezjjxzukwut yauk auk lsn
afagwut vxzulawue. lsnu, ialiswut ewtsl xd elnmsnu knkayze, sn qnul
lxfajke swv auk vakn jamwk ijxeene wu lsn awj, tzjtywut wu swe lsjxal
auk esagwut swe snak. elnmsnu knkayze, kwemynaenk auk eynnmc, ynaunk
swe ajve xu lsn lxm xd lsn elawjiaen auk yxxgnk ixykyc al lsn esagwut
tzjtywut dain lsal qyneenk swv, nhzwun wu wle ynutls, auk al lsn ywtsl
zulxuezjnk sawj, tjawunk auk sznk ywgn mayn xag.

qzig vzyywtau mnnmnk au wuelaul zuknj lsn vwjjxj auk lsnu ixbnjnk lsn
qxfy evajlyc.

-qaig lx qajjaige! sn eawk elnjuyc.

sn akknk wu a mjnaisnje lxun:

-dxj lswe, x knajyc qnyxbnk, we lsn tnuzwun isjwelwun: qxkc auk exzy
auk qyxxk auk xzue. eyxf vzewi, mynaen. eszl cxzj ncne, tnule. xun
vxvnul. a ywllyn ljxzqyn aqxzl lsxen fswln ixjmzeiyne. ewynuin, ayy.

sn mnnjnk ewknface zm auk tabn a yxut eyxf fswelyn xd iayy, lsnu mazenk
afswyn wu jaml allnulwxu, swe nbnu fswln lnnls tywelnuwut snjn auk lsnjn
fwls txyk mxwule. isjcexelxvxe. lfx eljxut esjwyy fswelyne auefnjnk
lsjxzts lsn iayv.

-lsauge, xyk isam, sn ijwnk qjwegyc. lsal fwyy kx uwinyc. efwlis xdd
lsn izjjnul, fwyy cxz?

sn egwmmnk xdd lsn tzujnel auk yxxgnk tjabnyc al swe falisnj, talsnjwut
aqxzl swe ynte lsn yxxen dxyke xd swe txfu. lsn myzvm esakxfnk dain auk
ezyynu xbay pxfy jniayynk a mjnyaln, maljxu xd ajle wu lsn vwkkyn atne.
a mynaeaul evwyn qjxgn hzwnlyc xbnj swe ywme.
 Clues: For example G=R QVW=THE
we=is c=y x=o z=u i=r i=c


 dictionary

 Solve


 

0   -1.439  ------------------------------------------------------------------------------- congrats here is your flag - substitution_ciphers_are_solvable_cdilgndlnp ------------------------------------------------------------------------------- stately, plump buck mulligan came from the stairhead, bearing a bowl of lather on which a mirror and a razor lay crossed. a yellow dressinggown, ungirdled, was sustained gently behind him on the mild morning air. he held the bowl aloft and intoned: -introibo ad altare dei. halted, he peered down the dark winding stairs and called out coarsely: -come up, kinch! come up, you fearful jesuit! solemnly he came forward and mounted the round gunrest. he faced about and blessed gravely thrice the tower, the surrounding land and the awaking mountains. then, catching sight of stephen dedalus, he bent towards him and made rapid crosses in the air, gurgling in his throat and shaking his head. stephen dedalus, displeased and sleepy, leaned his arms on the top of the staircase and looked coldly at the shaking gurgling face that blessed him, equine in its length, and at the light untonsured hair, grained and hued like pale oak. buck mulligan peeped an instant under the mirror and then covered the bowl smartly. -back to barracks! he said sternly. he added in a preachers tone: -for this, o dearly beloved, is the genuine christine: body and soul and blood and ouns. slow music, please. shut your eyes, gents. one moment. a little trouble about those white corpuscles. silence, all. he peered sideways up and gave a long slow whistle of call, then paused awhile in rapt attention, his even white teeth glistening here and there with gold points. chrysostomos. two strong shrill whistles answered through the calm. -thanks, old chap, he cried briskly. that will do nicely. switch off the current, will you? he skipped off the gunrest and looked gravely at his watcher, gathering about his legs the loose folds of his gown. the plump shadowed face and sullen oval jowl recalled a prelate, patron of arts in the middle ages. a pleasant smile broke quietly over his lips.

Don't like the solutions you got? Try changing the 'solve' mode (click above the 'solve' button)!

Thanks for using quipqiup.com! The code and website are (C) 2014-2016 by Edwin Olson, ebolson@umich.edu

congrats here is your flag - substitution_ciphers_are_solvable_cdilgndlnp という文字がでてきました。 substitution_ciphers_are_solvable_cdilgndlnpがフラグです。

picoCTF 2018 HEEEEEEERE'S Johnny! - Points: 100

f:id:loveeeeeebird:20200111140131p:plain

nc 2018shell.picoctf.com 35225 に接続してみると、ログインを求められます。

Linuxのetc/passwdとect/shadowの内容が書かれたファイルが問題で与えられているので、それを参考にログインしていく問題です。

passwadファイルの中身を見てみると、ユーザーはrootであることがわかります。 shadowファイルにはパスワードが書かれていますが、ハッシュ化されているので通常解読できません。

johnを使ってパスワードを求めてみます。 最初、CentOSの環境でjohnをyumでインストールしようとしたらできなかったので、英語のサイトを参考にしながらrpmでインストールしようとしたが、、、依存関係やその他もろもろ自分でできる能力がなくできませんでした。。。いつもyumに頼っているつけが。。。

気を取り直してkaliLinuxでjohnをインストールすることにしました。(いや最初からこっちでやれ)

無事インストールができたので、johnを使ってみます。 初めてjohnを使うとき、johnのディレクトリが勝手に作られました。 私はその作られたディレクトリの/.john/下にshadowファイルを置き、以下のように実行しました。

$ john shadow Using default input encoding: UTF-8 Loaded 1 password hash (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x]) Cost 1 (iteration count) is 5000 for all loaded hashes Will run 6 OpenMP threads Proceeding with single, rules:Single Press 'q' or Ctrl-C to abort, almost any other key for status Warning: Only 5 candidates buffered for the current salt, minimum 24 needed for performance. Almost done: Processing the remaining buffered candidate passwords, if any. Warning: Only 6 candidates buffered for the current salt, minimum 24 needed for performance. Proceeding with wordlist:/usr/share/john/password.lst, rules:Wordlist hellokitty (root) 1g 0:00:00:01 DONE 2/3 (2020-01-11 12:02) 0.9523g/s 4999p/s 4999c/s 4999C/s keller..karla Use the "--show" option to display all of the cracked passwords reliably Session completed

hellokitty がパスワードのようです。ユーザーもrootと教えてくれました。

これを使ってもう一度ログインに挑戦してみます。

$ nc 2018shell.picoctf.com 35225 Username: root Password: hellokitty picoCTF{J0hn_1$_R1pp3d_99c35524}

フラグがありました。 楽しそうなのでもっとjohnを使ってみたいな。

picoCTF leak-me - Points: 200

f:id:loveeeeeebird:20200110210328p:plain

$ nc 2018shell.picoctf.com 57659
What is your name?
ctf
Hello ctf,
Please Enter the Password.
ctf
Incorrect Password!

とりあえずサーバに接続してみましたが、ログインできません。
ソースコードを見てみます。

$ cat auth.c
#include
#include
#include
#include
#include

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;
}

char password[64];
char name[256];
char password_input[64];

をみると、オーバーフローさせるとフラグがとれそうです。

$ nc 2018shell.picoctf.com 57659
What is your name?
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjsddddddddddddoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooodffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjsddddddddddddoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo,a_reAllY_s3cuRe_p4s$word_56b977

・・・こんな感じに自由に入力すると「a_reAllY_s3cuRe_p4s$word_56b977」という文字列がくっついてきました。パスワードでしょうか?入れてみます。

Please Enter the Password.
a_reAllY_s3cuRe_p4s$word_56b977
picoCTF{aLw4y5_Ch3cK_tHe_bUfF3r_s1z3_2b5cbbaa}

フラグがでてきました。

ksnctf Sherlock Holmes 70pt

f:id:loveeeeeebird:20191228154141p:plain

URLにアクセスしてみます。

f:id:loveeeeeebird:20191228154356p:plain

この三つにアクセスするとこんな感じのページに移りますが、flagの文字はありませんでした。

f:id:loveeeeeebird:20191228161933p:plain

http://ctfq.sweetduet.info:10080/~q26/index.pl の一つ上のディレクトリ(http://ctfq.sweetduet.info:10080/~q26/)に入ってみます。

f:id:loveeeeeebird:20191228160609p:plain

flag.txtがあります。しかしながら中身を見ても権限がないみたいで見れません。

ここから分からなくなって他の方のwriteupを見ました。(すぐwriteup見る)

最初に開いたページの先で英文が見れたのは、/index.plを経由していたからみたいです
。どうやらindex.plの中でファイルを読み込む処理があって、それ経由じゃないとファイルへのアクセス権限がないようです。(そういうのあるんだ)

なので、/index.plを経由してflag.txtを見てみます。(http://ctfq.sweetduet.info:10080/~q26/index.pl/flag.txt

f:id:loveeeeeebird:20191228162226p:plain

おしい、、似てるけどflagではない、、、ソースコードを見てって書いてあるのでF12で見てみるもflagらしきものがありません。

また行き詰まったのでwriteupを見てみます。(ほんとに感謝です)

どうやらperl脆弱性の問題らしく、「Perl cgi 脆弱性」って調べるといろいろでてきます。
Perlの仕様で、ファイル名の前もしくは後ろに|(パイプ)を付けるとOSコマンドを実行するらしい。

試しにhttp://ctfq.sweetduet.info:10080/~q26/index.pl/|ls で開いてみます。

f:id:loveeeeeebird:20191228163952p:plain

すると、/index.pl下にあるファイルを確認することができます。
なんと、flag.txtがありました! |cat flag.txt にして中身をみます!、、、

FROG_CroakCroak How about to try to see the source code? といわれました。

lsしたときにPerlのファイルがあったので、それをみればいいのでしょうか。
cat index.pl をしてみます。フラグがありました。

f:id:loveeeeeebird:20191228164725p:plain

こういうのをOSコマンドインジェクションというらしいです。
Perlは比較的簡単に書けるので、初心者(私も知りませんでした!)が、
Perlで書いた脆弱性が改善されてないサイトがまだまだたくさんあるらしいです。。。
色々なコマンドインジェクションがまとめてあったサイトを載せておきます。

OSコマンドインジェクション