SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Segurança - Acesso Remoto

   Leandro Silva
   Leandro Purificacão
   David Wallace
   Tiago Cruz - http://everlinux.com
   Jeferson

   Níve: Intermediário
   Pre-requisitos: Básico em Inglês, protocolos de
    rede e universo Unix.
Tópicos

   Sniffer de senhas em plain text;
   Ataque de brute-force no SSH;
   Proteção: Firewall, IPS e/ou TCP Wrappers;
   Segurança básica no sshd_config;
   Chaves RSA/DSA para acesso remoto;
   SSH buscando chaves no LDAP;
   Porque previnir o acesso: Fork Bomb
Segurança - Acesso Remoto

   Telnet não tem criptografia, um atacante pode
     pegar a sua senha usando um sniffer
   OpenSSH criptografa a comunicação
   Presente em todos os Unixes (*BSD, Solaris,
     Linux, AIX...) e também nos roteadores
   Porém, uma máquina comprometida com um
     keylogger pode pegar a senha do
     administrador
Capturando senhas sem
criptografia (ex: telnet e
          FTP)
”Snifando” senhas: dsniff
Capturando senhas: ettercap
Ataques de força-bruta
    contra o SSH
SSH é sempre visado
...
Aug 31 23:21:28 localhost sshd[4560]: Illegal user admin from ::ffff:206.113.121.118
Aug 31 23:21:31 localhost sshd[4562]: Illegal user test from ::ffff:206.113.121.118
Aug 31 23:21:36 localhost sshd[4564]: Illegal user guest from ::ffff:206.113.121.118
Aug 31 23:21:39 localhost sshd[4566]: Illegal user webmaster from ::ffff:206.113.121.118
Aug 31 23:21:44 localhost sshd[4568]: Illegal user mysql from ::ffff:206.113.121.118
Aug 31 23:21:47 localhost sshd[4570]: Illegal user oracle from ::ffff:206.113.121.118
Aug 31 23:21:49 localhost sshd[4572]: Illegal user library from ::ffff:206.113.121.118
Aug 31 23:21:52 localhost sshd[4574]: Illegal user info from ::ffff:206.113.121.118
Aug 31 23:21:55 localhost sshd[4576]: Illegal user shell from ::ffff:206.113.121.118
Aug 31 23:21:59 localhost sshd[4578]: Illegal user linux from ::ffff:206.113.121.118
Aug 31 23:22:01 localhost sshd[4580]: Illegal user unix from ::ffff:206.113.121.118
Aug 31 23:22:05 localhost sshd[4582]: Illegal user webadmin from ::ffff:206.113.121.118
Aug 31 23:22:08 localhost sshd[4584]: Illegal user ftp from ::ffff:206.113.121.118
Aug 31 23:22:12 localhost sshd[4586]: Illegal user test from ::ffff:206.113.121.118
Aug 31 23:22:18 localhost sshd[4590]: Illegal user admin from ::ffff:206.113.121.118
Aug 31 23:22:21 localhost sshd[4592]: Illegal user guest from ::ffff:206.113.121.118
Aug 31 23:22:25 localhost sshd[4594]: Illegal user master from ::ffff:206.113.121.118
Aug 31 23:22:28 localhost sshd[4596]: Illegal user apache from ::ffff:206.113.121.118
Aug 31 23:22:33 localhost sshd[4598]: User root not allowed because not listed in AllowUsers
Aug 31 23:22:37 localhost sshd[4600]: User root not allowed because not listed in AllowUsers
...
ssh-brute force caseiro
Gerando senhas aleatórias
$ john -stdout -incremental
1952
sammy
stark
start
stack
stace
steve
steen
steet
samers

$ dd if=/dev/random ibs=6 count=1 2> /dev/null | mimencode
HKxWMgRD

$ pwgen
xaif7Nah lie1Ieth gook1aiD ur1Ahthi Noo3eo5M Baz4aeBu
ohMeek9a chiex7Iu Sipe0Eiv iDaighu7 Quuz3una AhB0echi
go0Um7yu azo6Tiel Thee5aWe Xo8jaim5 caif0ieN HuaWie9n
Proteções contra ataques
     de força-bruta
Básico /etc/ssh/sshd_config
# Grupos com acesso via SSH
AllowGroups sysadmin suporte
AllowUsers tcruz maria

# Logar direto como root é suicídio:
PermitRootLogin no

# Mudar a porta padrão mata alguns script kiddies:
Port 2258

   tcruz@tuxkiller:~$ ssh -p 2258 192.168.15.129


# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

   tcruz@tuxkiller:~$ ssh userteste@192.168.15.129
   Permission denied (publickey).
IDS/IPS - OSSEC
Brute Force - Mitigação
- No servidor a ser protegido:

# iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state 
NEW -m recent –set

# iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state 
NEW -m recent --update --seconds 60 --hitcount 4 -j DROP

# iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT

- Teste na estação ”atacante”:

$ for i in `seq 1 10` ; do echo 'exit' | nc 192.168.1.1 22 ; done
192.168.15.129 22 ; done
SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1
Protocol mismatch.
SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1
Protocol mismatch.
SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1
Protocol mismatch.
SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1
Protocol mismatch.
^C
TCP Wrappers
O pacote TCP Wrappers (tcp_wrappers) faz parte da instalação padrão e
oferece controle de de acesso a serviços de rede baseado no host. O
componente mais importante do pacote é a biblioteca /usr/lib/libwrap.a.

$ cat /etc/hosts.deny
sshd: ALL



$ cat /etc/hosts.allow
sshd: 10.10.1.0/255.255.255.0 10.10.2.240/255.255.255.240


$ cat /etc/hosts.allow
sshd: 200.222.222.55 200.222.222.94: ALLOW
Sem senha: chaves
públicas e privadas no
     acesso SSH
Chaves de Criptografia
tiago@cliente:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/tiago/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/tiago/.ssh/id_dsa.
Your public key has been saved in /home/tiago/.ssh/id_dsa.pub.
The key fingerprint is:
46:de:5d:e5:52:2a:8b:03:2d:75:e9:fd:fa:e6:b7:26 tiago@tuxkiller

tiago@cliente:~$ ssh-copy-id -i /home/tiago/.ssh/id_dsa
id_dsa      id_dsa.pub

tiago@cliente:~$ ssh-copy-id -i ~/.ssh/id_dsa.pub 192.168.15.129
tiago@192.168.15.129 password:
Now try logging into the machine, with "ssh '192.168.15.129'", and
check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
Copiando manualmente
                   Caso você não tenha o ssh-copy-id:
root@server:~# cat /home/tiago/.ssh/authorized_keys
ssh-dss
AAAAB3NzaC1kc3MAAACBANbDleaS26kY1Wukd0LiKhhzdxfG1dZC0EObXp8hIrK+xsNy
g6dLRFPbbDYtZGJ06M5/SIqPCFoeLqHIMVroIPzZ
1gDMSdOesSbJMYkTgytJQltG2RHBp9OdTd7sp9xldQj93IAvAPTzFoUUtq9RaBzJJZbu
2ZK9Jqg8Spc/lT8JAAAAFQD5kI62O8bqAS1lFqmf1kklnskl
SQAAAIA7Ff28UoKWAoECh0WFE5zqxvUPW+1Qz9sxCXjmXfDIwt2jBgyrGcDrJiyRffqQ
kWEAlgqPZPQ6HQ68sFS052CjYU/5HlLbh2lXaiFBEvYpRqPg
gnqbMgOcI2lBom1LSYwTCsbb61OZBKE9CC2KptGJdzXesaO4eo8ARzzOolnjUgAAAIEA
gBdKmuccKaMtUJPapa3Q7OJxPq5lHnOXNUVRwkavVjLd7MB/
OWJI1FBOcExb9nGuVRVB1DB1VxYjz1QEa9KxNyx8eZQTtvA64McyjUuWJuSS1ld+DqJG
TaeVvYDPICkgPK9HlDOvJUZmFHiUdwbn/BLUWAR/Bg106nkn
5s8WnQg= tiago@tuxkiller

