Tags: misc bruteforce 

Rating:

# Project Eulernt (Misc 200)

We get a python source, [eulernt_6d26d176de9f441923057d2b5c14f126.py](eulernt_6d26d176de9f441923057d2b5c14f126.py) and a host,
`eulernt.pwni.ng:5555`, where that code is running.

Analysing the code we can see that it requests for a number that is both a divisor of _N = 333!_ (333-smooth number) and close to its square root (_sN_),
with an relative error margin of _1e-8_.

We build a solution that just gets the factors of _N_, randomly shuffles them and check if we get any subsequence with a product within the valid range.
We first write it in python ([eulernt.py](eulernt.py)), but since it takes a while, we rewrite it in C++ too ([eulernt.cc](eulernt.cc)).

We then connect to the server and get the flag.

```sh
$ c++ eulernt.cc -lgmp -lgmpxx -O3
$ ./a.out
3214724638244592338929574336157302572951323085582819302449269218432782841988198693324942361005598255499445390916417366573442777402935092163167928803153708492324124799012987236567367031831505351605030172818940177625669924447673041630726404543125348067833208617162000948710471059133188661284703535575859200000000000000000000000000000000000000000000000
$ nc eulernt.pwni.ng 5555
Enter number: 3214726332154755748991079128846351062560778451862637883528691274756654374878844647025079591940578176759650427443606854127454330464131553816664001382397024890787110816276254358916583147465182493394800235346889527243496491766897151517308056569578296879300485562874711359654341221896407523796447391678839548240290864168960000000000000000000000000000000
PCTF{R3fr3sh1ngly_Sm00th}
```

So the flag is `PCTF{R3fr3sh1ngly_Sm00th}`.

Original writeup (https://github.com/abeaumont/ctfs/blob/master/plaidctf-2019/eulernt/README.md).