Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Assembly 

Can not execute when encode to shell code ..

There my first hello world app with asm(Litle edit,trying bypass null bytes etc..).

PHP Code

<?php 
section 
.text                                    
    
global  _start              
                                      
_start
:
    
add     edx,len                                 
    mov     ecx
,msg             
    add     ebx
,1            ;mov     ebx,1               
    add     eax
,4            ;mov     eax,4               
    int     0x80                

      
xor     ebx,ebx            ;mov     ebx,0               
    mov     al
, 1             ;mov     eax,1               
    int     0x80               

section 
.data                  

msg db      
"#Hello World! #B3mB4m",0xa 
len equ     
$ - msg 

When ım complie script to executable file, everything going normal.
PHP Code

<?php 
./hello
#Hello World! #B3mB4m 

There dump info ;

PHP Code

<?php 
hello
:     file format elf32-i386


Disassembly of section 
.text:

08048080 <.text>:
 
8048080:    83 c2 16                 add    $0x16,%edx
 8048083
:    b9 98 90 04 08           mov    $0x8049098,%ecx
 8048088
:    83 c3 01                 add    $0x1,%ebx
 804808b
:    83 c0 04                 add    $0x4,%eax
 804808e
:    cd 80                    int    $0x80
 8048090
:    31 db                    xor    %ebx,%ebx
 8048092
:    b0 01                    mov    $0x1,%al
 8048094
:    cd 80                    int    $0x80 


When im making that shellcode cant execute 😧
Already try to execute in Python/C/C++ ım always get this error ;

PHP Code

<?php 
//System :3.14-kali1-686-pae (32bit)
[php]fragmentation failure 


I'm too hectic right now, sorry for this.So any idea why fail ? 😁
Well firstly you can't utilise your 'message' variable in such a manner because you do not know what is going to be at address because ASLR will randomize that sections base address. You will have to instead utilise a:

Code
_start:
      jmp popme
resume:
      etc etc
      etc etc
popme:
      call resume
      db "#Hello World! #B3mB4m",0x0d,0x0a

Also if you were using this as part of a buffer overflow, it would not work to use 'add <reg32>,0xwhatever' as you've done in your code because you have not zeroed out the registers yet. Instead just use:

Code
xor <reg32>,<reg32>
mov <reg8>,0xwhatever

To be noted that you'll still get a segfault with making that initial change I first suggested because you must disable NX stack first by compiling with -fno-stack-protector -z execstack.
I'm pretty new in asm,asm looks like me little higgledy-piggledy.I will try again, thanks for advice 😉


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Help] by AirbourneApr 8, 2023 12:02 PM 1 78 Apr 8, 2023 12:02 PM
Last Post: luctvmgrzfsxn754
by Unc3nZureDOct 18, 2013 02:49 PM 0 109 Oct 18, 2013 02:49 PM
Last Post: Unc3nZureD
by gimzy.H-OJul 13, 2013 01:48 PM 2 93 Jul 13, 2013 01:48 PM
Last Post: gimzy.H-O