LoginSignup
0
1

More than 5 years have passed since last update.

WOWhoneypotのURI調査

Last updated at Posted at 2018-05-13

1日ごとに見たことがないURIがあるか調査したい。
そんな思いから、とてつもなく簡単なコードを書いた。

uri.sh

スクリプトしては、わずか2行です。
ago変数に前日の月日を文字列として渡してあげます。
5月13日に実行したら、「05-12」の文字列が返ってきます。
その後、該当文字列でgrepし、awkでURIだけを抽出し、ユニークにしてURLデコードしてあげます。

uri.sh
#!/bin/bash
ago=`date "+%m-%d" -d '1 day ago'`
grep $ago log/access_log.txt | awk {'print $5"\t"$6'} | nkf -w --url-input  | sort | uniq > uri/$ago.txt

crontab

毎日午前0時になったら、uri.shを実行したい。そんな時は、crontab -eコマンドを使用し、以下の1行を追加します。

0 0 * * * /tmp/wowhoneypot/uri.sh

最後に

commコマンドを使って、前日との差異を表示させる。
例えば、comm -23 05-12.txt 05-11.txtとか。
知ってるURIをまとめておいて、同じだったら見ないとかするともっと効率的に見れそう。

0
1
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
0
1