Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
put_me_in_coach
Browse files Browse the repository at this point in the history
  • Loading branch information
zeski99 authored and aJuvan committed Apr 14, 2022
1 parent cbd22f8 commit 4982ca7
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 0 deletions.
22 changes: 22 additions & 0 deletions challs/put_me_in_coach/challenge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Put me in coach"
author: "zeski"
category: Crypto

description: |
I've seen this kind of encryption before, but the script isn't working. What's wrong with it? This isn't standard.
value: 500
type: standard

files:
- serve/put_me_in_coach.py
- serve/ct.txt

flags:
- dctf{ctfs_would_be_boring_without_some_classical_ciphers}

tags:
- crypto

state: visible

version: "0.1"
39 changes: 39 additions & 0 deletions challs/put_me_in_coach/freq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from string import printable

f = open("ct.txt").readline()

alphabet = printable[:-6]

d = {c:0 for c in alphabet}

for c in f:
if c in alphabet:
d[c] += 1

a = sum(d.values())

# print({k:100*v/a for k,v in d.items()})

for k,v in d.items():
if v > 0:
print(f"{k}: {100*v/a}")


# key = dict()

# for k,v in zip( "^!J;>o&b}ysPUcxv8z:t?pf%0Q+guHNEe4",
# "dctf{}\n._ o?ananrdistatiere"):
# key[k] = v

# out=""

# for c in f:
# if c in key:
# out += key[c]
# else:
# # out += c
# out += "_"

# print(out)

# je solvable na roke, not doing it again tho
39 changes: 39 additions & 0 deletions challs/put_me_in_coach/gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from math import ceil

freq = {
"a": 8.167,
"b": 1.492,
"c": 2.782,
"d": 4.253,
"e": 12.702,
"f": 2.228,
"g": 2.015,
"h": 6.094,
"i": 6.966,
"j": 0.153,
"k": 0.772,
"l": 4.025,
"m": 2.406,
"n": 6.749,
"o": 7.507,
"p": 1.929,
"q": 0.095,
"r": 5.987,
"s": 6.327,
"t": 9.056,
"u": 2.758,
"v": 0.978,
"w": 2.360,
"x": 0.150,
"y": 1.974,
"z": 0.074,
" ": 15,
}

extra = "\n.,{}?_-'"

coef = 1.7

arr = [ceil(f/coef) for f in freq.values()] + [1]*len(extra)

print(arr)
13 changes: 13 additions & 0 deletions challs/put_me_in_coach/secret.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
text = """Following norms and regulations is essential for electricians. These norms and regulations exist to ensure that proper safety measures are taken while working, and to guarantee safe, high quality installations. In this text, I will discuss what kind of consequences breaching norms and regulations can bring in the field of an electrician. Can a breach of norms and regulations potentially reach the newspaper headlines?
In vocational professions, a norm is an official standard that an organization is expected to reach. These are not to be confused with social norms. In almost every field in engineering, you have norms that you need to follow, and these are often set according to market standards. Norms are guidelines to maintain official standards. Rules and regulations on the other hand, are set by committees or tribunals, and are mandatory for every electrician. In Norway, the Norwegian law is a foundation for rules and regulations.
Engineers and electricians alike take pride in making their work look organized and neat. Making the installations functional is only half of the job. There are a lot of unwritten rules for making an organized installation. At what length to strip the cables, where to clamp cables to a wall, or placement of switches and cable boxes are all examples of this. These seemingly trivial skills are vital to an engineer's skillset and are arguably equally important as following the official rules and regulations. Breaking these norms does not pose a threat to personal or structural damage, but it can lead to the customer being dissatisfied.
A vital aspect of an electrical installation is to choose the correct diameter of the cables. In Norway, the NEK-400 norms (Norwegian Electronic Committee) are used as guidelines for picking the right cable diameter. Varying thickness of cables can conduct different amounts of current without overheating, and it is therefore important to calculate exactly how much current your components will draw. Installing a cable with the wrong dimension can have critical consequences. To have a wider cable than necessary causes no technical problem. However, if the cable is not rated for the appropriate currents, the cable will overheat and potentially catch fire.
To know the norms and regulations is crucial to an electrician's field. As I have discussed, not following them can have unfortunate consequences. An installation could be certified by official rules while being unorganized. Likewise, you could have an installation that looks expertly executed, but is indeed a fire hazard. Breaching official regulations have the greatest potential to have a critical outcome. Simply choosing too narrow of a cable could have the potential to for example spark a large-scale factory fire. I would argue that this is a headline-worthy event. In conclusion, rules, norms and regulations should always be followed to ensure a safe and expertly done installation.
dctf{ctfs_would_be_boring_without_some_classical_ciphers}"""

