Skip to content

Instantly share code, notes, and snippets.

@vivekseth
Created June 24, 2020 23:34
Show Gist options
  • Save vivekseth/fc50319aaac24588bcf568209bf6df8e to your computer and use it in GitHub Desktop.
Save vivekseth/fc50319aaac24588bcf568209bf6df8e to your computer and use it in GitHub Desktop.
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 10, 15 sdk_version 10, 15, 4
.globl _runStringAsCode ## -- Begin function runStringAsCode
.p2align 4, 0x90
_runStringAsCode: ## @runStringAsCode
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
movb $88, -1(%rbp)
leaq -1(%rbp), %rax
addq $1, %rax
addq $8, %rax
movq %rax, -16(%rbp)
movq _execString(%rip), %rax
movq -16(%rbp), %rcx
movq %rax, (%rcx)
popq %rbp
retq
.cfi_endproc
## -- End function
.globl _test ## -- Begin function test
.p2align 4, 0x90
_test: ## @test
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
callq _runStringAsCode
popq %rbp
retq
.cfi_endproc
## -- End function
.globl _main ## -- Begin function main
.p2align 4, 0x90
_main: ## @main
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
subq $16, %rsp
movl $0, -4(%rbp)
callq _test
leaq L_.str.1(%rip), %rdi
leaq L_.str.2(%rip), %rsi
movb $0, %al
callq _printf
xorl %ecx, %ecx
movl %eax, -8(%rbp) ## 4-byte Spill
movl %ecx, %eax
addq $16, %rsp
popq %rbp
retq
.cfi_endproc
## -- End function
.section __TEXT,__const
l_.str: ## @.str
.asciz "UH\211\345H\307\302\013\377\377\377H\201\352\001\377\377\377H)\324A\272\005\001\001\003I\201\352\001\001\001\001L\211\320A\272\002\001\001\001I\201\352\001\001\001\001L\211\327H\000\271ABCDEFG\nI\211\350I)\320I\211\bH\211\356H)\326A\272\t\001\001\001I\201\352\001\001\001\001L\211\322\017\005A\272\002\001\001\003I\201\352\001\001\001\001L\211\320A\272\001\001\001\001I\201\352\001\001\001\001L\211\327\017\005"
.section __DATA,__data
.globl _execString ## @execString
.p2align 3
_execString:
.quad l_.str
.section __TEXT,__cstring,cstring_literals
L_.str.1: ## @.str.1
.asciz "%s\n"
L_.str.2: ## @.str.2
.asciz "Jump address overwrite failed."
.subsections_via_symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment