1、ss
查看正在连接的客户端:ss -nt
查看正在访问指定文件系统的进程
lsof MOUNT_POINT
fuser -v MOUNT_POINT
终止所有在正访问指定的文件系统的进程
fuser -km MOUNT_POINT
2、各种端口号的作用
在
cat /etc/services 这个文件中
windos在
C:\Windows\System32\drivers\etc
3、nc命令
1. -g<网关> 设置路由器跃程通信网关,最多可设置8个。
2. -G<指向器数目> 设置来源路由指向器,其数值为4的倍数。
3. -h 在线帮助。
4. -i<延迟秒数> 设置时间间隔,以便传送信息及扫描通信端口。
5. -l 使用监听模式,管控传入的资料。
6. -n 直接使用IP地址,而不通过域名服务器。
7. -o<输出文件> 指定文件名称,把往来传输的数据以16进制字码倾倒成该文件保存。
8. -p<通信端口> 设置本地主机使用的通信端口。
9. -r 乱数指定本地与远端主机的通信端口。
10. -s<来源位址> 设置本地主机送出数据包的IP地址。
11. -u 使用UDP传输协议。
12. -v 显示指令执行过程。
13. -w<超时秒数> 设置等待连线的时间。
14. -z 使用0输入/输出模式,只在扫描通信端口时使用。
#服务器开启UDP的端口
[root@centos8 ~]#nc -l 7000 -u#客户端连接
[root@centos7 ~]#nc 10.0.0.8 7000 -u
[root@centos8 ~]#ss -ntu
Netid State Recv-Q Send-Q Local Address:Port
Peer Address:Port
udp ESTAB 0 0 10.0.0.8:7000
10.0.0.7:52667
tcp ESTAB 0 0 10.0.0.8:8000
10.0.0.7:53402
tcp ESTAB 0 52 10.0.0.8:22
10.0.0.1:13305
[wang@centos8 ~]$nc -l 1023
Ncat: bind to :::1023: Permission denied. QUITTING.
查看谁在使用端口,及端口冲突
[root@centos8 ~]#ss -ntlp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
users:(("sshd",pid=699,fd=4))
LISTEN 0 128 [::]:22 [::]:*
users:(("sshd",pid=699,fd=6))
[root@centos8 ~]#lsof -i :22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 699 root 4u IPv4 26846 0t0 TCP *:ssh (LISTEN)
sshd 699 root 6u IPv6 26848 0t0 TCP *:ssh (LISTEN)
sshd 1287 root 5u IPv4 29875 0t0 TCP centos8.localdomain:ssh-
>10.0.0.1:pc-mta-addrmap (ESTABLISHED)
sshd 1300 root 5u IPv4 29875 0t0 TCP centos8.localdomain:ssh-
>10.0.0.1:pc-mta-addrmap (ESTABLISHED)
4、判断端口是否打开
root@centos8 LiveCMS-linux-3.2.4-22040820]#< /dev/tcp/127.0.0.1/10001 #打开了
[root@centos8 LiveCMS-linux-3.2.4-22040820]#
[root@centos8 LiveCMS-linux-3.2.4-22040820]#echo $?
0
[root@centos8 LiveCMS-linux-3.2.4-22040820]#< /dev/tcp/127.0.0.1/10000 #没打开
bash: connect: Connection refused
bash: /dev/tcp/127.0.0.1/10000: Connection refused
[root@centos8 LiveCMS-linux-3.2.4-22040820]#echo $?
1
模拟百度上网:
[root@centos8 ~]#exec 8<>/dev/tcp/www.baidu.com/80
[root@centos8 ~]#ll /proc/$$/fd
total 0
lrwx------ 1 root root 64 Apr 20 14:14 0 -> /dev/pts/0
lrwx------ 1 root root 64 Apr 20 14:14 1 -> /dev/pts/0lrwx------ 1 root root 64 Apr 20 14:14 2 -> /dev/pts/0
lrwx------ 1 root root 64 Apr 20 14:17 255 -> /dev/pts/0
lr-x------ 1 root root 64 Apr 20 14:14 3 -> /var/lib/sss/mc/passwd
lrwx------ 1 root root 64 Apr 20 14:14 4 -> 'socket:[32754]'
lrwx------ 1 root root 64 Apr 20 14:14 8 -> 'socket:[32777]'
[root@centos8 ~]#echo -e 'GET / HTTP/1.1\n' >& 8
[root@centos8 ~]#cat <& 8
5、sync半连接和accept全连接队列
10
/proc/sys/net/ipv4/tcp_max_syn_backlog 未完成连接队列大小,默认值128,建议调整大小为1024
以上
/proc/sys/net/core/somaxconn 完成连接队列大小,默认值128,建议调整大小为1024以
上
TCP超时重传
/proc/sys/net/ipv4/tcp_retries1,指定在底层IP接管之前TCP最少执行的重传次数,默认值是3
/proc/sys/net/ipv4/tcp_retries2,指定连接放弃前TCP最多可以执行的重传次数,默认值15(一
般对应13~30min)
6、ARP
静态绑定ARP
[root@centos8 ~]#arp -s 10.0.0.6 00:0c:29:32:80:38
[root@centos8 ~]#arp -n
Address HWtype HWaddress Flags Mask Iface
10.0.0.6 ether 00:0c:29:32:80:38 CM eth0
10.0.0.7 ether 00:0c:29:32:80:38 C eth0
10.0.0.1 ether 00:50:56:c0:00:08 C eth0
范例:kali 系统实现 arp 欺骗上网流量劫持
#启动路由转发功能
[root@kali ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
#安装包
[root@kali ~]# apt-get install dsniff
#欺骗目标主机,本机是网关
[root@kali ~]# arpspoof -i eth0 -t 被劫持的目标主机IP 网关IP
#欺骗网关,本机是目标主机
[root@kali ~]# arpspoof -i eth0 -t 网关IP 被劫持的目标主机IP
范例:发现IP冲突的主机
[root@centos8 ~]#arping 10.0.0.6ARPING 10.0.0.6 from 10.0.0.8 eth0
Unicast reply from 10.0.0.6 [00:0C:29:E0:2F:37] 0.779ms
Unicast reply from 10.0.0.6 [00:0C:29:32:80:38] 0.798msUnicast reply from 10.0.0.6 [00:0C:29:32:80:38] 0.926ms
Unicast reply from 10.0.0.6 [00:0C:29:32:80:38] 0.864ms
^CSent 3 probes (1 broadcast(s))
^CSent 3 probes (1 broadcast(s))
范例:ARP静态绑定可以防止ARP欺骗
[root@centos8 ~]#arp -s 10.0.0.6 00:0c:29:32:80:38
[root@centos8 ~]#arp -n
Address HWtype HWaddress Flags
Mask Iface
10.0.0.6 ether 00:0c:29:32:80:38 CM eth0
10.0.0.7 ether 00:0c:29:32:80:38 C eth0
10.0.0.1 ether 00:50:56:c0:00:08 C