SlideShare una empresa de Scribd logo
1 de 34
São Paulo 7 de Julho de 2012


“Segurança em Sistemas PHP”

             Erick Tedeschi
             @ericktedeschi
Tópicos
• Get the facts!!!
• Login
    – Armazenamento de Senhas
    – User Enumeration
    – Brute Force
    – HTTPS
• Hardening PHP
• Security Tools

Utilizar os conhecimentos aqui passados somente para fins academicos.
Password Leaks




• http://www.lastfm.com.br/passwordsecurity
• http://www.cbc.ca/news/technology/story/2012/06/08/tech-lastfm-passwords-
  leak.html
Password Leaks




• http://blog.linkedin.com/2012/06/06/linkedin-member-passwords-compromised/
• http://techcrunch.com/2012/06/06/6-5-million-linkedin-passwords-reportedly-leaked-
  linkedin-is-looking-into-it/
Afinal como as senhas são
       armazenadas?
Clear Text – Top Passwords
Seq    |   Senha        |   Qtd       |   Seq     |   Senha       |   Qtd         |
   1   |   123456       |      8746   |   26      |   juliana     |         420   |
   2   |   1234         |      2262   |      27   |   LILICA      |         418   |
   3   |   102030       |      1782   |      28   |   vitoria     |         415   |
   4   |   12345        |      1020   |      29   |   matheus     |         412   |
   5   |   010203       |       750   |      30   |   junior      |         407   |
   6   |   gabriel      |       697   |      31   |   654321      |         402   |
   7   |   felipe       |       596   |      32   |   123         |         399   |
   8   |   sucesso      |       582   |      33   |   renata      |         391   |
   9   |   101010       |       571   |      34   |   metallica   |         390   |
  10   |   mariana      |       561   |      35   |   DANIEL      |         389   |
  11   |   flamengo     |       559   |      36   |   marcelo     |         385   |
  12   |   123mudar     |       529   |      37   |   123456789   |         379   |
  13   |   estrela      |       521   |      38   |   amanda      |         376   |
  14   |   131313       |       494   |      39   |   eduardo     |         356   |
  15   |   carolina     |       486   |      40   |   marina      |         355   |
  16   |   camila       |       466   |      41   |   12345678    |         350   |
  17   |   brasil       |       460   |      42   |   leonardo    |         347   |
  18   |   rafael       |       447   |      43   |   gustavo     |         345   |
  19   |   Tricolor     |       446   |      44   |   leticia     |         340   |
  20   |   rodrigo      |       435   |      45   |   senha       |         320   |
  21   |   fernanda     |       433   |      46   |   palmeiras   |         313   |
  22   |   felicidade   |       430   |      47   |   giovanna    |         309   |
  23   |   beatriz      |       425   |      48   |   madonna     |         303   |
  24   |   121212       |       424   |      49   |   santos      |         299   |
  25   |   gabriela     |       421   |      50   |   larissa     |         299   |
Clear Text -> Nunca
Seq    |   Senha        |   Qtd       |   Seq     |   Senha       |   Qtd         |
   1   |   123456       |      8746   |   26      |   juliana     |         420   |
   2   |   1234         |      2262   |      27   |   LILICA      |         418   |
   3   |   102030       |      1782   |      28   |   vitoria     |         415   |
   4   |   12345        |      1020   |      29   |   matheus     |         412   |
   5   |   010203       |       750   |      30   |   junior      |         407   |
   6   |   gabriel      |       697   |      31   |   654321      |         402   |
   7   |   felipe       |       596   |      32   |   123         |         399   |
   8   |   sucesso      |       582   |      33   |   renata      |         391   |
   9   |   101010       |       571   |      34   |   metallica   |         390   |
  10   |   mariana      |       561   |      35   |   DANIEL      |         389   |
  11   |   flamengo     |       559   |      36   |   marcelo     |         385   |
  12   |   123mudar     |       529   |      37   |   123456789   |         379   |
  13   |   estrela      |       521   |      38   |   amanda      |         376   |
  14   |   131313       |       494   |      39   |   eduardo     |         356   |
  15   |   carolina     |       486   |      40   |   marina      |         355   |
  16   |   camila       |       466   |      41   |   12345678    |         350   |
  17   |   brasil       |       460   |      42   |   leonardo    |         347   |
  18   |   rafael       |       447   |      43   |   gustavo     |         345   |
  19   |   Tricolor     |       446   |      44   |   leticia     |         340   |
  20   |   rodrigo      |       435   |      45   |   senha       |         320   |
  21   |   fernanda     |       433   |      46   |   palmeiras   |         313   |
  22   |   felicidade   |       430   |      47   |   giovanna    |         309   |
  23   |   beatriz      |       425   |      48   |   madonna     |         303   |
  24   |   121212       |       424   |      49   |   santos      |         299   |
  25   |   gabriela     |       421   |      50   |   larissa     |         299   |
