LoginSignup
0
0

More than 3 years have passed since last update.

paizaでアセンブラ その6

Last updated at Posted at 2018-12-08

概要

paizaでアセンブラ、やってみた。
シェルコードやってみた。

サンプルコード

import subprocess
import os

def gcc():
    c_file = 'fizzbuzz.s'
    test_c = """
.code64
.text
.global main

main:
    xor    %rdx, %rdx
    push   %rdx
    mov    $0x68732f2f6e69622f, %rax
    push   %rax
    mov    %rsp, %rdi
    push   %rdx
    push   %rdi
    mov    %rsp, %rsi 
    lea    59(%rdx), %rax
    syscall
"""
    with open(c_file, 'w') as f:
        f.write(test_c)
    os.system("gcc -no-pie %s" % c_file)
    result = subprocess.Popen('./a.out', stdout = subprocess.PIPE).communicate()[0]
    for i, v in enumerate(result[ : -1].split('\n')):
        print v

if __name__ == '__main__':
  gcc()


成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0