This shows you the differences between two versions of the page.
isc:labs:01 [2024/03/03 12:07] vlad_iulius.nastase [08. [10p]Static compilation] |
isc:labs:01 [2024/10/07 08:29] (current) |
||
---|---|---|---|
Line 5: | Line 5: | ||
===== Objectives ===== | ===== Objectives ===== | ||
* Simple CTF tasks | * Simple CTF tasks | ||
+ | * Introduction to Python scripting | ||
* Introduction to basic security-related tools | * Introduction to basic security-related tools | ||
- | * Simple program compiling tools | + | |
- | * Basics of networking related monitoring tools | + | ===== Useful Tools ===== |
+ | * man | ||
+ | * find | ||
+ | * base64 | ||
+ | * hexedit | ||
+ | * Binwalk | ||
+ | * john, zip2john | ||
+ | * xxd | ||
+ | * gzip, bzip2, tar | ||
===== Preparation ===== | ===== Preparation ===== | ||
- | <del>You will solve this lab inside a virtual machine on [[https://cloud.grid.pub.ro|openstack]].</del> | + | You may use the UPB's OpenStack cloud to spawn a Virtual Machine to be used for this lab! |
- | + | [[:isc:info:virtualmachine|Read this guide]]. | |
- | OpenStack will be made available in the following days, until then, you can use your native OS for doing the labs (hint: WSL). | + | |
- | + | ||
- | <hidden> | + | |
- | - Log in with your LDAP credentials | + | |
- | - Create a RSA key pair on //fep.grid.pub.ro// (ssh LDAP-USERNAME@fep.grid.pub.ro; ssh-keygen -t rsa -b 4096 -C "your_email@example.com") | + | |
- | - Make sure you have the public key configured on openstack in Project -> Compute -> Key Pairs | + | |
- | * Passphrase authentication will be disabled on the SSH server | + | |
- | * The key that you provide will be automatically registered in //.ssh/authorized_keys// | + | |
- | - Create a new Instance with the following parameters: | + | |
- | * Flavor: m1.small | + | |
- | * Instance Boot Source: Boot from image | + | |
- | * Source (Image): ISC 2022 | + | |
- | * Network: vlan9 | + | |
- | * Key Pair: the one you just added | + | |
- | * **NOTE:** if you have //only one// key pair configured, it will be chosen by default; otherwise, make sure you don't skip this step | + | |
- | - From the fep console (ssh) login into the newly created VM (ssh student@VM-IP) | + | |
- | + | ||
- | </hidden> | + | |
{{page>:isc:rec&nofooter&noeditbutton}} | {{page>:isc:rec&nofooter&noeditbutton}} | ||
- | ===== CTF local tasks ===== | + | Download the {{:isc:labs:isc-lab01.zip|task archive}} for this section. Each exercise will have a corresponding folder. |
- | Download the {{:isc:labs:isc-01.zip|task archive}} for this section. Each exercise will have a corresponding folder. | + | ===== Python Warmup ===== |
- | ==== 01. [10p]B64 encoding ==== | + | ==== 01. Decode 'til You Drop ==== |
- | * The flag is in b64.txt. It should look something like this: **FLAG{...}**. | + | * One of your friends gave you this string which looks encoded... Figure out what encoding was used and decode it. Be patient, it may take a couple of decoding rounds :) |
- | * **Hint:** python3, base64 | + | |
- | ==== 02. [10p]EXIF ==== | + | ==== 02. Zip it good ==== |
- | * The flag is hidden somewhere within this image. Remember its format. | + | * The archive contains the flag. What is the password? |
- | * **Hint:** it's not steganography; don't look at the pixels | + | * **Hint:** the password is in the wordlist |
- | ==== 03. [10p]From Manchester with love ==== | + | ===== CTF tasks ===== |
- | * Remember RL? Remember [[https://en.wikipedia.org/wiki/Manchester_code#Encoding|Manchester]]? | + | |
- | ==== 04. [10p]Corrupted file ==== | + | ==== 03. Find the impostor ==== |
- | * The header seems to be damaged... | + | * The flag for this exercise is found in a file under the inhere directory. The file has the following properties: |
+ | * human-readable | ||
+ | * 987 bytes in size | ||
+ | * not executable | ||
- | Up for more? | + | ==== 04. Unknown File Type ==== |
- | * [[https://ctflearn.com|CTFlearn]] | + | |
- | * [[https://overthewire.org/wargames/|OverTheWire]] | + | |
- | * [[https://cryptopals.com/|Cryptopals Challenges]] | + | |
- | * [[https://picoctf.com/|PicoCTF]] | + | |
- | ===== OS Management ===== | + | * We've found this file on a confiscated machine, but we can't figure what it is. Can you help us? |
- | ==== 05. [10p]Web server & console browser ==== | + | |
- | * Install and configure **apache2** and **links**. Use the latter to connect to http://localhost | + | ==== 05. Corrupted File ==== |
- | * **Hint:** use the distro specific package manager. | + | |
- | <solution -hidden> | + | * During a transmission, one of our files got corrupted. Take a look and see if you can do something about it. |
- | <code bash> | + | Maybe there is something wrong with the header. |
- | $ sudo apt-get install apache2 links | + | * **Hint:** use a hex editor to check the file's header |
- | $ sudo /etc/init.d/apache2 start | + | |
- | $ links http://localhost | + | ==== 06. Hidden File ==== |
- | $ sudo /etc/init.d/apache2 stop | + | * There is something wrong with the size of this image. Is there anything else there? |
- | </code> | + | * **Hint:** use Binwalk. "-e" option is buggy sometimes. |
- | </solution> | + | |
- | ==== 06. [10p]Disk space & usage ==== | + | ==== 07. Waiting for eternity ==== |
- | * Display the disk space usage for each individual directory (. and .. excluded) in the first two hierarchical levels of ///usr/include/ // in a human readable format | + | * We stared at this gif for the last hour but nothing is happening. Would you like to join us and stare at it for the next hour? |
- | * **Hint:** find, du | + | |
- | * Sort the list in ascending order, by size | + | |
- | <solution -hidden> | + | ==== 08. The great file squeeze ==== |
- | <code bash> | + | * You are being given a file which is a hexdump of the flag that has been repeatedly compressed. Reverse the process and get the flag :) |
- | $ find /usr/include -maxdepth 2 -type d ! -name "." -exec du -sh {} \; | sort -rh | + | * **Hint:** hexdump, man |
- | </code> | + | |
- | </solution> | + | |
- | + | ||
- | ===== Program compilation tools ===== | + | |
- | + | ||
- | ==== 07. [10p]Program compilation ==== | + | |
- | * Download the following [[https://curl.haxx.se/libcurl/c/simple.html|program]] and compile it using **gcc**. | + | |
- | * What is the program intended for? | + | |
- | * Modify the program such that it connects to "http://localhost" (i.e. your local apache server) and prints the response (apache's default HTML test page) to stdout, just like standard curl. | + | |
- | * **Hint:** you need to install libcurl's development libraries. | + | |
- | * **Hint:** you need some flags for the compiler to know where libcurl is installed (see [[https://curl.haxx.se/libcurl/c/libcurl-tutorial.html|library's documentation]]) | + | |
- | <solution -hidden> | + | ==== 09 [bonus]. Web Fuzzer ==== |
- | <code bash> | + | * Start this task by opening a specific docker container on your VM: <code bash> |
- | $ sudo apt install gcc | + | docker run -d -p 8080:80 ghcr.io/cs-pub-ro/isc-lab-intro-web |
- | $ sudo apt install libcurl4-gnutls-dev | + | |
- | $ # Replace in simple.c "http://example.com" with "http://localhost" | + | |
- | $ gcc ./simple.c -lcurl -o simple | + | |
</code> | </code> | ||
- | </solution> | + | * You can now access a webserver on local port 8080 (try it with ''curl localhost:8080''). Your task is to retrieve the hidden flag by trying all web paths inside the given wordlist (write your own fuzzer in Python, check the lab archive for resources!). |
- | + | * //Hint//: use the [[https://requests.readthedocs.io/en/latest/|Python requests]] library to issue web requests! Check their HTTP status code to know when you successfully found an existing web file ;) | |
- | ==== 08. [10p]Static compilation ==== | + | |
- | + | ||
- | * Statically compile the program (but keep a copy of the old, shared executable). | + | |
- | * **Hint:** curl-config %%--%%static-libs | + | |
- | * **Hint:** Note that you'll need even more development libraries: libidn11-dev librtmp-dev libssl-dev libcrypto++-dev libkrb5-dev libldap2-dev libnghttp2-dev libpsl-dev libssh-dev libzstd-dev libbrotli-dev | + | |
- | * **Hint:** Getting a pthread-related linker error? Try //-lpthread// at the end of the gcc command! | + | |
- | * Check the size difference. What does it mean? | + | |
- | * **Hint:** ldd | + | |
- | * Uninstall libcurl and see which of the executables successfully run now! | + | |
- | * Reinstall curl again if you need it ;) | + | |
- | + | ||
- | + | ||
- | + | ||
- | <solution -hidden> | + | |
- | <code bash> | + | |
- | $ gcc -o simple_static simple.c $(curl-config --static-libs) -lpthread | + | |
- | </code> | + | |
- | </solution> | + | |
- | + | ||
- | ===== Networking related tools ===== | + | |
- | + | ||
- | ==== 09. [10p]Traffic sniffing ==== | + | |
- | + | ||
- | * Use the tcpdump suite to save all the traffic from interface ens3/eth0 to a file. | + | |
- | * **Hint:** Tcpdump may complain that it has no privileges to write the log file. Use "-Z student" (man!) to reacquire them. | + | |
- | + | ||
- | <solution -hidden> | + | |
- | <code bash> | + | |
- | $ tcpdump -Z student -i eth0 -w tcpdump_capture | + | |
- | + | ||
- | $ tcpdump -r tcpdump_capture | + | |
- | </code> | + | |
- | </solution> | + | |
===== Feedback ===== | ===== Feedback ===== | ||
{{page>:isc:lab-feedback&nofooter&noeditbutton}} | {{page>:isc:lab-feedback&nofooter&noeditbutton}} | ||
+ |