sexta-feira, 26 de janeiro de 2024

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()





More information

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

0 comentários:

Postar um comentário