mapping = [5, 1, 2, 3, 8, 2, 2, 4, 5, 1, 1, 3, 2, 4, 5, 2, 1, 4, 4, 6, 2, 1, 2, 1, 2, 1, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1]
1 change: 1 addition & 0 deletions challs/put_me_in_coach/serve/ct.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruDYu3GjR;jfa\%hN4[PZLRcYOsGuF?}g?)6??L4'dwDhTJv;_A6S>ZiS|w4%(;sI21=qFuZ\*;Nj[Ex6/cYOH|uF1E2pd1'}{uP6]?"Z2PHyN{)+xJ+Ka;*wr_Hehb2m1cZ61;wvL}^w:L]E`IGDLn`fa:g4Rkq0j[7>tPR"NamF'6LP1mT=k}lg/5EMc0YG'eni]%{mYDOsGt4*(PdF;H5|1qHLp{k}in`GAA7-i*Sc%%P3yO^h:|F[PfT)StF*2Mc_FSK1qBx=OSli4RhFua\170][7Z=/cAOHi8F?7@mF7BaGj/EdjP>56ETdUY-E8rqmjh=Y6S'ZiSd04(}S0j7m)BZUNSyEtT;jtZ\170FXna6R"Dm'i84?;$tHLFHG0DAenZKm@ln'y6q4=31$N+zZ)y2N[D|4=1.WWijqQu@Nsg8jwD)$ZtT=%?|8]*k)0Ej8vbEi17wj)JrTG@|wYP1^w4-mxXPslOsE0F}ux/wj|!w{gfF;i%}Kp$2@>6-q'f;ZUNSl(E^I=*LnNvU;jt'7HJ}BK}St4rc1_XP`|sIE%tSG0Y)Ftx\1(h|jh0Ybf*Hh=Q=ZeETG=Y[EiF)LjRd4L2ag]RkPe8c;ywQKE48a\*Psym>nof"7jzz[}^t)T8YDJ`k}OFXP'lU*2n0x6EuTHKjn*_'ENS@uv[gj/;'thb0x:_Hh%{w]X0x[?(q48xb%PNvUE/"GX=Dgj6?;{fnbOg]HmiF)trrdSgmA)%'m][0ZX?()v"AU?)O4XhvKRcDN{gt4?EujqHIU)u>52vnyN]Xk;Ov_P16>EBo;Sf\\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Oe%EB2hruAA8`U[hHJ7K]*"v=qwh1OrKh0][7_p$6Z>Do7[t]K)ij1{OYAmsGt](WWXS>T~S{r%&3fcAX&BU&Bfv|4/&3gsl8cs&*ubU&@DO?1d@mD&SG$y_a%9
32 changes: 32 additions & 0 deletions challs/put_me_in_coach/serve/put_me_in_coach.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import random
from secret import text, mapping
from string import printable

alphabet = "abcdefghijklmnopqrstuvwxyz \n.,{}?_-'"

def gen_key(alphabet, mapping):
pool = list(printable[:-6])
random.shuffle(pool)

key = dict()

for c, n in zip(alphabet, mapping):
tmp = []
for i in range(n):
tmp.append(pool.pop())
key[c] = tmp
return key


def encrypt(pt, key):
ct = ""
for c in pt:
if c in key:
ct += random.choice(key[c])
return ct


key = gen_key(alphabet, mapping)

