aboutsummaryrefslogtreecommitdiff
path: root/shellcode
diff options
context:
space:
mode:
Diffstat (limited to 'shellcode')
-rw-r--r--shellcode/Makefile6
-rw-r--r--shellcode/hello.asm19
2 files changed, 24 insertions, 1 deletions
diff --git a/shellcode/Makefile b/shellcode/Makefile
index e2b4b69..e7833cd 100644
--- a/shellcode/Makefile
+++ b/shellcode/Makefile
@@ -1,4 +1,5 @@
RM := rm
+ASM := nasm
CC := gcc
LD := ld
OBJCOPY := objcopy
@@ -6,7 +7,7 @@ XXD := xxd
CFLAGS = -c -Wall -fpic -Os
LDFLAGS =
SUBDIR ?= .
-TARGETS = $(patsubst %.c,%.o,$(wildcard $(SUBDIR)/*.c))
+TARGETS = $(patsubst %.c,%.o,$(wildcard $(SUBDIR)/*.c)) $(patsubst %.asm,%.o,$(wildcard $(SUBDIR)/*.asm))
all: $(TARGETS)
@@ -16,6 +17,9 @@ all: $(TARGETS)
$(OBJCOPY) -R .note -R .comment -S -O binary $(patsubst %.o,%,$@) $(patsubst %.o,%.bin,$@)
$(XXD) -i $(patsubst %.o,%.bin,$@)
+%.o : %.asm
+ $(ASM) -o $@ $<
+
clean:
$(RM) -f $(patsubst %.o,%.map,$(TARGETS)) $(patsubst %.o,%.bin,$(TARGETS)) $(patsubst %.o,%,$(TARGETS)) $(TARGETS)
diff --git a/shellcode/hello.asm b/shellcode/hello.asm
new file mode 100644
index 0000000..13eaaff
--- /dev/null
+++ b/shellcode/hello.asm
@@ -0,0 +1,19 @@
+BITS 32
+
+xor eax,eax
+xor ebx,ebx
+xor ecx,ecx
+xor edx,edx
+jmp short string
+code:
+pop ecx
+mov bl,1
+mov dl,12
+mov al,4
+int 0x80
+dec bl
+mov al,1
+int 0x80
+string:
+call code
+db 'Hello World!'