Afinal como as senhas são
         armazenadas?

Já Sei!!! Utilizando um algoritmo de hash
 (md5/sha1/etc). Dessa forma a senha é
  criptografada e não pode voltar a sua
                forma original.
Senhas vazadas em hash
Senhas vazadas em hash:
  Como reverter para clear text?

Considerando que pelo menos 85% das senhas tem no
máximo 8 caracteres, pode-se gerar todas as
combinações de hashes de 8 caracteres por exemplo!

Então nós comparamos o hash ‘vazado’ com a tabela de
hashes gerados!



SELECT senha_clear FROM hashes WHERE hash =
‘b6dd81aba52f079571e6659c7271a8c3bb9af1f3’;
Can you reverse this hash?!
Rainbow Tables




Fonte: http://ophcrack.sourceforge.net/tables.php
Utilizando ferramenta online
  Para reverter os hashes


                       Vamos quebrar
                         Todos os
                          hashes
Fazendo a coisa certa!
Mas

  Como gravar ‘corretamente’ uma senha de acordo
  com as recomendações do OWASP:

 Regra 1 – Utilize um algoritmo de hash moderno

 Regra 2 – Criar um ‘salt’ único para cada usuário

 Regra 3 – Iterar o hash (64k vezes!)



Fonte: https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet
Gravando no Bando de Dados




Obs.: Para fins de entendimento o $globalSalt está no código. Normalmente ele deve
                 ficar em um arquivo de configuração de difícil acesso.
Fazendo Login (comparação)
  Ex.: Método authenticate do Zend_Auth_Adapter_Interface
Benchmark da geração de hashes
mysql> select benchmark(10000000, md5(rand()));
+----------------------------------+
| benchmark(10000000, md5(rand())) |
+----------------------------------+
|                                0 |
+----------------------------------+
1 row in set (18.92 sec)
mysql> select benchmark(10000000, sha1(rand()));
+-----------------------------------+
| benchmark(10000000, sha1(rand())) |
+-----------------------------------+
|                                 0 |
+-----------------------------------+
1 row in set (22.34 sec)
mysql> select benchmark(10000000, sha2(rand(),512));
+---------------------------------------+
| benchmark(10000000, sha2(rand(),512)) |
+---------------------------------------+
|                                     0 |
+---------------------------------------+
1 row in set (26.85 sec)
User Enumeration
User Enumeration

     Independente se o usuário existe ou não na tabela, a
     mensagem de erro deve ser igual para ambos os casos.




https://www.owasp.org/index.php/Testing_for_user_enumeration_%28OWASP-AT-002%29
Brute Force (Login)
     Possibilita o atacante tentar se logar na aplicação
     exaustivamente utilizando um dicionário de usuários e
     senhas.

     A mensagem de erro fornecida pela aplicação pode
     ajudar na automatização do ataque. Pois quando a
     credencial for válida, a mensagem ‘Usuário e/ou senha
     inválidos’ não irá mais aparecer por exemplo.




https://www.owasp.org/index.php/Testing_for_Brute_Force_%28OWASP-AT-004%29
Brute Force (Login)
Exemplo de Brute Force utilizando o Metasploit
Modulo: auxiliary/scanner/http/wordpress_login_enum




https://www.owasp.org/index.php/Testing_for_Brute_Force_%28OWASP-AT-004%29
Controle para Brute Force




   - Pode-se persistir um status do usuário (ativo / bloqueado) e
   setar um número máximo de tentativas de login.
   - Somente o admin pode ‘desbloquear’o usuário.

