Sunday, January 28, 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()





More info


  1. Hacking Tools 2019
  2. Hack Tools Pc
  3. Tools Used For Hacking
  4. How To Install Pentest Tools In Ubuntu
  5. Hacking Tools Name
  6. Hacking Tools Windows
  7. Pentest Tools Open Source
  8. Hack Tools For Ubuntu
  9. Hack Tools For Games
  10. What Are Hacking Tools
  11. Hack Tool Apk No Root
  12. Hacking Tools Usb
  13. Hacker Tools Mac
  14. Pentest Tools Github
  15. Hack Tool Apk No Root
  16. Hacker Tools Free
  17. Hacker Tools
  18. Termux Hacking Tools 2019
  19. Hacker Tools Apk Download
  20. Hack Tools For Ubuntu
  21. Nsa Hack Tools Download
  22. Underground Hacker Sites
  23. Hacking Tools Mac
  24. Nsa Hack Tools
  25. Hack Tools Github
  26. Nsa Hack Tools
  27. Pentest Tools Download
  28. Hacker Tools Linux
  29. Hacker Hardware Tools
  30. What Is Hacking Tools
  31. Pentest Tools Port Scanner
  32. Hacker Tool Kit
  33. Hacker Tools Windows
  34. Pentest Tools Subdomain
  35. Hacker Search Tools
  36. Hacking Tools Windows 10
  37. Hack Tool Apk No Root
  38. Pentest Reporting Tools
  39. Hack Website Online Tool
  40. What Is Hacking Tools
  41. Bluetooth Hacking Tools Kali
  42. Hack Tools Download
  43. Bluetooth Hacking Tools Kali
  44. Hack Tools Pc
  45. Pentest Reporting Tools
  46. New Hacker Tools
  47. Hacking Tools For Beginners
  48. Hack Tools Mac
  49. Hack And Tools
  50. Hack Apps
  51. Hackrf Tools
  52. Hack Tools For Games
  53. Hack Tools For Windows
  54. Tools For Hacker
  55. Hack Website Online Tool
  56. Best Hacking Tools 2020
  57. New Hack Tools
  58. Pentest Tools Website
  59. Hacker Hardware Tools
  60. Hacker Tools For Mac
  61. Hak5 Tools
  62. Pentest Tools For Mac
  63. Hacking Tools For Windows
  64. Hack Tools
  65. Pentest Tools For Windows
  66. Hack Tools
  67. Hacker Tools Free Download
  68. Hacker Tools 2019
  69. Hacker Search Tools
  70. Pentest Tools For Windows
  71. Hacker Tools 2020
  72. Hack Tools For Games
  73. Tools 4 Hack
  74. Pentest Tools Free
  75. What Is Hacking Tools
  76. Pentest Tools Kali Linux
  77. Install Pentest Tools Ubuntu
  78. Hack Tools Pc
  79. Hacker Tools Online
  80. Wifi Hacker Tools For Windows
  81. Hackrf Tools
  82. Hack Tool Apk No Root
  83. Hacking Tools For Mac
  84. Pentest Tools Subdomain
  85. New Hacker Tools
  86. Pentest Recon Tools
  87. Hacking Tools Free Download
  88. Hacker Tools For Windows
  89. Hack Tool Apk No Root
  90. Hackrf Tools
  91. Hacking Tools Free Download
  92. Hacker Tool Kit
  93. Best Hacking Tools 2019
  94. Hack Tools
  95. Hack Tools Mac
  96. Hak5 Tools
  97. Hacking Tools Pc
  98. Hacking Tools For Windows
  99. What Is Hacking Tools
  100. Hacker Tools For Windows
  101. Tools 4 Hack
  102. How To Install Pentest Tools In Ubuntu
  103. Android Hack Tools Github
  104. Best Hacking Tools 2019

Top System Related Commands In Linux With Descriptive Definitions


Commands are just like an instructions given to a system to do something and display an output for that instruction. So if you don't know how to gave an order to a system to do a task then how it can do while you don't know how to deal with. So commands are really important for Linux users. If you don't have any idea about commands of Linux and definitely you also don't know about the Linux terminal. You cannot explore Linux deeply. Because terminal is the brain of the Linux and you can do everything by using Linux terminal in any Linux distribution. So, if you wanna work over the Linux distro then you should know about the commands as well.
In this blog you will get a content about commands of Linux which are collectively related to the system. That means if you wanna know any kind of information about the system like operating system, kernel release information, reboot history, system host name, ip address of the host, current date and time and many more.

Note:

If you know about the command but you don't have any idea to use it. In this way you just type the command, then space and then type -h or --help or ? to get all the usage information about that particular command like "uname" this command is used for displaying the Linux system information. You don't know how to use it. Just type the command with help parameter like: uname -h or uname --help etc.

uname 

