Reverse Engineering Erlang BEAM File

Study case Cyber Jawara 2021 Quals (Laser)

Preface

BEAM is the filename extension of bytecode compiled from library (ERL) and header (HRL) files written in Erlang programming language using BEAM compiler. It can be executed by the BEAM virtual machine bundled with the official Erlang development environment (source). During the competition, there is not much information about how to decompile BEAM file. So my approach is by disassembling the file then reconstructing it using another programming language.

Disassembling BEAM File

Given an Erlang BEAM file, here i try to run it using escript but it failed.

So i do it statically. Using iex i try to print the IR from the file

Below is the result

After that, analyze the whole IR code.

Reconstructing the Whole Code

Untuk rsa gunakan factordb untuk mendapatkan faktor prime dari n , ternyata multi prime cman ada prime yang cukup besar ( weird ) yang menyusun nilai n , padahal yang lainnnya nilainya kecil , kami coba hilangkan dan berhasil mendapatkan flag. Berikut solver yang kami gunakan

For RSA part, use factordb to get the prime factors of n, it turns out that it has more than two prime factors. One of the factor has much different than the other number, so removing it made the RSA decrypt process succesful. Below is the solver i use

Flag : CJ2021{welp_it_is_a_beam_multi-prime_rsa_because_i_ran_out_of_idea}

Last updated