節省工具箱公開簡報

LibreNMS 資安應用經驗分享

2019/07/11國際資訊安全組織臺灣高峰會102 張投影片

/ 102

簡報說明

在眾多裝置監視系統套件中,LibreNMS 是一款開源、功能豐富且容易使用的好工具。講者將由過去企業應用經驗中分享,如何以 LibreNMS 為中心,搭配週邊套件來達到多種異常檢測與預警系統建置。

勘誤:P.15 第二行字應為地理圖與「可用性地圖」資訊呈現。

議程介紹:http://2019.infosec.org.tw/agenda_0711.html#spkr_0711_c_04

逐頁文字

  1. LibreNMS 資安應⽤用經驗分享
    耀達電腦股份有限公司 / 鄭郁霖 Jason Cheng

  2. 鄭郁霖 Jason Cheng

    • 耀達電腦 / 技術總監
    • 軟體⾃自由協會 / 理理事長
    • 晟鑫科技 / 開源解決⽅方案顧問
    • 資策會數位教育研究所 / 講師
    • 國際資訊安全組織臺灣⾼高峰會 2018 / 講者
    • 臺灣資安⼤大會 2019 / 講者
    • 台中⾃自由軟體愛好者社群 (TFC) / 共同創辦⼈人

  3. ⾯面臨臨困境

  4. 錢能解決的問題都不是問題
    😭 問題是沒有錢 😭

  5. 開源軟體
    是另⼀一扇⾨門

  6. 企業需要監測 如何⾃自動監測
    之項⽬目眾多, 與立即警報?

  7. 解決⽅方案

  8. 開源裝置與服務狀態監視系統

  9. poller.1
    poller-2
    Welcome to LibreNMS, a fully featured network
    monitoring system that provides a wealth of
    poller-3
    features and device support.
    WHAT CAN IT DO?
    rdcachad-1

  10. PHP
    SNMP
    MariaDB
    RRD

  11. ICMP
    SNMP
    AGENT
    APPLICATION
    SERVICE

  12. 裝置資訊
    網路與伺服器相關基本資訊

  13. %1
    FreeBSD
    GENERIC
    GENERIC
    Common
    53m 485
    Generic Device
    SmartCell
    12d 12h
    41m 39s
    39m 9s

  14. LibreNMS

  15. 地圖資訊
    地理圖與可用性地圖資訊呈現

  16. Dashboard

  17. (本頁無文字)

  18. 效能資訊
    裝置效能數據資訊搜集

  19. RRDTOOL / TOBI OETIKER|
    - CPU usage
    RRDTOOL / TOBI OETIKER
    RRDTOOL / TODI OETIKER.

  20. NETGEAR
    2018-10-26
    2018-10-26

  21. 健康資訊
    裝置健康狀況資訊搜集

  22. IPMI settings
    * Fanspeed

  23. 裝置事件
    納管裝置異動事件記錄搜集

  24. DrayTek

  25. 09:51:03
    01:14:36

  26. Software Version: 9.11(2.1) Series: S4048-ON Copyright (c) 1999-

  27. (id=27) 11:54 AM

  28. 更新檢查
    監測主機套件更新程度

  29. Apps: OS Updates

  30. 網頁監測
    監測網站運作及內容異動

  31. Wireless Apps Routing Alerts
    兹Services
    % Ports
    ⑦ Inventory
    SonarQube Web
    HTTP OK: HTTP/1.1 200 - 1742 bytes in 0.014 second
    response time

  32. Type:
    http
    Config
    -P 9000 -s "SonarQube" -t 15
    87 days 16
    HTTP OK: HTTP/1.1 200 - 1742 bytes in 0.014 second

  33. 域名時效
    監測網域名稱有效期限

  34. %o Ports
    菇 Services
    ssl_cert 218 days 21 hours
    Certificate will not expire
    Certificate will not expire
    Certificate will not expire
    SSL_CERT OK - X.509 certificate for 'subject=OU = Domain
    US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com,
    Inc.", OU = http://certs.godaddy.com/repository/, CN = Go
    http

  35. Type:
    耀達域名
    ssl_cert 218 days 21 hours
    US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com,
    Inc.", OU = http://certs.godaddy.com/repository/, CN =Go
    (2025-02-24).

  36. 憑證效期
    監測 SSL 加密憑證有效期限

  37. %o Ports
    菇 Services
    ssl_cert 218 days 21 hours
    Certificate will not expire
    Certificate will not expire
    SSL_CERT OK - X.509 certificate for 'subject=OU = Domain
    US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com,
    Inc.", OU = http://certs.godaddy.com/repository/, CN = Go
    http
    211 days 5 hours 9

  38. 耀達官網憑證
    燊 Add Service
    Control Validated, CN = *.youstar.com.tw' from "issuer=C =
    US, ST = Arizona, L = Scottsdale, O = "GoDaddy.com,
    Inc.", OU = http://certs.godaddy.com/repository/, CN = Go
    http
    耀達官網 (https)

  39. RBL 監測
    監測郵件主機是否被列 RBL 清單

  40. <ip>

  41. http
    -t 60-c 1 -s cbl.anti-spam.org.cn -s cblplus.anti-spa
    CHECK_RBL OK -
    numoffileslbgsstour 47
    外寄 Queue 檢查

  42. 佇列監測
    監測郵件主機發信佇列是否正常

  43. (本頁無文字)

  44. 服務
    連接埠
    5 days (2023-04-
    Type:
    numoffiles_byssh
    外寄 Queue 檢查(>10)
    http
    second response
    -d /opt/zimbra/data/postfix/spool/active/ -w 5 -c10
    imap
    4 days
    9 days 8 hours 45
    外寄 Queue 檢查
    numoffiles_byssh
    (>10)

  45. 信箱監測
    監測特定郵件信箱是否正常

  46. Wireless Apps Routing Alerts
    Service
    Last Changed
    Description
    Message
    domain
    3 days 21 hours 50
    55 days 9 hours 25
    55 days 9 hours 25
    4 days 25 minutes
    9 days 8 hours 55
    IMAP RECEIVE OK - 0 seconds, 647 found, 0 captured
    minutes 43 seconds 信箱狀態
    4 days 25 minutes

  47. B74 days (2023-
    Type:
    imap_receive
    Description:
    .com.tw 信箱狀態
    http
    http
    com.tw" -P "pwd" -s ALL --nodelete
    Ignore:
    imap
    imap_receive
    IMAP RECEIVE OK - 0 seconds, 676 found, 0 captured
    numoffiles_byssh 21 days 1hour 13
    外寄 Queue 檢查
    minutes 9 seconds(>10)

  48. 反解監測
    監測 DNS 反解 IP 是否正常

  49. SOPHOS
    Security made simple.
    Memory Usage
    CPU Usage
    Y Overview
    Graphs
    Health
    % Ports
    Config
    Basic
    # Add Service
    dhcp
    74 days 8 hours
    DHCP 檢測
    OK: Received 1 DHCPOFFER(s), max lease time =
    11 minutes 17
    1228800 sec.
    dns
    35 days 23 hours
    中華 DNS 測試
    DNS OK: 0.016 seconds response time.
    www.google.com.tw returns 216.58.200.35
    seconds

  50. Global Search
    SOPHOS
    Security made simg
    Type:
    dns
    Description:
    中華 DNS 測試
    ? Overview
    onfig
    IP Address:
    168.95.1.1
    Performance
    Parameters:
    www.google.com.tw
    Services 》
    Basic
    dhcp
    74 days 8 hours
    DHCP 檢測
    OK: Received 1 DHCPOFFER(s), max lease time =
    18 minutes 20
    1228800 sec.
    35 days 23 hours
    中華 DNS 測試
    DNS OK: 0.014 seconds response time.
    dns
    www.google.com.tw returns 216.58.200.227

  51. 複寫監測
    監測 ZFS 快照複寫最新版本

  52. Processor Usage
    】 Processes
    http
    HTTP OK: HTTP/1.1 302 Redirect - 286 bytes in 0.002 second
    freenasrefp days 3 hours 2
    minutes 41 seconds
    時間差(>24H)
    freenasrepl days 17 hours 25
    時間差(>24H)

  53. Description:
    最新快照抄寫時間差(>24H)
    Q Overview
    Graphs
    -W 22 -C 25 -P /mnt/$5/rpbak/vmi/.zfs/snapshot
    http
    16 days 47 minutes
    Duplicati (jail)
    HTTP OK: HTTP/1.1 302 Redirect - 286 bytes in 0.002 second
    录新快照抄寫
    ok-The latest snapshot was 3 hours ago.(2019/06/15
    時間差(>24H)
    12:15)
    freenasrefl days 17 hours 25
    ok - The latest snapshot was 3 hours ago. (2019/06/15
    時間差(>24H)
    12:45)

  54. GNU nano 2.5.3
    File: check_freenasrep
    Modified
    error=""
    # get lastest snapshot name to date
    # ex. /mnt/S5/rpbak/S2/vmimage/.zfs/snapshot
    getdate="/usr/bin/ssh Sssh_connect "1s Ssnapshot_path | grep auto | tail -n 1 | cut -d'-' -f 2"
    getdate="/bin/echo Sgetdate | /bin/sed 's/V./ /g
    getdate=Sgetdate
    # debug msg
    #echo "Sgetdate"
    gethumandate="/bin/date -d "Sgetdate" "+%Y/%m/%d %R"
    # convert date to unix date (timestaamp)
    snapshotdate="/bin/date -d "Sgetdate" +%s
    #echo "Ssnapshotdate"
    # get now date
    # debug msg
    #echo "Snowdate"
    Get Help
    Justify
    Prev Page
    Read File
    Replace
    Next Page

  55. File: check_freenasrep
    # get user define date diff value (hours)
    datediff=S((Snowdate Ssnapshotdate)):
    datediff=S((Sdatediff/68/68)):
    "Sdatediff"
    exitstatus=SSTATE_OK
    "Sthresh_warn”!=
    if [ Sdatediff -ge Sthresh_warn ]:then
    result="warning"
    exitstatus=SSTATE_WARNING
    "Sthresh_crit"!=
    if [ Sdatediff -ge
    Sthresh_crit l: then
    result="critical"
    “Sresult - The latest snapshot was Sdatediff hours ago. (Sgethumandate) Idiffhours=3datediff;Sthresh_warn;Sthresh.crit"
    Where Is
    Justify
    Prev Page
    Next Page

  56. 流量帳單
    依據流量狀況設定門檻值與報告

  57. Transferned
    Bytes
    Rolling Monthly View

  58. 記錄監視
    搜集裝置事件並用做警報條件

  59. LibreNMS

  60. LibreNMS

  61. 組態備份
    裝置設定檔自動排程備份系統

  62. LibreNMS

  63. (本頁無文字)

  64. 圖表強化
    搭配更強的套件客製專用圖表

  65. Grafana Labs
    Grafana Enterprise
    Plugins
    The open platform for beautiful
    Time range
    analytics and monitoring
    Get Grafana
    The leading open source software for time series analytics

  66. Prometheus
    From metrics to insight
    Power your metrics and alerting with a leading
    open-source monitoring solution.
    GET STARTED
    DOWNLOAD
    Efficient storage
    Dimensional d..
    Q Powerful queri..
    Great visualiz.
    modes for visualizing data: a

  67. 設定 LibreNMS 對 Prometheus ⽀支援

    /opt/librenms/config.php

    $config['prometheus']['enable'] = true;
    $config['prometheus']['url'] = "http://127.0.0.1:9091";
    $config['prometheus']['job'] = "librenms"; # Optional

  68. 安裝 Prometheus PushGateway
    mkdir /opt/prometheus
    cd /opt/prometheus

    https://github.com/prometheus/pushgateway/releases/
    download/v0.7.0/pushgateway-0.7.0.linux-amd64.tar.gz

    tar -xvzf pushgateway-0.7.0.linux-amd64.tar.gz
    cd pushgateway-0.7.0.linux-amd64
    ./pushgateway &

  69. 驗證 Prometheus PushGateway
    http://ip:9091

  70. 設定 Prometheus Pull

    /opt/promtheus/prometheus.yml
    - job_name: 'librenms'
    scrape_interval: 300s
    honor_labels: true
    static_configs:
    - targets: [‘aaa.bbb.ccc.ddd:9091’]

  71. 啟⽤用 Prometheus Pull

  72. 設定 Grafana 數據來來源與圖表

  73. 系統驗證
    登入身份驗證及安全機制

  74. MySQL
    Active Directory
    LDAP
    Radius
    HTTP Auth
    Single Sign-on

  75. 雙因素驗證

  76. 雙因素驗證

  77. 警報發送

  78. 發送管道
    由 LibreNMS 發送告警事件

  79. API Mail Rocket.chat
    Boxcar MatterMost Slack
    Canopsis Microsoft Teams SMSEagle
    Cisco Spark Nagios Compatible Syslog
    Clickatell OpsGenie Telegram
    Discord osTicket Twilio SMS
    Elasticsearch PagerDuty VictorOps
    Gitlab Philips Hue Kayako Classic
    HipChat PlaySMS SMSFeedback
    IRC Pushbullet
    JIRA Pushover

  80. Telegram
    Telegram
    ON
    Chat ID:
    Save Transport

  81. Alert Transport:: Docs B
    Slack-Alert
    Transport type:
    https://hooks.slack.com/services
    Slack Options:
    Save Transport

  82. Transport type:
    Default Alert:

    https://
    Save Transport

  83. 警報規則
    警告發送條件與門檻設定

  84. bgpPeers.bgpPeerState != "established" AND
    bgpPeers. bgpPeerFsm EstablishedTime < 300 AND Critical|
    bgpPeers.bgpPeerState = “established"
    macros.port_usage_perc >= 80 AND
    ports.ifName NOT LIKE %tap%'
    sensors.sensor_current > sensors.sensor_limit
    AND sensors.sensor_alert = 20

  85. (本頁無文字)

  86. 裝置重啟
    SELECT * FROM devices,Ports WHERE (devices.device_id = ? AND devices.device_id = ports.devic
    bgpPeers.bgpPeerFsmEstablishedTime < 300 AND
    macros.port_down = 1
    = 1 AND macros.port = 1 AND ports.ifName NOT LIKE

  87. macros.device_down = "1"
    macros.port_down = "1"
    sensors.sensor_current >'sensors.sensor _limit' && sensors.sensor_alert = "1"&&
    services.service_status != "0" && macros.device_up = "1"

  88. OR
    'macros.past_5m'
    .*AUTH_FAILED.*

  89. 警報發送樣式
    實際警報推播發送範例

  90. X[警報]
    主機:
    說明:
    規則:服務狀態異常程
    系統(id=81)
    系統(id=81)
    string"請輸入帳號 not found

  91. (本頁無文字)

  92. (本頁無文字)

  93. (本頁無文字)

  94. 警報追蹤
    警報事件處理狀況與追蹤

  95. 「交換空間」使用率超過 80%
    Os-Updates 可用更新數>10

  96. (本頁無文字)

  97. )設備故障,送修中
    Tue, 18 Jun 2019 17:42:24 +0800 - Ack (
    )設備故障,送修中

  98. (本頁無文字)

  99. 參參考資料

  100. 考參
    LibreNMS
    https://www.librenms.org/

    LibreNMS GitHub
    https://github.com/librenms/librenms

    LibreNMS Docs
    https://docs.librenms.org/

    Nagios Plugins
    https://exchange.nagios.org/directory/Plugins

    LibreNMS 中⽂文使⽤用者社團
    https://facebook.com/groups/lnms.tw

  101. 1 2
    節省⼯工具箱 簡報集中處
    blog.jason.tools slide.jason.tools

  102. 謝謝