2024/08/12

之前一直都沒去找過 librenms 

temperature Sensor over limit

這裡的定義

發現不是一個固定的定值

而且超越前高時 就會出現




2024/08/10

昨天在升級ICX時 使用tftp
但試了好几種tftp server
包含 linux 及 windows 
都無法成功傳檔
一直出現timeout
使用 scp 才成功

copy scp flash 10.0.0.1 firmware_file secondary

不過 telnet timeout 要設長一點
不然有可能檔案還沒傳完就timeout 了
預設是 4 分鐘

telnet@10.0.0.2(config)#telnet timeout 10


2024/08/03

上次librenms升完OS後
一直出現hd容量不夠的狀況
今天才發現 /var/log/syslog 這個檔變的很大
內容都是以下的log

2024-08-03T12:14:01.608311+08:00 W-librenms-debian12 mariadbd[221]: 2024-08-03 12:14:01 283381 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'histogram' at position 10 to have type longblob, found type varbinary(255).
2024-08-03T12:14:01.608631+08:00 W-librenms-debian12 mariadbd[221]: 2024-08-03 12:14:01 283381 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'hist_type' at position 9 to have type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'), found type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB').
2024-08-03T12:14:01.608659+08:00 W-librenms-debian12 mariadbd[221]: 2024-08-03 12:14:01 283381 [ERROR] Incorrect definition of table mysql.column_stats: expected column 'histogram' at position 10 to have type longblob, found type varbinary(255).

google了一下
說是升OS時DB沒升造成
使用以下指令升級DB

mysql_upgrade --user=root --password=passwd

目前看來正常了
再觀察看看

2024/07/30

2024/07/19

這陣子PVE 在live migrade 時
有几台在migrade到新host後
就自動關几了
出現以下錯誤

2024-07-19 07:55:24 ERROR: tunnel replied 'ERR: resume failed - VM 103 qmp command 'query-status' failed - client closed connection' to command 'resume 103'

目前觀察到都是almalinux 9 
cpu type 是host
但又不是所有的almalinux 9 都會有問題

還在找問題

2024/07/17

今天打開OCS出現需要更新的畫面
就直接點update
想說應該不是大版本 應該沒問題
沒想到更新完
管理介面就完全空白了
看log也沒看到什麼error
決定重裝
原本的是在almalinux 8 順便升級os
依照原廠網頁安裝沒問題
這個檔裡的帳號密碼要記得改

/etc/httpd/conf.d/ocsinventory-server.conf

目前正常
再觀察看看



2024/07/03

移除檔案裡的所有特殊字元並保留 . 及 -

sed -i 's/[^[:alnum:].-]//g' test_file

2024/07/01

之前使用的 honeyports 因為OS升到 almalinux 9不能使用了
almalinux 9 不再支援 python2
另外再找了一個差不多功能 有提供 python跟shell 可以使用
不過一樣有python2的問題
所以改用shell

程式要改一下

honeyport.sh 裡第20行是設定要listen在port 31337
如果有listen在其他 port 必須修改此行 存成不同檔案 再執行

為了能批次執行 改成如下

#PORT=31337;
PORT=$1;


再來寫個shell 如下 把要listen的 port 加上去

#!/bin/bash

#revice port want to listen
port="21 22 23 ......."

for i in $port
do
        /root/honeyport.sh $i &
done

執行後就可以在log 找到相關ip並進行處理了 


https://github.com/securitygeneration/Honeyport

2024/06/16

今天把librenms的OS從debian 11 升到 12
照步驟做沒問題
要注意的是php不能升到 8.3
只能到 8.2
原來在debian 11上的是 8.1



2024/06/15

之前裝almalinux9時cpu都直接使用host
今天升級 almalinux 8 to 9 時 出現 cpu 的錯誤
原本使用 Default (kvm64)


訊息中指出cpu未使用 x86-64-v2 這個type
v2以上的type都可以




較舊的cpu 未支援 x86-64-v4 這個指令集
會導致 guest無法開几出現以下錯誤
















此時就必須要往下降為 v3 或 v2 或直接改為 host

由於几器本來就是從centos 7 升到 almalinux 8 所以再升到9時有些流程要注意

升級過程中出現

Error: Transaction test error:
  file /usr/include/gnumake.h from install of make-1:4.3-8.el9.x86_64 conflicts with file from package make-devel-1:4.2.1-11.el8.x86_64
移除 make-devel
rpm -e make-devel-4.2.1-11.el8.x86_64

升級後使用vi時出現

vi /tmp/1

Error detected while processing /etc/virc:
line   40:
E319: Sorry, the command is not available in this version: let skip_defaults_vim=1

刪除 /etc/virc 裡的第40行

let skip_defaults_vim=1

有些几器升級後出現以下的log 有些正常

Jun 15 21:46:29 localhost rsyslogd[593]: imjournal: open() failed for path: '/var/lib/rsyslog/imjournal.state.tmp': Operation not permitted [v8.2310.0-4.el9 try https://www.rsyslog.com/e/2433 ]

比對 /etc/rsyslog.conf發現有不同
複制正常几器的檔案過去就ok了
記得如果原rsyslog.conf有更改 新檔也要改
看起來是之前有改過
所以升級時會保留舊的rsyslog.conf

2024/06/13

如何使用zap docker

docker安裝好後

docker pull ghcr.io/zaproxy/zaproxy:stable
docker pull zaproxy/zap-stable


啟動

docker run -u zap -p 8080:8080 -p 8090:8090 -i ghcr.io/zaproxy/zaproxy:stable zap-webswing.sh

開browser
http://localhost:8080/zap




2024/06/12

本次弱掃有關SSH出現以下二個中風險


The remote SSH server is configured to allow / support weak key

exchange (KEX) algorithm(s).

Detection Result

The remote SSH server supports the following weak KEX algorithm(s):


KEX algorithm                      | Reason

------------------------------------------------

diffie-hellman-group-exchange-sha1 | Using SHA-1




The remote SSH server is configured to allow / support weak
encryption algorithm(s).
Detection Result
The remote SSH server supports the following weak client-to-server encryption algorithm(s):

aes128-cbc
aes256-cbc

解決方式是在 /etc/ssh/sshd_config
加入以下二行

Ciphers aes128-ctr,aes192-ctr,aes256-ctr

KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha1

重新啟動daemon



2024/06/05

118.195.223.15

start dos at 2024/6/4 18:20











block after few minutes




 

2024/05/27

今天看到rustdesk-server 天前有更新
版本是 1.1.11-1 
更新完要連線出現以下的訊息















再回頭看了一下官方頁面

This version changes default -k of hbbs to -, which means setting key on client side is mandatory. If you want to run empty -k as before, please run hbbs -k "".

這個版本client端強制要設定key
如果要跟之前的使用方法一樣
就要使用以下指令啟動 hbbs

hbbs -k ""

醬就正常了

2024/05/26

近期又開始社交工程演練
使用PMG把信隔離後會放在
/var/spool/pmg/spam
這個目錄下

由於內容是base64編碼
如果要解碼
使用以下指令

base64 -d encode_file > decode_file

2024/05/22

這几天用ZAP在弱掃

當網站很大時 因為會產生很大量的cache

所以要確保執行弱掃那台几器的HD空間要夠

不然有可能還沒做完就爆了

另外有很多網站都出現以下的報告


 


查了一下 可以在httpd.conf 設定

新增以下內容


<IfModule mod_headers.c>

Header set X-Frame-Options "SAMEORIGIN"

Header set Content-Security-Policy "default-src 'self'"

</IfModule>


設完要重啟apache

另外 如果有參考到外面的任何元件

版面是會亂掉的

這個要特別注意


設完後再掃一次出現另一個報告




如果要再處理

Header set 就要再改成如下的設定


Header set Content-Security-Policy "frame-ancestors 'self'; form-action 'self'; base-uri 'self'; img-src 'self'; default-src 'self'; script-src 'self'; style-src 'self';"


當然影響範圍就會更大


https://lawrencechuang760223.medium.com/%E5%A6%82%E4%BD%95%E5%9C%A8apache-server%E4%B8%8B%E6%96%B0%E5%A2%9Ex-frame-options%E8%88%87content-security-policy%E8%87%B3response-header%E4%B8%AD-fix-web-application-d68209ff385c


https://medium.com/@andy001018/owasp-zap-%E5%BC%B1%E6%8E%83%E8%99%95%E7%90%86%E7%B4%80%E9%8C%84-2fb0f4888908

2024/05/16

有几器要報廢
找到硬碟抹除的工具 shred
使用linux mint
下載iso後寫到usb開几

sudo fdisk -l 找到要抹除的硬碟代號

sudo shred -vfz /dev/sdX


-n - 覆盖的次数。默认是三次。
-u - 覆盖并删除。
-s - 要粉碎的字节数。
-v - 显示扩展信息。
-f - 必要时强制改变权限以允许写入。
-z - 最后用 0 覆盖来隐藏粉碎。

466G的傳統硬碟跑1次要1小時50分
總共要跑4次


2024/05/10

graylog6的indices 保存方法改變如下圖













之前的設定是多久之後可以刪除或close
如果是close 必需再手動刪除
目前看來沒這個選項了
不知道在比較長時間後會不會跟以前一樣
因為儲存大量資料導致search變的很慢

2024/05/09

這几天進graylog時提示6版已經出來了
看官網說的是可以直接更新
還是先裝一台來試看看好了
這次用的是almalinux 9
6版已經不再支援 elasticsearch 了
依照官網安裝流程裝到opensearch就有問題了
安裝後無法啟動
看了一下 opensearch.yml

裡面有一段 

######## Start OpenSearch Security Demo Configuration ########
# WARNING: revise all the lines below before you go into production
plugins.security.ssl.transport.pemcert_filepath: esnode.pem
plugins.security.ssl.transport.pemkey_filepath: esnode-key.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem
plugins.security.ssl.transport.enforce_hostname_verification: false
plugins.security.ssl.http.enabled: true
plugins.security.ssl.http.pemcert_filepath: esnode.pem
plugins.security.ssl.http.pemkey_filepath: esnode-key.pem
plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem
plugins.security.allow_unsafe_democertificates: true
plugins.security.allow_default_init_securityindex: true
plugins.security.authcz.admin_dn: ['CN=kirk,OU=client,O=client,L=test,C=de']
plugins.security.audit.type: internal_opensearch
plugins.security.enable_snapshot_restore_privilege: true
plugins.security.check_snapshot_restore_write_privileges: true
plugins.security.restapi.roles_enabled: [all_access, security_rest_api_access]
plugins.security.system_indices.enabled: true
plugins.security.system_indices.indices: [.plugins-ml-agent, .plugins-ml-config, .plugins-ml-connector,
  .plugins-ml-controller, .plugins-ml-model-group, .plugins-ml-model, .plugins-ml-task,
  .plugins-ml-conversation-meta, .plugins-ml-conversation-interactions, .plugins-ml-memory-meta,
  .plugins-ml-memory-message, .plugins-ml-stop-words, .opendistro-alerting-config,
  .opendistro-alerting-alert*, .opendistro-anomaly-results*, .opendistro-anomaly-detector*,
  .opendistro-anomaly-checkpoints, .opendistro-anomaly-detection-state, .opendistro-reports-*,
  .opensearch-notifications-*, .opensearch-notebooks, .opensearch-observability, .ql-datasources,
  .opendistro-asynchronous-search-response*, .replication-metadata-store, .opensearch-knn-models,
  .geospatial-ip2geo-data*, .plugins-flow-framework-config, .plugins-flow-framework-templates,
  .plugins-flow-framework-state]
node.max_local_storage_nodes: 3
######## End OpenSearch Security Demo Configuration ########

感覺是這段的問題

備分後重新開一個新的 opensearch.yml
裡面的內容只要以下這些就好

cluster.name: graylog
node.name: ${HOSTNAME}
path.data: /var/lib/opensearch
path.logs: /var/log/opensearch
discovery.type: single-node
network.host: 0.0.0.0
action.auto_create_index: false
plugins.security.disabled: true
indices.query.bool.max_clause_count: 32768

改完後啟動就沒問題了

跟之前不同 graylog這個版本安裝好後
打開 http://127.0.0.1:9000 無法進到web介面 
看了一下 /var/log/graylog-server/server.log

It seems you are starting Graylog for the first time. To set up a fresh install, a setup interface has
been started. You must log in to it to perform the initial configuration and continue.

Initial configuration is accessible at 0.0.0.0:9000, with username 'admin' and password 'iIcCiFzjWY'.
Try clicking on http://admin:iIcCiFzjWY@0.0.0.0:9000

需要先 Initial configuration 才能使用
進入後依照畫面的步驟設定後 就能進入graylog的介面了

Memory/Heap usage 預設是1G 要再調整

/etc/sysconfig/graylog-server

GRAYLOG_SERVER_JAVA_OPTS="-Xms1g -Xmx1g -server -XX:+UseG1GC -XX:-OmitStackTraceInFastThrow"

依ram大小調整



2024/05/08

使用 curl 取得ip的相關資訊

curl ipinfo.io/8.8.8.8
{
  "ip": "8.8.8.8",
  "hostname": "dns.google",
  "anycast": true,
  "city": "Mountain View",
  "region": "California",
  "country": "US",
  "loc": "37.4056,-122.0775",
  "org": "AS15169 Google LLC",
  "postal": "94043",
  "timezone": "America/Los_Angeles",
  "readme": "https://ipinfo.io/missingauth"
}