Thursday, 20 August 2020

Defcon 2015 Coding Skillz 1 Writeup

Just connecting to the service, a 64bit cpu registers dump is received, and so does several binary code as you can see:



The registers represent an initial cpu state, and we have to reply with the registers result of the binary code execution. This must be automated becouse of the 10 seconds server socket timeout.

The exploit is quite simple, we have to set the cpu registers to this values, execute the code and get resulting registers.

In python we created two structures for the initial state and the ending state.

cpuRegs = {'rax':'','rbx':'','rcx':'','rdx':'','rsi':'','rdi':'','r8':'','r9':'','r10':'','r11':'','r12':'','r13':'','r14':'','r15':''}
finalRegs = {'rax':'','rbx':'','rcx':'','rdx':'','rsi':'','rdi':'','r8':'','r9':'','r10':'','r11':'','r12':'','r13':'','r14':'','r15':''}

We inject at the beginning several movs for setting the initial state:

for r in cpuRegs.keys():
    code.append('mov %s, %s' % (r, cpuRegs[r]))

The 64bit compilation of the movs and the binary code, but changing the last ret instruction by a sigtrap "int 3"
We compile with nasm in this way:

os.popen('nasm -f elf64 code.asm')
os.popen('ld -o code code.o ')

And use GDB to execute the code until the sigtrap, and then get the registers

fd = os.popen("gdb code -ex 'r' -ex 'i r' -ex 'quit'",'r')
for l in fd.readlines():
    for x in finalRegs.keys():
           ...

We just parse the registers and send the to the server in the same format, and got the key.


The code:

from libcookie import *
from asm import *
import os
import sys

host = 'catwestern_631d7907670909fc4df2defc13f2057c.quals.shallweplayaga.me'
port = 9999

cpuRegs = {'rax':'','rbx':'','rcx':'','rdx':'','rsi':'','rdi':'','r8':'','r9':'','r10':'','r11':'','r12':'','r13':'','r14':'','r15':''}
finalRegs = {'rax':'','rbx':'','rcx':'','rdx':'','rsi':'','rdi':'','r8':'','r9':'','r10':'','r11':'','r12':'','r13':'','r14':'','r15':''}
fregs = 15

s = Sock(TCP)
s.timeout = 999
s.connect(host,port)

data = s.readUntil('bytes:')


#data = s.read(sz)
#data = s.readAll()

sz = 0

for r in data.split('\n'):
    for rk in cpuRegs.keys():
        if r.startswith(rk):
            cpuRegs[rk] = r.split('=')[1]

    if 'bytes' in r:
        sz = int(r.split(' ')[3])



binary = data[-sz:]
code = []

print '[',binary,']'
print 'given size:',sz,'bin size:',len(binary)        
print cpuRegs


for r in cpuRegs.keys():
    code.append('mov %s, %s' % (r, cpuRegs[r]))


#print code

fd = open('code.asm','w')
fd.write('\n'.join(code)+'\n')
fd.close()
Capstone().dump('x86','64',binary,'code.asm')

print 'Compilando ...'
os.popen('nasm -f elf64 code.asm')
os.popen('ld -o code code.o ')

print 'Ejecutando ...'
fd = os.popen("gdb code -ex 'r' -ex 'i r' -ex 'quit'",'r')
for l in fd.readlines():
    for x in finalRegs.keys():
        if x in l:
            l = l.replace('\t',' ')
            try:
                i = 12
                spl = l.split(' ')
                if spl[i] == '':
                    i+=1
                print 'reg: ',x
                finalRegs[x] = l.split(' ')[i].split('\t')[0]
            except:
                print 'err: '+l
            fregs -= 1
            if fregs == 0:
                #print 'sending regs ...'
                #print finalRegs
                
                buff = []
                for k in finalRegs.keys():
                    buff.append('%s=%s' % (k,finalRegs[k]))


                print '\n'.join(buff)+'\n'

                print s.readAll()
                s.write('\n'.join(buff)+'\n\n\n')
                print 'waiting flag ....'
                print s.readAll()

                print '----- yeah? -----'
                s.close()
                



fd.close()
s.close()





