rustscan

描述

端口扫描工具,地址

安装

brew

1
brew instsall rustscan

docker

1
docker pull rustscan/rustscan:2.0.0

使用

1
2
3
4
5
6
7
rustscan -a 192.168.6.100 --ulimit 5000

# 指定端口
rustscan -a 192.168.6.100 --ulimit 5000 -p 21,22,80

# 指定范围
rustscan -a 192.168.6.2 --ulimit 500 -r 1-65535

查看监听的端口

1
sudo netstat -tunlp

vpn

socks5

server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 安装
sudo apt install dante-server

# 配置
sudo vim /etc/danted.conf
# 修改配置
logoutput: /var/log/danted.log
internal: eth0 port = 1080
external: eth0
clientmethod: none
socksmethod: username
user.privileged: root
user.notprivileged: nobody

client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: error connect disconnect
}

socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: connect
log: error connect disconnect
socksmethod: username
}

# 启动服务
sudo service danted start

不启用认证配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
logoutput: /var/log/danted.log
internal: ens18 port = 1080
external: ens18
clientmethod: none
method: none
user.privileged: root
user.notprivileged: nobody

client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: error connect disconnect
}

socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: connect
log: error connect disconnect
method: none
}

ShadowSocks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 安装
sudo apt install shadowsocks-libev

# 配置
sudo nano /etc/shadowsocks-libev/config.json
{
"server":["::1", "127.0.0.1"],
"mode":"tcp_and_udp",
"server_port":8388,
"local_port":1080,
"password":"ACRrobo9ymXb",
"timeout":60,
"method":"chacha20-ietf-poly1305"
}

# 服务
sudo systemctl restart shadowsocks-libev.service
sudo systemctl enable shadowsocks-libev.service
systemctl status shadowsocks-libev.service

Http

squid

ubuntu

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 安装
sudo apt install squid

# 配置
sudo vim /etc/squid/squid.conf
## 配置项
http_port <port>
dns_nameservers 8.8.8.8 8.8.4.4

# 认证
sudo apt install apache2-utils
# 生成账号 & 密码并写入文件
sudo touch /etc/squid/passwords
sudo htpasswd /etc/squid/passwords <user-name>
# htpasswd -c 选项会重新生成文件

# 修改配置
sudo vim /etc/squid/squid.conf
## 添加如下内容
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
# 放在 http_access deney all 之前

# 其他配置
tcp_outgoing_address 198.18.192.194 # 设置出网端口(网络端口分配的ip)

# 启动服务
sudo systemctl start squid.service
# 或重启服务
sudo systemctl restart squid.service

# 开机启动
sudo systemctl enable squid.service

# 测试
curl -v -x http://<user-name>:<password>@<host>:3128 https://www.google.com/

rsync

Command

1
2
3
4
5
6
7
8
9
10
# local
rsync [OPTION]... SRC [SRC]... DEST

# remote
rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
rsync [OPTION]... [USER@]HOST:SRC [DEST]
rsync [OPTION]... [USER@]HOST::SRC [DEST]
rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]

参数

1
2
3
4
5
6
7
-r 递归同步
-R 使用相对路径名称
-c 文件比较使用校验和替代时间和大小
-P 显示进度并保留未传输完成的文件

--delete 删除目标文件夹无关的文件
--progress 显示进度

华硕路由器

通过域名解析内网机器

打开 高级设置 / 内部网络,修改路由器网络名称为 host