ct = encrypt(text.lower(), key)
print(ct)
21 changes: 21 additions & 0 deletions challs/put_me_in_coach/solv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
key={'N': 'a', 'w': 'a', 'm': 'a', 'O': 'a', '0': 'a', 'B': 'b', '@': 'c', 'S': 'c', '[': 'd', 'X': 'd', '-': 'd', 'z': 'e', 'K': 'e', '2': 'e', 'L': 'e', 'U': 'e', '=': 'e', '_': 'e', '6': 'e', 'r': 'f', 'T': 'f', 'R': 'g', '/': 'g', 'y': 'h', 'l': 'h', '5': 'h', 'I': 'h', 'i': 'i', 'd': 'i', '|': 'i', 'G': 'i', 'g': 'i', ',': 'j', ':': 'k', 'D': 'l', 'A': 'l', 'Y': 'l', '\\': 'm', 'b': 'm', '4': 'n', ']': 'n', 'F': 'n', 'j': 'n', 'u': 'o', 'J': 'o', 't': 'o', 'f': 'o', '8': 'o', '$': 'p', '+': 'p', 'M': 'q', 'a': 'r', 'Z': 'r', 'x': 'r', 'v': 'r', '1': 's', '%': 's', '?': 's', '*': 's', "'": 't', '>': 't', 's': 't', '^': 't', 'H': 't', '{': 't', '"': 'u', 'c': 'u', 'Q': 'v', '`': 'w', '3': 'w', 'p': 'x', 'e': 'y', 'o': 'y', '!': 'z', ')': ' ', '7': ' ', 'q': ' ', 'E': ' ', 'h': ' ', ';': ' ', 'P': ' ', 'n': ' ', '}': ' ', 'W': '\n', '(': '.', 'k': ',', '~': '{', '9': '}', '.': '?', '&': '_', 'C': '-', '#': "'"}

# def gen_dec_key(key):
# dec_key = dict()
# for k,v in key.items():
# for i in v:
# dec_key[i] = k
# return dec_key

def decrypt(ct, key):
pt = ""
for c in ct:
pt += key[c]
return pt

# dec_key = gen_dec_key(key)
# print(dec_key)

ct = open("ct.txt").read().strip()

print(decrypt(ct,key))
11 changes: 11 additions & 0 deletions challs/put_me_in_coach/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Following norms and regulations is essential for electricians. These norms and regulations exist to ensure that proper safety measures are taken while working, and to guarantee safe, high quality installations. In this text, I will discuss what kind of consequences breaching norms and regulations can bring in the field of an electrician. Can a breach of norms and regulations potentially reach the newspaper headlines?

In vocational professions, a norm is an official standard that an organization is expected to reach. These are not to be confused with social norms. In almost every field in engineering, you have norms that you need to follow, and these are often set according to market standards. Norms are guidelines to maintain official standards. Rules and regulations on the other hand, are set by committees or tribunals, and are mandatory for every electrician. In Norway, the Norwegian law is a foundation for rules and regulations.

Engineers and electricians alike take pride in making their work look organized and neat. Making the installations functional is only half of the job. There are a lot of unwritten rules for making an organized installation. At what length to strip the cables, where to clamp cables to a wall, or placement of switches and cable boxes are all examples of this. These seemingly trivial skills are vital to an engineer's skillset and are arguably equally important as following the official rules and regulations. Breaking these norms does not pose a threat to personal or structural damage, but it can lead to the customer being dissatisfied.

A vital aspect of an electrical installation is to choose the correct diameter of the cables. In Norway, the NEK-400 norms (Norwegian Electronic Committee) are used as guidelines for picking the right cable diameter. Varying thickness of cables can conduct different amounts of current without overheating, and it is therefore important to calculate exactly how much current your components will draw. Installing a cable with the wrong dimension can have critical consequences. To have a wider cable than necessary causes no technical problem. However, if the cable is not rated for the appropriate currents, the cable will overheat and potentially catch fire.

To know the norms and regulations is crucial to an electrician's field. As I have discussed, not following them can have unfortunate consequences. An installation could be certified by official rules while being unorganized. Likewise, you could have an installation that looks expertly executed, but is indeed a fire hazard. Breaching official regulations have the greatest potential to have a critical outcome. Simply choosing too narrow of a cable could have the potential to for example spark a large-scale factory fire. I would argue that this is a headline-worthy event. In conclusion, rules, norms and regulations should always be followed to ensure a safe and expertly done installation.

dctf{ctfs_would_be_boring_without_some_classical_ciphers}

0 comments on commit 4982ca7

Please sign in to comment.