This commit is contained in:
bfu4 2022-03-21 17:58:39 +00:00
parent 2ed4b837f1
commit 9c3a3751d0

83
bof.s

@ -1,43 +1,42 @@
.code64
#---------------------------------------------------------------#
.code64 #
#---------------------------------------------------------------#
#
.section .rodata #
money_str: .string "woohoo!! free money\n" #
#
#---------------------------------------------------------------#
.section .text #
.globl _start #
.extern printf #
.extern gets #
#
_get_input: #
push %rbp #
mov %rsp, %rbp #
sub $0x10, %rsp #
lea -0x8(%rbp),%rax #
mov %rax, %rdi #
call gets@plt #
nop # aaaaaaaa\x0\x0\x0\x0\x0\x0\x0\x0\x47\x10\x40
leave #
ret #
#
_get_rich_fast: #
push %rbp #
mov %rsp, %rbp #
lea money_str, %rdi #
mov %rdi, %rax #
call printf@plt #
pop %rbp #
nop #
ret #
.section .rodata
money_str: .string "woohoo!! free money\n"
.section .text
.globl _start
.extern printf
.extern gets
_get_input:
push %rbp
mov %rsp, %rbp
sub $0x10, %rsp
lea -0x8(%rbp),%rax
mov %rax, %rdi
call gets@plt
nop ; aaaaaaaa\x0\x0\x0\x0\x0\x0\x0\x0\x47\x10\x40
leave
ret
_get_rich_fast:
push %rbp
mov %rsp, %rbp
lea money_str, %rdi
mov %rdi, %rax
call printf@plt
pop %rbp
nop
ret
_start:
push %rbp
call _get_input
pop %rbp ; TODO: segfault
mov $0, %rax
mov $60, %rdi
syscall
ret
; .section bss
; .lcomm buf, 8
_start: #
push %rbp #
call _get_input #
pop %rbp # TODO: segfault
pop %rsp #
mov $1, %al #
mov $0, %rbx #
syscall #