This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
generated from BCACTF/chall-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
72da79e
commit 0be38d1
Showing
5 changed files
with
45 additions
and
50 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 |
---|---|---|
@@ -1,22 +1,17 @@ | ||
name: rad-be-damned | ||
categories: | ||
- crypto | ||
value: 100 | ||
value: 125 | ||
flag: | ||
file: ./flag.txt | ||
description: | | ||
My friend seems to be communicating something but I can't make out anything. | ||
Why do we live so close to Chernobyl anyways? | ||
(Each letter is encoded with CRC-4-ITU) | ||
hints: | ||
- What can CRCs also do besides error detection? | ||
- Encoded with CRC (Cyclic Redundancy Checks) | ||
files: | ||
- src: ./flag_gen.py | ||
deploy: | ||
nc: | ||
build: . | ||
expose: 1337/tcp | ||
- src: ./message.py | ||
- src: ./output.txt | ||
authors: | ||
- Nikhil | ||
visible: true |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,40 @@ | ||
import random | ||
def find_leftmost_set_bit(plaintext): | ||
pos = 0 | ||
while plaintext > 0: | ||
plaintext = plaintext >> 1 | ||
pos += 1 | ||
return pos | ||
|
||
def encrypt(plaintext: str): | ||
enc_plaintext = "" | ||
|
||
for letter in plaintext: | ||
cp = int("10011", 2) | ||
cp_length = cp.bit_length() | ||
bin_letter, rem = ord(letter), ord(letter) * 2**(cp_length - 1) | ||
while (rem.bit_length() >= cp_length): | ||
first_pos = find_leftmost_set_bit(rem) | ||
rem = rem ^ (cp << (first_pos - cp_length)) | ||
enc_plaintext += format(bin_letter, "08b") + format(rem, "0" + f"{cp_length - 1}" + "b") | ||
|
||
return enc_plaintext | ||
|
||
def rad(text: str): | ||
corrupted_str = "" | ||
for ind in range(0, len(text), 12): | ||
bit_mask = 2 ** (random.randint(0, 11)) | ||
snippet = int(text[ind : ind + 12], base = 2) | ||
rad_str = snippet ^ bit_mask | ||
corrupted_str += format(rad_str, "012b") | ||
return corrupted_str | ||
|
||
def main(): | ||
with open('flag.txt') as f: | ||
plaintext = f.read().strip() | ||
enc_plaintext = encrypt(plaintext) | ||
cor_text = rad(enc_plaintext) | ||
print(cor_text) | ||
|
||
if __name__ == '__main__': | ||
main() |
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 @@ | ||
011000001011010000111000011000111110011000111100011101001100001001100111011111110110011110010100011100010111011011111001010011011011010100011010001010011110010110010000001110111010001000011100011100011100010011111101010101101011110000110010001101100011011010100011001001010010001011011111011110000010001101100110010000110011011101110101010010111000011100011001010100011001001000111000001101010001011000100111010011000001011100011111111101010111010001001000001101000000001101011100010101101010101011011110011010100010010010010011010101010101010000010000001011011100011000011010010000111110001110011111011100011101010110001010010100100111001110011100011010101000011000101010001000101001001100011101111101100010010011100000010101111010011101101000011100100101001001000001010001111111010001001101111110100101011111001100 |