顯示具有 資安 標籤的文章。 顯示所有文章
顯示具有 資安 標籤的文章。 顯示所有文章

2026年4月12日 星期日

守護網路安全的瑞士刀:Security Onion 簡介

 

守護網路安全的瑞士刀:Security Onion 簡介

在網路安全的世界裡,如果你想要監控流量、偵測威脅並進行入侵分析,通常需要安裝一大堆工具。但 Security Onion (SO) 的出現,讓這一切變得簡單許多。

什麼是 Security Onion?

Security Onion 是一個自由且開源的 Linux 發行版,專門用於 威脅狩獵 (Threat Hunting)、企業安全監控 (Enterprise Security Monitoring, ESM) 以及 日誌管理。

簡單來說,它就像是一個「安全工具大禮包」,幫你把業界最強大的開源安全軟體全部整合在一起,並預先配置好,讓你開箱即用。


Security Onion 的核心三部曲

Security Onion 的強大來自於它整合了三種主要功能:

  1. 全數據包捕獲 (Full Packet Capture): 就像錄影機一樣,記錄下網路上發生的一切細節。

  2. 入侵偵測系統 (IDS): 包含主機端 (HIDS) 與網路端 (NIDS),當發現可疑行為時會立即發出警報。

  3. 分析工具 (Analysis Tools): 提供直觀的圖表與介面,讓分析師能快速從海量數據中抓出「害群之馬」。


內建的神級工具陣容

Security Onion 整合了多款重量級工具,形成了一個完整的防禦體系:

  • 流量分析: Zeek (舊稱 Bro) 與 Suricata。

  • 日誌處理: 著名的 ELK Stack (Elasticsearch, Logstash, Kibana),現在也支持 Elastic Fleet。

  • 分析介面: * Security Onion Console (SOC): 自家的管理中心。

    • CyberChef: 萬能的資料轉換工具。

    • TheHive: 專為事件響應設計的案例管理平台。


為什麼你應該嘗試 Security Onion?

1. 節省大量的部署時間

手動整合 Elasticsearch、Suricata、Zeek 等工具是一個地獄級的任務。Security Onion 透過簡單的安裝程序,幾分鐘內就能幫你搭建好一個專業級的 SOC 中心。

2. 強大的可視化

透過 Kibana 儀表板,你可以一眼看出當前網路的流量分佈、哪些 IP 正在嘗試攻擊你的伺服器,甚至追蹤惡意程式的連線行為。

3. 學習與實戰的絕佳平台

如果你是資安新手,Security Onion 是學習「藍隊 (Blue Teaming)」技能的最佳起點。它能讓你真實體驗到分析師在處理警報時的完整工作流。


以上內容撰寫: gemini ai

線上手冊: https://docs.securityonion.net/






2026年4月11日 星期六

Lab: Building a Network IDS with Active Response via Wazuh and Suricata




 Wazuh 整合 Suricata 達成網路入侵偵測與自動回應實驗

Wazuh Server 安裝  (192.168.100.10)

https://documentation.wazuh.com/current/quickstart.html

curl -sO https://packages.wazuh.com/4.14/wazuh-install.sh && sudo bash ./wazuh-install.sh -a

Wazuh Agent  安裝

 ( client interface ens160 192.168.100.20/24  / suricata monitor interface ens224  192.168.100.30/32)

curl -o wazuh-agent-4.14.4-1.x86_64.rpm https://packages.wazuh.com/4.x/yum/wazuh-agent-4.14.4-1.x86_64.rpm && sudo WAZUH_MANAGER='192.168.100.10' rpm -ihv wazuh-agent-4.14.4-1.x86_64.rpm


https://documentation.wazuh.com/current/proof-of-concept-guide/integrate-network-ids-suricata.html


[root@Wazuh-Client01 suricata]# ip add | grep ens

2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

    inet 192.168.100.20/24 brd 192.168.100.255 scope global noprefixroute ens160

3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

    inet 192.168.100.30/32 scope global noprefixroute ens224


參考 URL

Suricata 安裝 

https://docs.suricata.io/en/suricata-7.0.15/install.html#rpm-packages

https://copr.fedorainfracloud.org/coprs/g/oisf/suricata-7.0/


Suricata Rule 

https://rules.emergingthreats.net/open/suricata-7.0.15/

https://rules.emergingthreats.net/open/suricata-7.0.15/rules/


Suricata 重要設定

vi /etc/sysconfig/suricata

OPTIONS="-i eth0" -->  OPTIONS="-i ens224" 

vi /etc/suricata/suricata.yaml

interface: eth0 ---> interface: ens224

可以用

