aboutsummaryrefslogtreecommitdiff
path: root/shellcode
diff options
context:
space:
mode:
authortoni <toni@devlap.local>2014-11-05 15:25:23 +0100
committertoni <toni@devlap.local>2014-11-05 15:25:23 +0100
commit9bc57747bae6c40e6e5e8fc647b071e371ad371a (patch)
treeda8615aeecfa2514d6b8251d45589f2c7056b1bd /shellcode
parent223fd424332f536a801ffd9bebd25517835fb681 (diff)
- ignore *.o files
- makefile: dont rebuild unchanged sources - socket.asm: bind(), not done actually
Diffstat (limited to 'shellcode')
-rw-r--r--shellcode/socket.asm20
1 files changed, 17 insertions, 3 deletions
diff --git a/shellcode/socket.asm b/shellcode/socket.asm
index e5b1e9d..731383f 100644
--- a/shellcode/socket.asm
+++ b/shellcode/socket.asm
@@ -1,13 +1,27 @@
BITS 32
-; zero out eax
-xor eax,eax
; socket()
+xor eax,eax ; zero out eax
push eax ; push 0x0 on the stack: arg3(protocol) -> 0
mov ebx,0x01 ; socket sub-syscall: 0x01 -> socket()
push 0x01 ; socket type: 0x01 -> SOCK_STREAM
push 0x02 ; socket domain: 0x02 -> AF_INET
mov ecx,esp ; let ecx point to our structure above
-mov al,102 ; syscall 0x66 (socket())
+mov al,0x66 ; socketcall syscall 0x66
+int 0x80 ; let the kernel do the stuff
+
+; bind()
+mov edx,eax ; move socket descriptor (returned by socket()) to edx
+xor eax,eax ; zero out eax again
+push 0xBBBB ; push ip addr
+push 0x00AA ; push tcp port
+push 0x0002 ; sa_family -> AF_INET = 0x0002
+mov ecx,esp ; save stack pointer -> pointer to sockaddr struct
+push 0x12 ; arg3: socklen -> addrlen
+push ecx ; arg2: push pointer to sockaddr to the stack
+push edx ; arg1: push sockfd
+mov ecx,esp ; move stack pointer to reg (conform to socketcall)
+mov ebx,0x02 ; set socket subcall to 0x03 (bind)
+mov al,0x66 ; socketcall syscall
int 0x80 ; let the kernel do the stuff