Nkap: ペネトレで使えそうなツールを作った
なんかツールを作りたかった
vulnhubみたいな仮想環境でペネトレをしていく上でいろいろな人がいろいろなツールを作ってることを知って自分も作ってみたいと思いました。その第一歩として自分がペネトレをするときに最初に実行するnmap, nikto, gobusterらへんを勝手に実行してくれるツールを作りました。
Nkap
今回自分がつくったツールはNkapと命名しました。これは自分が作ったからにはしっかり使ってアップデートしていきたいので自分の馴染みがあるような名前にしたくてnmapのtypoみたいな名前にしました。
なにをしてくれるか
nmapでポートスキャンをしてHTTPがあったときに自動でnikto, gobusterでより深くスキャンしてくれます。
これから
今はポートスキャンしたあとにHTTPがあったらnikto, gobusterをするだけなのでもっといろいろなポートに対応していきたいですね。
使い方
Nkap is a simple network reconnaissance tool positional arguments: target The target URL optional arguments: -h, --help show this help message and exit -w WORDLIST, --wordlist WORDLIST Path to the wordlist -o OUTPUT_DIR, --output OUTPUT_DIR The output directory for results. Default: results
実行例
$ nkap 192.168.2.133 [NMAP] 22/ssh tcp open 25/smtp tcp open 53/domain tcp open 80/http tcp open 111/rpcbind tcp open 42012/unknown tcp open [*] Running port scan: 192.168.2.133:22 [*] Running port scan: 192.168.2.133:25 [*] Running port scan: 192.168.2.133:53 [*] Running port scan: 192.168.2.133:80 [*] Running port scan: 192.168.2.133:111 [*] Running port scan: 192.168.2.133:42012 [NIKTO] --------------------------------------------------------------------------- + Server: Apache + The anti-clickjacking X-Frame-Options header is not present. + The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS + The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type + No CGI Directories found (use '-C all' to force check all possible dirs) + OSVDB-3268: /games/: Directory indexing found. + Entry '/games/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/dropbox/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/contact/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/search/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/archive/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/wp-admin/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/wp-content/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/wp-includes/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/comment-page-/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/trackback/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/xmlrpc.php' in robots.txt returned a non-forbidden or redirect HTTP code (301) + Entry '/blackhole/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/mint/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + Entry '/feed/' in robots.txt returned a non-forbidden or redirect HTTP code (200) + "robots.txt" contains 26 entries which should be manually viewed. + Server may leak inodes via ETags, header found with file /, inode: d3, size: 54c550ee22d56, mtime: gzip + Allowed HTTP Methods: OPTIONS, GET, HEAD, POST + OSVDB-3092: /archive/: This might be interesting... + OSVDB-3092: /support/: This might be interesting... + OSVDB-3092: /manual/: Web server manual found. + OSVDB-3268: /manual/images/: Directory indexing found. + OSVDB-3233: /icons/README: Apache default file found. + /wp-admin/: Admin login page/section found. + /phpmyadmin/: phpMyAdmin directory found + 7943 requests: 0 error(s) and 28 item(s) reported on remote host + End Time: 2020-07-19 10:12:28 (GMT9) (63 seconds) --------------------------------------------------------------------------- [GOBUSTER] [*] 200 OK /robots.txt [*] 301 Moved Permanently /archive /blackhole /blog /contact /control /dropbox /extend /feed /games /manual /mint /phpmyadmin /plugins /search /support /tag /themes /trackback /wp-content /xmlrpc.php /wp-admin /wp-includes [*] 403 Forbidden /.htpasswd /.htpasswd.php /.htaccess /.htaccess.php /server-status [*] Finished
configディレクトリにどのようなオプションで実行されるかが記載されているので自由に変えれるはずですが、おそらくエラーでそうなのでオススメはしません!!
あと、sudoつけないと実行できない可能性があります。
結果
Nkapを使用すると実行した場所でresultsディレクトリが生成され以下のようにディレクトリ、ファイルが生成されます。
. | └── scans/ ├── nmap.txt ├── nikto.txt ├── gobuster.txt ├── tcp_22_ssh_nmap.txt ├── tcp_25_smtp_nmap.txt ├── tcp_53_domain_nmap.txt ├── tcp_80_http_nmap.txt └── tcp_42012_unknown_nmap.txt
$ ls results/192.168.2.133/scans/ gobuster.txt tcp_111_rpcbind_nmap.txt tcp_53_domain_nmap.txt nikto.txt tcp_22_ssh_nmap.txt tcp_54187_unknown_nmap.txt nmap.txt tcp_25_smtp_nmap.txt tcp_80_http_nmap.txt
nmap.txt, nikto.txt, gobuster.txtにはそれぞれそのコマンドの結果が書き込まれています。
tcp_22_ssh_nmap.txtみたいなファイルにはそれぞれのポートをもう少し詳細にスキャンされた結果が書き込まれています。これは実行したときに出力されないので確認したいポートを個別にチェックする感じになります。
インストール
$ sudo apt install nmap nikto gobuster
$ pip install git+https://github.com/kanywst/nkap