Skip to content

Commit

Permalink
update 2021年09月 3日 16:44:02
Browse files Browse the repository at this point in the history
  • Loading branch information
No-Github committed Sep 3, 2021
1 parent 7a3a155 commit 35b6d0a
Show file tree
Hide file tree
Showing 65 changed files with 1,166 additions and 257 deletions.
14 changes: 7 additions & 7 deletions 1earn/Integrated/Linux/God-Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

---

# bash
## bash

``` bash
# 判断当前是否是登陆式或非登陆式 shell
Expand Down Expand Up @@ -67,7 +67,7 @@ EOF
echo -e "\x68\x65\x6c\x6c\x6f"
```

## cd
### cd

**切换到上一个目录**
```
Expand Down Expand Up @@ -166,7 +166,7 @@ bind "set completion-ignore-case on"

---

# net
## net

```bash
# 在当前目录起个 8000 端口的 HTTP 服务
Expand All @@ -178,7 +178,7 @@ curl ifconfig.me

---

# shell
## shell

**fork 炸弹**
```bash
Expand All @@ -204,7 +204,7 @@ let i=`find . -type f | wc -l`/2 ; find . -type f -print0 | shuf -z -n $i | xarg

---

# VIM
## VIM

``` bash
无 root 权限,保存编辑的文件
Expand All @@ -213,7 +213,7 @@ let i=`find . -type f | wc -l`/2 ; find . -type f -print0 | shuf -z -n $i | xarg

---

# 性能
## 性能

```bash
sync # sync 命令做同步,以确保文件系统的完整性,将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延的块 I/O 和读写映射文件.否则在释放缓存的过程中,可能会丢失未保存的文件.
Expand All @@ -232,7 +232,7 @@ sysctl -w vm.nr_hugepages=128

---

# 文本
## 文本

**计算文本文件中的单词出现次数**
```bash
Expand Down
126 changes: 126 additions & 0 deletions 1earn/Integrated/Linux/Secure-Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* [Firewall](#firewall)
* [禁ping](#禁ping)
* [SSH](#ssh)
* [文件共享](文件共享)
* [加固](#加固)

---
Expand Down Expand Up @@ -676,6 +677,104 @@ firewall-cmd --reload

---

## iptable

**查询表中的规则**

```bash
iptables -t raw -L # 列出所有 raw 表中的所有规则
iptables -t mangle -L # 列出 mangle 表中所有规则
iptables -t nat -L # 列出 nat 表中所有规则
iptables -t filter -L # 列出 filter 表中所有规则
```

**查看不同的链中的规则**

```bash
iptables -L INPUT # 只看 filter 表中(默认 - t 是 filter 表)input 链的规则
iptables -vL INPUT # 只看 filter 表中(默认 - t 是 filter 表)input 链的规则详情
iptables -nvL INPUT # 只看 filter 表中(默认 - t 是 filter 表)input 链的规则详情,同时不对 IP 地址进行名称反解析,直接显示 IP
iptables --line-number -nvL INPUT # 只看 filter 表中(默认 - t 是 filter 表)input 链的规则详情,同时不对 IP 地址进行名称反解析,直接显示 IP,每行加行标
```

---

## nftables

**查看规则汇总**

```bash
nft list tables [<family>]
nft list table [<family>] <name> [-n] [-a]
nft list tables # 列出所有表
nft list table family table # 列出指定表中的所有链和规则
nft list table inet filter # 要列出inet簇中f
nft list chain family table chain # 列出一个链中的所有规则
nft list chain inet filter output # 要列出inet中filter表的output链中的所有规则
```

**nft表管理**

```bash
nft add table family table # 创建一个新的表
nft list tables # 列出所有表
nft list table family table # 列出指定表中的所有链和规则
nft list table inet filter # 要列出inet簇中filter表中的所有规则
nft delete table family table # 删除一个表
nft flush table family table # 要清空一个表中的所有规则
```

**nft链管理**

```bash
nft add chain family table chain # 将名为chain的常规链添加到名为table的表中
nft add chain inet filter tcpchain # 例如,将名为tcpchain的常规链添加到inet簇中名为filter的表中
nft add chain family table chain { type type hook hook priority priority \; } # 添加基本链,需要指定钩子和优先级值
nft list chain family table chain # 列出一个链中的所有规则
nft list chain inet filter output # 要列出inet中filter表的output链中的所有规则
nft chain family table chain { [ type type hook hook device device priority priority \; policy <policy> \; ] } # 要编辑一个链,只需按名称调用并定义要更改的规则
nft chain inet filter input { policy drop \; } # 将默认表中的input链策略从accept更改为drop
nft delete chain family table chain # 删除一个链,要删除的链不能包含任何规则或者跳转目标。
nft flush chain family table chain # 清空一个链的规则
```

**添加规则**

```bash
nft add rule family table chain handle handle statement # 将一条规则添加到链中
nft insert rule family table chain handle handle statement # 将规则插入到指定位置,如果未指定handle,则规则插入到链的开头。
```

**删除规则**

```bash
# 下面命令确定一个规则的句柄,然后删除。--number参数用于查看数字输出,如未解析的IP地址。
nft --handle --numeric list chain inet filter input
nft delete rule inet fltrTable input handle 10
# 可以用nft flush table命令清空表中的所有的链。可以用nft flush chain或者nft delete rule命令清空单个链。
# 第一个命令清空foo表中的所有链。第二个命令清空ip foo表中的bar链。第三个命令删除ip6 foo表bar两种的所有规则。
nft flush table foo
nft flush chain foo bar
nft delete rule ip6 foo bar
```

**自动重载**

```bash
清空当前规则集:
# echo "flush ruleset" > /tmp/nftables
导出当前规则集:
# nft list ruleset >> /tmp/nftables
可以直接修改/tmp/nftables文件,使更改生效则运行:
# nft -f /tmp/nftables
```

---

## 禁ping

**临时性,重启后失效**
Expand Down Expand Up @@ -845,6 +944,33 @@ net.ipv4.icmp_echo_ignore_all=1

---

## 文件共享

**NFS服务**

配置文件
```
/etc/exports
```

**TFTP服务**

配置文件
```
/etc/default/tftpd-hpa
/etc/xinetd.d/tftp
```

**samba服务**

配置文件
```
/etc/samba/smb.conf
```

---

# 加固

**查后门**
Expand Down
5 changes: 3 additions & 2 deletions 1earn/Integrated/Linux/实验/Firewall.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ firewall-cmd --reload

---

**Source & Reference**
- [使用防火墙让你的 Linux 更加强大 ](https://linux.cn/article-11093-1.html)
## Source & Reference

- [使用防火墙让你的 Linux 更加强大](https://linux.cn/article-11093-1.html)
6 changes: 3 additions & 3 deletions 1earn/Integrated/Linux/实验/LAMP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

LAMP 指的 Linux(操作系统)、ApacheHTTP 服务器,MySQL(有时也指 MariaDB,数据库软件) 和 PHP(有时也是指 Perl 或 Python) 的第一个字母,一般用来建立 web 应用平台

# MairaDB
## MairaDB

**安装**
```
Expand All @@ -31,7 +31,7 @@ firewall-cmd --reload

---

# Apache+PHP
## Apache+PHP

**安装**
```bash
Expand All @@ -58,7 +58,7 @@ firewall-cmd --reload

---

# phpmyadmin
## phpmyadmin

**配置数据库**
```bash
Expand Down
12 changes: 6 additions & 6 deletions 1earn/Integrated/Linux/实验/Nginx.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

---

# 反向代理
## 反向代理

反向代理(Reverse Proxy)方式是指以代理服务器来接受 internet 上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给 internet 上请求连接的客户端,此时代理服务器对外就表现为一个反向代理服务器.

Expand Down Expand Up @@ -40,7 +40,7 @@ server {

---

# 添加https
## 添加https
```bash
openssl req -new -x509 -nodes -days 365 -newkey rsa:1024 -out httpd.crt -keyout httpd.key # 生成自签名证书,信息不要瞎填,Common Name一定要输你的网址

Expand Down Expand Up @@ -70,13 +70,13 @@ server {
}
}
```
```
```bash
systemctl restart nginx
```

---

# 添加PHP环境支持
## 添加PHP环境支持

**Centos**
```bash
Expand Down Expand Up @@ -148,7 +148,7 @@ server {
}
```

```
```bash
service nginx restart
service firewalld stop
```
Expand Down Expand Up @@ -186,7 +186,7 @@ server {
}
```

```
```bash
service nginx restart
service firewalld stop
```
10 changes: 5 additions & 5 deletions 1earn/Integrated/Linux/实验/dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

---

# 基本配置
## 基本配置

- www.abc.com 解析为 192.168.192.1
- 192.168.192.1 解析为 www.abc.com
Expand Down Expand Up @@ -73,7 +73,7 @@ systemctl restart named

---

## 案例 1
### 案例 1

配置 DNS 服务,将相关主机名添加 A 记录,分别为 www.abc.com、ftp.abc.com、vpn.abc.com、web.abc.com;

Expand Down Expand Up @@ -177,7 +177,7 @@ service named start

---

## 案例 2
### 案例 2

- 监听所有地址;
- 允许所有机器查询;
Expand Down Expand Up @@ -301,7 +301,7 @@ firewall-cmd --reload

---

## 案例 3
### 案例 3

- 监听当前主机的所有地址;
- 允许所有主机查询和递归查询;
Expand Down Expand Up @@ -401,7 +401,7 @@ firewall-cmd --reload
---


## 案例 4
### 案例 4

- 配置 abc.com 域的从 DNS 服务,主 DNS 为主机 A;
- 配置 0.16.172 反向域的从 DNS 服务,主 DNS 为主机 A;
Expand Down
14 changes: 9 additions & 5 deletions 1earn/Integrated/Linux/实验/gpg.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@

---

建立新的 GPG 密钥对
## 建立新的 GPG 密钥对

```bash
gpg --gen-key
```

导出您的公钥
## 导出公钥

```bash
gpg --export {user-name}
gpg --export ffffffff0x > ffffffff0x-pub.gpg
```

导入其他人的公钥
## 导入其他人的公钥

```bash
gpg --import FileName
```

读取加密的消息
## 读取加密的消息

```bash
gpg --decrypt test-file.asc
```

---

**Source & Reference**
## Source & Reference
- [Gpg Key-Pair Encryption and Decryption Examples](https://linux.101hacks.com/unix/gpg-command-examples/)
Loading

0 comments on commit 35b6d0a

Please sign in to comment.