There is nothing like returning to a place that remains unchanged to find the ways in which you yourself have altered. Não há nada como regressar a um local que permanece inalterado para encontrar as maneiras em que você próprio tenha alterado.
Published by: apples , on 2008-04-05 22:18:00 Publicado por: maçãs, em 2008-04-05 22:18:00
shellcode for beginners shellcode para principiantes by apples por maçãs
pre-requisites: pré-requisitos: -basic x86 assembly knowledge conhecimentos básicos x86-montagem -buffer overflow techniques (for implementation of the shellcode) -técnicas de buffer overflow (para a execução do shell) -common sense -senso comum
okay, so you just found a buffer overflow in the latest application. Ok, então você acaba encontrado um buffer overflow no último pedido. you overwrite the EIP, and..suddenly you realize you need code to execute. você substituir o PEI, bem .. de repente você percebe que você precisa para executar código. AND, this code has to be small enough to work in your newfound vulnerability. E, este código tem de ser pequeno o suficiente para trabalhar em sua recém descoberta vulnerabilidade. so, what do you use? afirmativo, qual você usa?shellcode, of course! shellcode, claro!
shellcode can be very modular, meaning that it can be used in many different areas, shellcode pode ser extremamente modular, o que significa que ele pode ser usado em muitas áreas diferentes, as long it meets some basic requirements, such as the architecture type and operating system. desde que preencha alguns requisitos básicos, tais como o tipo de arquitetura e sistema operacional. shellcode is written in assembly, which means that while it's more difficult to create, shellcode é escrito em assembléia, o que significa que, enquanto ela é mais difícil de criar, it's much smaller, due to the lack of abstraction. ele é muito menor, devido à falta de abstração.so, let's get started, shall wee? portanto, vamos começar, é pequenino?
our first shellcode will perform something very simple. nossa primeira shellcode irão realizar algo muito simples.it will call the ele vai chamar o exit() syscall in linux. exit () syscall no linux.first, let's take a look at the syntax of the em primeiro lugar, vamos dar uma olhada na sintaxe do syscall itself. syscall si mesmo.
CODE : CÓDIGO:
int sys_exit(int status)int sys_exit (int status) -terminates the current process-termine o processo atual -status is the return code-se o estado código devolvido
here's the code that i wrote to call exit(). aqui está o código que eu escrevi a chamada exit ().(this code is for use in NASM) (este código é para uso em NASM) CODE : CÓDIGO:
this is equivalent to the following code in C: Isto é equivalente ao seguinte código em C: CODE : CÓDIGO:
void main()void main () {( exit(0);exit (0); })
write those in your favorite text editor, then assemble it and link it. escrever os seus favoritos no editor de texto, em seguida, reunir-lo e vinculá-lo. here's what i did. aqui está o que eu fiz.
finally, we start to see some results from our work! finalmente, começamos a ver alguns resultados do nosso trabalho!the shellcode is o shell é "xb8x01x00x00x00xbbx00x00x00x00xcdx80" ! "xb8x01x00x00x00xbbx00x00x00x00xcdx80"!but, there's an mas, há uma obvious problem with this shellcode, and anyone who uses strings in C problema óbvio com esta shell, e todos que usam seqüências em C will see it instantly. irá vê-lo instantaneamente.strings cannot contain NULL bytes, because a NULL strings não podem conter NULL bytes, porque um NULL byte is used to signify the end of the string. byte é usado para indicar o final da string.which means, the o que significa, a vulnerable program would stop reading after "xb8x01". programa vulnerável iria parar depois da leitura "xb8x01".this is a very esta é uma forma muito bad thing indeed. coisa ruim na verdade.let's try writing one again, with this knowledge. vamos tentar escrever uma vez mais, com esse conhecimento.
first, we notice that 'mov eax, 1' generated 3 null bytes. em primeiro lugar, percebemos que «mov eax, 1 'gerado 3 bytes nulos.now, think Agora, acho about why this would happen. sobre por que isso ia acontecer.eax is a 32-bit register, and we're only eax 32-bit é um registo, e nós estamos apenas changing 1 byte with our value of 1. 1 byte mudando com o nosso valor de 1.think about it this way: pensar nisso desta maneira: CODE : CÓDIGO:
now you can see where the problem might arise. Agora você pode ver onde o problema poderia surgir.on another note, the em outra nota, o lower 16 bits of eax can be divided into two 8-bit registers, known as menor de 16 bits eax podem ser divididos em dois registos 8-bit, conhecido como ah and al. ah e al.as you might be able to tell, ah is the high 8 bits, and al is como você pode ser capaz de dizer, ah é o elevado 8 bits, e al é the low 8 bits. a baixa 8 bits.since 1 only takes up one byte, then we can simply move desde 1 só ocupa um byte, então nós podemos simplesmente passar it to al. que a al.
now, we still have the second command to worry about. Agora, temos ainda o segundo comando com que se preocupar.how can we set ebx como podemos definir EBX to 0 without moving the value of 0 to it? a 0 sem mover o valor de 0 a ela?the answer lies within the a resposta está dentro do bitwise operator XOR. operador bitwise XOR.here's a table on how it works: aqui está uma tabela sobre como funciona:
a | b | c a | b | c ----------------------------------- 0 | 0 = 0 0 | 0 = 0 1 | 0 = 1 1 | 0 = 1 0 | 1 = 1 0 | 1 = 1 1 | 1 = 0 1 | 1 = 0
when a and b are the same value, then it returns 0. quando a e b são o mesmo valor, em seguida, ele retorna 0.when they are quando são different, it returns 1. diferente, ele retorna 1.now, think about how this can be applied to Agora, pense em como isso pode ser aplicado a ebx. EBX.if you XOR ebx with itself, it will create 0, since ebx has the se você XOR EBX com ele mesmo, ele irá criar 0, já que a EBX tem same value as ebx (duh?! :P) mesmo valor de EBX (duh!: P)
make the following changes to your shellcode, and re-assemble and link faça as seguintes alterações ao seu shell, e voltar a montar e ligar it. ele.then run 'objdump -d exit' again, and this should be your shiny new em seguida, execute "exit objdump-d 'novamente, e este deveria ser o seu novo brilho output: Saída: CODE : CÓDIGO:
exit: file format elf32-i386saída: o formato do arquivo elf32-i386
Disassembly of section .text:A desmontagem da seção. Texto:
08048080 <_start>:08048080 <_start>: 8048080: b0 01 mov $0x1,%al8048080: b0 01 mov $ 0x1,% al 8048082: 31 db xor %ebx,%ebx8048082: 31% db XOR EBX, EBX% 8048084: cd 80 int $0x808048084: cd $ 80 int 0x80
thus, our new shellcode is "xb0x01x31xdbxcdx80" ! assim, o nosso novo código da shell é "xb0x01x31xdbxcdx80"!and, it's NULL e, é NULL free! livre!next, try using these techniques to create shellcode that spawns a próxima, tente utilizar estas técnicas para criar um shell que desova shell.
Cast your vote on this article Elenco seu voto sobre este artigo *Note: the order of the votes has been reversed. * Nota: a ordem das votações foi revertida.
Nines - 03:42 am Sunday April 06th, 2008Noves - 03h42 domingo 06 de abril de 2008
The original was better cause it contained slashes :P Well done bud, good article. O original era melhor, porque continham barras: P Bem feito broto, bom artigo.
Karec - 08:52 am Sunday April 06th, 2008Karec - 08h52 domingo 06 de abril de 2008
Good things: Coisas boas: 1. I liked the truth table. Eu gostei de verdade da tabela.(Digital Sytems class reference) (Digital Sytems classe referência) 2. The article flows very well information wise. O artigo fluxos de informação muito bem sábio.
Bad Things: Coisas ruins: 1. Lack of captialization or capitalisation (depending if you are US or European) at all in the article. Falta de captialization ou capitalização (dependendo se você está E.U. ou europeu) em todo o artigo. 2. Bad grammar as far as going comma happy. Bad gramática, tanto quanto vai vírgula feliz.
7/10 7 / 10
KSEboom - 12:33 pm Sunday April 06th, 2008KSEboom - 12:33 domingo 06 de abril de 2008
Not bad! Nada mau!
signsoft - 01:38 am Monday April 14th, 2008signsoft - 01h38 Segunda-feira 14 de abril de 2008
Nice article, simple and explaining. Nice artigo, simples e explicando.Really good job. Trabalho realmente bom. I have one suggestion though: Tenho uma sugestão pensou: MOV EAX,1 and MOV EAX, 1 e MOV AL,1 aren't equal. MOV AL, 1 não são iguais. MOV AL,1 only alters 8 lowest bits and leaves the upper 24 unchanged. MOV AL, 1 modifica apenas 8 bits mais baixos e as folhas superiores a 24 inalterados.Whatever was there will stay there and in effect you can end with something other than 1 in EAX. Qualquer que estava lá vai ficar lá e no efeito que pode terminar com algo diferente de 1 em EAX. Placing XOR EAX,EAX in front of XOR EAX colocação, na frente de EAX MOV AL,1 solves the problem. MOV AL, 1 resolve o problema.
bitchasshoe - 05:22 pm Wednesday April 23rd, 2008bitchasshoe - 05:22 hs Quarta-feira 23 de abril de 2008
nice, simple and straight to the point. simpática, simples e direto ao ponto.
sikes - 09:19 am Friday May 02nd, 2008Sikes - 09h19 Sexta-feira maio 02o, 2008
Nice Agradável
VARUNmca123 - 04:51 am Monday May 12th, 2008VARUNmca123 - 04h51 segunda-feira 12 de maio de 2008
not very hard to understand! Não muito difícil entender!
herotrojanz - 11:28 am Thursday June 05th, 2008herotrojanz - 11:28 Quinta-feira 05 de junho, 2008
understood and gud job writing the article entendido e gud trabalho escrito o artigo
rohit_007 - 02:24 am Monday October 13th, 2008rohit_007 - 02h24 segunda-feira 13 Oct 2008
abyss - 02:25 am Saturday November 01st, 2008abismo - 02h25 sabado novembro 01o, 2008
WICKED! Ímpios!Thanks for that Indeed! Obrigado por esse facto!
This site is the collective work of the HackThisSite staff. Este site é o trabalho coletivo da equipe HackThisSite.Please don't reproduce in part or whole without permission. Por favor, não reproduzir, total ou parcial, sem a sua permissão. Page Generated: Tue, 02 Dec 2008 00:09:14 -0500 Exec: 10 Página Criado em: Tue, 02 dezembro 2008 00:09:14 -0500 Exec: 10 Page loaded in 0.21646 seconds!Página carregada em 0,21646 segundos!
The original was better cause it contained slashes :P Well done bud, good article. O original era melhor, porque continham barras: P Bem feito broto, bom artigo.