sed -i 's/interface: eth0/interface: ens224/g' /etc/suricata/suricata.yaml


運行 rule 宣告 
vi /etc/suricata/suricata.yaml

## Configure Suricata to load Suricata-Update managed rules.
default-rule-path: /var/lib/suricata/rules
rule-files:
  - suricata.rules


觸發log檢查

[root@Wazuh-Client01 rules]# cat /var/log/suricata/fast.log
04/11/2026-20:01:05.711058  [**] [1:2100498:7] GPL ATTACK_RESPONSE id check returned root [**] [Classification: Potentially Bad Traffic] [Priority: 2] {TCP} 217.160.0.187:80 -> 192.168.100.20:59428
04/11/2026-20:07:12.072266  [**] [1:2039584:2] ET FILE_SHARING Observed DNS Query to Filesharing Service (mega .co .nz) [**] [Classification: Misc activity] [Priority: 3] {UDP} 192.168.100.99:52525 -> 8.8.8.8:53
04/11/2026-20:07:12.072339  [**] [1:2039584:2] ET FILE_SHARING Observed DNS Query to Filesharing Service (mega .co .nz) [**] [Classification: Misc activity] [Priority: 3] {UDP} 192.168.100.99:52525 -> 8.8.8.8:53
04/11/2026-20:07:13.250532  [**] [1:2039584:2] ET FILE_SHARING Observed DNS Query to Filesharing Service (mega .co .nz) [**] [Classification: Misc activity] [Priority: 3] {UDP} 192.168.100.99:52525 -> 8.8.8.8:53
04/11/2026-20:07:13.250583  [**] [1:2039584:2] ET FILE_SHARING Observed DNS Query to Filesharing Service (mega .co .nz) [**] [Classification: Misc activity] [Priority: 3] {UDP} 192.168.100.99:52525 -> 8.8.8.8:53
04/11/2026-20:15:53.248125  [**] [1:2047866:4] ET INFO Observed Google DNS over HTTPS Domain (dns .google in TLS SNI) [**] [Classification: Misc activity] [Priority: 3] {TCP} 192.168.100.99:53705 -> 8.8.8.8:443
04/11/2026-20:16:25.147099  [**] [1:2039584:2] ET FILE_SHARING Observed DNS Query to Filesharing Service (mega .co .nz) [**] [Classification: Misc activity] [Priority: 3] {UDP} 192.168.100.99:52525 -> 8.8.8.8:53
04/11/2026-20:16:25.147133  [**] [1:2039584:2] ET FILE_SHARING Observed DNS Query to Filesharing Service (mega .co .nz) [**] [Classification: Misc activity] [Priority: 3] {UDP} 192.168.100.99:52525 -> 8.8.8.8:53
04/11/2026-20:16:25.741758  [**] [1:2062715:1] ET INFO Observed UA-CPU Header [**] [Classification: Misc activity] [Priority: 3] {TCP} 192.168.100.99:53720 -> 66.203.127.11:80
04/11/2026-20:19:40.406579  [**] [1:2027695:5] ET INFO Observed Cloudflare DNS over HTTPS Domain (cloudflare-dns .com in TLS SNI) [**] [Classification: Misc activity] [Priority: 3] {TCP} 192.168.100.99:52061 -> 104.16.248.249:443
04/11/2026-21:08:39.787225  [**] [1:1000001:1] DEBUG SQL Injection Attempt [**] [Classification: (null)] [Priority: 3] {TCP} 192.168.100.10:51566 -> 192.168.100.30:80

 

Demo







Client 端自我測試

curl http://testmyids.com

在 Server 端發向 Client 端的 SQL Injection 測試. 

echo "UNION SELECT 1,2,3" | nc -w 1 192.168.100.30 80


SQL Injection rules

cat /var/lib/suricata/rules/local.rules

alert tcp any any -> any any (msg:"DEBUG SQL Injection Attempt"; content:"UNION SELECT"; nocase; sid:1000001; rev:1;)






2022年6月2日 星期四

CentOS 7 安裝 NGINX ModSecurity WAF 筆記

 [root@centos7 yum.repos.d]# vi epel.repo 

[epel]

name=Extra Packages for Enterprise Linux 7 - $basearch

#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch

metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch

failovermethod=priority

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7


[epel-debuginfo]

name=Extra Packages for Enterprise Linux 7 - $basearch - Debug

#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug

metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

gpgcheck=1


[epel-source]

name=Extra Packages for Enterprise Linux 7 - $basearch - Source

#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS

metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

gpgcheck=1


====================================

[root@centos7 /]# vi /etc/yum.repos.d/nginx.repo 

