Apóyanos

La Fundación Ideando, es una organización sin fines de lucro y funciona gracias al apoyo de personas como usted, que colaboran de manera desinteresada en beneficio de un progreso cultural y educativo con mayor oportunidad para el mundo. Presione sobre Donate y coloque el monto que quiere aportar..

sábado, 27 de mayo de 2023

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

No hay comentarios:

Publicar un comentario

Compartir

Bookmark and Share