Skip to content
Permalink
Browse files
update
  • Loading branch information
fernandofilipe13 committed Nov 5, 2021
1 parent 4df533f commit 1acf4063cf6be86a19c40ca8dbca43e8847d5355
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 20 deletions.
@@ -5,3 +5,4 @@
/html/
/submission/5062CEM_2021_22_SepJan_CW1_main_sit_0123456789.html
/tests/__pycache__/
.DS_Store
@@ -1,3 +1,4 @@
# !/usr/bin/python3

table=[27, 128, 105, 153, 231, 42, 147, 187, 20, 224, 154, 202, 39, 8, 7, 226, 46, 109, 35, 229, 104, 116, 0, 99, 121, 125, 122, 38, 5, 55, 160, 23, 30, 240, 157, 146, 102, 115, 189, 86, 158, 82, 176, 95, 2, 126, 124, 239, 103, 106, 54, 72, 123, 43, 241, 230, 161, 171, 73, 249, 3, 61, 78, 221, 223, 44, 174, 181, 156, 19, 74, 225, 214, 69, 197, 204, 71, 162, 219, 234, 4, 247, 248, 98, 66, 186, 205, 101, 93, 151, 75, 193, 167, 179, 208, 194, 94, 40, 235, 77, 62, 144, 76, 32, 100, 119, 152, 237, 107, 33, 142, 18, 88, 172, 163, 182, 227, 58, 199, 250, 50, 165, 228, 253, 24, 14, 45, 139, 64, 140, 213, 245, 215, 164, 97, 236, 89, 243, 159, 12, 168, 84, 37, 173, 141, 180, 177, 192, 134, 90, 110, 222, 191, 255, 129, 232, 188, 118, 87, 57, 21, 196, 242, 49, 47, 155, 195, 148, 92, 149, 15, 11, 96, 132, 170, 131, 1, 203, 135, 207, 127, 210, 178, 190, 51, 67, 220, 63, 211, 79, 185, 217, 13, 85, 68, 120, 34, 206, 22, 9, 201, 150, 56, 212, 29, 60, 183, 130, 200, 113, 36, 81, 218, 233, 244, 41, 26, 91, 216, 83, 112, 111, 48, 65, 25, 10, 108, 246, 136, 28, 133, 166, 145, 70, 117, 80, 31, 137, 251, 175, 209, 17, 6, 169, 184, 53, 114, 254, 138, 198, 16, 252, 238, 59, 143, 52]

@@ -36,6 +37,7 @@ def asHex(v):
return " ".join("{:02x}".format(c) for c in v).upper()