[nginx-stable]

name=nginx stable repo

baseurl=http://nginx.org/packages/centos/$releasever/$basearch/

gpgcheck=1

enabled=1

gpgkey=https://nginx.org/keys/nginx_signing.key

module_hotfixes=true


[nginx-mainline]

name=nginx mainline repo

baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/

gpgcheck=1

enabled=0

gpgkey=https://nginx.org/keys/nginx_signing.key

module_hotfixes=true


======================================

[root@centos7 yum.repos.d]# vi remi.repo 



# Repository: http://rpms.remirepo.net/

# Blog:       http://blog.remirepo.net/

# Forum:      http://forum.remirepo.net/


[remi]

name=Remi's RPM repository for Enterprise Linux 7 - $basearch

#baseurl=http://rpms.remirepo.net/enterprise/7/remi/$basearch/

#mirrorlist=https://rpms.remirepo.net/enterprise/7/remi/httpsmirror

mirrorlist=http://cdn.remirepo.net/enterprise/7/remi/mirror

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi


[remi-php55]

name=Remi's PHP 5.5 RPM repository for Enterprise Linux 7 - $basearch

#baseurl=http://rpms.remirepo.net/enterprise/7/php55/$basearch/

#mirrorlist=https://rpms.remirepo.net/enterprise/7/php55/httpsmirror

mirrorlist=http://cdn.remirepo.net/enterprise/7/php55/mirror

# NOTICE: common dependencies are in "remi-safe"

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi


=================================

參考 URL


https://github.com/SpiderLabs/ModSecurity/


https://github.com/SpiderLabs/ModSecurity-nginx


https://github.com/SpiderLabs/owasp-modsecurity-crs


===================================


cd /opt

git clone https://github.com/SpiderLabs/ModSecurity

cd ModSecurity

git checkout -b v3/master origin/v3/master

sh build.sh

git submodule init

git submodule update

./configure

make

make install

cd ..

git clone https://github.com/SpiderLabs/ModSecurity-nginx.git modsecurity-nginx

wget https://nginx.org/download/nginx-1.22.0.tar.gz

tar -zvxf nginx-1.22.0.tar.gz 

cd nginx-1.22.0/


build a dynamic module


./configure --with-compat --add-dynamic-module=/opt/modsecurity-nginx

make modules

cd objs/

cp ngx_http_modsecurity_module.so /etc/nginx/modules/

cp /opt/ModSecurity/modsecurity.conf-recommended /etc/nginx/modsecurity.conf

在 /etc/nginx/nginx.conf 放入 load_module

load_module modules/ngx_http_modsecurity_module.so;

在 /etc/nginx/conf.d/default.conf(或其他 ) 的 server 內放 

    modsecurity on;

    modsecurity_rules_file /etc/nginx/modsecurity.conf;


===========================

cp /opt/ModSecurity/unicode.mapping /etc/nginx

sed -ie 's/SecRuleEngine DetectionOnly/SecRuleEngine On/g' /etc/nginx/modsecurity.conf


安裝 OWASP  rules

cd /opt

git clone https://github.com/SpiderLabs/owasp-modsecurity-crs.git

cd /opt/owasp-modsecurity-crs/rules

[root@centos7 rules]# pwd

/opt/owasp-modsecurity-crs/rules

cat *.conf > /etc/nginx/csr.conf

cp /opt/owasp-modsecurity-crs/crs-setup.conf.example /etc/nginx/crs-setup.conf

cd /etc/nginx 

cat modsecurity.conf crs-setup.conf csr.conf > rules.conf

 cp *.data  /etc/nginx/


======================

[root@centos7 conf.d]# cat /etc/nginx/nginx.conf 


user  nginx;

worker_processes  auto;


error_log  /var/log/nginx/error.log notice;

pid        /var/run/nginx.pid;



load_module modules/ngx_http_modsecurity_module.so;


events {

    worker_connections  1024;

}



