-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
8 changed files
with
245 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# mise-a-jour-requise | ||
|
||
Reverse en Python3.10 | ||
|
||
Utilise les matchs pour montrer que cette syntaxe est super. | ||
|
||
Il y a un script de solution. `chall_sol.py` | ||
Il y a un script pour changer le flag. `chall_recreate.py` | ||
|
||
Rien n'est commenté désolé. |
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,61 @@ | ||
#!/usr/bin/python3.10 | ||
import random as rd | ||
|
||
s = [16, 3, 12, 9, 1, 60, 1, 3, 14, 39, 13, 16, 16, 1, 9, 13, 3, 39, 60, | ||
16, 16, 1, 60, 7, 39, 13, 3, 13, 18, 3, 13, 25, 14, 3, 1, 14, 60, | ||
13, 32, 13, 3, 39, 16, 18, 18, 3, 43, 16, 18, 3, 1, 43, 18, 16, | ||
13, 16, 1, 3, 1, 16, 13, 18, 60, 16, 3, 3, 14, 18, 13, 14, 16, 18, | ||
7, 3, 7, 25, 7, 7, 13, 13, 13, 3, 60, 1, 3, 13, 1, 25, 18, 16, 32, | ||
16, 60, 1, 7, 44, 18, 39, 39, 39, 60, 3, 1, 60, 3, 16, 13, 13, 14, | ||
1, 3, 39, 39, 31, 32, 39, 32, 18, 39, 3, 13, 32, 60, 7, 7, 39, 14, | ||
3, 18, 14, 60, 39, 18, 7, 1, 32, 13, 3, 14, 39, 39, 7, 1, 1, 13, | ||
29, 60, 13, 39, 14, 14, 16, 60, 1, 3, 44, 14, 3, 1, 1, 1, 39, 13, | ||
14, 39, 18, 3, 7, 13, 39, 32, 1, 43, 1, 16, 1, 3, 18, 14, 25, 32, | ||
7, 13, 39, 7, 1, 3, 60, 13, 13, 7, 18, 1, 3, 18, 1, 60, 7, 1, 39, | ||
14, 3, 39, 7, 31, 1, 7, 18, 7, 32, 3, 3, 14, 32, 14, 1, 32, 12, | ||
18, 31, 39, 1, 13, 13, 43, 44, 32, 3, 32, 60, 14, 60, 60, 7, 3, 1, | ||
3, 3, 14, 1, 60, 16, 44, 3, 1, 32, 13, 5, 16, 39, 3, 60, 7, 14, 3, | ||
13, 7, 31, 13, 39, 9, 3, 44, 13, 16, 14, 18, 18, 3, 7, 3, 3, 3, 7, | ||
3, 3, 16, 39, 3, 3, 13, 32, 13, 3, 18, 7, 10, 3, 18, 1, 7, 7, 18, | ||
13, 43, 18, 3, 32, 39, 32, 13, 1, 18, 10, 1, 32, 1, 16, 32, 3, 44, | ||
3, 18, 1, 1, 1, 16, 18, 25, 60, 1, 39, 1, 18, 60, 16, 1, 7, 3, 13, | ||
16, 18, 39, 14, 7, 14, 3, 14, 13, 7, 16, 10, 18, 13, 3, 16, 13, 3, | ||
32, 43, 13, 14, 1, 13, 1, 14, 18, 60, 7, 3, 7, 31, 1, 18, 26, 7, | ||
3, 3, 32, 1, 7, 18, 7, 1, 16, 18, 39, 14, 7, 3 | ||
] | ||
|
||
## | ||
def a(c, r=True): | ||
n = ord(c) | ||
if r: rd.seed(n) | ||
match n: | ||
case 0: | ||
return dict.fromkeys(range(10), 0) | ||
case _: | ||
return (d:=a(chr(n - 1), False)) | {(m:=rd.randint(0, 9)): d[m] + rd.randint(0,2)} | ||
|
||
## | ||
|
||
def b(p, n): | ||
match list(p): | ||
case []: | ||
return [] | ||
case [f, *rest]: | ||
l = list(a(f).values()) + b(''.join(rest), n*2) | ||
rd.seed(n) | ||
rd.shuffle(l) | ||
return l | ||
|
||
## | ||
def c(p, n=0): | ||
match p: | ||
case []: | ||
return n!=0 | ||
case [f, *rest]: | ||
rd.seed(s[n]) | ||
return rd.randint(0,30) == f and c(rest, n + 1) | ||
## | ||
if c(b(input("password:"), 1)): | ||
print("Utilise ce mot de passe pour valider le challenge!") | ||
else: | ||
print("Essaye Encore!") |
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,45 @@ | ||
#!/usr/bin/python3.10 | ||
import random as rd | ||
|
||
## | ||
def a(c, r=True): | ||
n = ord(c) | ||
if r: rd.seed(n) | ||
match n: | ||
case 0: | ||
return dict.fromkeys(range(10), 0) | ||
case _: | ||
return (d:=a(chr(n - 1), False)) | {(m:=rd.randint(0, 9)): d[m] + rd.randint(0,2)} | ||
|
||
## | ||
def b(p, n): | ||
match list(p): | ||
case []: | ||
return [] | ||
case [f, *rest]: | ||
l = list(a(f).values()) + b(''.join(rest), n*2) | ||
rd.seed(n) | ||
rd.shuffle(l) | ||
return l | ||
|
||
## | ||
def c(p, n=0): | ||
match p: | ||
case []: | ||
return n!=0 | ||
case [f, *rest]: | ||
rd.seed(s[n]) | ||
return rd.randint(0,30) == f and c(rest, n + 1) | ||
|
||
## | ||
def encode(s): | ||
e = b(s, 1) | ||
for c in e: | ||
i = 0 | ||
while 1: | ||
rd.seed(i) | ||
if rd.randint(0,30) == c: break | ||
i += 1 | ||
yield i | ||
## | ||
print(list(encode("404CTF{M3RC1_PY7H0N3.10_P0UR_L3_M47CH}"))) |
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,90 @@ | ||
#!/usr/bin/python3.10 | ||
import random as rd | ||
|
||
s = [16, 3, 12, 9, 1, 60, 1, 3, 14, 39, 13, 16, 16, 1, 9, 13, 3, 39, 60, | ||
16, 16, 1, 60, 7, 39, 13, 3, 13, 18, 3, 13, 25, 14, 3, 1, 14, 60, | ||
13, 32, 13, 3, 39, 16, 18, 18, 3, 43, 16, 18, 3, 1, 43, 18, 16, | ||
13, 16, 1, 3, 1, 16, 13, 18, 60, 16, 3, 3, 14, 18, 13, 14, 16, 18, | ||
7, 3, 7, 25, 7, 7, 13, 13, 13, 3, 60, 1, 3, 13, 1, 25, 18, 16, 32, | ||
16, 60, 1, 7, 44, 18, 39, 39, 39, 60, 3, 1, 60, 3, 16, 13, 13, 14, | ||
1, 3, 39, 39, 31, 32, 39, 32, 18, 39, 3, 13, 32, 60, 7, 7, 39, 14, | ||
3, 18, 14, 60, 39, 18, 7, 1, 32, 13, 3, 14, 39, 39, 7, 1, 1, 13, | ||
29, 60, 13, 39, 14, 14, 16, 60, 1, 3, 44, 14, 3, 1, 1, 1, 39, 13, | ||
14, 39, 18, 3, 7, 13, 39, 32, 1, 43, 1, 16, 1, 3, 18, 14, 25, 32, | ||
7, 13, 39, 7, 1, 3, 60, 13, 13, 7, 18, 1, 3, 18, 1, 60, 7, 1, 39, | ||
14, 3, 39, 7, 31, 1, 7, 18, 7, 32, 3, 3, 14, 32, 14, 1, 32, 12, | ||
18, 31, 39, 1, 13, 13, 43, 44, 32, 3, 32, 60, 14, 60, 60, 7, 3, 1, | ||
3, 3, 14, 1, 60, 16, 44, 3, 1, 32, 13, 5, 16, 39, 3, 60, 7, 14, 3, | ||
13, 7, 31, 13, 39, 9, 3, 44, 13, 16, 14, 18, 18, 3, 7, 3, 3, 3, 7, | ||
3, 3, 16, 39, 3, 3, 13, 32, 13, 3, 18, 7, 10, 3, 18, 1, 7, 7, 18, | ||
13, 43, 18, 3, 32, 39, 32, 13, 1, 18, 10, 1, 32, 1, 16, 32, 3, 44, | ||
3, 18, 1, 1, 1, 16, 18, 25, 60, 1, 39, 1, 18, 60, 16, 1, 7, 3, 13, | ||
16, 18, 39, 14, 7, 14, 3, 14, 13, 7, 16, 10, 18, 13, 3, 16, 13, 3, | ||
32, 43, 13, 14, 1, 13, 1, 14, 18, 60, 7, 3, 7, 31, 1, 18, 26, 7, | ||
3, 3, 32, 1, 7, 18, 7, 1, 16, 18, 39, 14, 7, 3 | ||
] | ||
|
||
## | ||
def a(c, r=True): | ||
n = ord(c) | ||
if r: rd.seed(n) | ||
match n: | ||
case 0: | ||
return dict.fromkeys(range(10), 0) | ||
case _: | ||
return (d:=a(chr(n - 1), False)) | {(m:=rd.randint(0, 9)): d[m] + rd.randint(0,2)} | ||
|
||
## | ||
def b(p, n): | ||
match list(p): | ||
case []: | ||
return [] | ||
case [f, *rest]: | ||
l = list(a(f).values()) + b(''.join(rest), n*2) | ||
rd.seed(n) | ||
rd.shuffle(l) | ||
return l | ||
|
||
## | ||
def c(p, n=0): | ||
match p: | ||
case []: | ||
return n!=0 | ||
case [f, *rest]: | ||
rd.seed(s[n]) | ||
return rd.randint(0,30) == f and c(rest, n + 1) | ||
|
||
## | ||
def deshuffle(n, seed): | ||
match n: | ||
case 0: | ||
return [] | ||
case _: | ||
l = list(range(10* (n-1), 10 * n)) + deshuffle(n - 1, seed*2) | ||
rd.seed(seed) | ||
rd.shuffle(l) | ||
return l | ||
|
||
## | ||
PASSWORD = [] | ||
for e in s: | ||
rd.seed(e) | ||
PASSWORD.append(rd.randint(0, 30)) | ||
|
||
e = deshuffle(len(PASSWORD)//10, 1) | ||
PASSWORD = [PASSWORD[e.index(i)] for i in range(len(e))] | ||
|
||
l=[] | ||
for i in range(0, len(PASSWORD), 10): | ||
l.append(PASSWORD[i:i+10]) | ||
l.reverse() | ||
|
||
dict = {chr(i): list(a(chr(i)).values()) for i in range(128)} | ||
password = '' | ||
|
||
for char in l: | ||
for key, item in dict.items(): | ||
if item == char: | ||
password += key | ||
print(password) | ||
|
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,9 @@ | ||
# pas de mise à jour | ||
|
||
challenge reverse pyc en 3.10 | ||
|
||
à ma connaissance (et pour l'instant) le seul decompilateur qui supporte le 3.10 ne reconnait pas les pattern match... comme c'est dommage... | ||
|
||
le fichier `sol.py` est une solution et le fichier `chall.py` est le fichier source du challenge. | ||
|
||
Bien sûr les participants n'avaient accès qu'à `chall.pyc`. |
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,17 @@ | ||
#!/usr/local/bin/python3.10 | ||
|
||
userInput = [ord (e) for e in input("Password:")] | ||
key = 'd1j#H(&Ja1_2\x2061fG&' | ||
|
||
|
||
def code(l): | ||
match l: | ||
case [el, *rest]: | ||
return [(5 * el ^ ord(key[len(rest) % len(key)]))] + code(rest) | ||
case []: | ||
return [] | ||
|
||
if code(userInput) == [292, 194, 347, 382, 453, 276, 577, 434, 183, 295, 318, 196, 482, 325, 412, 502, 396, 402, 328, 194, 473, 490, 299, 503, 386, 215, 263, 211, 318, 206, 533]: | ||
print('Bravo!') | ||
else: | ||
print('Dommage...') |
Binary file not shown.
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,13 @@ | ||
coded = [292, 194, 347, 382, 453, 276, 577, 434, 183, 295, 318, 196, 482, 325, 412, 502, 396, 402, 328, 194, 473, 490, 299, 503, 386, 215, 263, 211, 318, 206, 533] | ||
#404CTF{R34D1NG_PYTH0N_BYT3C0D3} | ||
key = 'd1j#H(&Ja1_2\x2061fG&' | ||
|
||
def decode(l): | ||
match l: | ||
case [el, *rest]: | ||
y = ord(key[len(rest) % len(key)]) | ||
return chr(((el ^ y)//5)) + decode(rest) | ||
case []: | ||
return '' | ||
|
||
print(decode(coded)) |