Saturday, January 20, 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 word
  1. Ethical Hacker Tools
  2. Pentest Tools Linux
  3. Growth Hacker Tools
  4. Pentest Tools Subdomain
  5. Hack Tool Apk No Root
  6. Hack Tools For Ubuntu
  7. Hacking App
  8. Hack Tools For Pc
  9. Pentest Tools For Windows
  10. Hacker Tools For Mac
  11. What Are Hacking Tools
  12. Pentest Tools For Android
  13. Pentest Tools Apk
  14. Nsa Hack Tools Download
  15. Hack Tools For Pc
  16. Hacker Tools Apk
  17. How To Install Pentest Tools In Ubuntu
  18. Hack Tools For Ubuntu
  19. Hacking Tools Download
  20. Hacker Tools For Mac
  21. Termux Hacking Tools 2019
  22. Hackers Toolbox
  23. Hack Tools For Ubuntu
  24. Hacking Tools For Pc
  25. Hacker Tools Linux
  26. Hacking Tools Windows
  27. Blackhat Hacker Tools
  28. Hack Tools For Ubuntu
  29. Hack Tool Apk
  30. Tools 4 Hack
  31. Hack Tools Online
  32. Android Hack Tools Github
  33. Pentest Recon Tools
  34. Hack Apps
  35. Hacker Tools For Mac
  36. Tools 4 Hack
  37. Hacker Tools Mac
  38. Install Pentest Tools Ubuntu
  39. Hacking Tools Download
  40. Hacker Tools List
  41. Pentest Box Tools Download
  42. Hacking Tools For Windows
  43. Pentest Reporting Tools
  44. Hacking Tools Kit
  45. Hacker Tool Kit
  46. Pentest Tools Tcp Port Scanner
  47. Pentest Tools List
  48. Usb Pentest Tools
  49. Hacker Tools Linux
  50. Usb Pentest Tools
  51. Nsa Hacker Tools
  52. Hacks And Tools
  53. Hackrf Tools
  54. Hack Rom Tools
  55. Github Hacking Tools
  56. Physical Pentest Tools
  57. Hacker Tools Online
  58. Hacking App
  59. Hacker Tools For Windows
  60. Hack Tools 2019
  61. Pentest Tools Review
  62. Top Pentest Tools
  63. Hacker Tools Hardware
  64. Beginner Hacker Tools
  65. Pentest Tools For Mac
  66. Pentest Tools List
  67. Pentest Tools Url Fuzzer
  68. Best Pentesting Tools 2018
  69. Hack Tools For Windows
  70. Pentest Tools For Android
  71. Pentest Tools Android
  72. Hacker Hardware Tools
  73. Hacker Tools Online
  74. Hackrf Tools
  75. Hacker Tools Windows
  76. Pentest Tools Subdomain
  77. Pentest Tools Url Fuzzer
  78. Hack Tools
  79. Pentest Recon Tools
  80. Hacking Tools Software
  81. Pentest Tools Find Subdomains
  82. Hacking Tools For Windows 7
  83. Hacker Tools Hardware
  84. Hacking Tools Github
  85. Hacker Tools Mac
  86. Hacker Security Tools
  87. Nsa Hack Tools Download
  88. Hak5 Tools
  89. Free Pentest Tools For Windows
  90. Hacks And Tools
  91. Pentest Tools
  92. Termux Hacking Tools 2019
  93. Pentest Tools Alternative
  94. Pentest Tools Alternative
  95. Hack Apps
  96. Hack Tools Mac
  97. Hak5 Tools
  98. Hacking Tools Windows
  99. Hacker Tools List
  100. Hacking Tools Windows
  101. Game Hacking
  102. Hacker Security Tools
  103. Hacker Tools Linux
  104. Best Pentesting Tools 2018
  105. Hacker Tools Apk Download
  106. Hacking Tools
  107. Nsa Hacker Tools
  108. Tools 4 Hack
  109. Hacker Tools Online
  110. Bluetooth Hacking Tools Kali
  111. Install Pentest Tools Ubuntu
  112. Pentest Tools Review
  113. Hackrf Tools
  114. Hacker Tools Github
  115. Hack Tools For Ubuntu
  116. Pentest Reporting Tools
  117. Pentest Tools
  118. Pentest Tools Website Vulnerability
  119. Pentest Tools Free
  120. Hacking Tools Hardware
  121. Hacker Tools Mac
  122. Easy Hack Tools
  123. Tools 4 Hack
  124. Hack Website Online Tool
  125. Best Hacking Tools 2020

0 comments:

Country

free counters
 

ဦးဘုန္း (ဓာတု) မႏၱေလး. Copyright 2011 All Rights Reserved Free Wordpress Templates by Brian Gardner Blogger Templates presents HD TV Fringe Streaming. Featured on Wedding Photographers Singapore.