root@server:~# ls -l /home/tiago/.ssh/authorized_keys
-rw------- 1 tiago tiago 605 2009-06-17 15:06 ~/.ssh/authorized_keys

root@server:~# ls -ld /home/tiago/.ssh
drwx------ 2 tiago tiago 4096 2009-06-17 15:06 /home/tiago/.ssh
Logs de acesso
   # Log Antes:
   Jun 17 15:06:15 ubuntu sshd[2938]:
    Accepted password for tiago from
    192.168.15.1 port 32813 ssh2


   # Log Depois:
   Jun 17 15:28:26 ubuntu sshd[3184]:
    Accepted publickey for tiago from
    192.168.15.1 port 60079 ssh2
Acessando sem senha
SSH com as chaves
públicas centralizadas em
          LDAP
SSH buscando chave no LDAP
OpenSSH-LPK

The OpenSSH LDAP Public Key patch provides an easy way of centralizing
strong user authentication by using an LDAP
server for retrieving public keys instead of ~/.ssh/authorized_keys.

=> http://code.google.com/p/openssh-lpk/


No Servidor LDAP - slapd.conf:

include     /etc/openldap/schema/openssh-lpk_openldap.schema


Nos clientes - sshd_config:

   UseLPK yes
   LpkLdapConf /etc/ldap.conf
Busca no LDAP de exemplo
[root@testmachine ~]# ldapsearch -x uid=tcruz
# tcruz, People, empresa.com.br
dn: uid=tcruz,ou=People,dc=empresa,dc=com,dc=br
gecos: Tiago Cruz
loginShell: /bin/bash
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
objectClass: ldapPublicKey
uid: tcruz
uidNumber: 1002
cn: tcruz
homeDirectory: /home/tcruz
SshPublicKey:: ssh-dss
c3NoLWRzcyBBQUFBQjNOemFDMWtjM01BQUFDQkFPTDF0alppRmdXdEdtMkJ2UWx
9DOHJKNVYwaE90R3J3QUFBSUJIZVlzWnJGR2xITG4xblVGUTBTSXB6bzlnNG90RmFje
gidNumber: 1010
shadowLastChange: 14196

# search result
search: 2
result: 0 Success
Um bom motivo para deixar
 o atacante longe da shell
Fork Bomb
Um processo que cria várias cópias dele mesmo recursivamente com o objetivo de
acabar com os recursos do servidor – DOS ou denial of service

A fork bomb using the Microsoft Windows (any version) batch language:
%0|%0

In poetic Perl:
fork while fork

Using Python:
import os
while True:
      os.fork()

Or in C or C++:
#include <unistd.h>

int main(void)
{
  while(1)
    fork();
  return 0;
}
Fork Bomb
tcruz@ubuntu:~$ ulimit -a | grep proce
max user processes              (-u) unlimited

tcruz@ubuntu:~$ ulimit -u 1024
tcruz@ubuntu:~$ ulimit -a | grep proce
max user processes              (-u) 1024

tcruz@ubuntu:~$ :(){ :|:& };:
[1] 3755

tcruz@ubuntu:~$ -bash: fork: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable

[1]+   Terminated               : | :

              Nota: Utilizado nesse teste uma VM com 512 GB de RAM
Referências


   http://everlinux.com/blog
   http://www.linux.com/archive/feature/61061
   http://code.google.com/p/openssh-lpk/
   http://en.wikipedia.org/wiki/Fork_bomb
   http://www.redhat.com/docs/manuals/enterprise/RH

Mais conteúdo relacionado

Mais procurados

Ssh and sshfp dns records v04
Ssh and sshfp dns records v04Ssh and sshfp dns records v04
Ssh and sshfp dns records v04Bob Novas
 
