> For the complete documentation index, see [llms.txt](https://arne-ctf.gitbook.io/ctf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arne-ctf.gitbook.io/ctf/2023/bucketctf/rev-random-security.md).

# Rev - Random security

## Description

<div align="left"><figure><img src="/files/r1H9Y8GoutytMJExW9Qa" alt=""><figcaption></figcaption></figure></div>

## Solution

<div align="left"><figure><img src="/files/PHYSi6lRna9hmaV8paTo" alt=""><figcaption><p>Interaction with server</p></figcaption></figure></div>

In this challenge, the server gives us a random number and if we give back a wrong number, it will print **"WRONG DOUBLE!!!!!"**. Also, in the challenge description, the word **Java** is highlighted which suggest that this challenge has something to do with Java randomization.

A quick google search reveals that Java's random is just a linear congruential generator which can be easily cracked. Rather than reinventing the wheel, I will use the code from this Github page: <https://github.com/fta2012/ReplicatedRandom>

The modified Java code:

```java
import java.util.Random;

public class ReplicatedRandomTest {
    public static void main(String args[]) {
        Random r = new Random();
        ReplicatedRandom rr = new ReplicatedRandom();
        rr.replicateState(Double.parseDouble("0.9326890248362221"));
        for (int j = 0; j < 10; j++)
            System.out.println(rr.nextDouble());
        System.out.println();
    }
}
```

The code will predict the next 10 doubles but we will only need the first one.

<div align="left"><figure><img src="/files/zDuaaHDMGvzAaN5CwZWo" alt=""><figcaption><p>Predicted number</p></figcaption></figure></div>

Flag: `bucket{RaNd0m_nUmb3r5_53cur3_d24d8c961}`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://arne-ctf.gitbook.io/ctf/2023/bucketctf/rev-random-security.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
