incomplete
This commit is contained in:
108
clouds/clouds.py
Executable file
108
clouds/clouds.py
Executable file
@@ -0,0 +1,108 @@
|
||||
#!python2.7
|
||||
import binascii
|
||||
|
||||
ROUNDS = 5
|
||||
BLOCK_LEN = 8
|
||||
HEX_BLOCK_LEN = BLOCK_LEN * 2
|
||||
MAX_NOTES = 2048
|
||||
MAX_NOTE_LEN = 512
|
||||
|
||||
|
||||
def pad(p):
|
||||
if len(p) % BLOCK_LEN != 0:
|
||||
return p + "\0" * (BLOCK_LEN - (len(p) % BLOCK_LEN))
|
||||
else:
|
||||
return p
|
||||
|
||||
def g(i):
|
||||
b = bin(i).lstrip("0b").rstrip("L").rjust(BLOCK_LEN * 8, "0")
|
||||
return int(b[::-1], 2)
|
||||
|
||||
def encrypt_block(b):
|
||||
k = open("./key").read().rstrip()
|
||||
assert (len(b) * ROUNDS) == len(k)
|
||||
result = int(binascii.hexlify(b), 16)
|
||||
for i in range(ROUNDS):
|
||||
key = int(binascii.hexlify(k[i * BLOCK_LEN:(i + 1) * BLOCK_LEN]), 16)
|
||||
key_odd = key | 1
|
||||
result ^= key
|
||||
result = g(result)
|
||||
result = (result * key_odd) % (1 << 64)
|
||||
return hex(result).lstrip("0x").rstrip("L").rjust(HEX_BLOCK_LEN, "0")
|
||||
|
||||
def encrypt(msg):
|
||||
plain = pad(msg)
|
||||
result = ""
|
||||
for i in range(0, len(plain), BLOCK_LEN):
|
||||
result += encrypt_block(plain[i:i + BLOCK_LEN])
|
||||
return result
|
||||
|
||||
def menu(n):
|
||||
notes = n
|
||||
print("""
|
||||
1) Store
|
||||
2) Retrieve
|
||||
Anything else to quit
|
||||
""")
|
||||
ui = raw_input("Selection? ").rstrip()
|
||||
if ui == "1":
|
||||
if len(notes) >= MAX_NOTES:
|
||||
print("Max capacity")
|
||||
return notes
|
||||
ui = raw_input("Give me a note to encrypt: ").rstrip()
|
||||
try:
|
||||
msg = binascii.unhexlify(ui)
|
||||
except:
|
||||
print("Invalid input.")
|
||||
return notes
|
||||
if len(msg) > MAX_NOTE_LEN:
|
||||
print("Invalid input.")
|
||||
else:
|
||||
notes.append(encrypt(msg))
|
||||
elif ui == "2":
|
||||
ui = raw_input("What index would you like to read? ").rstrip()
|
||||
try:
|
||||
index = int(ui)
|
||||
except:
|
||||
print("Invalid index.")
|
||||
return notes
|
||||
if index >= 0 and index < len(notes):
|
||||
print(notes[index])
|
||||
else:
|
||||
print("Invalid index.")
|
||||
else:
|
||||
return None
|
||||
return notes
|
||||
|
||||
|
||||
art = """
|
||||
.
|
||||
|
||||
|
|
||||
. /
|
||||
\ I
|
||||
/
|
||||
\ ,g88R_
|
||||
d888(` ). _
|
||||
- --== 888( ).=-- .+(` )`.
|
||||
) Y8P( '`. :( . )
|
||||
.+(`( . ) .-- `. ( ) )
|
||||
(( (..__.:'-' .=( ) ` _` ) )
|
||||
`. `( ) ) ( . ) ( ) ._
|
||||
) ` __.:' ) ( ( )) `-'.:(` )
|
||||
) ) ( ) --' `- __.' :( ))
|
||||
.-' (_.' .') `( ) ))
|
||||
(_ ) ` __.:'
|
||||
|
||||
--..,___.--,--'`,---..-.--+--.,,-,,..._.--..-._.-a:f--.
|
||||
|
||||
"""
|
||||
|
||||
print(art)
|
||||
print("I love cloud watching, so I made a place to store all my notes about them.")
|
||||
|
||||
flag = open("./flag").read().rstrip()
|
||||
notes = [encrypt(flag)]
|
||||
notes = menu(notes)
|
||||
while notes:
|
||||
notes = menu(notes)
|
||||
1
clouds/flag
Normal file
1
clouds/flag
Normal file
@@ -0,0 +1 @@
|
||||
picoCTF{flagFLAG}
|
||||
1
clouds/key
Normal file
1
clouds/key
Normal file
@@ -0,0 +1 @@
|
||||
12345678abcdefgh1a2b3c4d5e6f7g8hffffffff
|
||||
40
clouds/sol.py
Executable file
40
clouds/sol.py
Executable file
@@ -0,0 +1,40 @@
|
||||
#!python3
|
||||
from sage.all import *
|
||||
from pwn import *
|
||||
|
||||
conn = remote("mercury.picoctf.net", 24402)
|
||||
conn.recvuntil(b"? ")
|
||||
|
||||
def store(msg):
|
||||
conn.sendline(b"1")
|
||||
conn.recvuntil(b": ")
|
||||
conn.sendline(msg)
|
||||
conn.recvuntil(b"? ")
|
||||
|
||||
def retrieve(i):
|
||||
conn.sendline(b"2")
|
||||
conn.recvuntil(b"? ")
|
||||
conn.sendline(str(i).encode())
|
||||
msg = conn.recvline().strip()
|
||||
conn.recvuntil(b"? ")
|
||||
return msg
|
||||
|
||||
def sbox(input):
|
||||
output = Integer("".join(reversed(input.binary())))
|
||||
return output
|
||||
|
||||
def sbox_inv(output):
|
||||
pass
|
||||
|
||||
def mixin_pre(input, key):
|
||||
pass
|
||||
|
||||
def mixin_pre_inv(output, result):
|
||||
pass
|
||||
|
||||
def mixin_post(input, key):
|
||||
pass
|
||||
|
||||
def mixin_post_inv(output, result):
|
||||
pass
|
||||
|
||||
6
sans_alpha/sol.py
Executable file
6
sans_alpha/sol.py
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/home/maxime/.pyvenv/bin/python3
|
||||
from pwn import *
|
||||
|
||||
s = ssh(host="mimas.picoctf.net", user="ctf-player" , port=50061, password="6abf4a82")
|
||||
#sh = s.shell(tty=True)
|
||||
|
||||
Reference in New Issue
Block a user