Creating "Secure" PHP applications, Part 2, Server Hardening
Creating "Secure" PHP applications, Part 2, Server HardeningCreating "Secure" PHP applications, Part 2, Server Hardening
Creating "Secure" PHP applications, Part 2, Server Hardeningarchwisp
 
Fail2ban - the system security for green hand -on linux os
Fail2ban  - the system security  for green hand -on linux osFail2ban  - the system security  for green hand -on linux os
Fail2ban - the system security for green hand -on linux osSamina Fu (Shan Jung Fu)
 
[4] 아두이노와 인터넷
[4] 아두이노와 인터넷[4] 아두이노와 인터넷
[4] 아두이노와 인터넷Chiwon Song
 
Linux 系統管理與安全:進階系統管理系統防駭與資訊安全
Linux 系統管理與安全:進階系統管理系統防駭與資訊安全Linux 系統管理與安全:進階系統管理系統防駭與資訊安全
Linux 系統管理與安全:進階系統管理系統防駭與資訊安全維泰 蔡
 
Configuring ssh on switch
Configuring ssh on switchConfiguring ssh on switch
Configuring ssh on switchtcpipguru
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
Linux 系統管理與安全:系統防駭與資訊安全
Linux 系統管理與安全:系統防駭與資訊安全Linux 系統管理與安全:系統防駭與資訊安全
Linux 系統管理與安全:系統防駭與資訊安全維泰 蔡
 
Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識維泰 蔡
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filterGiovanni Bechis
 
Analysis of Compromised Linux Server
Analysis of Compromised Linux ServerAnalysis of Compromised Linux Server
Analysis of Compromised Linux Serveranandvaidya
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by pythonwonyong hwang
 
Nmap not only a port scanner by ravi rajput comexpo security awareness meet
Nmap not only a port scanner by ravi rajput comexpo security awareness meet Nmap not only a port scanner by ravi rajput comexpo security awareness meet
Nmap not only a port scanner by ravi rajput comexpo security awareness meet Ravi Rajput
 

Mais procurados (19)

Ssh cookbook
Ssh cookbookSsh cookbook
Ssh cookbook
 
Ssh and sshfp dns records v04
Ssh and sshfp dns records v04Ssh and sshfp dns records v04
Ssh and sshfp dns records v04
 
Creating "Secure" PHP applications, Part 2, Server Hardening
Creating "Secure" PHP applications, Part 2, Server HardeningCreating "Secure" PHP applications, Part 2, Server Hardening
Creating "Secure" PHP applications, Part 2, Server Hardening
 
Fail2ban - the system security for green hand -on linux os
Fail2ban  - the system security  for green hand -on linux osFail2ban  - the system security  for green hand -on linux os
Fail2ban - the system security for green hand -on linux os
 
Metasploitable
MetasploitableMetasploitable
Metasploitable
 
Proxy arp
Proxy arpProxy arp
Proxy arp
 
[4] 아두이노와 인터넷
[4] 아두이노와 인터넷[4] 아두이노와 인터넷
[4] 아두이노와 인터넷
 
Ethical hacking with Python tools
Ethical hacking with Python toolsEthical hacking with Python tools
Ethical hacking with Python tools
 
Linux 系統管理與安全:進階系統管理系統防駭與資訊安全
Linux 系統管理與安全:進階系統管理系統防駭與資訊安全Linux 系統管理與安全:進階系統管理系統防駭與資訊安全
Linux 系統管理與安全:進階系統管理系統防駭與資訊安全
 
Configuring ssh on switch
Configuring ssh on switchConfiguring ssh on switch
Configuring ssh on switch
 
Containers for sysadmins
Containers for sysadminsContainers for sysadmins
Containers for sysadmins
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Linux 系統管理與安全:系統防駭與資訊安全
Linux 系統管理與安全:系統防駭與資訊安全Linux 系統管理與安全:系統防駭與資訊安全
Linux 系統管理與安全:系統防駭與資訊安全
 
Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識Linux 系統管理與安全:基本 Linux 系統知識
Linux 系統管理與安全:基本 Linux 系統知識
 
R-House (LSRC)
R-House (LSRC)R-House (LSRC)
R-House (LSRC)
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filter
 
Analysis of Compromised Linux Server
Analysis of Compromised Linux ServerAnalysis of Compromised Linux Server
Analysis of Compromised Linux Server
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by python
 
Nmap not only a port scanner by ravi rajput comexpo security awareness meet
Nmap not only a port scanner by ravi rajput comexpo security awareness meet Nmap not only a port scanner by ravi rajput comexpo security awareness meet
Nmap not only a port scanner by ravi rajput comexpo security awareness meet
 

Semelhante a SSH: Seguranca no Acesso Remoto

An introduction to SSH
An introduction to SSHAn introduction to SSH
An introduction to SSHnussbauml
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commandsHanan Nmr
 
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform EnviornmentNagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform EnviornmentNagios
 
Triangle OpenStack meetup 09 2013
Triangle OpenStack meetup 09 2013Triangle OpenStack meetup 09 2013
Triangle OpenStack meetup 09 2013Dan Radez
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHwebelement
 
Sudo – Giving access while staying in control
Sudo – Giving access while staying in controlSudo – Giving access while staying in control
Sudo – Giving access while staying in controlAll Things Open
 
Passbolt Introduction and Usage for secret managment
Passbolt Introduction and Usage for secret managmentPassbolt Introduction and Usage for secret managment
Passbolt Introduction and Usage for secret managmentThierry Gayet
 
Issuing temporary credentials for my sql using hashicorp vault
Issuing temporary credentials for my sql using hashicorp vaultIssuing temporary credentials for my sql using hashicorp vault
Issuing temporary credentials for my sql using hashicorp vaultOlinData
 
SSH for pen-testers
SSH for pen-testersSSH for pen-testers
SSH for pen-testersE D Williams
 
Tatu: ssh as a service
Tatu: ssh as a serviceTatu: ssh as a service
Tatu: ssh as a servicePino deCandia
 

Semelhante a SSH: Seguranca no Acesso Remoto (20)

Da APK al Golden Ticket
Da APK al Golden TicketDa APK al Golden Ticket
Da APK al Golden Ticket
 
An introduction to SSH
An introduction to SSHAn introduction to SSH
An introduction to SSH
 
Linux Network commands
Linux Network commandsLinux Network commands
Linux Network commands
 
Ssh cookbook v2
Ssh cookbook v2Ssh cookbook v2
Ssh cookbook v2
 
Linuxserver harden
Linuxserver hardenLinuxserver harden
Linuxserver harden
 
Intro to SSH
Intro to SSHIntro to SSH
Intro to SSH
 
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform EnviornmentNagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
Nagios Conference 2013 - Leland Lammert - Nagios in a Multi-Platform Enviornment
 
Triangle OpenStack meetup 09 2013
Triangle OpenStack meetup 09 2013Triangle OpenStack meetup 09 2013
Triangle OpenStack meetup 09 2013
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
Hacking the swisscom modem
Hacking the swisscom modemHacking the swisscom modem
Hacking the swisscom modem
 
tutorial-ssh.pdf
tutorial-ssh.pdftutorial-ssh.pdf
tutorial-ssh.pdf
 
Sudo – Giving access while staying in control
Sudo – Giving access while staying in controlSudo – Giving access while staying in control
Sudo – Giving access while staying in control
 
Passbolt Introduction and Usage for secret managment
Passbolt Introduction and Usage for secret managmentPassbolt Introduction and Usage for secret managment
Passbolt Introduction and Usage for secret managment
 
Essential security for linux servers
Essential security for linux serversEssential security for linux servers
Essential security for linux servers
 
Issuing temporary credentials for my sql using hashicorp vault
Issuing temporary credentials for my sql using hashicorp vaultIssuing temporary credentials for my sql using hashicorp vault
Issuing temporary credentials for my sql using hashicorp vault
 
Linux Hardening - nullhyd
Linux Hardening - nullhydLinux Hardening - nullhyd
Linux Hardening - nullhyd
 
