# CrossCTF_2018: Human Powered Flag Generator

Category: Mobile Points: 444 Description:

Keep cranking until the whole flag appears! Creator - prokarius (@prokarius)

## Write-up

This challenge is not solvable through traditional means and the solution requires some hard work in analysing the actual algorithm used in this case.

Now, we can convert all of these into Python and try to have it crack it faster.

``````#! /usr/bin/env python3
##
from pwn import *
import gmpy2
import math

calculated_thousand = math.factorial(1000)

def lucas_sequence(n):
return (5 ** n) + 1

def speedup_loop(x):
while x % 10 == 0:
x //= 10
return x

def factorial(n):
num = math.factorial(n % 1000) + (n // 1000) * calculated_thousand
return num

flag = ""
prod = 1
p_max = 1
for level in range(1, 13):
# Set max factorials
max = (2**level) + 1

# Start factorialing
for curr in range(p_max, max):
l_num = lucas_sequence(curr)
prod *= factorial(l_num - 1)
prod = speedup_loop(prod) % 1000000

# Set p_max to max factorials
p_max = max

# Get prod
new_prod = (str(prod).rstrip('0'))[-3:]
prod = int(new_prod)

# Add flag
flag += new_prod
print(f"CrossCTF{{{flag}}}")
``````

Running this gives us the flag, pretty fast.

``````# ./solve.py
CrossCTF{808}
CrossCTF{808664}
CrossCTF{808664096}
CrossCTF{808664096416}
CrossCTF{808664096416256}
CrossCTF{808664096416256736}
CrossCTF{808664096416256736896}
CrossCTF{808664096416256736896016}
CrossCTF{808664096416256736896016456}
CrossCTF{808664096416256736896016456136}
CrossCTF{808664096416256736896016456136696}
CrossCTF{808664096416256736896016456136696616}
``````

Therefore, the flag is `CrossCTF{808664096416256736896016456136696616}`