if __name__=="__main__":
nBytes=2
tests=["6fxzw","This is a Test", "yes", "no", "maybe", "Chowder for the kitten. Mellow yellow lemon."]
@@ -137,9 +137,21 @@ def generateTable(chainStarts, hashFunc, guessFunc, chainLength, minLen=3,maxLen


#### These lines are here so I can run my own answer. Replace the next two lines with your code
import answer
return answer.generateTable(chainStarts,hashFunc,guessFunc,chainLength,minLen,maxLen, charset)

# import answer
# return answer.generateTable(chainStarts,hashFunc,guessFunc,chainLength,minLen,maxLen, charset)
guessesArr =[]
hashArr =[]
for i in range(len(chainStarts)):
for value in range(chainLength):
if value == 0:
guess = chainStarts[i]
hash = hashFunc(guess)
if not hash in hashArr:
guessesArr.append(guess)
hashArr.append(hash)

guess = guessFunc(hash,0,minLen,maxLen,charset)
return hashArr



@@ -0,0 +1,107 @@
<h1>5062CEM Coursework 1</h1>
<ul>
<li>Student ID: (10697667)</li>
</ul>
<h2>Task 1: Passwords and Hashes (10%)</h2>
<pre><code>If the hashes produced are all 2 bytes, how many possible hash values are there? Explain how you calculate this value.


(With one byte is 2^8 = 256 values. The number 2 is from the binary because a binary number is represented in the base 2 numeral system, because the binary only has two numbers (zeros and ones), and the 8 is because one byte are 8 bits.
2 bytes which is 16 bits is 65,536. (2^16) )


With minimum password length of 3 and maximum of 6, and possible characters being all upper and lowecase letters and digits (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789) how many possible passwords are in our "search space"? Explain how you calculate this value.
</code></pre>
<p>The alphabet has 26 characters. Upper and Lower case alphabet characters are 52 (26+26 or 26*2), plus 10 numbers (0-9) is 62.
I know the password has the minimum of 3 characters so I'm going to multiply 3 times 62. Which is:
62^3 = 238,328
I know the password has the maximum of 6 characters so I'm going to multiply 6 times 62. Which is:
62^6 = 56,800,235,584
I already know the system will not accept passwords with a lenght smaller then 3 characters, I'm going to subtract the minimum possiblities passwords accepted with the maximum.
56,800,235,584 - 238,328 = 56,799,997,256</p>
<p>The possible passwords are 56,799,997,256</p>
<pre><code>One of these numbers is larger than the other. What implications does this have for security if this hash function is used in storing passwords? What implications does this have for our rainbow table?

(The rainbow table will break easily and faster the shortest passwords then the largest)
</code></pre>
<h2>Task 2: Implementing the table (30%)</h2>
<p>Include your <code>generateTable</code> function below. The three back-ticks before and after the code tell Markdown that the text between should be marked-up as code.</p>
<pre><code class="language-python">
def generateTable(chainStarts, hashFunc, guessFunc, chainLength, minLen=3,maxLen=6,charset=defaultCharset):
&quot;&quot;&quot; Create a rainbow table for the given hash function

Arguments:
chainStarts -- a list of starting values. The length of this list determines how many chains will be constructed.
hashFunc -- a hash function to be used in the hashing step.
guessFunc -- a function that can produce valid inputs to the hash function. The function should accept a value and the keyword arguments `minLen` (minimum guess length) `maxLen` (maximum guess length) and `charset` (a string containing all valid characters to be used in the table). These will be passed directly from the arguments of the same names given to this funciton.
chainLength -- length of each chain
minLen -- minimum length of values to be hashed
maxLen -- maximum length of values to be hashed
charset -- string containing all valid characters for values being hashed

&quot;&quot;&quot;
guessesArr =[]
hashArr =[]
for i in range(len(chainStarts)):
for value in range(chainLength):
if value == 0:
guess = chainStarts[i]
hash = hashFunc(guess)
if not hash in hashArr:
guessesArr.append(guess)
hashArr.append(hash)
guess = guessFunc(hash,0,minLen,maxLen,charset)
return hashArr
</code></pre>
<h2>Task 3: Parameters (10%)</h2>
<pre><code>Discuss how to select the best parameters for generating a rainbow table.
</code></pre>
<p>(Things we need to care when generating a rainbow table is the chain lenght and how many chains will the table have. Also we have to know how many rows and collumns we need for our rainbow table. If we choose a small table with 10 rows, 10 collumns which are 100 hashes and we are working in a fast computer it will be very quickly to generate a table but if we create a big table with 100 rows and 100 collumns which is 10000 hashes will take more time to generate. But here we are thinking in a small number, let's try 1 million rows and 1 millions collumns, I did it, and it took a lot of time.
To take get a hash from a small table it's super fast but if we're trying to get a hash from a big table it will take a while to retrivie the value.)</p>
<p>Some hints:</p>
<ul>
<li>You can change the number of chains and the length of each chain</li>
<li>What effect does changing each of these have on:<ul>
<li>How well the table works, as in how many hashes it can break?</li>
<li>How long it takes to create?</li>
<li>How much space it takes up? </li>
<li>How long it takes to search the chains for hashes? It depends </li>
</ul>
</li>
</ul>
<h2>Task 4: Reversing Hashes (10%)</h2>
<pre><code>What are possible passwords that produce the following hashes?

I couldn't find the right password but I have a chain guess.
</code></pre>
<ul>
<li>BA FF - kvSo</li>
<li>BE 21 - ZeH3l</li>
<li>12 34 - LXiKL</li>
<li>9A 2E - ODlYoo</li>
</ul>
<p>(Write your answers next to the hashes above. HINT: you can check your answers by putting them into the pearson hashN function and seeing if they give you the right hash)</p>
<h2>Task 5: Improving Guess Generation Efficiency (20%)</h2>
<pre><code>The function that currently produces guesses is not as efficient as it could be.

Discuss how the time it takes is related to the index argument and propose a solution that makes it independant of this value.
</code></pre>
<p>()</p>
<h2>Challenge: Web service compromise (20%)</h2>
<p>The docker container <code>cueh/pears_tree:latest</code> uses unsalted 2-byte pearson hashes for checking passwords. See if you can steal the password list and find passwords that result in the hashes.</p>
<p>To run the container: <code>docker run -it cueh/pears_tree:latest</code>. The container should tell you which IP and port to use. If it's the only running container, it will probably be: <code>http://172.17.0.2:80</code>.</p>
<p>If you're doing it on a chromebook, use this instead: <code>docker run -p 8000:80 -it cueh/pears_tree:latest</code> and browse to <code>http://penguin.linux.test:8000</code></p>
<p>You should submit the usernames you found, along with matching
passwords that will work on the site.</p>
<pre><code>Write a short description of how you found the hashes and used them to gain access to the site.

List the hashes you found and passwords that can be used for the found usernames.
</code></pre>
<p>(The first thing I did was open the site and I tried to explore everything with the browser tools. I found the cookies called "userID" and "authToken". I tried to change them and I realised the cookies were being checked in the server side. I went to the login page were I found the username input and password, I also found the hidden input which is a CSRF TOKEN. I didn't know what type of token was that and I googled it and I realised it is a server side unique token generated by the server but only when the client is accessing the site. One time generated by the server I read and I assume the server will check the token and I was right because I tried to change the token and I could check the debug result saying <em>invalid token</em>.
I also tried to do SQL injection but I think the password is already set onto a variable or a list in the server side.</p>
<p>After that I went to terminal and I started looking for hidden files in the server. I used some methods learned in other lectures. I used <em>gobuster</em> tool and I found the console page and one directory. I already knew about the static page but when I did again the same thing but inside the directory I found the password hidden page. That's how I found the usernames and passwords list.</p>
<p>root: 5B 1B
sally: FF 4A
duncan: 50 CB</p>
<p>I don't have any guess of the passwords.
)</p>
@@ -1,14 +1,15 @@
# 5062CEM Coursework 1

- Student ID: (12031928301)
- Student ID: (10697667)


## Task 1: Passwords and Hashes (10%)

If the hashes produced are all 2 bytes, how many possible hash values are there? Explain how you calculate this value.


(Insert your answer here)
(With one byte is 2^8 = 256 values. The number 2 is from the binary because a binary number is represented in the base 2 numeral system, because the binary only has two numbers (zeros and ones), and the 8 is because one byte are 8 bits.
2 bytes which is 16 bits is 65,536. (2^16) )


With minimum password length of 3 and maximum of 6, and possible characters being all upper and lowecase letters and digits (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789) how many possible passwords are in our "search space"? Explain how you calculate this value.
@@ -19,14 +20,16 @@ The alphabet has 26 characters. Upper and Lower case alphabet characters are 52
62^3 = 238,328
I know the password has the maximum of 6 characters so I'm going to multiply 6 times 62. Which is:
62^6 = 56,800,235,584
I already know the system will not accept passwords with a lenght smaller then 3 characters, I'm going to subtract the minimum possiblities passowrd accepted with the maximum.
I already know the system will not accept passwords with a lenght smaller then 3 characters, I'm going to subtract the minimum possiblities passwords accepted with the maximum.
56,800,235,584 - 238,328 = 56,799,997,256

The possible passwords are 56,799,997,256



One of these numbers is larger than the other. What implications does this have for security if this hash function is used in storing passwords? What implications does this have for our rainbow table?

(The rainbow table will break easily and faster the shortest passwords then the largest)

## Task 2: Implementing the table (30%)

@@ -48,47 +51,46 @@ def generateTable(chainStarts, hashFunc, guessFunc, chainLength, minLen=3,maxLen
charset -- string containing all valid characters for values being hashed
"""
count = 0
guessesArr =[]
guessesArr =[]
hashArr =[]
for i in range(len(chainStarts)):
for value in range(chainLength):
if value == 0:
guess = chainStarts[count]
guess = chainStarts[i]
hash = hashFunc(guess)
if not hash in hashArr:
guessesArr.append(guess)
hashArr.append(hash)
guess = guessFunc(hash,0,minLen,maxLen,charset)
count=count+1
return hashArr
```

## Task 3: Parameters (10%)

Discuss how to select the best parameters for generating a rainbow table.

(Write your answer here)
(Things we need to care when generating a rainbow table is the chain lenght and how many chains will the table have. Also we have to know how many rows and collumns we need for our rainbow table. If we choose a small table with 10 rows, 10 collumns which are 100 hashes and we are working in a fast computer it will be very quickly to generate a table but if we create a big table with 100 rows and 100 collumns which is 10000 hashes will take more time to generate. But here we are thinking in a small number, let's try 1 million rows and 1 millions collumns, I did it, and it took a lot of time.
To take get a hash from a small table it's super fast but if we're trying to get a hash from a big table it will take a while to retrivie the value.)

Some hints:

- You can change the number of chains and the length of each chain
- What effect does changing each of these have on:
- How well the table works, as in how many hashes it can break?
- How long it takes to create?
- How much space it takes up?
- How long it takes to search the chains for hashes?
- How much space it takes up?
- How long it takes to search the chains for hashes? It depends


## Task 4: Reversing Hashes (10%)

What are possible passwords that produce the following hashes?

- BA FF
- BE 21
- 12 34
- 9A 2E
I couldn't find the right password but I have a chain guess.
- BA FF - kvSo
- BE 21 - ZeH3l
- 12 34 - LXiKL
- 9A 2E - ODlYoo

(Write your answers next to the hashes above. HINT: you can check your answers by putting them into the pearson hashN function and seeing if they give you the right hash)

@@ -100,7 +102,7 @@ Some hints:
Discuss how the time it takes is related to the index argument and propose a solution that makes it independant of this value.


(Write your answer here)
()

## Challenge: Web service compromise (20%)

@@ -117,3 +119,14 @@ passwords that will work on the site.

List the hashes you found and passwords that can be used for the found usernames.

(The first thing I did was open the site and I tried to explore everything with the browser tools. I found the cookies called "userID" and "authToken". I tried to change them and I realised the cookies were being checked in the server side. I went to the login page were I found the username input and password, I also found the hidden input which is a CSRF TOKEN. I didn't know what type of token was that and I googled it and I realised it is a server side unique token generated by the server but only when the client is accessing the site. One time generated by the server I read and I assume the server will check the token and I was right because I tried to change the token and I could check the debug result saying *invalid token*.
I also tried to do SQL injection but I think the password is already set onto a variable or a list in the server side.

After that I went to terminal and I started looking for hidden files in the server. I used some methods learned in other lectures. I used *gobuster* tool and I found the console page and one directory. I already knew about the static page but when I did again the same thing but inside the directory I found the password hidden page. That's how I found the usernames and passwords list.

root: 5B 1B
sally: FF 4A
duncan: 50 CB

I don't have any guess of the passwords.
)
@@ -2,7 +2,7 @@ import markdown


#Insert your student ID here
student_id="0123456789"
student_id="10697667"



0 comments on commit 1acf406

Please sign in to comment.