SSH for pen-testers
SSH for pen-testersSSH for pen-testers
SSH for pen-testers
 
Tatu: ssh as a service
Tatu: ssh as a serviceTatu: ssh as a service
Tatu: ssh as a service
 
Linux class 9 15 oct 2021-5
Linux class 9   15 oct 2021-5Linux class 9   15 oct 2021-5
Linux class 9 15 oct 2021-5
 

Último

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 

SSH: Seguranca no Acesso Remoto

  • 1. Segurança - Acesso Remoto  Leandro Silva  Leandro Purificacão  David Wallace  Tiago Cruz - http://everlinux.com  Jeferson  Níve: Intermediário  Pre-requisitos: Básico em Inglês, protocolos de rede e universo Unix.
  • 2. Tópicos  Sniffer de senhas em plain text;  Ataque de brute-force no SSH;  Proteção: Firewall, IPS e/ou TCP Wrappers;  Segurança básica no sshd_config;  Chaves RSA/DSA para acesso remoto;  SSH buscando chaves no LDAP;  Porque previnir o acesso: Fork Bomb
  • 3. Segurança - Acesso Remoto  Telnet não tem criptografia, um atacante pode pegar a sua senha usando um sniffer  OpenSSH criptografa a comunicação  Presente em todos os Unixes (*BSD, Solaris, Linux, AIX...) e também nos roteadores  Porém, uma máquina comprometida com um keylogger pode pegar a senha do administrador
  • 7. Ataques de força-bruta contra o SSH
  • 8. SSH é sempre visado ... Aug 31 23:21:28 localhost sshd[4560]: Illegal user admin from ::ffff:206.113.121.118 Aug 31 23:21:31 localhost sshd[4562]: Illegal user test from ::ffff:206.113.121.118 Aug 31 23:21:36 localhost sshd[4564]: Illegal user guest from ::ffff:206.113.121.118 Aug 31 23:21:39 localhost sshd[4566]: Illegal user webmaster from ::ffff:206.113.121.118 Aug 31 23:21:44 localhost sshd[4568]: Illegal user mysql from ::ffff:206.113.121.118 Aug 31 23:21:47 localhost sshd[4570]: Illegal user oracle from ::ffff:206.113.121.118 Aug 31 23:21:49 localhost sshd[4572]: Illegal user library from ::ffff:206.113.121.118 Aug 31 23:21:52 localhost sshd[4574]: Illegal user info from ::ffff:206.113.121.118 Aug 31 23:21:55 localhost sshd[4576]: Illegal user shell from ::ffff:206.113.121.118 Aug 31 23:21:59 localhost sshd[4578]: Illegal user linux from ::ffff:206.113.121.118 Aug 31 23:22:01 localhost sshd[4580]: Illegal user unix from ::ffff:206.113.121.118 Aug 31 23:22:05 localhost sshd[4582]: Illegal user webadmin from ::ffff:206.113.121.118 Aug 31 23:22:08 localhost sshd[4584]: Illegal user ftp from ::ffff:206.113.121.118 Aug 31 23:22:12 localhost sshd[4586]: Illegal user test from ::ffff:206.113.121.118 Aug 31 23:22:18 localhost sshd[4590]: Illegal user admin from ::ffff:206.113.121.118 Aug 31 23:22:21 localhost sshd[4592]: Illegal user guest from ::ffff:206.113.121.118 Aug 31 23:22:25 localhost sshd[4594]: Illegal user master from ::ffff:206.113.121.118 Aug 31 23:22:28 localhost sshd[4596]: Illegal user apache from ::ffff:206.113.121.118 Aug 31 23:22:33 localhost sshd[4598]: User root not allowed because not listed in AllowUsers Aug 31 23:22:37 localhost sshd[4600]: User root not allowed because not listed in AllowUsers ...
  • 10. Gerando senhas aleatórias $ john -stdout -incremental 1952 sammy stark start stack stace steve steen steet samers $ dd if=/dev/random ibs=6 count=1 2> /dev/null | mimencode HKxWMgRD $ pwgen xaif7Nah lie1Ieth gook1aiD ur1Ahthi Noo3eo5M Baz4aeBu ohMeek9a chiex7Iu Sipe0Eiv iDaighu7 Quuz3una AhB0echi go0Um7yu azo6Tiel Thee5aWe Xo8jaim5 caif0ieN HuaWie9n
  • 11. Proteções contra ataques de força-bruta
  • 12. Básico /etc/ssh/sshd_config # Grupos com acesso via SSH AllowGroups sysadmin suporte AllowUsers tcruz maria # Logar direto como root é suicídio: PermitRootLogin no # Mudar a porta padrão mata alguns script kiddies: Port 2258 tcruz@tuxkiller:~$ ssh -p 2258 192.168.15.129 # Change to no to disable tunnelled clear text passwords PasswordAuthentication no tcruz@tuxkiller:~$ ssh userteste@192.168.15.129 Permission denied (publickey).
  • 14. Brute Force - Mitigação - No servidor a ser protegido: # iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent –set # iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j DROP # iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT - Teste na estação ”atacante”: $ for i in `seq 1 10` ; do echo 'exit' | nc 192.168.1.1 22 ; done 192.168.15.129 22 ; done SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1 Protocol mismatch. SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1 Protocol mismatch. SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1 Protocol mismatch. SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1 Protocol mismatch. ^C
  • 15. TCP Wrappers O pacote TCP Wrappers (tcp_wrappers) faz parte da instalação padrão e oferece controle de de acesso a serviços de rede baseado no host. O componente mais importante do pacote é a biblioteca /usr/lib/libwrap.a. $ cat /etc/hosts.deny sshd: ALL $ cat /etc/hosts.allow sshd: 10.10.1.0/255.255.255.0 10.10.2.240/255.255.255.240 $ cat /etc/hosts.allow sshd: 200.222.222.55 200.222.222.94: ALLOW
  • 16. Sem senha: chaves públicas e privadas no acesso SSH
  • 17. Chaves de Criptografia tiago@cliente:~$ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/tiago/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/tiago/.ssh/id_dsa. Your public key has been saved in /home/tiago/.ssh/id_dsa.pub. The key fingerprint is: 46:de:5d:e5:52:2a:8b:03:2d:75:e9:fd:fa:e6:b7:26 tiago@tuxkiller tiago@cliente:~$ ssh-copy-id -i /home/tiago/.ssh/id_dsa id_dsa id_dsa.pub tiago@cliente:~$ ssh-copy-id -i ~/.ssh/id_dsa.pub 192.168.15.129 tiago@192.168.15.129 password: Now try logging into the machine, with "ssh '192.168.15.129'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting.
  • 18. Copiando manualmente Caso você não tenha o ssh-copy-id: root@server:~# cat /home/tiago/.ssh/authorized_keys ssh-dss AAAAB3NzaC1kc3MAAACBANbDleaS26kY1Wukd0LiKhhzdxfG1dZC0EObXp8hIrK+xsNy g6dLRFPbbDYtZGJ06M5/SIqPCFoeLqHIMVroIPzZ 1gDMSdOesSbJMYkTgytJQltG2RHBp9OdTd7sp9xldQj93IAvAPTzFoUUtq9RaBzJJZbu 2ZK9Jqg8Spc/lT8JAAAAFQD5kI62O8bqAS1lFqmf1kklnskl SQAAAIA7Ff28UoKWAoECh0WFE5zqxvUPW+1Qz9sxCXjmXfDIwt2jBgyrGcDrJiyRffqQ kWEAlgqPZPQ6HQ68sFS052CjYU/5HlLbh2lXaiFBEvYpRqPg gnqbMgOcI2lBom1LSYwTCsbb61OZBKE9CC2KptGJdzXesaO4eo8ARzzOolnjUgAAAIEA gBdKmuccKaMtUJPapa3Q7OJxPq5lHnOXNUVRwkavVjLd7MB/ OWJI1FBOcExb9nGuVRVB1DB1VxYjz1QEa9KxNyx8eZQTtvA64McyjUuWJuSS1ld+DqJG TaeVvYDPICkgPK9HlDOvJUZmFHiUdwbn/BLUWAR/Bg106nkn 5s8WnQg= tiago@tuxkiller root@server:~# ls -l /home/tiago/.ssh/authorized_keys -rw------- 1 tiago tiago 605 2009-06-17 15:06 ~/.ssh/authorized_keys root@server:~# ls -ld /home/tiago/.ssh drwx------ 2 tiago tiago 4096 2009-06-17 15:06 /home/tiago/.ssh
  • 19. Logs de acesso  # Log Antes:  Jun 17 15:06:15 ubuntu sshd[2938]: Accepted password for tiago from 192.168.15.1 port 32813 ssh2  # Log Depois:  Jun 17 15:28:26 ubuntu sshd[3184]: Accepted publickey for tiago from 192.168.15.1 port 60079 ssh2
  • 21. SSH com as chaves públicas centralizadas em LDAP
  • 22. SSH buscando chave no LDAP OpenSSH-LPK The OpenSSH LDAP Public Key patch provides an easy way of centralizing strong user authentication by using an LDAP server for retrieving public keys instead of ~/.ssh/authorized_keys. => http://code.google.com/p/openssh-lpk/ No Servidor LDAP - slapd.conf: include /etc/openldap/schema/openssh-lpk_openldap.schema Nos clientes - sshd_config: UseLPK yes LpkLdapConf /etc/ldap.conf
  • 23. Busca no LDAP de exemplo [root@testmachine ~]# ldapsearch -x uid=tcruz # tcruz, People, empresa.com.br dn: uid=tcruz,ou=People,dc=empresa,dc=com,dc=br gecos: Tiago Cruz loginShell: /bin/bash objectClass: account objectClass: posixAccount objectClass: top objectClass: shadowAccount objectClass: ldapPublicKey uid: tcruz uidNumber: 1002 cn: tcruz homeDirectory: /home/tcruz SshPublicKey:: ssh-dss c3NoLWRzcyBBQUFBQjNOemFDMWtjM01BQUFDQkFPTDF0alppRmdXdEdtMkJ2UWx 9DOHJKNVYwaE90R3J3QUFBSUJIZVlzWnJGR2xITG4xblVGUTBTSXB6bzlnNG90RmFje gidNumber: 1010 shadowLastChange: 14196 # search result search: 2 result: 0 Success
  • 24. Um bom motivo para deixar o atacante longe da shell
  • 25. Fork Bomb Um processo que cria várias cópias dele mesmo recursivamente com o objetivo de acabar com os recursos do servidor – DOS ou denial of service A fork bomb using the Microsoft Windows (any version) batch language: %0|%0 In poetic Perl: fork while fork Using Python: import os while True: os.fork() Or in C or C++: #include <unistd.h> int main(void) { while(1) fork(); return 0; }
  • 26. Fork Bomb tcruz@ubuntu:~$ ulimit -a | grep proce max user processes (-u) unlimited tcruz@ubuntu:~$ ulimit -u 1024 tcruz@ubuntu:~$ ulimit -a | grep proce max user processes (-u) 1024 tcruz@ubuntu:~$ :(){ :|:& };: [1] 3755 tcruz@ubuntu:~$ -bash: fork: Resource temporarily unavailable -bash: fork: Resource temporarily unavailable -bash: fork: Resource temporarily unavailable -bash: fork: Resource temporarily unavailable -bash: fork: Resource temporarily unavailable -bash: fork: Resource temporarily unavailable [1]+ Terminated : | : Nota: Utilizado nesse teste uma VM com 512 GB de RAM
  • 27. Referências  http://everlinux.com/blog  http://www.linux.com/archive/feature/61061  http://code.google.com/p/openssh-lpk/  http://en.wikipedia.org/wiki/Fork_bomb  http://www.redhat.com/docs/manuals/enterprise/RH