这里选 host 是应为 host 是合法的定级域名,浏览器输入不添加协议头 (http:// 等) 时不会调用搜索。

image-20221106215611021

修改机器名称

在下面的 手动指定 IP 的 DHCP 列表 中添加内网机器记录。

image-20221106224817651

检查 Hosts

1
2
3
4
5
6
7
8
9
10
11
$ ssh admin@192.168.6.1

$ cat /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.6.1 RT-AX88U-BD78.host RT-AX88U-BD78
192.168.6.1 RT-AX88U-BD78.local
192.168.6.1 router.asus.com
192.168.6.1 www.asusnetwork.net
192.168.6.1 www.asusrouter.com
192.168.6.6 unraid.host
...

浏览器访问

image-20221106220852396

注意

上面示例使用了 host,但是出现了一些意外的情况。有一台新的机器初始化,不知道为何,连接公司网络后,网络连接配置里面的 Search Domain 仍然保留了 host,按道理来说,更换网络后 Search Domain 会从新的网络获取。如果继续配置 Search Domain 为 host,那么会出现这么一种情况:如果访问的域名不存在,那么会尝试搜索 domain.host,然而 .host 是一个可用的顶级域名,然后出现了跳转到 domain.host ,有些公司的 dOmain 恰巧被一些大聪明利用,就出现了实际不存在但是会跳转到不可言状的站点(比如访问 git.compony.com 有可能被解析为 git.compony.com.host 并被重定向到某些网站)。

总之,不用 .host,选择一个和顶级域名不冲突的 search domain。

ikuai

远程访问

生成证书

1
$ openssl req -x509 -days 7200 -newkey rsa:2048 -keyout server.key -out server.crt -nodes -subj "/C=CN/ST=Beijing/L=Beijing/O=Wii/OU=IT/CN={your.domain}" -addext "subjectAltName = DNS:{your.domain}"

将生成的 crt 和 key 文件内容拷贝到爱快远程访问的证书管理里面。

image-20241016122718014

证书认证问题导致的无法访问

Chrome 浏览器 + Mac OS 会触发这个问题,访问方式如下。

  • 点击页面空白处(位置随意)
  • 然后使用键盘输入 thisisunsafe (对,没有任何输入框,盲输。注意,一定要先点击页面空白处)

或者使用 Safari 浏览器(或者其他),在显示详细信息里面点继续访问即可。

VPN

L2TP 服务端

只需要启动服务端、添加账号,无需其他配置。

启动服务端

image-20241016121909165

  • 预共享密钥选填

配置账号

image-20241016122101208

  1. 输入账号密码
  2. 输入收款金额 0

问题排查

无法访问内网

官网排查手册

image-20241016122215464

客户端排查

Mac os 用户,需要开启 VPN 里面的 通过 VPN 连接发送所有流量,如果不开启的话部分内网 ip 网段可能不走 VPN,导致无法访问远端内网。

image-20241016122318114

netgear

回刷官方固件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1. 下载固件并解压
https://www.netgear.com/support/download/

2. 路由器恢复模式
- 路由器关机
- 按住 Reset
- 开机
- 等待一二十秒,电源灯白灯闪烁

3. 上传固件
// 不同系统的命令稍有差异
$ tftp 192.168.1.1
tftp> binary
tftp> put R9000-V1.0.5.42.img

4. 等待刷新完成

openwrt

开启 Samba

1
2
3
4
5
6
# 安装依赖
opkg install shadow-common shadow-useradd

# 添加用户
useradd share
smbpasswd -a share

扩容 overlay

已验证的镜像类型

1
openwrt-...-...-generic-squashfs-combined-efi.img

扩容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 扩容镜像
dd if=/dev/zero bs=1G count=30 >> openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img
# 分区
$ parted openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img
...
(parted) print
...
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 126MB 109MB

(parted) resizepart 2 100%
(parted) print
...
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 32.3GB 32.3GB

(parted) quit

# [pve] 加载镜像为虚拟机磁盘
qm importdisk 103 openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img local-lvm

挂载新的磁盘

1
2
3
4
5
6
7
8
9
# 格式化磁盘
mkfs.ext4 /dev/sdb

# 安装 block-mount
opkg install block-mount

# 进入网页, 打开 系统 -> 挂载点
挂载点 -> 新增
保存并应用

预编译固件

  • Immortal Wrt
  • iStoreOs

配置

soft router

镜像

主题

LEDE

更新源配置

腾讯

1
2
3
4
5
6
src/gz openwrt_core https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/targets/x86/64/packages
src/gz openwrt_base https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/packages/x86_64/base
src/gz openwrt_luci https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/packages/x86_64/luci
src/gz openwrt_packages https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/packages/x86_64/packages
src/gz openwrt_routing https://mirrors.cloud.tencent.com/openwrt/releases/22.03.2/packages/x86_64/routing
src/gz openwrt_telephony https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/telephony

清华源

1
2
3
4
5
6
7
8
9
src/gz openwrt_core https://mirrors.cloud.tencent.com/lede/snapshots/targets/x86/64/packages
src/gz openwrt_base https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/base
src/gz openwrt_helloworld https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/helloworld
src/gz openwrt_kenzo https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/kenzo
src/gz openwrt_luci https://mirrors.cloud.tencent.com/lede/releases/18.06.9/packages/x86_64/luci
src/gz openwrt_packages https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/packages
src/gz openwrt_routing https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/routing
src/gz openwrt_small https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/small
src/gz openwrt_telephony https://mirrors.cloud.tencent.com/lede/snapshots/packages/x86_64/telephony

PVE

查看 debian 版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 1. 查看文件 release 文件
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

# 2. 通过 lsb-release 命令
$ apt update
$ apt install lsb-release
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

修改 debian 更新源

参考这里

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 安装依赖
apt update
apt install apt-transport-https ca-certificates -y

# 修改源文件
$ mv /etc/apt/sources.list /etc/apt/sources.list.back
$ vi /etc/apt/sources.list
## 输入如下内容 (注意版本, 下面是 bullseye)
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

更新

1
2
apt update
apt upgrade -y

修改更新源

参考这里

proxmox 更新

1
2
3
4
# 添加源文件
vi /etc/apt/sources.list.d/pve-no-subscription.list
# 输入 (注意 debian 版本)
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian bullseye pve-no-subscription

CT 模板加速

1
2
cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back
sed -i 's|http://download.proxmox.com|https://mirrors.tuna.tsinghua.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm

重启生效。

从 qcow2 启动 openwrt

1. 拷贝镜像至 pve

1
scp openwrt-x86-64-generic-squashfs-combined-efi.qcow2 root@192.168.6.60:

2. 创建虚拟机

不用添加硬盘盒配置 CD/DVD 驱动器。

3. 挂载镜像为磁盘

1
2
3
4
# qcow2
qm importdisk 100 openwrt-x86-64-generic-squashfs-combined-efi.qcow2 local-lvm
# img
qm importdisk 100 openwrt-x86-64-generic-squashfs-combined-efi.img local-lvm

这里的 100 是虚拟机 ID

local-lvm 是存储池名称

image-20221105161004992

4. 为虚拟机添加硬盘

image-20221105160819628

选中未使用的磁盘,并点击编辑。

image-20221105160840881

类型选择 IDE。

5. 修改引导

image-20221105161029736

image-20221105161048645

启用新添加的硬盘,并把优先级设为最高(拖动序号前的三条横杠)。

6. 启动虚拟机

保存上述更改,启动虚拟机即可。

硬盘直通

1
2
3
4
5
6
$ vi /etc/default/grub
# 修改 GRUB_CMDLINE_LINUX_DEFAULT 为如下
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"

# 更新 grub
$ update-grub

修改网络地址

1
2
3
$ vim /etc/config/network 
# 修改对应的网络接口地址, 比如 eth0
$ /etc/init.d/network restart

修改密码

1
$ passwd root

Openwrt

初始化

修改网络配置

/etc/config/network

1
2
# interface 'lan'
option ipaddr ... # 修改这里
1
2
$ service network reload
$ service network restart

修改密码

1
$ passwd root

安装应用

1
2
3
opkg install <package>
opkg install <package.ipk>
opkg install <http://path/to/package.ipk>

扩容 overlay

已验证的镜像类型

1
openwrt-...-...-generic-squashfs-combined-efi.img

扩容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 扩容镜像
dd if=/dev/zero bs=1G count=30 >> openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img
# 分区
$ parted openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img
...
(parted) print
...
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 126MB 109MB

(parted) resizepart 2 100%
(parted) print
...
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 32.3GB 32.3GB

(parted) quit

# [pve] 加载镜像为虚拟机磁盘
qm importdisk 103 openwrt-22.03.2-x86-64-generic-squashfs-combined-efi.img local-lvm

旁路由

  • 网络 / 接口 / LAN
    • 基本设置
      • ipv4 地址,修改为主路由局域网合法且未被占用地址(如 192.168.6.2~192.168.6.254)
      • 网关,主路由 ip 地址(如 192.168.6.1)
      • 广播地址,如 192.168.6.255
      • DNS 服务器,主路由 ip 地址
      • IPv6 分配长度,已禁用
    • 高级设置
      • 使用内置的 ipv6 管理,关闭
    • 物理设置
      • 关闭桥接
    • DHCP 服务器
      • 忽略此接口
  • 网络 / 防火墙
    • image-20231026230034381
  • 运行 SSR

设备设置

Mac OS

image-20231026230223222

Ubuntu Server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
enp5s0:
dhcp4: false
addresses: [192.168.6.55/24]
match:
macaddress: 2a:04:a0:xx:xx:xx
wakeonlan: true
nameservers:
addresses: [223.6.6.6, 8.8.8.8]
routes:
- to: default
via: 192.168.6.89
metric: 40
enp6s0:
dhcp4: true
version: 2

连通性校验

  • ping 使用 ICMP 协议,代理一般只支持 TCP 和 UDP,所以使用 ping 可能无法判断是否代理成功
1
2
# 可以尝试下面命令
curl https://www.google.com

自定义规则

image-20240519224634959