erlic122

erlic122 OP

Ok perfect thank you very much, could you explain or tell me what are the commands to decompress it or convert it to .erl? is that there are several files and I want to know so I can decompile them all,

Gmail

0
Post #11
lud

lud

I sent the file, please hide your address from public sight :slight_smile:

1
Post #12
erlic122

erlic122 OP

Thank you very much man, very grateful to you

0
Post #13
lud

lud

To get the source I created a base mix project:

mix new myproject

In mix.exs deps() function I added this dependency:

{:decompilerl, github: "niahoo/decompilerl"}

Then I renamed your beam file to holiday_role_data.beam (removed the “4”) because the module inside is holiday_role_data and must match the file name.

The beam file is in the root of the project directory.

Then I created a tt.exs file with this content:

Code.append_path(File.cwd!())
Decompilerl.decompile(:holiday_role_data)
System.halt()

And then run this file with mix run tt.exs > holiday_role_data.erl

Note that you must then edit the file to remove the text “Retrieving code for holiday_role_data”.

It may be possible to have better results with GitHub - michalmuskala/decompile · GitHub because it can generate elixir source instead of erlang. But I don’t know it as much as decompilerl.

1
Post #14
erlic122

erlic122 OP

Thank you very much, very grateful, it works perfectly, but now with some files I get an error, I would like to know why? and how to fix it to be able to decompile

this is the error it gives me


** (MatchError) no match of right hand side value: {:error, :beam_lib, {:key_missing_or_invalid, <<70, 79, 82, 49, 0, 1, 52, 148, 66, 69, 65, 77, 65, 116, 111, 109, 0, 0, 4, 172, 0, 0, 0, 72, 11, 99, 104, 97, 114, 103, 101, 95, 100, 97, 116, 97, 4, 108, 105, 115, 116, 5, 108, 105, 115, ...>>, :abstract_code}}
     (decompilerl 0.0.1) lib/decompilerl.ex:25: Decompilerl.do_decompile/1
     (decompilerl 0.0.1) lib/decompilerl.ex:5: Decompilerl.decompile/2
     tt.exs:2: (file)
     (elixir 1.12.2) lib/code.ex:1261: Code.require_file/2

this is the file
https://github.com/granados12/decompile/blob/main/charge_data.beam?raw=true

0
Post #15
kartheek

kartheek

There is a thread which is active in erlang forums. You can take a look at it.

1
Post #16
erlic122

erlic122 OP

Ok thank you very much, I will see if there is what I need

0
Post #17
erlic122

erlic122 OP

No, it didn’t work for me, @lud solution does work, for most files, but one or another doesn’t work, it gives the error message I mentioned

1
Post #18
al2o3cr

al2o3cr

That kind of chunk is optional in a BEAM file - it’s not usually included for “production” builds.

0
Post #19
erlic122

erlic122 OP

This is the code you have, what should I change?

defp do_decompile(beam_code) do
    {:ok, {_, [abstract_code: {_, ac}]}} =
      :beam_lib.chunks(beam_code, [:abstract_code])

    :erl_prettypr.format(:erl_syntax.form_list(ac))
  end
0
Post #20