■Fortigate-80CのWAN側の待ち受けポートについて nmapで確認すると、3つのポートを検知。openなのは8009/tcp $ sudo nmap -sT 192.168.1.251 | grep "^PORT\|^[0-9]" PORT STATE SERVICE 25/tcp open smtp 80/tcp open http 113/tcp closed ident 8000/tcp closed http-alt 8009/tcp open ajp13 ■8000/tcpはFSSOでシングルサインオンを行うための 「Windows Active Directory (AD) Collector Agent」らしい。 Traffic Types and TCP/UDP Ports used by Fortinet Products http://kb.fortinet.com/kb/viewContent.do?externalId=10773 FortiOS ports http://docs-legacy.fortinet.com/fos50hlp/50/index.html#page/FortiOS%25205.0%2520Help/troubleshooting_tools.173.29.html ■mail/ftpサーバがIDENTを流している場合は、 Denyでは無く、RejectしてRSTを返す必要があるらしい。 TCP/113 AUTH/IDENT に関して http://unixluser.org/techmemo/ident/ Opening TCP 113 http://docs-legacy.fortinet.com/fos50hlp/50/index.html#page/FortiOS%25205.0%2520Help/advanced.105.91.html ■次の脆弱性チェックの最中、113/tcpはRSTを返していて、 平常時はメールサーバからの113/tcpのパケットが無いことを確認。 $ sudo tcpdump -i eth0 -n tcp port 113 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes 22:41:18.215660 IP 192.168.1.253.62904 > 192.168.1.251.113: Flags [S], seq 2699535288, win 1024, options [mss 1460], length 0 22:41:18.215773 IP 192.168.1.251.113 > 192.168.1.253.62904: Flags [R.], seq 0, ack 2699535289, win 0, length 0 ■脆弱性のチェック Fortinet FortiGate-*までは特定されている。 penetration.sh https://raw.githubusercontent.com/labunix/penetration/master/penetration.sh 2012/10/13 debianのsambaを「tcp/445」のみに制限する http://d.hatena.ne.jp/labunix/comment?date=20121013 $ sudo ./myscripts/penetration.sh 192.168.1.251 ... PORT STATE SERVICE VERSION 25/tcp open smtp Postfix smtpd | ssl-cert: Subject: commonName=myhome.local | Issuer: commonName=myhome.local | Public Key type: rsa | Public Key bits: 2048 | Not valid before: 2012-10-21 12:29:02 | Not valid after: 2022-10-19 12:29:02 | MD5: XXXX 052f XXXX 697c XXXX a75a XXXX 5c73 |_SHA-1: XXXX 5f21 XXXX 9f3f XXXX 1c60 XXXX 017d XXXX f0e8 |_smtp-commands: myhome.local, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, 80/tcp open http Apache httpd 2.2.22 ((Debian)) |_http-methods: GET HEAD POST OPTIONS |_http-title: Site doesn't have a title (text/html). 113/tcp closed ident 8000/tcp closed http-alt 8009/tcp open ajp13? ... Device type: firewall Running (JUST GUESSING): Fortinet embedded (99%) Aggressive OS guesses: Fortinet FortiGate-50B or 310B firewall (99%), Fortinet FortiGate-60B or -100A firewall (91%) No exact OS matches for host (test conditions non-ideal). Uptime guess: 0.033 days (since Mon Feb 23 21:57:31 2015) Network Distance: 1 hop TCP Sequence Prediction: Difficulty=263 (Good luck!) IP ID Sequence Generation: Broken little-endian incremental Service Info: Host: myhome.local TRACEROUTE HOP RTT ADDRESS 1 0.57 ms 192.168.1.251
■open判定の8009/tcpについてはFortiOSでは使われず、 FortiClient Endpoint Control機能で使用されるとのこと。 使用していないので、無効化出来る。 FortiOS 5.0のTCP/8009番ポートについて https://hds.networld.co.jp/helpdesk/support/FaqFacadeServlet?TaskType=Detail&seriesId=Fortinet&id=00002780&categoryId=0194&JspUrl=/support/FrequentlyDetail.jsp ■8009/TCPの有効、無効のconfigを作成、流し込みで変更出来るようにした。 ※実行前後の設定出力は行いますが、 無効の際にはconfigの削除がありますのでご注意下さい。 githubには上げておいた。 https://github.com/labunix/fortigate-80c-settings FortiClient_EndPoint_Control_disable.log FortiClient_EndPoint_Control_enable.log ■例えばtelnetで流し込む場合 パスワードの例が良くないので、変更してください。 なお、デフォルトはパス無しなので、「echo ""」です。 $ (sleep 1 ; echo "admin"; \ sleep 2;echo "Password"; \ sleep 1; cat FortiClient_EndPoint_Control_enable.log; \ sleep 1;echo "exit";) | telnet 172.31.31.251 ■wan1に対してはfilterされるようになり、 internel側ではopenのままとなった。 $ sudo nmap -sT -p 8009 192.168.1.251 | grep "PORT\|^[0-9]" PORT STATE SERVICE 8009/tcp filtered ajp13 $ sudo nmap -sT -p 8009 172.31.31.251 | grep "PORT\|^[0-9]" PORT STATE SERVICE 8009/tcp open ajp13 ■今度は無効化してみる。 $ (sleep 1 ; echo "admin"; \ sleep 2;echo "Password"; \ sleep 1; cat FortiClient_EndPoint_Control_disable.log; \ sleep 1;echo "exit";) | telnet 172.31.31.251 ■きちんとwan1に対してもopenになった。 これでいつ必要になってもすぐに有効出来るようになった。 $ sudo nmap -sT -p 8009 192.168.1.251 | grep "^PORT\|^[0-9]" PORT STATE SERVICE 8009/tcp open ajp13 $ sudo nmap -sT -p 8009 172.31.31.251 | grep "^PORT\|^[0-9]" PORT STATE SERVICE 8009/tcp open ajp13