http {

    include       /etc/nginx/mime.types;

    default_type  application/octet-stream;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';


    access_log  /var/log/nginx/access.log  main;


    sendfile        on;

    #tcp_nopush     on;


    keepalive_timeout  65;


    #gzip  on;


    include /etc/nginx/conf.d/*.conf;

}

[root@centos7 conf.d]# 



===========================


[root@centos7 conf.d]# cat default.conf 

server {

    listen       80;

    server_name  localhost;

    modsecurity on;

    modsecurity_rules_file /etc/nginx/modsecurity.conf;

    # or  use OWASP  rules modsecurity_rules_file /etc/nginx/rules.conf;

    #access_log  /var/log/nginx/host.access.log  main;


    location / {

        root   /usr/share/nginx/html;

        index  index.html index.htm;


        #modsecurity_rules_file rules.conf;


    }


    #error_page  404              /404.html;


    # redirect server error pages to the static page /50x.html

    #

    error_page   500 502 503 504  /50x.html;

    location = /50x.html {

        root   /usr/share/nginx/html;

    }


    # proxy the PHP scripts to Apache listening on 127.0.0.1:80

    #

    #location ~ \.php$ {

    #    proxy_pass   http://127.0.0.1;

    #}


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    location ~ \.php$ {

        root           /usr/share/nginx/html;

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;  

        include        fastcgi_params;

    }


    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    #location ~ /\.ht {

    #    deny  all;

    #}

}


[root@centos7 conf.d]# 


vi /etc/php.ini


; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's

; http://php.net/cgi.fix-pathinfo

;cgi.fix_pathinfo=1

cgi.fix_pathinfo=0




vi /etc/php-fpm.d/www.conf 



; RPM: apache user chosen to provide access to the same directories as httpd

user = nginx

; RPM: Keep a group allowed to write in log dir.

group = nginx




vi /etc/nginx/conf.d/default.conf


    location ~ \.php$ {

        root           /usr/share/nginx/html;

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

        include        fastcgi_params;

    }






2016年11月15日 星期二

FortiGate Firmware Upgrade Paths

FortiGate Firmware Upgrade

有時候,它就是一版,一版升上來..

如 5.0.12 --> 5.2.8 ---> 5.4.2


在 fortios-v5.4.2-release-notes.pdf 有指出
...

Upgrade Information

Upgrading to FortiOS 5.4.2
FortiOS version 5.4.2 officially supports upgrading from version 5.4.0 and later and 5.2.8 and later.
.....

=================

另在 fortios-v5.2.8-release-notes.pdf 又指出

..

Upgrade Information


Upgrading from FortiOS 5.0.12 or later
FortiOS version 5.2.8 officially supports upgrade from version 5.0.12 or later

.....

================

其實另外亦也可以參考  Upgrade Paths 的 URL

http://cookbook.fortinet.com/sysadmins-notebook/supported-upgrade-paths-fortios/3/

照它上面是寫 應該也是 OK 的....待驗證

如 5.0.12--> 5.2.9 ---> 5.4.2




2016年10月19日 星期三

Apache 關閉 RC4 加密演算法加上也不使用 SSL v3 及 TLSv1.0

Apache 關閉 RC4 加密演算法加上
也不使用 SSL v3 及 TLSv1.0協定

考古題

昨天同事問我如何關閉 Apache RC4 加密演算法,
所以順便整理這個小筆記,供需要的人參考.


網路常用的RC4加密演算法已可快速破解,研究人員呼籲別再使用
http://www.ithome.com.tw/news/97445


Google 發現 SSL 3.0 漏洞,小心「貴賓犬」攻擊!
http://www.ithome.com.tw/news/91571

TLS加密協定竟然也不安全!企業須審慎內部漏洞
http://www.ithome.com.tw/promotion/93094

懶人包..--> 不使用不安全的加密演算法及通訊協定


#vi /etc/httpd/conf.d/ssl.conf ( Cenots 6 / httpd 2.2 預設檔案位置 )


原 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW

使用 nmap RC4 檢測結果為

[root@bbb conf.d]# nmap --script ssl-cert,ssl-enum-ciphers -p 443  127.0.0.1 | grep RC4
|       TLS_ECDHE_RSA_WITH_RC4_128_SHA
|       TLS_RSA_WITH_RC4_128_MD5
|       TLS_RSA_WITH_RC4_128_SHA
|       TLS_ECDHE_RSA_WITH_RC4_128_SHA
|       TLS_RSA_WITH_RC4_128_MD5
|       TLS_RSA_WITH_RC4_128_SHA
|       TLS_ECDHE_RSA_WITH_RC4_128_SHA
|       TLS_RSA_WITH_RC4_128_MD5
|       TLS_RSA_WITH_RC4_128_SHA
|       TLS_ECDHE_RSA_WITH_RC4_128_SHA
|       TLS_RSA_WITH_RC4_128_MD5
|       TLS_RSA_WITH_RC4_128_SHA

中獎-->使用 RC4....

===========

改為

SSLHonorCipherOrder on
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH

再檢測即可看到: 已無 RC4 加密演算法

[root@bbb conf.d]# nmap --script ssl-cert,ssl-enum-ciphers -p 443  127.0.0.1 | grep RC4

再看一次該主機的 ssl 資訊 , 可發現有使用不安全的 SSLv3 的協定

[root@bbb conf.d]# nmap --script ssl-cert,ssl-enum-ciphers -p 443  127.0.0.1

Starting Nmap 5.51 ( http://nmap.org ) at 2016-10-19 15:48 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000027s latency).
PORT    STATE SERVICE
443/tcp open  https
| ssl-cert: Subject: commonName=aaa/organizationName=SomeOrganization/stateOrProvinceName=SomeState/countryName=--
| Issuer: commonName=aaa/organizationName=SomeOrganization/stateOrProvinceName=SomeState/countryName=--
| Public Key type: rsa
| Public Key bits: 2048
| Not valid before: 2015-04-08 02:58:19
| Not valid after:  2016-04-07 02:58:19
| MD5:   de0e fdf1 11c0 f3e4 2cc2 3b0b 8e9e 6b9a
|_SHA-1: fc10 b6c3 b1e8 695c 19f4 78a2 3e5d 58f6 6a69 a9f5
| ssl-enum-ciphers:
|   SSLv3
|     Ciphers (2)
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
|     Compressors (1)
|       uncompressed
|   TLSv1.0
|     Ciphers (2)
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
|     Compressors (1)
|       uncompressed
|   TLSv1.1
|     Ciphers (2)
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
|     Compressors (1)
|       uncompressed
|   TLSv1.2
|     Ciphers (8)
|       TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
|       TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
|       TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
|       TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
|     Compressors (1)
|_      uncompressed

Nmap done: 1 IP address (1 host up) scanned in 0.38 seconds



但還是中獎 --> 使用 SSLv3 + TLSv1.0


==============

所以再次 vi 該檔案 ssl.conf , 將它改為下面這樣的宣告僅使用 TLS 協定方式.

#SSLProtocol all -SSLv2
SSLProtocol -all +TLSv1.1 +TLSv1.2


再次驗證,已無使用 SSLv3 及 TLSv1 ...


[root@bbb conf.d]# nmap --script ssl-cert,ssl-enum-ciphers -p 443  127.0.0.1

Starting Nmap 5.51 ( http://nmap.org ) at 2016-10-19 16:10 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000028s latency).
PORT    STATE SERVICE
443/tcp open  https
| ssl-cert: Subject: commonName=aaa/organizationName=SomeOrganization/stateOrProvinceName=SomeState/countryName=--
| Issuer: commonName=aaa/organizationName=SomeOrganization/stateOrProvinceName=SomeState/countryName=--
| Public Key type: rsa
| Public Key bits: 2048
| Not valid before: 2015-04-08 02:58:19
| Not valid after:  2016-04-07 02:58:19
| MD5:   de0e fdf1 11c0 f3e4 2cc2 3b0b 8e9e 6b9a
|_SHA-1: fc10 b6c3 b1e8 695c 19f4 78a2 3e5d 58f6 6a69 a9f5
| ssl-enum-ciphers:
|   TLSv1.1
|     Ciphers (2)
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
|     Compressors (1)
|       uncompressed
|   TLSv1.2
|     Ciphers (8)
|       TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA
|       TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
|       TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
|       TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
|       TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
|     Compressors (1)
|_      uncompressed

Nmap done: 1 IP address (1 host up) scanned in 0.35 seconds



這樣應該好多了....可以弱點掃描或滲透測試的軟體去試看看...是否還有其它的問題???


參考資訊
https://raymii.org/s/tutorials/Strong_SSL_Security_On_Apache2.html
https://www.owasp.org/index.php/Testing_for_Weak_SSL/TLS_Ciphers,_Insufficient_Transport_Layer_Protection_(OTG-CRYPST-001)
http://serverfault.com/questions/314858/how-to-enable-tls-1-1-and-1-2-with-openssl-and-apache

外部 FQDN 檢測網站

https://www.ssllabs.com/ssltest

2013年6月24日 星期一

CentOS 6.4 64 bit w3af_gui 無法執行 ( w3af )


w3af 請參考

http://xrcd2.blogspot.tw/2012/07/w3af-waf-for-apache.html


root@w3af w3af]# ./w3af_gui                          
On Debian systems please install the following operating system packages before running the pip installer:                                                   
   
       sudo apt-get install build-essential python-setuptools git python-pip graphviz python2.7-dev libsqlite3-dev libxslt1-dev python-gtksourceview2 python-gtk2 libxml2-dev                                                                     

Your python installation needs the following modules to run w3af:
    clamd github git.util esmre phply chardet pdfminer concurrent.futures guess_language cluster msgpack ntlm xdot                                             

After installing any missing operating system packages, use pip to install the remaining modules:                                                            
    sudo pip install clamd PyGithub GitPython esmre chardet pdfminer futures guess-language cluster msgpack-python python-ntlm xdot                          
    sudo pip install -e git+git://github.com/ramen/phply.git#egg=phply         
A script with these commands has been created for you at /tmp/w3af_dependency_install.sh 


=======================

python-setuptools
Easy Install  是一個 Python的模組化工具 (easy_install),是包含在 setuptools rpm 中,提供Python自動化程式下載、編譯、安裝和管理的模組。
使用方法 #easy_install [套件名稱]
如 easy_install pip
或使用 #pip [套件名稱] 也行


更詳細的介紹請自行參閱
http://www.openfoundry.org/tw/tech-column/8536-introduction-of-python-extension-management-tools

2012年10月7日 星期日

再論 ModSecurity (如何保護 Apache )


前二篇文章我是透過 滲透測試 & 弱點掃描去探討,如何去保護Apache這個議題,
以 Apache 來說,它可以在 Windows(WAMP)及Linux(LAMP)或 BSD等其它 UNIX
平台上運作,當然它只需要有 C compiler 或 gcc compiler 的開發環境,只需取得官
網上的 Tarball(Source Code),自然可以透過 Compiler 、 Make 、 Make install將
ModSecurity(Apache module)安裝於該系統的平台之上,再透過設定  ModSecurity
Config & Rule 即可讓 Apache 得到一定的保護!

相關文章請自行參閱我之前寫的相關文章!
滲透測試 & 弱點掃描 w3af + WAF for Apache (Part 1)
http://xrcd2.blogspot.tw/2012/07/w3af-waf-for-apache.html
滲透測試 & 弱點掃描 w3af + WAF for Apache (Part 2)
http://xrcd2.blogspot.tw/2012/07/modsecurity-waf-for-apache.html

除此之外也可以透過修改 Apache config,啟用一些預設機置去做一些基本的保護.
如在設定檔內設定 ServerTokens Prod 、 ServerSignature Off 、 TraceEnable Off  等等(不顯示相關資本資訊,關閉除錯)

以 CVE-2011-3192  (Apache HTTP Server CVE-2011-3192 Denial Of Service Vulnerability) 為例
http://www.securityfocus.com/bid/49303
參考 http://wiki.apache.org/httpd/CVE-2011-3192 即可得到解法.

Apaache 2.2.x DoS 解法 (httpd.conf)

LoadModule headers_module modules/mod_headers.so
LoadModule rewrite_module modules/mod_rewrite.so
ServerTokens Prod
ServerSignature Off
SetEnvIf Range (?:,.*?){5,5} bad-range=1
RequestHeader unset Range env=bad-range
RequestHeader unset Request-Range
RewriteEngine on
RewriteCond %{HTTP:range} !(^bytes=[^,]+(,[^,]+){0,4}$|^$) [NC]
RewriteRule .* - [F]
RequestHeader unset Request-Range

圖一為某台主機經由 Nessus 找到的 Apache 弱點 (初掃)
圖二為加上  ServerTokens Prod & ServerSignature Off (第一次複掃的弱點)
圖三為啟用  headers_module  & rewrite_module (第二次複掃的弱點)
當然再上以  TraceEnable Off 或 透過
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
圖中的 HTTP Trace/Track Methods Allowed 這個中風險也應該會被排除才是.

WAMP 的使用環境  ModSecurity 可透過安裝 mod_security win32.zip 進行更進階的保護.
Download的URL可參考 http://www.apachelounge.com/download/
LAMP 的使用環境  ModSecurity 可透過安裝 modsecurity-apache_x.x.x.tar.gz 進行更進階的保護.
Download的URL可參考 http://www.modsecurity.org/download/

如果您是 IIS 的使用者 請參考 http://www.modsecurity.org/projects/modsecurity/iis/index.html
及 http://blogs.technet.com/b/srd/archive/2012/07/26/announcing-the-availability-of-modsecurity-extension-for-iis.aspx
相關內容應該可以得到相關的資訊..
如果您是 LNMP 的使用環境請參考  http://www.modsecurity.org/projects/modsecurity/nginx/index.html

滲透測試
w3af
http://w3af.sourceforge.net/
弱點掃描
dragonsoft ( http://www.dragonsoft.com.tw/ ) or
nessus ( http://www.nessus.org/products/nessus ) or
openvas ( http://www.openvas.org/ )

WAF for Apache  [WAF (Web Application Firewall)]
ModSecurity
http://www.modsecurity.org/
WANP (Windows、Apache、MySQL、PHP)
LAMP (Linux、Apache、MySQL、PHP)
LNMP (Linux、Nginx、MySQL、PHP)

2012年7月14日 星期六

滲透測試 & 弱點掃描 w3af + WAF for Apache (Part 2)

ModSecurity  Configuration

使用平台為 CentOS 6.3

弱點掃描
dragonsoft ( http://www.dragonsoft.com.tw/  )

相關文章為
http://xrcd2.blogspot.tw/2012/07/w3af-waf-for-apache.html

[root@centos conf.d]# cat modsecurity.conf
LoadFile /usr/lib/libxml2.so
LoadModule unique_id_module modules/mod_unique_id.so
LoadModule security2_module modules/mod_security2.so
Include conf/rule/*.conf                     #modsec-2.5-free-latest.tar.gz
Include conf/rule2/activated_rules/*.conf    #modsecurity-crs_2.2.5.tar.gz
Include conf/rule2/base_rules/*.conf         #modsecurity-crs_2.2.5.tar.gz


<IfModule mod_security>
SecFilterEngine On
Debug logging options
#Debug log
SecDebugLog /tmp/logs/modsec_debug.log
SecDebugLogLevel 0
Audit logging options
#Serial Audit log
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus ^5
SecAuditLogParts ABIFHZ
SecAuditLogType Serial
SecAuditLog /tmp/logs/modsec_audit.log

</IfModule>

<IfModule mod_security2.c>
SecServerSignature "Microsoft-IIS/6.0"
SecRuleEngine On
SecRequestBodyAccess On
SecResponseBodyAccess On
#Handling of uploaded files
SecUploadDir /tmp/
SecUploadKeepFiles Off
SecRule REQUEST_HEADERS:Content-Type "text/xml" \
     "phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
SecRequestBodyLimit 13107200
SecRequestBodyNoFilesLimit 131072
SecRequestBodyInMemoryLimit 131072
SecRequestBodyLimitAction Reject
SecRule REQBODY_ERROR "!@eq 0" \
"phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
"phase:2,t:none,log,deny,status:44,msg:'Multipart request body \
failed strict validation: \
PE %{REQBODY_PROCESSOR_ERROR}, \
BQ %{MULTIPART_BOUNDARY_QUOTED}, \
BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
DB %{MULTIPART_DATA_BEFORE}, \
DA %{MULTIPART_DATA_AFTER}, \
HF %{MULTIPART_HEADER_FOLDING}, \
LF %{MULTIPART_LF_LINE}, \
SM %{MULTIPART_SEMICOLON_MISSING}, \
IQ %{MULTIPART_INVALID_QUOTING}, \
IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
IH %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
"phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'"
SecPcreMatchLimit 1000
SecPcreMatchLimitRecursion 1000
SecRule TX:/^MSC_/ "!@streq 0" \
        "phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
SecResponseBodyAccess On
SecResponseBodyMimeType text/plain text/html text/xml
SecResponseBodyLimit 524288
SecResponseBodyLimitAction ProcessPartial
SecTmpDir /tmp/
SecDataDir /tmp/
#
#SecUploadDir /opt/modsecurity/var/upload/
#SecUploadKeepFiles RelevantOnly
#SecUploadFileMode 0600
#SecDebugLog /opt/modsecurity/var/log/debug.log
#SecDebugLogLevel 3
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
SecAuditLogParts ABIJDEFHZ
SecAuditLogType Serial
SecAuditLog /var/log/modsec_audit.log
# Specify the path for concurrent audit logging.
#SecAuditLogStorageDir /opt/modsecurity/var/audit/
SecArgumentSeparator &
SecCookieFormat 0
</IfModule>
[root@centos conf.d]#



2012年7月9日 星期一

滲透測試 & 弱點掃描 w3af + WAF for Apache (Part 1)

滲透測試
w3af
http://w3af.sourceforge.net/

http://sourceforge.net/projects/w3af/files/w3af/


弱點掃描
dragonsoft ( http://www.dragonsoft.com.tw/ ) or
nessus ( http://www.nessus.org/products/nessus ) or
openvas ( http://www.openvas.org/ )

WAF for Apache
ModSecurity
http://www.modsecurity.org/
yum install httpd-devel*  pcre-devel* pcre* libxml2* libcurl* lua* libtool openssl
cd /usr/local/src/
wget http://www.modsecurity.org/download/modsecurity-apache_2.6.6.tar.gz
tar -xvzf modsecurity-apache_2.6.6.tar.gz
cd modsecurity-apache_2.6.6
./configure --with-apxs=/usr/sbin/apxs
make
make test
make install

/etc/httpd/modules/mod_security2.so
/usr/local/modsecurity/lib/mod_security2.so

vi  /etc/httpd/conf.d/modsecurity.conf
[root@lvm conf]# cat /etc/httpd/conf.d/modsecurity.conf
LoadModule security2_module modules/mod_security2.so
<IfModule mod_security>
SecFilterEngine On
SecServerSignature "Microsoft-IIS/6.0"
</IfModule>
<IfModule mod_security2.c>
SecServerSignature "Microsoft-IIS/6.0"
</IfModule>
[root@lvm conf]#

wget http://www6.atomicorp.com/channels/rules/delayed/modsec-2.5-free-latest.tar.gz
                                                
tar -zvxf modsec-2.5-free-latest.tar.gz               
cd modsec                                             
mkdir /etc/httpd/conf/rule                            
cp ??_*.conf /etc/httpd/conf/rule/                    
vi /etc/httpd/conf/httpd.conf                         
                                                      
include conf/rule/*.conf

 mkdir -p /etc/asl/whitelist                           
 cp whitelist.txt /etc/asl/whitelist/                  
 vi /etc/httpd/conf/rule/00_asl_rbl.conf               
 vi  /etc/httpd/conf/rule/00_asl_whitelist.conf        
 cp mal* /etc/httpd/conf/rule/                         
 cp sql* /etc/httpd/conf/rule/                         
 cp do* /etc/httpd/conf/rule/                          
 vi /etc/httpd/conf/rule/domain-spam-whitelist.con     
 vi /etc/httpd/conf/rule/domain-spam-whitelist.conf    
 service httpd restart                                 

參考文件
http://www.openfoundry.org/tw/tech-column/8286--modsecurity-webapp-firewall

yum install python-*

[root@lvm w3af]# ./w3af_gui
Your python installation needs the following packages:
    nltk pysvn scapy
On debian based systems:
    sudo apt-get install python-nltk python-svn python-scapy
Additional information:
    If you can not install nltk, please try the following:
        wget http://pyyaml.org/download/pyyaml/PyYAML-3.09.tar.gz
        tar -xzvf PyYAML-3.09.tar.gz
        cd PyYAML-3.09
        python setup.py install
        cd ..
        wget http://nltk.googlecode.com/files/nltk-2.0b9.tar.gz
        tar -xzvf nltk-2.0b9.tar.gz
        cd nltk-2.0b9
        python setup.py install
[root@lvm w3af]#
rpm -Uvh http://www6.atomicorp.com/channels/atomic/centos/6/i386/RPMS/atomic-release-1.0-14.el6.art.noarch.rpm

yum install python-nltk  pysvn scapy
yum install tigervnc-server*
yum install graphviz graphviz-*
yum install pygtksourceview*


VNC:

[root@lvm .vnc]# yum search vncserver
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * atomic: www3.atomicorp.com
 * base: ftp://ftp.cs.pu.edu.tw/
 * extras: ftp://ftp.cs.pu.edu.tw/
 * updates: ftp://ftp.cs.pu.edu.tw/
atomic                                                                                                                                | 1.9 kB     00:00    
base                                                                                                                                  | 3.7 kB     00:00    
extras                                                                                                                                | 3.5 kB     00:00    
updates                                                                                                                               | 3.5 kB     00:00    
================================================================== N/S Matched: vncserver ===================================================================
libvncserver-devel.i686 : Development files for libvncserver
libvncserver.i686 : Library to make writing a vnc server easy
  Name and summary matches only, use "search all" for everything.
[root@lvm .vnc]# rpm -qa | grep vnc
tigervnc-server-applet-1.0.90-0.17.20110314svn4359.el6.noarch
libvncserver-0.9.7-4.el6.i686
tigervnc-server-module-1.0.90-0.17.20110314svn4359.el6.i686
tigervnc-server-1.0.90-0.17.20110314svn4359.el6.i686
[root@lvm .vnc]#


[root@lvm w3af]# vncserver
You will require a password to access your desktops.
Password:
Verify:
xauth:  creating new authority file /root/.Xauthority
xauth: (stdin):1:  bad display name "lvm:1" in "add" command
New 'lvm:1 (root)' desktop is lvm:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/lvm:1.log
[root@lvm w3af]# netstat -an | grep :59
tcp        0      0 0.0.0.0:5901                0.0.0.0:*                   LISTEN     
[root@lvm w3af]# cat /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that. 
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see this URL:
# http://kbase.redhat.com/faq/docs/DOC-7028
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
[root@lvm w3af]# vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see this URL:
# http://kbase.redhat.com/faq/docs/DOC-7028
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"