-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7cfe0df
Showing
32 changed files
with
3,568 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/build | ||
/build | ||
*/build | ||
/out | ||
/pack | ||
.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
project(rp2sm_chall LANGUAGES CXX) | ||
|
||
# GLOBAL COMPILE SETTINGS | ||
# TODO: should be moved into a utility library somewhere probably | ||
include(CheckPIESupported) | ||
check_pie_supported() | ||
|
||
include(CheckCXXCompilerFlag) | ||
|
||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
check_cxx_compiler_flag(-fstack-protector-strong has_stack_protector_strong) | ||
if(has_stack_protector_strong) | ||
add_compile_options(-fstack-protector-strong) | ||
else() | ||
check_cxx_compiler_flag(-fstack-protector has_stack_protector) | ||
if(has_stack_protector) | ||
add_compile_options(-fstack-protector) | ||
else() | ||
message(WARNING "Stack protector could not be enabled") | ||
endif() | ||
endif() | ||
# TODO: use tests | ||
add_link_options(LINKER:--sort-common,--as-needed,-z,relro,-z,now) | ||
|
||
# MAIN CODE | ||
|
||
add_subdirectory(rp2sm) | ||
|
||
add_executable(chall | ||
chall/main.cpp | ||
) | ||
target_link_libraries(chall rp2sm) | ||
|
||
# packing | ||
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}") | ||
include(CPack) | ||
install(TARGETS chall rp2sm) | ||
set_target_properties(chall PROPERTIES INSTALL_RPATH "\${ORIGIN}/../lib") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"version": 2, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 20, | ||
"patch": 0 | ||
}, | ||
"configurePresets": [ | ||
{ | ||
"name": "default", | ||
"generator": "Ninja Multi-Config", | ||
"binaryDir": "build", | ||
"cacheVariables": { | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON", | ||
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "-O3 -g -DNDEBUG", | ||
"CMAKE_CXX_FLAGS_DEBUG": "-Og -g", | ||
"CMAKE_BUILD_RPATH_USE_ORIGIN": "ON", | ||
"CPACK_GENERATOR": "TGZ" | ||
}, | ||
"environment": { | ||
"CC": "clang", | ||
"CXX": "clang++" | ||
} | ||
}, | ||
{ | ||
"name": "docker", | ||
"inherits": "default", | ||
"generator": "Unix Makefiles", | ||
"cacheVariables": { | ||
"CMAKE_BUILD_TYPE": "Release" | ||
} | ||
} | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
DOCKER ?= docker | ||
DOCKER-BUILD ?= $(DOCKER) buildx build | ||
GIT ?= git | ||
TAR ?= tar # must be GNU tar | ||
TARFLAGS := --numeric-owner --owner=0 --group=0 --sort=name --mtime=1970-01-01T00:00Z --no-xattr $(TARFLAGS) | ||
|
||
dist_files = $(shell $(GIT) ls-files deploy) $(shell find out -type f) run.Dockerfile | ||
source_files = $(dist_files) flag1.txt flag2.txt solve/loader.py solve/stg1.rp2b solve/stg2.rp2b | ||
tar_transform = --transform 's|^|rp2sm/|;s|\brun\.Dockerfile\b|Dockerfile|' | ||
|
||
.PHONY: default | ||
default: help | ||
|
||
.PHONY: all | ||
all: pack/source.tar pack/dist.tar out | ||
@true | ||
|
||
.PHONY: out | ||
out: | ||
$(DOCKER-BUILD) . -f build.Dockerfile --target extractor -o type=local,dest=out | ||
|
||
out/%: out | ||
@# dummy dependency resolution target | ||
@true | ||
|
||
pack/source.tar: $(source_files) | ||
@mkdir -p pack | ||
$(TAR) $(TARFLAGS) $(tar_transform) -cf $@ $^ | ||
|
||
pack/dist.tar: $(dist_files) | ||
@mkdir -p pack | ||
$(TAR) $(TARFLAGS) $(tar_transform) -cf $@ $^ | ||
|
||
.PHONY: help | ||
help: | ||
@echo "Available targets:" | ||
@echo "" | ||
@echo " out: compile binaries (in out/)" | ||
@echo " pack/source.tar: create \"source\" tarball (for challenge builds)" | ||
@echo " pack/dist.tar: create player-facing tarball" | ||
@echo " all: all of the above" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# rp2sm | ||
|
||
A rev/pwn challenge for [redpwnCTF 2021](https://github.com/redpwn/redpwnctf-2021-challenges). | ||
|
||
Some rough notes I made for myself are in [notes.md](notes.md). The assembler | ||
I wrote is in [assembler/assembler.hs](assembler/assembler.hs), and is used for | ||
assembling the solutions in [solve/](solve/). Reproducible builds of challenge | ||
artifacts are done with Docker; `make out` will build the binaries, and | ||
`make pack/dist.tar` creates the tarball of files distrbuted to competitors. | ||
|
||
[Author writeup](https://ethanwu.dev/blog/2021/07/14/redpwn-ctf-2021-rp2sm/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.hi | ||
*.o | ||
assembler |
Oops, something went wrong.