Friday, January 19, 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()





Continue reading


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

No comments:

Post a Comment