分类目录归档:运维

Redis安全基线汇总

检查项


禁止使用root用户启动 | 访问控制
禁止监听在公网 | 访问控制
打开保护模式 | 访问控制
限制redis 配置文件访问权限 | 文件权限
修改默认6379端口 | 服务配置
禁用或者重命名危险命令 | 入侵防范
开启redis密码认证,并设置高复杂度密码 | 身份鉴别
版本存在安全漏洞 | 入侵防范
Redis未授权访问 | 身份鉴别

继续阅读

wazuh采集sysmon日志

agent.conf

在服务器agent.conf文件中添加以下内容

<agent_config>
  <localfile>
    <location>Microsoft-Windows-Sysmon/Operational</location>
    <log_format>eventchannel</log_format>
  </localfile>
</agent_config>

docker安装的wazuh,agent配置文件在 `wazuh.manager` 容器中。

ossec.conf

将logall_json修改为yes,如下:

<logall_json>yes</logall_json>

docker安装的wazuh,agent配置文件在 `wazuh.manager` 容器中。

修改上述两项后重启wazuh-manager服务

filebeat.yml

修改filebeat配置文件,修改内容如下:

...
filebeat.modules:
 - module: wazuh
  alerts:
   enabled: true
  archives:
   enabled: true
...

重启filebeat

service filebeat restart

测试filebeat输出

filebeat test output

添加Index Patterns

在WUI中,Management -> Stack Management -> Index Patterns

添加wazuh-archives-*的Patterns

添加完后,可以在Discover中看到客户端的sysmon日志。

添加IP黑名单

开始接收sysmon日志后,日志存储量会无限增大,需要对发送过来的源地址进行限制。

如果使用docker安装,需要在docker-compose.yml中,添加privileged,不添加的话无法在容器中启动iptables,如下:

services:
  wazuh.manager:
    image: wazuh/wazuh-manager:4.8.0
    hostname: wazuh.manager
    restart: always
    privileged: true       #添加
    ports:
      - "1514:1514"
      - "1515:1515"
      - "514:514/udp"
      - "55000:55000"

构建好docker容器后,在`wazuh.manager`容器中安装iptables,并添加目的端口为1514的黑名单即可,如下:

# apt update
# apt install iptables
# iptables -I INPUT -s x.x.x.x -p tcp --dport 1514 -j DROP
# iptables-save

 

 

 

hash批量查询VirusTotal

virustotal-search.py  用于批量搜索VirusTotal的hash值

virustotal-submit.py  用于向VirusTotal提交文件

官方博客(virustotal-search v0.1.4) 基于python2

官方博客(virustotal-search v0.1.5) 基于python2

GitHub版本(virustotal-search v0.1.6) 基于python3

如何使用:

获取VirusTotal API KEY(免费API每分钟允许4次请求,每天允许500次查询,每月15.50 K次查询)

VirusTotal API KEY 获取地址

获取后,修改脚本中的VIRUSTOTAL_API2_KEY变量,或在运行脚本时,使用 -k 选项指定API KEY

VIRUSTOTAL_API2_KEY = 'xxxx0d4d0784d2b457f40a6xxxx3b678064c1edxxxxxfed17f2e57948afxxxxx'

在sha256.txt中包存需要查询的hash值后执行

python virustotal-search.py sha256.txt -o out.csv

执行后,在当前目录会生成out.csv文件,csv文件默认以;作为分隔符。指定分隔符使用 -s 选项

 

MikroTik PCC多线叠加+ospf+ovpn

RouterOS V6.47.7

ROS可以进行的负载均衡配置及特点如下:

ECMP(Equal-Cost Multi-path):
ECMP是通过在route列表添加多网关的静态路由,然后由路由协议建立劢态的多线路由。这种负载均衡有个缺点,缺点就是每十分钟内核会重新均衡线路,使一些连接会被指定到其他路线,出现频繁掉线的情况。
NTH:
NTH是采用第N次链接的负载均衡,它不仅可以实现基于IP的负载均衡,同时还能实现对端口负载均衡和对nat指定有序的访问。这样基本实现了不掉线的真正负载均衡。但是NTH存在着一个弊端,就是在某些对IP要求严格的网站会反复要求验证。比如,网银!这样我们需要通过策略将一些IP或者端口指定走固定的线路出去,从而避开网站繁琐的验证。
PCC(Per connection classified):
PCC是通过判断源地址或者目的地址、源端口或者目的端口对数据迚行分类来实现负载均衡,对每个连接迚行分类大多保持了连续性,这样大大弥补了NTH的不足。

