2021年3月23日 星期二

routeros

防止別人掃描你的routeros

/ip firewall filter add chain=input protocol=tcp psd=21,3s,3,1  action=add-src-to-address-list address-list="port scanners"  address-list-timeout=14d comment="Port scanners to list " disabled=no

/ip firewall filter add chain=input protocol=tcp  tcp-flags=fin,!syn,!rst,!psh,!ack,!urg action=add-src-to-address-list  address-list="port scanners" address-list-timeout=14d comment="NMAP FIN  Stealth scan"

/ip firewall filter add chain=input protocol=tcp tcp-flags=fin,syn  action=add-src-to-address-list address-list="port scanners"  address-list-timeout=14d comment="SYN/FIN scan"

/ip firewall filter add chain=input protocol=tcp tcp-flags=syn,rst  action=add-src-to-address-list address-list="port scanners"  address-list-timeout=14d comment="SYN/RST scan"

/ip firewall filter add chain=input protocol=tcp  tcp-flags=fin,psh,urg,!syn,!rst,!ack action=add-src-to-address-list  address-list="port scanners" address-list-timeout=14d  comment="FIN/PSH/URG scan"

/ip firewall filter add chain=input protocol=tcp  tcp-flags=fin,syn,rst,psh,ack,urg action=add-src-to-address-list  address-list="port scanners" address-list-timeout=14d comment="ALL/ALL  scan"

/ip firewall filter add chain=input protocol=tcp  tcp-flags=!fin,!syn,!rst,!psh,!ack,!urg action=add-src-to-address-list  address-list="port scanners" address-list-timeout=14d comment="NMAP NULL  scan"

/ip firewall filter add chain=input src-address-list="port scanners" action=drop comment="dropping port scanners" disabled=no



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


MikroTik RouterOS RAW 設定

RouterOS 從 6.36 版後多了一個 RAW 功能,上網收集資料了解了解,順便整理起來。

(上圖是依網友的流程圖模仿重畫的)

firewall Raw 列表允許選擇性在 connection tracking 之前繞過或者丟棄封包,這樣能大大的降低 CPU 負載。
該功能非常有助於防御 DOS 攻擊,RAW 列表不能匹配連接狀態的追蹤,例如 connection-state 和 L7 協議。

Raw Policy 出現在 Prerouting chin 和 output chin,並在 connection-tracking 前執行。

Raw 目的是對指定的 IP 訪問可以不經過連接追蹤(connection-tracking),有助於減少 CPU 負載 ,
但對於私有網路做 NAT 轉換,connection-tracking 是必須的,Raw 又如何在實際網路應用中發揮作用。
例如遭到 DDoS 攻擊,可以通過 Raw 規則關閉掉攻擊來源 IP 的連接追蹤,不建立本地連接會話,不予回應,降低 CPU 負載 。

在 Raw 中有兩個連表,分別是 prerouting 和 output:
prerouting 用於處理任何進入路由器的封包
output 用於處理封包來自於路由器,並通過其中一個接口離開,即由路由器自身發出的封包

例如:
遭到 11.22.33.44 的 IP 通過 syn 的 DDoS 攻擊,可以拒絕對該 IP 做連接追蹤,減少 CPU 負載 :
/ip firewall raw
add chain=prerouting src-address=11.22.33.44 action=notrack


另一種情況, 如較大的網路環境,涉及內網和外網請求,在訪問外網時需要做 nat 轉換,而內網則不需要,
因此流量和對話增加的情況下,避免 CPU 負載過高,可以透過 Raw 關閉掉訪問內網的連接追蹤。

例如,在一個大型網絡,內網IP地址段是192.168.0.0/16,關閉掉內網的連接跟蹤,配置如下:
/ip firewall raw
add chain=prerouting dst-address=192.168.0.0/16 action=notrack

配置後,在 connection-tracking 列表將不會看到內網訪問 192.168.0.0/16 的連接訊息

