Last active
August 21, 2023 03:14
-
-
Save domenukk/7f9b353d2887d1b98fe370ff254069d7 to your computer and use it in GitHub Desktop.
Funsafe Rust Jail (for HackIM CTF 2023)
This file contains hidden or 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
#!/bin/bash | |
echo "Your code please." | |
FOLDER=$(mktemp -d) | |
cp flag.txt "$FOLDER" | |
cd "$FOLDER" | |
mkdir src | |
cat <<EOF > Cargo.toml | |
[package] | |
name = "funsafe" | |
version = "0.1.0" | |
edition = "2021" | |
[lib] | |
name = "funsafe" | |
path = "src/lib.rs" | |
[[bin]] | |
name = "funsafe-bin" | |
path = "src/main.rs" | |
[dependencies] | |
ctor = "0.2.4" | |
[profile.release] | |
panic = "abort" | |
EOF | |
read program | |
echo "#![no_std] ${program//!/}" > src/lib.rs | |
echo "use funsafe::fun; pub fn main() {fun()}" > src/main.rs | |
RUSTFLAGS="$RUSTFLAGS -Funsafe-code -Zsanitizer=address" timeout 20 cargo +nightly run --target x86_64-unknown-linux-gnu --release | |
rm -rf "$FOLDER" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment