2021年6月4日 星期五

Disable LINE desktop diagnostic report

禁止 LINE 電腦版傳送連線診斷報告
當把 desktop.line-scdn.net 擋掉時 (ref. Disable LINE desktop force update),
LINE 會傳送連線診斷報告到 nelo2-col.linecorp.com,
內容 body 大概是這樣

診斷報告裡可以看到 desktop.line-scdn.net 解析為 127.0.0.1,
就是故意擋掉還回報 ?
所以 C:\Windows\System32\drivers\etc\hosts 再加入
127.0.0.1 nelo2-col.linecorp.com

若遇到無法存檔問題,
記事本,按右鍵,以系統管理員身份執行,再開上面那個檔

2021年6月3日 星期四

iptables redirect to localhost

iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to 127.0.0.1:8080
若要用 iptables 把 traffic 導到 localhost,需要比較新的 Kernel >= 3.6 才可以做到
需要設此參數為 1
sysctl -w net.ipv4.conf.all.route_localnet=1


2021年5月28日 星期五

Setup PPPoE with nmcli

以前都是用 rp-pppoe 套件裡的 adsl-setup 來設定 PPPoE
現在比較新的 Linux 已經沒有這個套件了,要用 NetworkManager 的 nmcli 來設定
設定也很簡單,準備帳號、密碼及網路卡就行了
以下範例帳號是 xxxx@hinet.net
密碼 xxxx1234
網路卡是用 eth1
連線名稱 hinet

nmcli connection add con-name hinet type pppoe ifname eth1 username xxxx@hinet.net password xxx1234
設完就馬上連上了

某些情況可能需要調 metric,metric 較小是優先權比較大
nmcli connection modify hinet ipv4.route-metric 90

手動啟動
nmcli connection up hinet

設定開機啟動 yes or no (connection add 預設是 yes)
nmcli connection modify hinet connection.autoconnect yes
nmcli connection modify hinet connection.autoconnect no

若設定完後沒有連上,手動啟動出現: 錯誤:啟動連線失敗:無法啟動 PPP 服務
表示沒有安裝 NetworkManager-ppp 套件

2021年5月19日 星期三

Install MySQL 5 on CentOS 8 / RHEL 8

CentOS 8 / RHEL 8 預設 MySQL 版本是 8
若要裝 MySQL 5,需將 8 的設定移除,再裝 5 的 repo

dnf remove @mysql
dnf module reset mysql
dnf module disable mysql
rpm -ivh https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
dnf -y install mysql-community-client mysql-community-common mysql-community-devel mysql-community-libs mysql-community-server
systemctl enable --now mysqld

2021年5月12日 星期三

SQL injection

SQL injection 是個老東西,但 20 幾年過去,它依然健在!
在所有 Web 攻擊,弱點佔比仍然是最高的

NEITHNET 精選講座-資安教室:SQL injection - CYBERSEC 2021 臺灣資安大會

NEITHNET_SQL_injection.pptx 這份簡報是 2021 臺灣資安大會在公司攤位分享的資料

還架了一個 Demo Site https://sqlinjection.cf
Demo Site 預計下架時間 2021-05-31,有興趣的可以玩玩看

Windows 10 NFS Client

Windows 的 NFS Client 從 Windows 7 之後就內建了,但預設沒有開啟,
要到 設定 / 應用程式 / 程式與功能 / 開啟或關閉 Windows 功能 開啟 Client for NFS


但是預設的情況下,遇到中文檔名會有亂碼,
到 設定 / 時間與語言 / 日期、時間及地區格式設定 / 地區
(或直接執行 intl.cpl)
系統管理 / 變更系統地區設定,勾選 Beta:使用Unicode UTF8提供全球語言支援


這個設定可以解決 NFS 的中文亂碼,但有可能會造成一些比較舊的程式有亂碼,
需斟酌使用。

NFS 掛載方式跟網芳差不多,用這樣就行了 \\192.168.1.1\share

指定掛載到 N: 糟 mount -o anon \\10.168.112.11\share N:

2021年5月7日 星期五

mysql_config_editor version < 5.7.33 does not escape strings

mysql_config_editor 在版本小於 5.7.33 有一個 Bug,當 Password 有包含像 # % 特殊符號時,因為沒有 escape 而無法正確的設定,
Workaround 是在輸入密碼時用雙引號括起來
這個問題已在 5.7.33 修正

ref. Bug #74691 mysql_config_editor does not escape strings


iptables security policy for Cloudflare

若網站是掛在 Cloudflare 上,可以設定只容許 Cloudflare 的 IP 存取,會較安全

注意: 不要直接執行這個 Script,至少要加上 ACCEPT 自己管理用的 Source IP,不然會管理失聯

2021年4月19日 星期一

CentOS upgrade GCC

使用 SCL 安裝方式,它不會取代原本系統的 gcc ,是透過 sch enable 進行切換,相對比較安全

以 gcc 9 為例:
yum -y install centos-release-scl-rh
yum -y install devtoolset-9-toolchain.x86_64

# which gcc
/usr/bin/gcc
# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

切換到 gcc 9 的環境

# scl enable devtoolset-9 bash
# which gcc
/opt/rh/devtoolset-9/root/usr/bin/gcc
# gcc --version
gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

DNS-PERSIST-01 DCV

Let's encrypt 建立的新 DCV 方式  DNS-PERSIST-01 它是用綁定帳號,在域名直接設上 accounturi 的 TXT 資料, 來達到長效授權,之後經由綁定帳號來申請的憑證,就直接過了,不需再設定 DNS 已經上 Staging 環境 (--...