The "uname" is a Linux terminal command responsible of displaying the information about Linux system. This command has different parameter to display a particular part of information like kernel release (uname -r) or all the information displayed by typing only one command (uname -a).

uptime

This command is used to show how long the system has been running and how much load on it at current state of the CPU. This command is very useful when you system slows down or hang etc and you can easily get the info about the load on the CPU with the help of this command.

hostname

The "hostname" is the the command in Linux having different parameters to display the information bout the current host which is running the kernel at that time. If you wanna know about the parameters of hostname command then you just type hostname --help or hostname -h to get all the info about the command and the usage of the command.

last reboot

The "last reboot" is the command in Linux operating system used to display the reboot history. You just have to type this command over the Linux terminal it will display the reboot history of that Linux system.

date

The "date" is the command used in Linux operating system to show the date of the day along with the current time of the day.

cal

The "cal" command in Linux used to display the calendar which has the current date highlighted with a square box along with a current month dates and days just like a real calendar.

w

The "w" is the command used in Linux distro for the sake of getting the information about current user. If you type this command it will display who is online at the time.

whoami

The "whoami" is the command in Linux operating system used to show the information that who you are logged in as. For example if you are logged in as a root then it'll display "root" etc.

finger user

The "finger user" is the command used in Linux distribution to display the information about user which is online currently over that Linux system.

Related links


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

Saturday, January 27, 2024

Linux Command Line Hackery Series - Part 4




Welcome back to Linux Command Line Hackery, hope you have enjoyed this series so far. Today we are going to learn new Linux commands and get comfortable with reading text files on Linux.

Suppose that you wanted to view your /etc/passwd file. How will you do that? From what we have learned so far what you'll do is type:

cat /etc/passwd

And there you go, but really did you see all the output in one terminal? No, you just ended up with last few lines and you'll have to cheat (i,e use graphical scroll bar) in order to see all the contents of /etc/passwd file. So is there a command line tool in linux with which we can see all the contents of a file easily without cheating? Yes, there are actually a few of them and in this article we'll look at some common ones.

Command: more
Syntax:  more [options] file...
Function: more is a filter for paging through text one screenful at a time. With more we can parse a file one terminal at a time or line by line. We can also go backward and forward a number of lines using more.

So if we're to use more on /etc/passwd file how will we do that? We'll simply type

more /etc/passwd

now we'll get a screenful output of the file and have a prompt at the bottom of terminal. In order to move forward one line at a time press <Enter Key>. Using enter we can scroll through the file one line at a time. If you want to move one screen at a time, you can press <Space Key> to move one screen at a time. There are more functions of more program, you can know about them by pressing <h key>. To exit out of more program simply type <q key> and you'll get out of more program.

Command: less
Syntax: less [options] file...
Function: less is similar to more but less has more functionality than more. less is particularly useful when reading large files as less does not have to read the entire input file before starting, so it starts up quickly than many other editors.

less command is based on more so what you've done above with more can be done with less as well. Try it out yourself.

Command: head
Syntax: head [OPTION]... [FILE]...
Function: head command prints the head or first part of a file. By default head prints out first 10 lines of a file. If more than one file is specified, head prints first 10 lines of all files as a default behavior.

If we want to see only first 10 lines of /etc/passwd we can type:

head /etc/passwd

We can also specify to head how many lines we want to view by using the -n flag. Suppose you want to see first 15 lines of /etc/passwd file you've to type:

head -n 15 /etc/passwd

Ok you can view the first lines of a file what about last lines, is there a tool for that also? Exactly that's what our next command will be about.

Command: tail
Syntax: tail [OPTION]... [FILE]...
Function: tail is opposite of head. It prints the last 10 lines of a file by default. And if more than one file is specified, tail prints last 10 lines of all files by default.

To view last 10 lines of /etc/passwd file you'll type:

tail /etc/passwd

and as is the case with head -n flag can be used to specify the number of lines

tail -n 15 /etc/passwd

Now one more thing that we're going to learn today is grep.

Command: grep
Syntax: grep [OPTIONS] PATTERN [FILE...]
Function: grep is used to search a file for lines matching the pattern specified in the command.

A PATTERN can simply be a word like "hello" or it can be a regular expression (in geek speak regex). If you aren't familiar with regex, it's ok we'll not dive into that it's a very big topic but if you want to learn about it I'll add a link at the end of this article that will help you get started with regex.

Now back to grep say we want to find a line in /etc/passwd file which contains my user if we'll simply type:

grep myusername /etc/passwd

Wohoo! It gives out just that data that we're looking for. Remember here myusername is your username.
One cool flag of grep is -v which is used to look in file for every line except the line containing the PATTERN specified after -v [it's lowercase v].

Take your time practicing with these commands especially grep and more. We'll learn a lot more about grep in other upcoming articles.

References:
https://en.wikipedia.org/wiki/Regular_expression
http://www.regular-expressions.info/
Awesome website to learn Regular expressions - http://www.regexr.com/

Related word


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