Skip to content

Commit 26730dc

Browse files
committed
新增设备
深信服态势感知、启明星辰全网安全态势感知系统、天融信防火墙、深信服防火墙
1 parent b0ceb97 commit 26730dc

File tree

19 files changed

+556
-23
lines changed

19 files changed

+556
-23
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ Docker全部运行后访问 [http://127.0.0.1/](http://127.0.0.1/) 访问管理
8585
| [奇安信椒图](./device/alarm/qianxin_jowtolock) | [CheckPoint](./check_point) |
8686
| [绿盟WAF](./device/alarm/nsfocus_waf) | [奇安信防火墙](./device/block/qianxin_firewall) |
8787
| [科来网络安全分析审计系统](./device/alarm/kelai_wangluoanquanfenxishenjixitong) | [钉钉告警通知](./device/block/dingtalk_robot) |
88-
| | [BGP封禁](./device/block/bgp) |
89-
88+
| [深信服态势感知](./device/alarm/sangfor_sip) | [BGP封禁](./device/block/bgp) |
89+
| [启明星辰全网安全态势感知系统](./device/alarm/venustech_qwaqtsgzxt) | [天融信防火墙](./device/block/topsec_firewall) |
90+
| | [深信服防火墙](./device/block/sangfor_firewall) |
9091

9192
## 黑/白名单说明
9293

device/alarm/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@
66
* [qianxin_skyeye](./qianxin_skyeye): 奇安信天眼
77
* [qianxin_jowtolock](./qianxin_jowtolock): 奇安信椒图
88
* [nsfocus_waf](./nsfocus_waf): 绿盟WAF
9-
* [kelai_wangluoanquanfenxishenjixitong](./kelai_wangluoanquanfenxishenjixitong): 科来网络安全分析审计系统
9+
* [kelai_wangluoanquanfenxishenjixitong](./kelai_wangluoanquanfenxishenjixitong): 科来网络安全分析审计系统
10+
* [sangfor_sip](./sangfor_sip): 深信服态势感知
11+
* [venustech_qwaqtsgzxt](./venustech_qwaqtsgzxt): 启明星辰全网安全态势感知系统

device/alarm/example/multi_syslog_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def add_count(device_name):
2323
else:
2424
message_count[device_name] += 1
2525

26-
class SyslogUDPHandler(socketserver.BaseRequestHandler):
26+
class SyslogUDPHandler(socketserver.DatagramRequestHandler):
2727
def handle(self):
2828
data = self.request[0].split(b' ')
2929
if len(data) < 7:

device/alarm/example/syslog_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from SecAutoBan import SecAutoBan
33

44
# 假设Syslog格式为`攻击IP\t被攻击资产\t报警详情,例如:1.1.1.1\t127.0.0.1\tNMAP 扫描`
5-
class SyslogUDPHandler(socketserver.BaseRequestHandler):
5+
class SyslogUDPHandler(socketserver.DatagramRequestHandler):
66
def __init__(self, request, client_address, server, ws_client):
77
self.ws_client = ws_client
88
super().__init__(request, client_address, server)
@@ -18,7 +18,7 @@ def handle(self):
1818

1919
def alarm_analysis(ws_client):
2020
with socketserver.ThreadingUDPServer(("0.0.0.0", listen_syslog_udp_port), lambda *args: SyslogUDPHandler(*args, ws_client=ws_client)) as server:
21-
print("[+] 监听SysLog端口: " + str(listen_syslog_udp_port) + "/UDP")
21+
sec_auto_ban.print("[+] 监听SysLog端口: " + str(listen_syslog_udp_port) + "/UDP")
2222
server.serve_forever()
2323

2424

device/alarm/kelai_wangluoanquanfenxishenjixitong/kelai_wangluoanquanfenxishenjixitong.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def is_lan(ip: str) -> bool:
1010
return False
1111

1212

13-
class SyslogUDPHandler(socketserver.BaseRequestHandler):
13+
class SyslogUDPHandler(socketserver.DatagramRequestHandler):
1414
def __init__(self, request, client_address, server, ws_client):
1515
self.ws_client = ws_client
1616
super().__init__(request, client_address, server)

device/alarm/nsfocus_waf/nsfocus_waf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from SecAutoBan import SecAutoBan
33

44

5-
class SyslogUDPHandler(socketserver.BaseRequestHandler):
5+
class SyslogUDPHandler(socketserver.DatagramRequestHandler):
66
def __init__(self, request, client_address, server, ws_client):
77
self.ws_client = ws_client
88
super().__init__(request, client_address, server)

device/alarm/qianxin_jowtolock/qianxin_jowtolock.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from SecAutoBan import SecAutoBan
44

55

6-
class SyslogUDPHandler(socketserver.BaseRequestHandler):
6+
class SyslogUDPHandler(socketserver.DatagramRequestHandler):
77
def __init__(self, request, client_address, server, ws_client):
88
self.ws_client = ws_client
99
super().__init__(request, client_address, server)
@@ -19,8 +19,6 @@ def handle(self):
1919
continue
2020
if msg["attackIp"] == "":
2121
continue
22-
if bypass_lan and msg["attackIpAddress"] == "局域网":
23-
continue
2422
self.ws_client.send_alarm(msg["attackIp"], "", msg["action"]["text"])
2523

2624

@@ -32,7 +30,6 @@ def alarm_analysis(ws_client):
3230

3331
if __name__ == "__main__":
3432
listen_syslog_udp_port = 567
35-
bypass_lan = True # 过滤内网攻击,True 开启 | False 关闭
3633
sec_auto_ban = SecAutoBan(
3734
server_ip="127.0.0.1",
3835
server_port=80,

device/alarm/qianxin_skyeye/qianxin_skyeye.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import json
2-
import ipaddress
32
import socketserver
43
from SecAutoBan import SecAutoBan
54

65

7-
def is_lan(ip: str) -> bool:
8-
if bypass_lan:
9-
return ipaddress.ip_address(ip).is_private
10-
return False
11-
12-
13-
class SyslogUDPHandler(socketserver.BaseRequestHandler):
6+
class SyslogUDPHandler(socketserver.DatagramRequestHandler):
147
def __init__(self, request, client_address, server, ws_client):
158
self.ws_client = ws_client
169
super().__init__(request, client_address, server)
@@ -23,8 +16,6 @@ def handle(self):
2316
sip = msg["attack_sip"]
2417
if sip == "":
2518
return
26-
if is_lan(sip):
27-
return
2819
self.ws_client.send_alarm(sip, msg["alarm_sip"], "[" + msg["type"] + "]" + msg["vuln_type"])
2920

3021

@@ -36,7 +27,6 @@ def alarm_analysis(ws_client):
3627

3728
if __name__ == "__main__":
3829
listen_syslog_udp_port = 567
39-
bypass_lan = True # 过滤内网攻击,True 开启 | False 关闭
4030
sec_auto_ban = SecAutoBan(
4131
server_ip="127.0.0.1",
4232
server_port=80,

device/alarm/sangfor_sip/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# 深信服态势感知
2+
3+
4+
## 下载模块
5+
6+
```
7+
wget https://raw.githubusercontent.com/SecAegis/SecAutoBan/main/device/alarm/sangfor_sip/sangfor_sip.py
8+
```
9+
10+
## 配置说明
11+
12+
### 配置深信服态势感知
13+
14+
添加syslog推送,由于默认数据包过大,UDP存在截断问题,需选择TCP推送。
15+
16+
### 安装依赖
17+
18+
```
19+
pip3 install SecAutoBan
20+
```
21+
22+
### 配置模块
23+
24+
#### 修改回连核心模块配置
25+
26+
更改脚本第`40`-`42`
27+
28+
```
29+
server_ip = "127.0.0.1",
30+
server_port = 80,
31+
sk = "sk-xxx",
32+
```
33+
34+
#### 配置syslog监听地址
35+
36+
更改脚本第`38`行,请与天眼SYSLOG中配置的端口一致
37+
38+
```
39+
listen_syslog_tcp_port = 567
40+
```
41+
42+
## 运行
43+
44+
```shell
45+
python3 sangfor_sip.py
46+
```
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import json
2+
import socketserver
3+
from SecAutoBan import SecAutoBan
4+
5+
6+
class SyslogTCPHandler(socketserver.BaseRequestHandler):
7+
def __init__(self, request, client_address, server, ws_client):
8+
self.ws_client = ws_client
9+
super().__init__(request, client_address, server)
10+
def handle(self):
11+
buffer = b""
12+
with self.request.makefile('rb') as f:
13+
for chunk in f:
14+
buffer += chunk
15+
parts = buffer.split(b"\x00")
16+
buffer = parts.pop()
17+
for line in parts:
18+
line = line.strip()
19+
if not line:
20+
continue
21+
sub_parts = line.split(b"|!")
22+
if len(sub_parts) <= 3:
23+
continue
24+
try:
25+
msg = json.loads(sub_parts[3])
26+
self.ws_client.send_alarm(msg["attack_ip"], msg["suffer_ip"], msg["event_desc"])
27+
except Exception as e:
28+
pass
29+
30+
31+
def alarm_analysis(ws_client):
32+
with socketserver.ThreadingTCPServer(("0.0.0.0", listen_syslog_tcp_port), lambda *args: SyslogTCPHandler(*args, ws_client=ws_client)) as server:
33+
sec_auto_ban.print("[+] 监听SysLog端口: " + str(listen_syslog_tcp_port) + "/TCP")
34+
server.serve_forever()
35+
36+
37+
if __name__ == "__main__":
38+
listen_syslog_tcp_port = 567
39+
sec_auto_ban = SecAutoBan(
40+
server_ip="127.0.0.1",
41+
server_port=80,
42+
sk="sk-*****",
43+
client_type="alarm",
44+
alarm_analysis = alarm_analysis
45+
)
46+
sec_auto_ban.run()

0 commit comments

Comments
 (0)