其他 RAW policy:
/ip firewall raw
add action=drop chain=prerouting comment="Port scanners" protocol=tcp psd=21,3s,3,1
add action=drop chain=prerouting comment="Drop oversized unfragmented packets" packet-size=1492-65535 protocol=icmp
add action=drop chain=prerouting comment="SYN-FIN attack protection" protocol=tcp tcp-flags=fin,syn
add action=drop chain=prerouting comment="SYN-RST attack protection" protocol=tcp tcp-flags=syn,rst
add action=drop chain=prerouting comment="X-Mas attack protection" protocol=tcp tcp-flags=fin,psh,urg,!syn,!rst,!ack
add action=drop chain=prerouting comment="NMAP FIN attack protection" protocol=tcp tcp-flags=fin,!syn,!rst,!psh,!ack,!urg
add action=drop chain=prerouting comment="NMAP Push attack protection" protocol=tcp tcp-flags=fin,syn,rst,ack,urg,!psh
add action=drop chain=prerouting comment="NMAP FIN/PSH/URG attack protection" protocol=tcp tcp-flags=fin,psh,urg,!syn,!rst,!ack
add action=drop chain=prerouting comment="NULLflags attack protection" protocol=tcp tcp-flags=!fin,!syn,!rst,!psh,!ack,!urg
add action=drop chain=prerouting comment="ALLflags attack protection" protocol=tcp tcp-flags=fin,syn,rst,psh,ack,urg

add action=drop chain=prerouting comment="Drop udp DNS queries from WAN" dst-port=53 in-interface="WAN" protocol=udp
add action=drop chain=prerouting comment="Drop tcp DNS queries from WAN" dst-port=53 in-interface="WAN" protocol=tcp




資料來源:
http://www.rosjb.com/803.html
https://quchao.com/entry/basic-rules-of-raw-table-in-the-routeros-firewall/



===============
ddos 拒絕 設定
/ip firewall filter add action=drop chain=input comment="drop sniffer" in-interface=ether1 src-address-list=sniffer
/ip firewall filter add action=add-src-to-address-list address-list=sniffer address-list-timeout=30d chain=input comment="mark sniffer" dst-port=22,23,876,3306,3389,137,139,445,5001,6379,27017 in-interface=ether1 log=yes log-prefix=sniffer protocol=tcp
/ip firewall filter add action=add-src-to-address-list address-list=sniffer address-list-timeout=30d chain=input comment="mark sniffer" dst-port=22,23,876,3306,3389,137,139,445,5001,6379,27017 in-interface=ether1 log=yes log-prefix=sniffer protocol=udp
/ip firewall filter add action=add-src-to-address-list address-list=sniffer address-list-timeout=30d chain=input comment="mark sniffer" dst-port=2323,5555,80,81,37215,8000,8080,8081,8291,8443,53 in-interface=ether1 log=yes log-prefix=sniffer protocol=tcp
/ip firewall filter add action=add-src-to-address-list address-list=sniffer address-list-timeout=30d chain=input comment="mark sniffer" dst-port=2323,5555,80,81,37215,8000,8080,8081,8291,8443 in-interface=ether1 log=yes log-prefix=sniffer protocol=udp
/ip firewall filter add action=drop chain=input comment="drop sniffer" in-interface=ether1 src-address-list=sniffer

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

2021年3月13日 星期六

adguard home use

info




https://github.com/neoFelhz/neohosts

去廣告,去全天候定位,中國專用,但也去掉法輪功相關資訊 Copyright (c), Neko Dev Team & neoHosts Team. # https://github.com/neofelhz/neohosts








adguardhome
neoHosts

https://cdn.jsdelivr.net/gh/neoFelhz/neohosts@gh-pages/full/hosts.txt




https://www.blueskyxn.com/202012/2940.html



AdGuardHomeRules-由BlueSkyXN原创的ADH广告过滤拦截规则大全


https://raw.githubusercontent.com/BlueSkyXN/AdGuardHomeRules/master/all.txt

https://cdn.000714.xyz/BlueSkyXN/AdGuardHomeRules/master/all.txt




anti-AD是目前中文区命中率最高的广告过滤列表

https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-easylist.txt




https://github.com/233Bazinga/AdGuardHome

2021年3月11日 星期四

synology 黑群暉 lan中有二個一樣的mac 黑牛 is sdb4

 很多的黑群晖已安装好,然后找到匹配的SN/MAC,想洗白。也许用优盘引导的直接把优秀拨下来用DG修改就行了,但是有不少人用的是固态硬盘做引导就不方便拆机了。下面就教你不用拆机、不用拨优盘直接修改SN和MAC的方法。

所用工具:putty或者Xshell。

一、开启SSH端口

在控制面板里面——>终端机和SNMP ,启动SSH功能打勾,并设置端口(建议别用22,改用其他的,比如220或者其他都行)。