Related links


  1. Hacker Tools Free Download
  2. Pentest Tools Windows
  3. Kik Hack Tools
  4. Pentest Tools Android
  5. Pentest Tools Find Subdomains
  6. Hack Tool Apk
  7. Hacking Tools Windows
  8. Wifi Hacker Tools For Windows
  9. Hack Apps
  10. Hackers Toolbox
  11. Hack Tools For Windows
  12. Pentest Tools Windows
  13. Easy Hack Tools
  14. Physical Pentest Tools
  15. Best Hacking Tools 2020
  16. Pentest Tools Github
  17. Hacking Tools For Windows
  18. Hacking Tools Hardware
  19. Hackers Toolbox
  20. Hacker Tools For Mac
  21. Hacking Tools Windows
  22. Hacking Tools For Windows
  23. Hacking Tools For Windows Free Download
  24. How To Hack
  25. Pentest Tools Alternative
  26. Hacking Tools For Games
  27. Install Pentest Tools Ubuntu
  28. Hack Tools For Ubuntu
  29. Pentest Tools Github
  30. Tools Used For Hacking
  31. Hacker Hardware Tools
  32. Pentest Tools Subdomain
  33. Hacking Tools Download
  34. Blackhat Hacker Tools
  35. Pentest Tools For Ubuntu
  36. Hacker Security Tools
  37. Hacker Tools 2019
  38. Hacking Tools For Games
  39. Termux Hacking Tools 2019
  40. Hacker
  41. Pentest Tools Tcp Port Scanner
  42. Nsa Hack Tools
  43. Pentest Tools Framework
  44. Hack Tools Download
  45. Hacking Tools And Software
  46. Nsa Hacker Tools
  47. Underground Hacker Sites
  48. Hacking Tools For Kali Linux
  49. How To Make Hacking Tools
  50. Hacking Tools Usb
  51. Hacking Tools Name
  52. Beginner Hacker Tools
  53. Hacking Tools For Beginners
  54. Pentest Tools Online
  55. Install Pentest Tools Ubuntu
  56. Hacking Tools Github
  57. Hacking Tools Download
  58. Hacking Tools Software
  59. Best Pentesting Tools 2018
  60. Hack Tools For Ubuntu
  61. Underground Hacker Sites
  62. Tools 4 Hack
  63. Pentest Tools Android
  64. Pentest Tools Download
  65. Hacker Search Tools
  66. Hacking App
  67. Pentest Tools For Ubuntu
  68. Hack Tools
  69. Hacking Tools For Beginners
  70. Hacking Tools Download
  71. Best Pentesting Tools 2018
  72. Hacking Tools And Software
  73. Best Hacking Tools 2019
  74. Hack Rom Tools
  75. Hacker Search Tools
  76. Hak5 Tools
  77. Hacker Hardware Tools
  78. Pentest Reporting Tools
  79. Nsa Hack Tools Download
  80. Pentest Tools For Ubuntu
  81. Beginner Hacker Tools
  82. Hack Tools For Pc
  83. Usb Pentest Tools
  84. Pentest Tools List
  85. Hacking Tools For Games
  86. Hack Apps
  87. Hacker Tools Windows
  88. Hacker Tools Free
  89. World No 1 Hacker Software
  90. Pentest Box Tools Download
  91. Hack Tools Online
  92. Nsa Hacker Tools
  93. Hacking Tools
  94. How To Install Pentest Tools In Ubuntu
  95. World No 1 Hacker Software
  96. Pentest Tools Kali Linux
  97. Physical Pentest Tools
  98. Hacker Tools For Pc
  99. Hack Apps
  100. Hack Tools Mac
  101. Pentest Tools Website
  102. Hacking Tools Usb
  103. Hack Tools For Ubuntu
  104. Hacker Tools Free
  105. Hacking Tools For Windows 7
  106. Hacking Tools For Kali Linux
  107. Hack Tools
  108. Pentest Tools Nmap
  109. Bluetooth Hacking Tools Kali
  110. Hak5 Tools
  111. Nsa Hack Tools
  112. Hacker Tools
  113. Hacker Tools Mac
  114. Beginner Hacker Tools
  115. Hack Tools Download
  116. Hacking App
  117. Best Pentesting Tools 2018
  118. How To Install Pentest Tools In Ubuntu
  119. Hack Rom Tools
  120. Hacker Techniques Tools And Incident Handling
  121. Pentest Tools Apk
  122. Pentest Tools Open Source
  123. Hacking Tools Windows 10
  124. How To Install Pentest Tools In Ubuntu
  125. Hacker Tools
  126. Hacking Tools Windows 10
  127. Physical Pentest Tools
  128. What Are Hacking Tools
  129. Beginner Hacker Tools
  130. Pentest Tools Subdomain
  131. Ethical Hacker Tools
  132. How To Make Hacking Tools
  133. Pentest Reporting Tools
  134. Best Hacking Tools 2020
  135. Hack Tool Apk No Root
  136. Hacker Tools Free Download
  137. Hack Tools
  138. Termux Hacking Tools 2019
  139. Pentest Tools Nmap
  140. Best Pentesting Tools 2018
  141. Hacking Tools For Windows 7
  142. Hacker Tools Windows
  143. Hack And Tools
  144. Hacker Search Tools
  145. Hacker Tools Windows
  146. Pentest Tools Download
  147. Computer Hacker
  148. What Are Hacking Tools
  149. Black Hat Hacker Tools
  150. How To Hack
  151. Hack Tools Mac
  152. Tools 4 Hack
  153. Black Hat Hacker Tools
  154. Computer Hacker
  155. Best Hacking Tools 2020
  156. Hack Tools Online
  157. Hack And Tools
  158. Tools Used For Hacking
  159. Best Hacking Tools 2020
  160. Pentest Tools For Mac
  161. World No 1 Hacker Software
  162. Hack And Tools
  163. Pentest Tools Tcp Port Scanner
  164. Hack Tools
  165. World No 1 Hacker Software
  166. Hacker
  167. Hack Tools Mac
  168. Hacker Security Tools
  169. Hackers Toolbox
  170. Hack Tools Github

0 comments:

Post a Comment