Rabu, 17 Januari 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()





Related articles


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

Tidak ada komentar: