working example
This commit is contained in:
parent
f83393b0a7
commit
46ce08588a
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.direnv/
|
||||
.direnv/
|
||||
/result
|
@ -1,15 +0,0 @@
|
||||
def rot13(message):
|
||||
subs = {'A': 'N', 'B': 'O', 'C': 'P', 'D': 'Q', 'E': 'R', 'F': 'S', 'G': 'T', 'H': 'U', 'I': 'V', 'J': 'W', 'K': 'X', 'L': 'Y', 'M': 'Z', 'N': 'A', 'O': 'B', 'P': 'C', 'Q': 'D', 'R': 'E', 'S': 'F', 'T': 'G', 'U': 'H', 'V': 'I', 'W': 'J', 'X': 'K', 'Y': 'L', 'Z': 'M',
|
||||
'a': 'N', 'b': 'O', 'c': 'P', 'd': 'Q', 'e': 'R', 'f': 'S', 'g': 'T', 'h': 'U', 'i': 'V', 'j': 'W', 'k': 'X', 'l': 'Y', 'm': 'Z', 'n': 'A', 'o': 'B', 'p': 'C', 'q': 'D', 'r': 'E', 's': 'F', 't': 'G', 'u': 'H', 'v': 'I', 'w': 'J', 'x': 'K', 'y': 'L', 'z': 'M'}
|
||||
|
||||
return ''.join(list(map(
|
||||
lambda x: subs[x] if x in subs else x,
|
||||
message
|
||||
)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open('./000-999/144/inputs/input') as file:
|
||||
input = file.read()
|
||||
|
||||
print(rot13(input))
|
@ -7,4 +7,4 @@ The folder name is the challenge id, as found in the URL (<https://play.picoctf.
|
||||
|
||||
Inside the folder there is an `inputs` subfolder which just includes all the files from the challenge description.
|
||||
|
||||
Executing `main.py` runs the challenge.
|
||||
Executing `nix run .#CHALLENGE_ID` runs the challenge.
|
||||
|
15
exercises/144/main.py
Normal file
15
exercises/144/main.py
Normal file
@ -0,0 +1,15 @@
|
||||
def rot13(message):
|
||||
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
subs = {char: alphabet[(i + 13) % 26] for i, char in enumerate(alphabet)}
|
||||
|
||||
return ''.join(list(map(
|
||||
lambda x: subs[x] if x in subs else x,
|
||||
message
|
||||
)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open("./exercises/144/inputs/input") as file:
|
||||
input = file.read()
|
||||
|
||||
print(rot13(input))
|
@ -1,5 +1,5 @@
|
||||
if __name__ == '__main__':
|
||||
with open('./000-999/147/inputs/flag') as file:
|
||||
with open('./exercises/147/inputs/flag') as file:
|
||||
input = file.read()
|
||||
|
||||
print(input)
|
32
flake.nix
32
flake.nix
@ -11,11 +11,37 @@
|
||||
}: let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
exercises = builtins.attrNames (builtins.readDir ./exercises);
|
||||
forAllExercises = nixpkgs.lib.genAttrs exercises;
|
||||
in {
|
||||
formatter.${system} = pkgs.alejandra;
|
||||
|
||||
devShells.${system}.default = pkgs.mkShellNoCC {
|
||||
packages = with pkgs; [python3];
|
||||
};
|
||||
packages.${system} = forAllExercises (
|
||||
exercise:
|
||||
pkgs.writers.writePython3Bin "picoCTF_${exercise}" {
|
||||
# libraries = with pkgs.python3.pkgs; [ requests ];
|
||||
} "${builtins.readFile ./exercises/${exercise}/main.py}"
|
||||
);
|
||||
|
||||
apps.${system} = forAllExercises (
|
||||
exercise: {
|
||||
type = "app";
|
||||
program = "${self.packages.${system}.${exercise}}/bin/picoCTF_${exercise}";
|
||||
}
|
||||
);
|
||||
|
||||
devShells.${system} =
|
||||
forAllExercises (
|
||||
exercise:
|
||||
pkgs.mkShellNoCC {
|
||||
packages = with pkgs; [python3];
|
||||
}
|
||||
)
|
||||
// {
|
||||
default = pkgs.mkShellNoCC {
|
||||
packages = with pkgs; [python3];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user