shellcode

execve shellcode writing segmentation fault

风格不统一 提交于 2019-11-26 17:58:25
I am trying to study execve shellcode, OS : Linux bt 2.6.39.4 root@bt:~/exploit# cat gshell.s .globl _start _start: nop jmp MyString shell: popl %esi xorl %eax,%eax movl %al,9(%esi) movl %esi,10(%esi) movl %eax,14(%esi) movb $11,%al movl %esi, %ebx leal 0xa(%esi),%ecx leal 0xe(%esi),%edx int $0x80 movl $1,%eax movl $0,%ebx int $0x80 MyString: call shell shellvar: .ascii "/bin/bashADDDDCCCC" root@bt:~/exploit# as -gstabs -o gshell.o gshell.s root@bt:~/exploit# ld -o gshell gshell.o root@bt:~/exploit# ./gshell Segmentation fault (core dumped) root@bt:~/exploit# GDB: (gdb) break *_start

Why NASM on Linux changes registers in x86_64 assembly

余生长醉 提交于 2019-11-26 14:39:23
问题 I am new to x86_64 assembly programming. I was writing simple "Hello World" program in x86_64 assembly. Below is my code, which runs perfectly fine. global _start section .data msg: db "Hello to the world of SLAE64", 0x0a mlen equ $-msg section .text _start: mov rax, 1 mov rdi, 1 mov rsi, msg mov rdx, mlen syscall mov rax, 60 mov rdi, 4 syscall Now when I disassemble in gdb, it gives below output: (gdb) disas Dump of assembler code for function _start: => 0x00000000004000b0 <+0>: mov eax,0x1

Linux Shellcode “Hello, World!”

不羁岁月 提交于 2019-11-26 12:03:17
问题 I have the following working NASM code: global _start section .text _start: mov eax, 0x4 mov ebx, 0x1 mov ecx, message mov edx, 0xF int 0x80 mov eax, 0x1 mov ebx, 0x0 int 0x80 section .data message: db \"Hello, World!\", 0dh, 0ah which prints \"Hello, World!\\n\" to the screen. I also have the following C wrapper which contains the previous NASM object code: char code[] = \"\\xb8\\x04\\x00\\x00\\x00\" \"\\xbb\\x01\\x00\\x00\\x00\" \"\\xb9\\x00\\x00\\x00\\x00\" \"\\xba\\x0f\\x00\\x00\\x00\" \"