SSH在线修改黑群晖DS3617 DS918+的SN/MAC 群晖NAS 第1张

二、挂载synoboot1分区。

第一步:用ssh工具如xshell连接到群晖的地址,用创建群晖的管理用户登陆。

如:admin   密码 123456

用自組的黑群暉已經一陣子了,系統是使用網絡上常見的DS918二合一引導盤,省去了另外使用U盤的麻煩。

然而唯一美中不足的地方:無法使用常見的網絡喚醒功能(WOL),本次教學將一步一步教你如何達成目標。

事前準備

  • 筆記本(蘋果,Windows皆可,只要能夠使用ssh功能即可)
  • 黑群暉(安裝完成,已經可正常使用)
  • 網絡(os. 這不是廢話?但請注意筆記本和黑群暉必須在同個局域網內)

教學開始

ssh連接黑群暉

筆記本打開終端機(Terminal),輸入下列指令:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 注意192.168.xxx.xxx 請修改成自己黑群暉的地址
jk@local:~$ ssh admin@192.168.xxx.xxx

# 連接成功
admin@DS918Plus:~$

# 以root執行
admin@DS918Plus:~$ sudo -i

# 輸入密碼後回車(不會顯示輸入的密碼)
Password:

# 以root登入成功
root@DS918Plus:~#

掛載開機設定檔案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 建立臨時掛載位置
root@DS918Plus:~# mkdir /tmp/boot

# 移動到本機設備目錄
root@DS918Plus:~# cd /dev

# 掛載開機區,注意指令中的sdb4依據硬件可能為不同
root@DS918Plus:/dev# mount -t vfat sdb4 /tmp/boot

# 掛載成功後移動到開機區
root@DS918Plus:/dev# cd /tmp/boot/grub/

# 查看開機區檔案
root@DS918Plus:/tmp/boot/grub# ls
fonts grub.cfg grubenv loader locale x86_64-efi

修改grub.cfg設定

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# 修改grub.cfg設定(此處使用vi編輯器,可使用自己習慣的編輯器進行修改)
root@DS918Plus:/tmp/boot/grub# vi grub.cfg

# 找到文件中與下列相似的內容並修改
set sn=1780PDN21xxxx
set mac1=001132xxxxxx
set mac2=001132xxxxxx
set rootdev=/dev/md0

# 修改完成範例
set sn=1780PDN216002 # 通常不需修改
set mac1=001132e12242 # 單網卡修改此處即可,實體位置可參考主板上實體網卡
set mac2=001132xxxxxx # 雙網卡可修改此處
set rootdev=/dev/md0 # 維持不變

# 重新啟動,完成
root@DS918Plus:/tmp/boot/grub# reboot

遠端開機

在局域網內,可使用任意網絡喚醒工具,如手機APP、指令等,此處以python腳本為例,筆記本打開終端機(Terminal),輸入下列指令:

1
2
3
4
5
6
7
8
9
10
# 安裝套件wakeonlan
jk@local:~$ pip3 install wakeonlan

# 撰寫腳本
jk@local:~$ python3
Python 3.7.6 (default, Dec 30 2019, 19:38:28)
[Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from wakeonlan import send_magic_packet
>>> send_magic_packet('02.11.32.2A.03.E9') # 此處MAC地址為黑群暉的地址
cd grub
vi grub.cfg

此时,进入了vim查看 grub.cfg文件。

SSH在线修改黑群晖DS3617 DS918+的SN/MAC 群晖NAS 第2张

按键盘向下、向右等箭头,将光标移动到要修改的地方 (注:我这里是双网卡)

此时还是命令模式,按键盘上的 键(小写状态),进入文档编辑模式,此时就可以输入新的SN,MAC1的新值。

修改完成后,按键盘上的Esc键,返回到命令模式,输入:wq (英文状态的字符),保存并退出。如果修改乱了,想不保存并退出,则是输入 :q! 。

此时可以再  vi grub.cfg 进去看看是否修改成功。

最后重启主机,

reboot

修改成功了。






注意,我自己修改 set mac1 的部份只修改倒數第二碼即可使用,3改為5

如果有二個一樣的mac 會形成封包重傳,變成loss封包,以為機器或是網路有攻擊/亂傳,這情形沒有辦法查,相同的mac address ,在封包中傳給二個機器,會傳送,很慢,因為機器/網路有問題