Instantly share code, notes, and snippets.

# theKidOfArcrania/babyrev.md

Created November 16, 2020 05:14
Show Gist options
• Save theKidOfArcrania/c16a4db2db02e89327300012f85176d2 to your computer and use it in GitHub Desktop.

Here is the reversed scala code:

```object Main {
def f1(nums: Stream[Int], trans: Seq[Seq[Int]]): Stream[Int] = {
return nums.sum #:: f1(nums.flatMap(trans), trans);
}

def main() = {
val broken = f1(Stream(0), Seq(Seq(0,1,2,3), Seq(0), Seq(0), Seq(0)));
val enc : Array[Byte] = Array(
71, 20, -82, 84, -45, -4, 25, -122, 77, 63, -107, 13, -111, -43, 43, -42,
96, 38, -88, 20, -67, -40, 79, -108, 77, 8, -75, 80, -45, -69, 25, -116,
117, 106, -36, 69, -67, -35, 79, -114, 113, 36, -112, 87, -67, -2, 19,
-67, 80, 42, -111, 23, -116, -55, 40, -92, 77, 121, -51, 86, -46, -85, 93
)
val key = BigInt(broken(60107) % scala.math.pow(2, 62).toLong).toByteArray
val flag = (0 until enc.length).foreach((ind: Int) => key[ind % key.length] ^ enc[ind]);
}
}```

f1 function is basically just a fibonacci-esque function with the following parameters:

``````F(0) = 0
F(1) = 6
F(n) = F(n-1) + F(n-2) * 3
``````

Then to get `f1(60107) % 2**62`, we just dp it, which is 1318425925675285730.

Then just XOR this number with the flag bytes to get flag.