> For the complete documentation index, see [llms.txt](https://alham-rizvi.gitbook.io/alhamrizvi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/reverse-engineering/safe-opener-2.md).

# Safe Opener 2

### Step 1: Download the decompiler

You downloaded the CFR Java decompiler using:

```bash
wget https://www.benf.org/other/cfr/cfr-0.152.jar
```

### Step 2: Decompile the `.class` file

```bash
java -jar cfr-0.152.jar SafeOpener.class > SafeOpener.java
```

#### What this does:

* `java -jar` → runs the `.jar` file
* `cfr-0.152.jar` → the decompiler
* `SafeOpener.class` → input file (compiled Java bytecode)
* `>` → redirects output into a file
* `SafeOpener.java` → readable source code output

So basically: 👉 You converted compiled bytecode → back into readable Java code

### Step 3: View the decompiled code

```bash
cat SafeOpener.java
```

### Step 4: Analyze the code

Key parts of the code:

```java
encodedkey = encoder.encodeToString(key.getBytes());
```

👉 Whatever user enters is **Base64 encoded**

```java
String encodedkey = "picoCTF{SAf3_0p3n3rr_y0u_solv3d_it_198203f7}";
```

👉 This is the **target value**

```java
if (password.equals(encodedkey))
```

👉 The program checks:

* Your **Base64 encoded input**
* Against this **hardcoded string**

### Step 5: Understand the logic

Flow:

1. You enter a password
2. Program converts it → Base64
3. Compares it with:

   ```
   picoCTF{SAf3_0p3n3rr_y0u_solv3d_it_198203f7}
   ```
4. If equal → safe opens

ays return true (advanced RE)


---

# 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://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/reverse-engineering/safe-opener-2.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.
