commit 5a6f3e0b7e1854cb74de173a18b3693fb8b0b9db Author: boyreau Date: Thu Nov 5 11:10:32 2026 +0100 A few intro-level challenges. diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/challenge.py b/challenge.py new file mode 100644 index 0000000..e81c58e --- /dev/null +++ b/challenge.py @@ -0,0 +1,10 @@ +from intro import int_to_ascii, hex_to_ascii, hex_to_b64, int_to_message_rsa + +if __name__ == "__main__": + # Intro-level challenge + # fmt: off + print(int_to_ascii([99, 114, 121, 112, 116, 111, 123, 65, 83, 67, 73, 73, 95, 112, 114, 49, 110, 116, 52, 98, 108, 51, 125])) + print(hex_to_ascii("63727970746f7b596f755f77696c6c5f62655f776f726b696e675f776974685f6865785f737472696e67735f615f6c6f747d")) + print(hex_to_b64("72bca9b68fc16ac7beeb8f849dca1d8a783e8acf9679bf9269f7bf")) + print(int_to_message_rsa(11515195063862318899931685488813747395775516287289682636499965282714637259206269)) + # fmt: on diff --git a/intro.py b/intro.py new file mode 100644 index 0000000..c735d7e --- /dev/null +++ b/intro.py @@ -0,0 +1,26 @@ +import base64 +from Crypto.Util.number import * +from pwntools import xor + + +# Challenge intro-1 +def int_to_ascii(input: [int]) -> str: + res = bytearray() + for i in input: + res += i.to_bytes() + return res.decode("utf-8") + + +# Challenge intro-2 +def hex_to_ascii(input: str) -> str: + return bytes.fromhex(input).decode("utf-8") + + +# Challenge intro-3 +def hex_to_b64(input: str) -> bytes: + return base64.b64encode(bytes.fromhex(input)) + + +# Challenge intro-4 +def int_to_message_rsa(input: int) -> str: + return long_to_bytes(input) diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..8f17e90 --- /dev/null +++ b/shell.nix @@ -0,0 +1,14 @@ +let + pkgs = import { }; +in +pkgs.mkShell { + packages = [ + pkgs.python314 + pkgs.openssl + pkgs.ruff + pkgs.python314Packages.python-lsp-server + pkgs.python314Packages.pwntools + pkgs.python314Packages.pycryptodome + pkgs.python314Packages.sympy + ]; +}