LoginSignup
3
4

More than 5 years have passed since last update.

【T-Pot 】Cowrieログから実行されたコマンドの集計

Last updated at Posted at 2018-11-27

やりたいこと

T-PotのCowrieログから、SSH接続に成功した攻撃者がどのようなコマンドを実行してどんな情報を引き出しているのか等集計してみたい。

事前情報

保存先

デフォルトでは、データの格納先は以下のパスになっている。カスタマイズされている方は読み替えてほしい。
/data/cowrie/log/cowrie-textlog.log

※過去のものは圧縮されている
/data/cowrie/log/cowrie-textlog.log.1.gz

データ形式

ログの中を見てみると、だいたいが以下のようなログで埋め尽くされていることがわかる。

2018-11-26T18:39:51.623555Z New connection: *.*.*.*:52904 (172.24.0.2:2222) [session: 24f914cda400]
2018-11-26T18:39:51.818871Z Remote SSH version: SSH-2.0-Granados-1.0
2018-11-26T18:39:51.821196Z Connection lost after 0 seconds

この中に稀にこのような実行されたコマンドのログが残っている

2018-11-27T12:58:40.796273Z Command found: head -n 1
2018-11-27T12:58:40.797353Z Command found: grep name

集計の表示

このログを集計してみる。
圧縮された過去のファイルがたくさんあるので、そちらを対象にしてみる。

zcat cowrie-textlog.*gz | grep "Command found" | cut -d ' ' -f 4- | sort | uniq -c | sort -rn | head -10
    540 mkdir /tmp/.xs/
    167 cat /proc/cpuinfo
    114 grep name
    108 chmod 777 /tmp/.xs/test.mod
    108 chmod 777 /tmp/.xs/daemon.mips.mod
    108 chmod 777 /tmp/.xs/daemon.mipsel.mod
    108 chmod 777 /tmp/.xs/daemon.i686.mod
    108 chmod 777 /tmp/.xs/daemon.armv4l.mod
    108 cat > /tmp/.xs/test.mod
    108 cat > /tmp/.xs/daemon.mips.mod

お客様はフォルダ作成がお好きなようで。

ちなみに引数とオプションを無視した場合は以下のようになった。

zcat cowrie-textlog.*gz | grep "Command found" | cut -d ' ' -f 4 | sort | uniq -c | sort -rn | head -10
    724 cat
    546 chmod
    540 mkdir
    250 grep
    129 export
    123 uname
    116 head
    100 free
     86 unset
     65 ps

この結果はなんとなくわかる気がする。
そしてフォルダ作成大好きな方はもしかするとお一人様なのかもしれない。

おわり

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4