今天做pwn题的时候突然报错
from pwn import *
shellcode = asm(shellcraft.amd64.sh())
[ERROR] There was an error running ['/usr/bin/as', '-32', '-o', '/tmp/pwn-asm-2a_arm3i/step2', '/tmp/pwn-asm-2a_arm3i/step1']:
It had the exitcode 1.
It had this on stdout:
/tmp/pwn-asm-2a_arm3i/step1: Assembler messages:
/tmp/pwn-asm-2a_arm3i/step1:11: Error: operand size mismatch for `mov'
/tmp/pwn-asm-2a_arm3i/step1:13: Error: too many memory references for `mov'
/tmp/pwn-asm-2a_arm3i/step1:22: Error: too many memory references for `add'
/tmp/pwn-asm-2a_arm3i/step1:24: Error: too many memory references for `mov'
[ERROR] An error occurred while assembling:
1: .section .shellcode,"awx"
2: .global _start
3: .global __start
4: _start:
5: __start:
6: .intel_syntax noprefix
7: .p2align 0
8: /* execve(path='/bin///sh', argv=['sh'], envp=0) */
9: /* push b'/bin///sh\x00' */
10: push 0x68
11: mov rax, 0x732f2f2f6e69622f
12: push rax
13: mov rdi, rsp
14: /* push argument array ['sh\x00'] */
15: /* push b'sh\x00' */
16: push 0x1010101 ^ 0x6873
17: xor dword ptr [rsp], 0x1010101
18: xor esi, esi /* 0 */
19: push rsi /* null terminate */
20: push 8
21: pop rsi
22: add rsi, rsp
23: push rsi /* 'sh\x00' */
24: mov rsi, rsp
25: xor edx, edx /* 0 */
26: /* call execve() */
27: push 11 /* 0x3b */
28: pop rax
29: syscall
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pwnlib/asm.py", line 704, in asm
_run(assembler + ['-o', step2, step1])
File "/usr/local/lib/python3.6/site-packages/pwnlib/asm.py", line 422, in _run
log.error(msg, *args)
File "/usr/local/lib/python3.6/site-packages/pwnlib/log.py", line 439, in error
raise PwnlibException(message % args)
pwnlib.exception.PwnlibException: There was an error running ['/usr/bin/as', '-32', '-o', '/tmp/pwn-asm-2a_arm3i/step2', '/tmp/pwn-asm-2a_arm3i/step1']:
It had the exitcode 1.
It had this on stdout:
/tmp/pwn-asm-2a_arm3i/step1: Assembler messages:
/tmp/pwn-asm-2a_arm3i/step1:11: Error: operand size mismatch for `mov'
/tmp/pwn-asm-2a_arm3i/step1:13: Error: too many memory references for `mov'
/tmp/pwn-asm-2a_arm3i/step1:22: Error: too many memory references for `add'
/tmp/pwn-asm-2a_arm3i/step1:24: Error: too many memory references for `mov'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/pwnlib/context/__init__.py", line 1578, in setter
return function(*a, **kw)
File "/usr/local/lib/python3.6/site-packages/pwnlib/asm.py", line 750, in asm
log.exception("An error occurred while assembling:\n%s" % lines)
File "/usr/local/lib/python3.6/site-packages/pwnlib/asm.py", line 704, in asm
_run(assembler + ['-o', step2, step1])
File "/usr/local/lib/python3.6/site-packages/pwnlib/asm.py", line 422, in _run
log.error(msg, *args)
File "/usr/local/lib/python3.6/site-packages/pwnlib/log.py", line 439, in error
raise PwnlibException(message % args)
pwnlib.exception.PwnlibException: There was an error running ['/usr/bin/as', '-32', '-o', '/tmp/pwn-asm-2a_arm3i/step2', '/tmp/pwn-asm-2a_arm3i/step1']:
It had the exitcode 1.
It had this on stdout:
/tmp/pwn-asm-2a_arm3i/step1: Assembler messages:
/tmp/pwn-asm-2a_arm3i/step1:11: Error: operand size mismatch for `mov'
/tmp/pwn-asm-2a_arm3i/step1:13: Error: too many memory references for `mov'
/tmp/pwn-asm-2a_arm3i/step1:22: Error: too many memory references for `add'
/tmp/pwn-asm-2a_arm3i/step1:24: Error: too many memory references for `mov'
然后发现原来是要设置环境,也就是加上 context.arch = 'amd64'
from pwn import *
content.arch = 'amd64'
shellcode = asm(shellcraft.amd64.sh())