Nee*_*fra -3 assembly shellcode
我需要知道如何从机器代码中删除空值 (00)。我用汇编语言编写了代码。它运行成功。我需要没有 NULL 的输出
.data
Bash:
.asciz "/bin/hostname"
Null1:
.int 0
AddrToBash:
.int 0
NULL2:
.int 0
.text
.globl _start
_start:
#execute routine
xor %eax,%eax
movl $Bash, AddrToBash
movl $11,%eax
movl $Bash,%ebx
movl $AddrToBash,%ecx
movl $NULL2,%edx
int $0x80
#exit routine
Exit:
movl $10,%ebx
movl $1,%eax
int $0x80
Run Code Online (Sandbox Code Playgroud)
以下输出是
4000b0: 31 c0 xor %eax,%eax
4000b2: c7 04 25 f2 00 60 00 movl $0x6000e0,0x6000f2
4000b9: e0 00 60 00
4000bd: b8 0b 00 00 00 mov $0xb,%eax
4000c2: bb e0 00 60 00 mov $0x6000e0,%ebx
4000c7: b9 f2 00 60 00 mov $0x6000f2,%ecx
4000cc: ba f6 00 60 00 mov $0x6000f6,%edx
4000d1: cd 80 int $0x80
00000000004000d3 <Exit>:
4000d3: bb 0a 00 00 00 mov $0xa,%ebx
4000d8: b8 01 00 00 00 mov $0x1,%eax
4000dd: cd 80 int $0x80
Run Code Online (Sandbox Code Playgroud)
如何删除00,我做了变了样eax
来al
,bx
给BL blahahahahahaha ......但不工作有人可以修改它.......
如果你想避免 shellcode 中的 NULL 字节,你必须考虑很多事情。然而,大多数时候它涉及用等效的指令替换指令。
例如,
mov $0, %eax
Run Code Online (Sandbox Code Playgroud)
产生b8 00 00 00 00
其中包含 NULL 字节。将其替换为
xor %eax, %eax
Run Code Online (Sandbox Code Playgroud)
在语义上是等价的,但产生了31 c0
。
有关编写 shellcode 的良好介绍,请阅读Smashing The Stack For Fun And Profit。Hacking: The Art of Exploitation这本书包含一个关于避免 shellcode 中的 NULL 字节的部分 (0x523)。