继续阅读

iproute2在openwrt中实现策略路由

安装ip-full

opkg install ip-full

新增路由表

id:252(1-252可用),name:wifi2zt

id:251,name:ovpn2ta

id:250,name:bg

echo "252 wifi2zt" >> /etc/iproute2/rt_tables
echo "251 ovpn2ta" >> /etc/iproute2/rt_tables
echo "250 bg" >> /etc/iproute2/rt_tables

为新建的路由表指定路由

ip route add 0.0.0.0/0 via 10.49.160.1 table wifi2zt
ip route add 0.0.0.0/0 via 172.16.21.254 table ovpn2ta
ip route add 0.0.0.0/0 via 192.168.170.1 table bg

添加策略路由

ip rule add from 192.168.171.0/24 table wifi2zt #源IP为192.168.171.0/24,添加到wifi2zt表,使用网关:10.49.160.1
ip rule add from 192.168.170.0/24 table ovpn2ta #源IP为192.168.170.0/24,添加到ovpn2ta表,使用网关:172.16.21.254
ip rule add to 192.168.169.0/24 table bg #目的IP为192.168.169.0/24,添加到bg表,使用网关:192.168.170.1

查看路由表及清空路由表

root@LEDE:/etc/iproute2# ip route list table ovpn2ta   #查看ovpn2ta表
default via 172.16.21.254 dev tun0
root@LEDE:/etc/iproute2#


root@LEDE:/etc/iproute2# ip rule list  #查看策略
0: from all lookup local
32740: from all to 192.168.168.0/24 lookup ovpn2ta
32741: from all to 192.168.169.0/24 lookup ovpn2ta
32742: from all to 192.168.170.0/24 lookup bg
32763: from all lookup main
32764: from all lookup default
root@LEDE:/etc/iproute2#


root@LEDE:/etc/iproute2# ip route flush table bg  #清空路由表

 

 

 

Huge List of free VPS/places where you can host your web for free

1. Vercel give you loads of hosting for free as well with no credit card required and if you choose to use a custom domain they won’t charge you. Also, SSL is included. https://vercel.com/pricing
2. Oracle gives you 2 AMD VM with 1 core and 1 GB of RAM each, plus up to four ARM VM with a total of 4 cores and 24 GB of RAM (so you can have 2 VM with 2 cores each or 1 VM with 4 cores), forever. https://www.oracle.com/cloud/free/
3. Google cloud has a pretty generous permanent free tier, including an f1-micro VM and 50 cpu-hours a month on Cloud Run (which only bills when a request is progressing). https://cloud.google.com/free
4. if you don’t need a 24/7 VPS (or persistent storage), I have a website (https://rs1.es) that can be useful. It’s easy to set up (1-click), you can add a startup script (so you can download, unzip, and test your code quickly), you can type commands in your browser (you can use SSH as well) and it’s free (supported by ads). VPS have 2vCPU (Intel Xeon), 2GB RAM. You can use them for 3 hours each.
5. AWS – you get 1 year of free EC2 server
6. Heroku – lifetime free for 1 app. It is not exactly a full fledged server but rather a hosting place for your code.
7. Azure. Free hosting for shared tier web sites and you could use Azure Devops for CI/CD, source control and bug tracking. They even have OSS (public projects) option. Azure Devops gives 5 free user licenses and 1800 CI/CD pipeline minutes a month. https://azure.microsoft.com/en-us/free/
8. netlify https://www.netlify.com/pricing/

继续阅读

RouterOS路由OSPF协议+树莓派分流国外流量

跟原文作者一样,之前尝试过使用RouterOS的iptables给链接打标记的方式配置过,但不知道为什么,速度奇慢无比,直到看到通过动态路由协议的方式进行分流。

OSPF简介

OSPF (Open Shortest Path First) 是一种常用的 IGP 路由协议,相对于 BGP 这种主要是为自治域之间通信设计的协议,OSPF 的配置相对来说要简单易懂的多,而且收敛速度非常的快,适合用来在内网快速发布大量的路由。

OSPF 唯一不足的地方是一开始设计的时候没有考虑到多种协议的支持,导致 IPv6 出来后又设计了 OSPFv3 这个新的协议。因为我们希望有 IPv6 支持,所以后面会同时配置 OSPFv2 和 OSPFv3 的实例。但是相对于 IS-IS 和 iBGP 这些支持原生双栈的协议还是配置起来要简单了不少。

继续阅读