https://www.owasp.org/index.php/Testing_for_Brute_Force_%28OWASP-AT-004%29
Controle para Brute Force




Plugin de WordPress para proteção contra Brute Force
http://wordpress.org/extend/plugins/user-security-tools/
HTTPS
Exemplo de configuração de Virtual Host com HTTPS
Tutorial exemplo: http://onlamp.com/onlamp/2008/03/04/step-by-step-configuring-ssl-under-
apache.html
Hardening PHP

Hardening é um processo de mapeamento das
ameaças, mitigação dos riscos e execução das
atividades corretivas, com foco na infra-estrutura e
objetivo principal de torná-la preparada para
enfrentar tentativas de ataque.

Fonte: http://pt.wikipedia.org/wiki/Hardening
Hardening PHP
Dicas para deixar o php.ini mais seguro em produção



Evite que outros saibam a versão do PHP que você
está utilizando:




expose_php = Off
Hardening PHP
Logar todos os erros em arquivo no servidor e
desabilitar a visualização de erros por clientes.


display_errors = Off
log_errors = On
error_log = /var/log/php/error.log
Hardening PHP
Desabilitar upload de arquivos caso a aplicação não
utilize esse recurso. Caso sim limitar o tamnho do
arquivo.



file_uploads = Off

# ou se utilizar
file_uploads = Off
upload_max_filesize = 1M
Hardening PHP
   Desabilitar funções maliciosas




disable_functions
=exec,passthru,shell_exec,system,proc_open,popen,show_s
ource
Hardening PHP
   Limitar o acesso da aplicação ao file system do
   servidor:




open_basedir = “/usr/share/php/PEAR:/var/www/”
Hardening PHP
Exemplo de restrição com open_basedir
Guia de teste de segurança para aplicação web:
https://www.owasp.org/images/5/56/OWASP_Testing_Guide_v3.pdf


Guia de Desenvolvimento Seguro (em construção):
http://code.google.com/p/owasp-development-guide/wiki/Introduction
Ferramentas para Pentest e
              Auditoria

- Metasploit Framework
www.metasploit.com
- W3af – Web Application Attack and Audit Framework
http://w3af.sourceforge.net
- THC Hydra (brute force de senha)
http://www.thc.org/thc-hydra
- John The Ripper (brute force de senha)
http://www.openwall.com/john
- BurpSuite – Proxy de Interceptação
http://portswigger.net/burp/
Perguntas?




Erick Tedeschi

http://oerick.com

E-mail/Gtalk: erick@oerick.com

Twitter: @ericktedeschi
Obrigado

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

