Created
November 7, 2022 14:40
-
-
Save kaiili/6fdd23e8809606a3156cbd949f927247 to your computer and use it in GitHub Desktop.
movectf-2022-wp-c🍊t
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
// code : https://github.com/movebit/movectf-6 | |
// sui move build --dump-bytecode-as-base64 --path . | |
// sui client publish --path ./ --gas-budget 30000 | |
module c6::exp { | |
use ctf::hero; | |
use ctf::adventure; | |
use sui::tx_context::TxContext; | |
public entry fun start( | |
h: &mut hero::Hero, ctx: &mut TxContext | |
): () { | |
let i = 0; | |
while (i < 120) { | |
i = i + 1; | |
adventure::slay_boar(h,ctx); | |
}; | |
hero::level_up(h); | |
while (i > 80) { | |
i = i - 1; | |
adventure::slay_boar_king(h,ctx); | |
}; | |
} | |
} | |
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
// code : https://github.com/movebit/movectf-4 | |
// sui move build --dump-bytecode-as-base64 --path . | |
// sui client publish --path ./ --gas-budget 30000 | |
module c4::exp { | |
use movectf::flash; | |
use sui::tx_context::TxContext; | |
public entry fun loan( | |
self: &mut flash::FlashLender, amount: u64, ctx: &mut TxContext | |
): () { | |
let (loan, receipt) = flash::loan(self,amount,ctx); | |
flash::get_flag(self,ctx); | |
flash::repay(self,loan); | |
flash::check(self,receipt); | |
} | |
} | |
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
# code : https://github.com/movebit/movectf-5 | |
from typing import List | |
from rich import print | |
from z3 import Int, Solver | |
def out(p1, p2, p3, r1, r2, r3): | |
tpl = f""" | |
( (a11 * {p1}) + (a12 * {p2}) + (a13 * {p3}) ) % 26 == {r1} | |
( (a21 * {p1}) + (a22 * {p2}) + (a23 * {p3}) ) % 26 == {r2} | |
( (a31 * {p1}) + (a32 * {p2}) + (a33 * {p3}) ) % 26 == {r3} | |
""" | |
return tpl | |
def get_key(): | |
a11 = Int("a11") | |
a12 = Int("a12") | |
a13 = Int("a13") | |
a21 = Int("a21") | |
a22 = Int("a22") | |
a23 = Int("a23") | |
a31 = Int("a31") | |
a32 = Int("a32") | |
a33 = Int("a33") | |
s = Solver() | |
s.add(a11 > 0) | |
s.add(a12 > 0) | |
s.add(a13 > 0) | |
s.add(a21 > 0) | |
s.add(a22 > 0) | |
s.add(a23 > 0) | |
s.add(a31 > 0) | |
s.add(a32 > 0) | |
s.add(a33 > 0) | |
s.add(((a11 * 4) + (a12 * 15) + (a13 * 11)) % 26 == 19) | |
s.add(((a21 * 4) + (a22 * 15) + (a23 * 11)) % 26 == 16) | |
s.add(((a31 * 4) + (a32 * 15) + (a33 * 11)) % 26 == 17) | |
s.add(((a11 * 0) + (a12 * 13) + (a13 * 4)) % 26 == 11) | |
s.add(((a21 * 0) + (a22 * 13) + (a23 * 4)) % 26 == 9) | |
s.add(((a31 * 0) + (a32 * 13) + (a33 * 4)) % 26 == 21) | |
s.add(((a11 * 19) + (a12 * 19) + (a13 * 19)) % 26 == 18) | |
s.add(((a21 * 19) + (a22 * 19) + (a23 * 19)) % 26 == 2) | |
s.add(((a31 * 19) + (a32 * 19) + (a33 * 19)) % 26 == 3) | |
s.check() | |
m = s.model() | |
print(m) | |
def get_text(key: List[Int], result: List[Int]): | |
s1 = Int("s1") | |
s2 = Int("s2") | |
s3 = Int("s3") | |
s = Solver() | |
s.add(s1 > 0) | |
s.add(s2 > 0) | |
s.add(s3 > 0) | |
s.add(((key[0] * s1) + (key[1] * s2) + (key[2] * s3)) % 26 == result[0]) | |
s.add(((key[3] * s1) + (key[4] * s2) + (key[5] * s3)) % 26 == result[1]) | |
s.add(((key[6] * s1) + (key[7] * s2) + (key[8] * s3)) % 26 == result[2]) | |
s.check() | |
m = s.model() | |
print(m[s1], ",", m[s2], ",", m[s3], ",") | |
if __name__ == "__main__": | |
input_list = [[4, 15, 11], [0, 13, 4], [19, 19, 19]] | |
output_list = [[19, 16, 17], [11, 9, 21], [18, 2, 3]] | |
result_list = [[19, 16, 17], [11, 9, 21], [18, 2, 3], | |
[22, 7, 4], [25, 21, 5], | |
[7, 23, 6], [23, 5, 13], [3, 5, | |
9], [16, 12, 22], [14, 3, 14], [12, | |
22, 18], [4, 3, 9], [2, 19, 5], | |
[16, 7, 20], [1, 11, 18], [23, 4, | |
15], [20, 5, 24], [9, 1, 12], [5, | |
16, 10], [7, 2, 1], [21, 1, 25], | |
[18, 22, 2], [2, 7, 25], [15, 7, 10] | |
] | |
text = [184, 14, 2015, | |
58, 43, 1118, | |
71, 72, 1649, | |
156, 123, 3154, | |
92, 65, 1760, | |
102, 66, 1866, | |
194, 156, 3965, | |
26, 6, 316, | |
575, 71, 6670, | |
53, 43, 1070, | |
182, 140, 3633, | |
163, 134, 3361, | |
86, 63, 1675, | |
184, 164, 3967, | |
7, 4, 121, | |
189, 156, 3902, | |
114, 97, 2399, | |
56, 7, 650, | |
28, 10, 388, | |
15, 37, 624, | |
65, 4, 695] | |
# -- setup 1 : use z3-solver get key | |
# # generate z3 formula | |
# for i in input_list: | |
# p1, p2, p3 = i | |
# index = input_list.index(i) | |
# r1, r2, r3 = output_list[index] | |
# print(out(p1, p2, p3, r1, r2, r3)) | |
get_key() | |
# -- setup 2 : use z3-solver get plain txt | |
key = [545, 63, 32, 140, 13, 285, 12, 71, 28] | |
for i in result_list: | |
get_text(key, i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment