0
我讀「砸堆棧的樂趣和利潤」,由阿萊夫一個, 並達成這點:Aleph的shell代碼在哪裏變化?
jmp 0x2a # 2 bytes
popl %esi # 1 byte
movl %esi,0x8(%esi) # 3 bytes
movb $0x0,0x7(%esi) # 4 bytes
movl $0x0,0xc(%esi) # 7 bytes
movl $0xb,%eax # 5 bytes
movl %esi,%ebx # 2 bytes
leal 0x8(%esi),%ecx # 3 bytes
leal 0xc(%esi),%edx # 3 bytes
int $0x80 # 2 bytes
movl $0x1, %eax # 5 bytes
movl $0x0, %ebx # 5 bytes
int $0x80 # 2 bytes
call -0x2f # 5 bytes
.string \"/bin/sh\" # 8 bytes
------------------------------------------------------------------------------
Looks good. To make sure it works correctly we must compile it and run it.
**But there is a problem. Our code modifies itself**, but most operating system
mark code pages read-only.
我的問題是在哪裏(以及如何)這段代碼修改自身? [我不知道裝配那麼好]
謝謝!
謝謝,我知道了:-) 甲後續問題: 無效的主要(){INT * RET; RET =(INT *)&RET + 2;(* RET)=(int)的的shellcode;} 想象一下現在代碼段中的shellcode(全局)數組。我想執行它。 在main的最後一行,我們將shellcode的地址複製到了「ret」指針。 **我的問題是:** 它之前的行(主要)在做什麼? 爲什麼「+2」? 我的意思是,我們不應該希望shellcode的地址覆蓋主目錄 的返回地址,它比當前「ret」指針位置前** 8 **個字節。 [\t爲什麼我認爲8字節: \t 4字節[傳遞* int] + 4字節[傳遞幀指針] = 8字節。 ] 謝謝! – SuperCowInSpace 2014-12-13 15:56:49
下次請創建一個單獨的問題。 '+ 2'是由於C指針算法的工作原理所致,它將按項目大小'4'來縮放。因此'+ 2'實際上是'8'的一個字節偏移量。請注意,編譯器可能使用任何堆棧佈局,所以返回地址甚至可能不超過8個字節。 – Jester 2014-12-13 16:21:35