TDC 2012 - PHP

  • 1. São Paulo 7 de Julho de 2012 “Segurança em Sistemas PHP” Erick Tedeschi @ericktedeschi
  • 2. Tópicos • Get the facts!!! • Login – Armazenamento de Senhas – User Enumeration – Brute Force – HTTPS • Hardening PHP • Security Tools Utilizar os conhecimentos aqui passados somente para fins academicos.
  • 3. Password Leaks • http://www.lastfm.com.br/passwordsecurity • http://www.cbc.ca/news/technology/story/2012/06/08/tech-lastfm-passwords- leak.html
  • 4. Password Leaks • http://blog.linkedin.com/2012/06/06/linkedin-member-passwords-compromised/ • http://techcrunch.com/2012/06/06/6-5-million-linkedin-passwords-reportedly-leaked- linkedin-is-looking-into-it/
  • 5. Afinal como as senhas são armazenadas?
  • 6. Clear Text – Top Passwords Seq | Senha | Qtd | Seq | Senha | Qtd | 1 | 123456 | 8746 | 26 | juliana | 420 | 2 | 1234 | 2262 | 27 | LILICA | 418 | 3 | 102030 | 1782 | 28 | vitoria | 415 | 4 | 12345 | 1020 | 29 | matheus | 412 | 5 | 010203 | 750 | 30 | junior | 407 | 6 | gabriel | 697 | 31 | 654321 | 402 | 7 | felipe | 596 | 32 | 123 | 399 | 8 | sucesso | 582 | 33 | renata | 391 | 9 | 101010 | 571 | 34 | metallica | 390 | 10 | mariana | 561 | 35 | DANIEL | 389 | 11 | flamengo | 559 | 36 | marcelo | 385 | 12 | 123mudar | 529 | 37 | 123456789 | 379 | 13 | estrela | 521 | 38 | amanda | 376 | 14 | 131313 | 494 | 39 | eduardo | 356 | 15 | carolina | 486 | 40 | marina | 355 | 16 | camila | 466 | 41 | 12345678 | 350 | 17 | brasil | 460 | 42 | leonardo | 347 | 18 | rafael | 447 | 43 | gustavo | 345 | 19 | Tricolor | 446 | 44 | leticia | 340 | 20 | rodrigo | 435 | 45 | senha | 320 | 21 | fernanda | 433 | 46 | palmeiras | 313 | 22 | felicidade | 430 | 47 | giovanna | 309 | 23 | beatriz | 425 | 48 | madonna | 303 | 24 | 121212 | 424 | 49 | santos | 299 | 25 | gabriela | 421 | 50 | larissa | 299 |
  • 7. Clear Text -> Nunca Seq | Senha | Qtd | Seq | Senha | Qtd | 1 | 123456 | 8746 | 26 | juliana | 420 | 2 | 1234 | 2262 | 27 | LILICA | 418 | 3 | 102030 | 1782 | 28 | vitoria | 415 | 4 | 12345 | 1020 | 29 | matheus | 412 | 5 | 010203 | 750 | 30 | junior | 407 | 6 | gabriel | 697 | 31 | 654321 | 402 | 7 | felipe | 596 | 32 | 123 | 399 | 8 | sucesso | 582 | 33 | renata | 391 | 9 | 101010 | 571 | 34 | metallica | 390 | 10 | mariana | 561 | 35 | DANIEL | 389 | 11 | flamengo | 559 | 36 | marcelo | 385 | 12 | 123mudar | 529 | 37 | 123456789 | 379 | 13 | estrela | 521 | 38 | amanda | 376 | 14 | 131313 | 494 | 39 | eduardo | 356 | 15 | carolina | 486 | 40 | marina | 355 | 16 | camila | 466 | 41 | 12345678 | 350 | 17 | brasil | 460 | 42 | leonardo | 347 | 18 | rafael | 447 | 43 | gustavo | 345 | 19 | Tricolor | 446 | 44 | leticia | 340 | 20 | rodrigo | 435 | 45 | senha | 320 | 21 | fernanda | 433 | 46 | palmeiras | 313 | 22 | felicidade | 430 | 47 | giovanna | 309 | 23 | beatriz | 425 | 48 | madonna | 303 | 24 | 121212 | 424 | 49 | santos | 299 | 25 | gabriela | 421 | 50 | larissa | 299 |
  • 8. Afinal como as senhas são armazenadas? Já Sei!!! Utilizando um algoritmo de hash (md5/sha1/etc). Dessa forma a senha é criptografada e não pode voltar a sua forma original.
  • 10. Senhas vazadas em hash: Como reverter para clear text? Considerando que pelo menos 85% das senhas tem no máximo 8 caracteres, pode-se gerar todas as combinações de hashes de 8 caracteres por exemplo! Então nós comparamos o hash ‘vazado’ com a tabela de hashes gerados! SELECT senha_clear FROM hashes WHERE hash = ‘b6dd81aba52f079571e6659c7271a8c3bb9af1f3’; Can you reverse this hash?!
  • 12. Utilizando ferramenta online Para reverter os hashes Vamos quebrar Todos os hashes
  • 13. Fazendo a coisa certa! Mas Como gravar ‘corretamente’ uma senha de acordo com as recomendações do OWASP: Regra 1 – Utilize um algoritmo de hash moderno Regra 2 – Criar um ‘salt’ único para cada usuário Regra 3 – Iterar o hash (64k vezes!) Fonte: https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet
  • 14. Gravando no Bando de Dados Obs.: Para fins de entendimento o $globalSalt está no código. Normalmente ele deve ficar em um arquivo de configuração de difícil acesso.
  • 15. Fazendo Login (comparação) Ex.: Método authenticate do Zend_Auth_Adapter_Interface
  • 16. Benchmark da geração de hashes mysql> select benchmark(10000000, md5(rand())); +----------------------------------+ | benchmark(10000000, md5(rand())) | +----------------------------------+ | 0 | +----------------------------------+ 1 row in set (18.92 sec) mysql> select benchmark(10000000, sha1(rand())); +-----------------------------------+ | benchmark(10000000, sha1(rand())) | +-----------------------------------+ | 0 | +-----------------------------------+ 1 row in set (22.34 sec) mysql> select benchmark(10000000, sha2(rand(),512)); +---------------------------------------+ | benchmark(10000000, sha2(rand(),512)) | +---------------------------------------+ | 0 | +---------------------------------------+ 1 row in set (26.85 sec)
  • 18. User Enumeration Independente se o usuário existe ou não na tabela, a mensagem de erro deve ser igual para ambos os casos. https://www.owasp.org/index.php/Testing_for_user_enumeration_%28OWASP-AT-002%29
  • 19. Brute Force (Login) Possibilita o atacante tentar se logar na aplicação exaustivamente utilizando um dicionário de usuários e senhas. A mensagem de erro fornecida pela aplicação pode ajudar na automatização do ataque. Pois quando a credencial for válida, a mensagem ‘Usuário e/ou senha inválidos’ não irá mais aparecer por exemplo. https://www.owasp.org/index.php/Testing_for_Brute_Force_%28OWASP-AT-004%29
  • 20. Brute Force (Login) Exemplo de Brute Force utilizando o Metasploit Modulo: auxiliary/scanner/http/wordpress_login_enum https://www.owasp.org/index.php/Testing_for_Brute_Force_%28OWASP-AT-004%29
  • 21. Controle para Brute Force - Pode-se persistir um status do usuário (ativo / bloqueado) e setar um número máximo de tentativas de login. - Somente o admin pode ‘desbloquear’o usuário. https://www.owasp.org/index.php/Testing_for_Brute_Force_%28OWASP-AT-004%29
  • 22. Controle para Brute Force Plugin de WordPress para proteção contra Brute Force http://wordpress.org/extend/plugins/user-security-tools/
  • 23. HTTPS Exemplo de configuração de Virtual Host com HTTPS Tutorial exemplo: http://onlamp.com/onlamp/2008/03/04/step-by-step-configuring-ssl-under- apache.html
  • 24. Hardening PHP Hardening é um processo de mapeamento das ameaças, mitigação dos riscos e execução das atividades corretivas, com foco na infra-estrutura e objetivo principal de torná-la preparada para enfrentar tentativas de ataque. Fonte: http://pt.wikipedia.org/wiki/Hardening
  • 25. Hardening PHP Dicas para deixar o php.ini mais seguro em produção Evite que outros saibam a versão do PHP que você está utilizando: expose_php = Off
  • 26. Hardening PHP Logar todos os erros em arquivo no servidor e desabilitar a visualização de erros por clientes. display_errors = Off log_errors = On error_log = /var/log/php/error.log
  • 27. Hardening PHP Desabilitar upload de arquivos caso a aplicação não utilize esse recurso. Caso sim limitar o tamnho do arquivo. file_uploads = Off # ou se utilizar file_uploads = Off upload_max_filesize = 1M
  • 28. Hardening PHP Desabilitar funções maliciosas disable_functions =exec,passthru,shell_exec,system,proc_open,popen,show_s ource
  • 29. Hardening PHP Limitar o acesso da aplicação ao file system do servidor: open_basedir = “/usr/share/php/PEAR:/var/www/”
  • 30. Hardening PHP Exemplo de restrição com open_basedir
  • 31. Guia de teste de segurança para aplicação web: https://www.owasp.org/images/5/56/OWASP_Testing_Guide_v3.pdf Guia de Desenvolvimento Seguro (em construção): http://code.google.com/p/owasp-development-guide/wiki/Introduction
  • 32. Ferramentas para Pentest e Auditoria - Metasploit Framework www.metasploit.com - W3af – Web Application Attack and Audit Framework http://w3af.sourceforge.net - THC Hydra (brute force de senha) http://www.thc.org/thc-hydra - John The Ripper (brute force de senha) http://www.openwall.com/john - BurpSuite – Proxy de Interceptação http://portswigger.net/burp/