Noteable Posts

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

No comments: