Fix minor markdown syntax errors.

This commit is contained in:
Thanwer 2024-11-03 11:16:56 -03:00
parent 8735ceb930
commit a2778009b5
10 changed files with 51 additions and 28 deletions

View File

@ -42,9 +42,7 @@ Next, we have the `jail.conf` file, which is where we configure our "jails" as t
Here we are going to make some changes, so first let's create a `jail.local` file with the following content: Here we are going to make some changes, so first let's create a `jail.local` file with the following content:
```text
```
[DEFAULT] [DEFAULT]
bantime.multipliers = 5 15 30 60 300 720 1440 2880 bantime.multipliers = 5 15 30 60 300 720 1440 2880
bantime = 86400 bantime = 86400
@ -66,6 +64,7 @@ Take your time to fine tune those parameters.
## Enabling and testing Fail2ban ## Enabling and testing Fail2ban
Enable and start the fail2ban service Enable and start the fail2ban service
```bash ```bash
systemctl enable --now fail2ban systemctl enable --now fail2ban
``` ```
@ -73,6 +72,7 @@ systemctl enable --now fail2ban
For SSH jails the test is very simple, you can test by simply failing to log on a couple times. For SSH jails the test is very simple, you can test by simply failing to log on a couple times.
You can check the status with the command: You can check the status with the command:
```bash ```bash
fail2ban-client status fail2ban-client status
fail2ban-client status sshd fail2ban-client status sshd
@ -82,7 +82,7 @@ fail2ban-client status sshd
As you can see, the SSH service on a cloud VPS is constantly being attacked, my server has almost 400 currently banned IPs. As you can see, the SSH service on a cloud VPS is constantly being attacked, my server has almost 400 currently banned IPs.
## More jails! ## More jails
Today I showed how to protect your GNU/Linux SSH service, but is is not over, you can use fail2ban to protect any service that you run! Today I showed how to protect your GNU/Linux SSH service, but is is not over, you can use fail2ban to protect any service that you run!

View File

@ -43,7 +43,7 @@ Depois, temos o arquivo `jail.conf` , que é onde configuramos as nossas "jails"
Aqui vamos fazer algumas alterações, primeiro vamos criar um arquivo `jail.local` com o seguinte conteúdo: Aqui vamos fazer algumas alterações, primeiro vamos criar um arquivo `jail.local` com o seguinte conteúdo:
``` ```text
[DEFAULT] [DEFAULT]
bantime.multipliers = 5 15 30 60 300 720 1440 2880 bantime.multipliers = 5 15 30 60 300 720 1440 2880
bantime = 86400 bantime = 86400
@ -65,6 +65,7 @@ Invista seu tempo para estudar e melhorar esses parâmetros.
## Ativando e testando o fail2ban ## Ativando e testando o fail2ban
Ative e inicie o serviço fail2ban: Ative e inicie o serviço fail2ban:
```bash ```bash
systemctl enable --now fail2ban systemctl enable --now fail2ban
``` ```
@ -72,6 +73,7 @@ systemctl enable --now fail2ban
Para testar as jails SSH, basta tentar o login com a senha incorreta por algumas vezes. Para testar as jails SSH, basta tentar o login com a senha incorreta por algumas vezes.
Voce pode ver o status com os seguintes comandos: Voce pode ver o status com os seguintes comandos:
```bash ```bash
fail2ban-client status fail2ban-client status
fail2ban-client status sshd fail2ban-client status sshd
@ -81,7 +83,7 @@ fail2ban-client status sshd
Como voce pode ver, o serviço SSH em uma VPS em cloud é constantemente atacada, meu servidor já tem mais de 400 IPs banidos. Como voce pode ver, o serviço SSH em uma VPS em cloud é constantemente atacada, meu servidor já tem mais de 400 IPs banidos.
## Mais jails! ## Mais jails
Hoje eu mostrei como proteger o seu serviço SSH em uma maquina GNU/Linux, mas não acabou, voce pode usar o fail2ban para qualquer serviço! Hoje eu mostrei como proteger o seu serviço SSH em uma maquina GNU/Linux, mas não acabou, voce pode usar o fail2ban para qualquer serviço!

View File

@ -31,6 +31,7 @@ You can also use [Github Pages](https://pages.github.com/) or [Cloudflare Pages]
I followed Hugo guide to [deploy by rsync](https://gohugo.io/hosting-and-deployment/deployment-with-rsync/) and I worked very well for me. I followed Hugo guide to [deploy by rsync](https://gohugo.io/hosting-and-deployment/deployment-with-rsync/) and I worked very well for me.
A simple bash script to generate the website and deploy, all in one line! A simple bash script to generate the website and deploy, all in one line!
```bash ```bash
#!/usr/bin/env bash #!/usr/bin/env bash
hugo && rsync -avz --delete public/ shinobi.thanwer.com:/srv/www/blog/ hugo && rsync -avz --delete public/ shinobi.thanwer.com:/srv/www/blog/

View File

@ -1,7 +1,7 @@
+++ +++
date = '2024-10-19T23:00:41-03:00' date = '2024-10-19T23:00:41-03:00'
title = 'First Post' title = 'First Post'
description = "A simple bolog post about using Hugo as a framework for Thanwer's Blog" description = "A simple blog post about using Hugo as a framework for Thanwer's Blog"
tags = [ tags = [
"webserver", "webserver",
"Hugo", "Hugo",
@ -32,6 +32,7 @@ Você também pode usar o [Github Pages](https://pages.github.com/) ou o [Cloudf
Eu segui o guia oficial do Hugo para fazer o [deploy via rsync](https://gohugo.io/hosting-and-deployment/deployment-with-rsync/) e ele funcionou bem para mim Eu segui o guia oficial do Hugo para fazer o [deploy via rsync](https://gohugo.io/hosting-and-deployment/deployment-with-rsync/) e ele funcionou bem para mim
Um simples script em bash gera o site e faz o deploy, tudo em uma linha! Um simples script em bash gera o site e faz o deploy, tudo em uma linha!
```bash ```bash
#!/usr/bin/env bash #!/usr/bin/env bash
hugo && rsync -avz --delete public/ shinobi.thanwer.com:/srv/www/blog/ hugo && rsync -avz --delete public/ shinobi.thanwer.com:/srv/www/blog/

View File

@ -34,12 +34,14 @@ You can check those well made diagrams by [nerdalert on Github](https://gist.git
Lets start with a quick overview of essential iptables commands: Lets start with a quick overview of essential iptables commands:
### Show current rules: ### Show current rules
```bash ```bash
iptables -L iptables -L
``` ```
### Flush (delete) all existing rules: ### Flush (delete) all existing rules
```bash ```bash
iptables -F iptables -F
``` ```
@ -87,6 +89,7 @@ iptables -P OUTPUT ACCEPT
``` ```
This means any incoming connection will be dropped unless you explicitly allow it. Outgoing traffic, on the other hand, is allowed by default. This means any incoming connection will be dropped unless you explicitly allow it. Outgoing traffic, on the other hand, is allowed by default.
### Step 3: Allow SSH Traffic (Port 22) ### Step 3: Allow SSH Traffic (Port 22)
Youll need SSH access to manage your server, so well allow traffic on port 22. Its important to only allow connections from trusted IP addresses, but for simplicity, well start by allowing all connections on SSH: Youll need SSH access to manage your server, so well allow traffic on port 22. Its important to only allow connections from trusted IP addresses, but for simplicity, well start by allowing all connections on SSH:
@ -151,8 +154,7 @@ iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
This ensures your server can accept responses to any requests it makes. This ensures your server can accept responses to any requests it makes.
### Step 8: Don't forget IPv6 rules
### Step 8: Don't forget IPv6 rules!
For IPv6, the syntax is the same, you mostly need to change the command from `iptables` to `ip6tables` For IPv6, the syntax is the same, you mostly need to change the command from `iptables` to `ip6tables`

View File

@ -36,11 +36,13 @@ Recomendo que voce inicie por esses diagramas muito bem feitos nesse gist do [ne
Vamos começar com uma overview dos comandos essenciais do iptables: Vamos começar com uma overview dos comandos essenciais do iptables:
### Mostrar regras atuais ### Mostrar regras atuais
```bash ```bash
iptables -L iptables -L
``` ```
### Deletar regras atuais ### Deletar regras atuais
```bash ```bash
iptables -F iptables -F
``` ```
@ -153,7 +155,7 @@ iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
Isso garante que o servidor aceite respostas para requisições que ele mesmo fez. Isso garante que o servidor aceite respostas para requisições que ele mesmo fez.
### Passo 8: Não esqueça o IPv6! ### Passo 8: Não esqueça o IPv6
Para IPv6, a sintaxe é a mesma, voce apenas precisa mudar o comando de `iptables` para `ip6tables` Para IPv6, a sintaxe é a mesma, voce apenas precisa mudar o comando de `iptables` para `ip6tables`

View File

@ -12,8 +12,8 @@ I heard too many times a work colleague, or a third-party vendor telling me "the
You can use websites to try to test for open ports, a quick Google search should yield you a couple good results, but sometimes that is not enough. You can use websites to try to test for open ports, a quick Google search should yield you a couple good results, but sometimes that is not enough.
## The problem ## The problem
Let's suppose you followed my other post about [restricting source address with iptables]({{< ref "/posts/iptables-basics" >}} "Iptables basics"), in this case those random web tools won't help you, so you use nmap! Let's suppose you followed my other post about [restricting source address with iptables]({{< ref "/posts/iptables-basics" >}} "Iptables basics"), in this case those random web tools won't help you, so you use nmap!
I will make a post about nmap in the future, for now let's use it in a very simple way to check for an open port: I will make a post about nmap in the future, for now let's use it in a very simple way to check for an open port:
@ -47,8 +47,9 @@ Netcat is a very simple, but very powerful tool for those cases. With that, you
### Installing ### Installing
The installation is very simple! On Debian systems you can do it with the command: The installation is very simple! On Debian systems you can do it with the command:
```bash ```bash
$ sudo apt install netcat sudo apt install netcat
``` ```
### Using the tool ### Using the tool
@ -66,15 +67,18 @@ The main options we need to use are:
#### Check for network communication #### Check for network communication
Listen on port 2000: Listen on port 2000:
```bash ```bash
$ nc -l 2000 nc -l 2000
``` ```
This starts a server which listens on port 2000. This starts a server which listens on port 2000.
Now let's open another terminal and connect a client to this port: Now let's open another terminal and connect a client to this port:
```bash ```bash
$ nc localhost 2000 nc localhost 2000
``` ```
@ -91,12 +95,13 @@ Netcat can be used to send and receive files between two hosts over a network. T
On the receivers end: On the receivers end:
```bash ```bash
$ nc -l -p 1234 > received_file.txt nc -l -p 1234 > received_file.txt
``` ```
On the senders end, assuming that 192.0.0.2 is the receiving server: On the senders end, assuming that 192.0.0.2 is the receiving server:
```bash ```bash
$ nc 192.0.0.2 -p 1234 < file_to_send.txt nc 192.0.0.2 -p 1234 < file_to_send.txt
``` ```
This can be useful for transferring a log file for example. This can be useful for transferring a log file for example.
@ -104,6 +109,7 @@ This can be useful for transferring a log file for example.
#### Port scan #### Port scan
nc can be used as a simpler alternative to nmap: nc can be used as a simpler alternative to nmap:
```bash ```bash
$ nc -z host.example.com 20-30 $ nc -z host.example.com 20-30
Connection to host.example.com 22 port [tcp/ssh] succeeded! Connection to host.example.com 22 port [tcp/ssh] succeeded!

View File

@ -14,6 +14,7 @@ Já ouvi muitas vezes de algum colega de trabalho, ou de algum prestador de serv
Voce pode usar testes online para verificar as portas abertas, uma rápida pesquisa no Google vai te trazer resultados bons, porem nem sempre isso é o suficiente. Voce pode usar testes online para verificar as portas abertas, uma rápida pesquisa no Google vai te trazer resultados bons, porem nem sempre isso é o suficiente.
## O problema ## O problema
Vamos supor que voce seguiu meu outro post sobre [restringir por endereço de origem no iptables]({{< ref "/posts/iptables-basics" >}} "Iptables basics"), nesse caso essas ferramentas aleatórias não vão lhe ajudar, então voce pode usar o nmap! Vamos supor que voce seguiu meu outro post sobre [restringir por endereço de origem no iptables]({{< ref "/posts/iptables-basics" >}} "Iptables basics"), nesse caso essas ferramentas aleatórias não vão lhe ajudar, então voce pode usar o nmap!
Farei um post sobre o nmap no futuro, por enquanto vamos usa-lo de forma bem simples para verificar se uma porta está aberta: Farei um post sobre o nmap no futuro, por enquanto vamos usa-lo de forma bem simples para verificar se uma porta está aberta:
@ -47,8 +48,9 @@ O netcat é uma ferramenta super simples, porem muito poderosa para esses casos.
### Instalação ### Instalação
A instalação é muito simples! Em um sistema Debian basta executar o seguinte comando: A instalação é muito simples! Em um sistema Debian basta executar o seguinte comando:
```bash ```bash
$ sudo apt install netcat sudo apt install netcat
``` ```
### Usando a ferramenta ### Usando a ferramenta
@ -66,15 +68,18 @@ Os principais argumentos que precisamos são:
#### Testar comunicação de rede #### Testar comunicação de rede
Escutar na porta 2000: Escutar na porta 2000:
```bash ```bash
$ nc -l 2000 nc -l 2000
``` ```
Isso inicia um serviço na porta 2000. Isso inicia um serviço na porta 2000.
Agora vamos abrir outro terminal e conectar um cliente a essa porta: Agora vamos abrir outro terminal e conectar um cliente a essa porta:
```bash ```bash
$ nc localhost 2000 nc localhost 2000
``` ```
@ -91,12 +96,13 @@ O netcat tambem pode ser usado para transferir arquivos entre dois hosts, isso
No receptor: No receptor:
```bash ```bash
$ nc -l -p 1234 > arquivo_recebido.txt nc -l -p 1234 > arquivo_recebido.txt
``` ```
No transmissor, assumindo que o receptor seja o IP 192.0.0.2:: No transmissor, assumindo que o receptor seja o IP 192.0.0.2::
```bash ```bash
$ nc 192.0.0.2 -p 1234 < arquivo_para_enviar.txt nc 192.0.0.2 -p 1234 < arquivo_para_enviar.txt
``` ```
Isso pode ser util para transferir um arquivo de log, por exemplo. Isso pode ser util para transferir um arquivo de log, por exemplo.
@ -104,6 +110,7 @@ Isso pode ser util para transferir um arquivo de log, por exemplo.
#### Port scac #### Port scac
nc pode ser usado como uma alternativa "mais barata" para o nmap: nc pode ser usado como uma alternativa "mais barata" para o nmap:
```bash ```bash
$ nc -z host.example.com 20-30 $ nc -z host.example.com 20-30
Connection to host.example.com 22 port [tcp/ssh] succeeded! Connection to host.example.com 22 port [tcp/ssh] succeeded!

View File

@ -55,6 +55,7 @@ When you finish those tunings, check with the [ssh-audit tool](https://github.co
On top of iptables rules, the `/etc/ssh/sshd_config` file can apply restrictions based on users, groups and/or source IPs. On top of iptables rules, the `/etc/ssh/sshd_config` file can apply restrictions based on users, groups and/or source IPs.
For example, to whitelist by IP, you can add the following: For example, to whitelist by IP, you can add the following:
```bash ```bash
# Restrict to a specific IP address # Restrict to a specific IP address
AllowUsers *@192.0.0.2 AllowUsers *@192.0.0.2

View File

@ -56,6 +56,7 @@ Quando voce terminar, verifique com a ferramenta [ssh-audit](https://github.com/
Além das regras do iptables, o arquivo `/etc/ssh/sshd_config` pode aplicar restrições baseadas em usuário, grupo e/ou IP de origem. Além das regras do iptables, o arquivo `/etc/ssh/sshd_config` pode aplicar restrições baseadas em usuário, grupo e/ou IP de origem.
Por exemplo, para permitir conexões por IP, voce pode adicionar conforme os seguintes exemplos: Por exemplo, para permitir conexões por IP, voce pode adicionar conforme os seguintes exemplos:
```bash ```bash
# Restrict to a specific IP address # Restrict to a specific IP address
AllowUsers *@192.0.0.2 AllowUsers *@192.0.0.2