6

I need to modify a script which is part of a programme I downloaded. However, when I try to view the script with vim, it is full of symbols, numbers and letters placed randomly. Is there anything I can do to read this script? This is part of the script:

ELF          >    @     @        J         @ 8  @         @       @ @     @ @     À      À                           @      @                                          @       @     TB     TB                   XB     XBa     XBa     \      ˜†                   €B     €Ba     €Ba     à      à                         @     @                            Påtd   „(     „(A     „(A     ´      ´             Qåtd                                                  /lib64/ld-linux-x86-64.so.2          GNU                   %   8   )   #   7              $          .   '      "          ,                            1          *   6      5   3      /   2   %   -   0                                                        

   !             (   +                     4      &                               ±                                       A             !                    ®       *                       9                       ×             ñ       «             P       z              â      ó             ³       í             
       a             ¥      
             3       ¢                     Æ                                    ?       s             Š      X             ð                    é       ö                       #             N       t             9                           Ü                    M              )       Š             £       z             [       -             :      S             B       Ô                    3             e                   Ô       P             t      :                                                     €       ‘             \                   È       ò                    –             É       ²              ï                    Û      h                     :                   û             ¦       A    ÀFa            )             E       [             ­       †             Á       H                    â              d       &    ÈFa            ä             û       Ð             þ       ‹             –        libgfortran.so.3 _gfortran_st_write_done __gmon_start__ _Jv_RegisterClasses _gfortran_transfer_integer _gfortran_st_read _gfortran_st_inquire _gfortran_set_args _gfortran_iargc _gfortran_st_rewind _ITM_deregisterTMCloneTable _gfortran_pow_i4_i4 _ITM_registerTMCloneTable _gfortran_st_write _gfortran_st_read_done _gfortran_transfer_integer_write _gfortran_compare_string _gfortran_set_options _gfortran_st_close _gfortran_getarg_i4 _gfortran_transfer_character_write _gfortran_transfer_real_write _gfortran_transfer_logical_write _gfortran_stop_string _gfortran_transfer_real _gfortran_st_open _gfortran_transfer_character libm.so.6 truncf cosf sinf sqrtf powf log10f libgcc_s.so.1 __powisf2 libquadmath.so.0 libc.so.6 fflush exit sprintf _IO_putc fopen strncmp strncpy signal getpid calloc strlen memset stdout fputs memcpy fclose stderr fprintf memmove _IO_getc __libc_start_main free /cm/shared/apps/mpich2/3.2/gcc/lib:/cm/shared/apps/fftw/gcc/64/3.3.4/lib/ GLIBC_2.2.5 GCC_4.0.0 GFORTRAN_1.0 GFORTRAN_1.4                                                                      p         ui       Â                 `Z'       Î        Æ         ui       Â                  €eù   Ø     „eù   å      `Da                   ÀFa        .           ÈFa        4           €Da                   ˆDa                   Da                   ˜Da                    Da                   ¨Da                   °Da                      ¸Da        
           ÀDa                   ÈDa                   ÐDa        
           ØDa                   àDa                   èDa                   ðDa                   øDa                    Ea                   Ea                   Ea                   Ea                    Ea                   (Ea                   0Ea                   8Ea                   @Ea                   HEa                   PEa                   XEa                    `Ea        !           hEa        "           pEa        #           xEa        $           €Ea        %           ˆEa        &           Ea        '           ˜Ea        (            Ea        )           ¨Ea        *           °Ea        +           ¸Ea        ,           ÀEa        -           ÈEa        /           ÐEa        0           ØEa        1           àEa        2           èEa        3           ðEa        5           øEa        6            Fa        7           Hƒìè[  èZ  èõ HƒÄÃÿ5z1! ÿ%|1! @ ÿ%z1! h    éàÿÿÿÿ%r1! h   éÐÿÿÿÿ%j1! h   éÀÿÿÿÿ%b1! h   é°ÿÿÿÿ%Z1! h   é ÿÿÿÿ%R1! h   éÿÿÿÿ%J1! h   é€ÿÿÿÿ%B1! h   épÿÿÿÿ%:1! h   é`ÿÿÿÿ%21! h    éPÿÿÿÿ%*1! h
   é@ÿÿÿÿ%"1! h   é0ÿÿÿÿ%1! h   é ÿÿÿÿ%1! h
   éÿÿÿÿ%
1! h   é ÿÿÿÿ%1! h   éðþÿÿÿ%ú0! h   éàþÿÿÿ%ò0! h   éÐþÿÿÿ%ê0! h   éÀþÿÿÿ%â0! h   é°þÿÿÿ%Ú0! h   é þÿÿÿ%Ò0! h   éþÿÿÿ%Ê0! h   é€þÿÿÿ%Â0! h   épþÿÿÿ%º0! h   é`þÿÿÿ%²0! h   éPþÿÿÿ%ª0! h   é@þÿÿÿ%¢0! h   é0þÿÿÿ%š0! h   é þÿÿÿ%’0! h   éþÿÿÿ%Š0! h   é þÿÿÿ%‚0! h   éðýÿÿÿ%z0! h    éàýÿÿÿ%r0! h!   éÐýÿÿÿ%j0! h"   éÀýÿÿÿ%b0! h#   é°ýÿÿÿ%Z0! h$   é ýÿÿÿ%R0! h%   éýÿÿÿ%J0! h&   é€ýÿÿÿ%B0! h'   épýÿÿÿ%:0! h(   é`ýÿÿÿ%20! h)   éPýÿÿÿ%*0! h*   é@ýÿÿÿ%"0! h+   é0ýÿÿÿ%0! h,   é ýÿÿÿ%0! h-   éýÿÿÿ%
0! h.   é ýÿÿÿ%0! h/   éðüÿÿÿ%ú/! h0   éàüÿÿ1íI‰Ñ^H‰âHƒäðPTIÇÀ@A HÇÁPA HÇÇA°@ èWýÿÿôHƒìH‹.! H…ÀtÿÐHƒÄø¿Fa UH-¸Fa HƒøH‰åw]ø    H…Àtô]¿¸Fa ÿà€    ¸¸Fa UH-¸Fa HÁøH‰åH‰ÂHÁê?HÐHÑøu]ú    H…Òtô]H‰Æ¿¸Fa ÿ†   €=ù/!  u_UH‰åS»pBa HëhBa HƒìH‹ã/! HÁûHƒëH9Øs$fD  HƒÀH‰Å/! ÿÅhBa H‹·/! H9Ørâè5ÿÿÿÆž/! HƒÄ[]À    Hƒ=0+!  t¸    H…ÀtU¿xBa H‰åÿÐ]é+ÿÿÿ é#ÿÿÿUH‰åH‰}è‰uä‹MäHcÉH‰Èº    ‹Eä‰EøÇEô   ‹Eø‰Eüƒ}ü ~.‹Eü‰EôH‹Uè‹EüƒèH˜¶< uƒ}ü”À¶Àƒmü…ÀuëÒ‹Eô]ÃUH‰åHƒì`H‰}ØH‰uÐH‰UÈH‰MÀL‰E¸D‰M´‹E´H˜I‰ÂA»    ‹U´H‹EȉÖH‰Çè   ‰EøH‹EØ‹ ‰EôH‹EØó‹Eøó*ÀH‹EÀóóYÂóXÁóEðH‹EÐóH‹EÀóóà óYÂó\È(ÁóEìH‹EÐóH‹EÀó óXÁóEè¿@A ¸    èTš  HMèHUðHuìHEôHÇD$DA HÇ$DA A¹@A A¸@A H‰Ç¸    èZ³  H‹E¸H‰Ç¸    è š  ‹Eø…À~4‹T ‰EüLMøLEüH‹MÈH‹UÀH‹uÐH‹EØ‹}´‰<$H‰Ç¸    èV«  ÉÃUH‰åH‰}è‰uä‹MäHcÉH‰Èº    ‹Eä‰Eø‹Eø‰Eüƒ}ü ~3‹Eü‰EôH‹Uè‹EüƒèH˜¶< t‹Eôëƒ}ü”À¶Àƒmü…ÀuëÍ‹Eô]ÃUH‰åHƒìpH‰}ÈH‰uÀH‰U¸H‰M°L‰E¨L‰M H‹E@Ç     H‹E ‹ ‰EàH‹E(‹ ‰EØH‹E0‹ ‰EÜH‹E8‹ ‰EÔL‹MÀL‹E¸H‹MÈH‹U°HuØHEàH}èH‰<$H‰Çèy  L‹MÀL‹E¸H‹MÈH‹U°HuÔHEÜH}äH‰<$H‰ÇèQ  óEàóMÜ.Áz.Át%óEÔóMØó\ÁóMÜóUàó\Êó^ÁóEøóEØóMÔ.Áz.Át%óEÜóMàó\ÁóMÔóUØó\Êó^ÁóEô‹Eè…Àu‹Eä…À„œ  ‹Eè™ÁêЃà)Ѓøu‹Eä™ÁêЃà)Ѓø„°   ‹Eè‰ÂÁêÐÑø™ÁêЃà)Ѓøu‹Eä‰ÂÁêÐÑø™ÁêЃà)Ѓøtx‹EèP…ÀHÂÁø™ÁêЃà)Ѓøu‹EäP…ÀHÂÁø™ÁêЃà)Ѓøt<‹EèP…ÀHÂÁø™ÁêЃà)Ѓøu#‹EäP…ÀHÂÁø™ÁêЃà)Ѓøuéì  ‹Uè‹Eä9ÂuéÝ  ‹Eè…Àu‹Eä‰Eüë‹Eè‰Eü‹Eü™ÁêЃà)Ѓøu-H‹EÈó óMàó\ÁóYEøóMØóXÁóEìH‹EÈ‹ ‰Eð‹Eü‰ÂÁêÐÑø™ÁêЃà)Ѓøu-H‹EÀó óMàó\ÁóYEøóMØóXÁóEìH‹EÀ‹ ‰Eð‹EüP…ÀHÂÁø™ÁêЃà)Ѓøu-H‹E°ó óMØó\ÁóYEôóMàóXÁóEðH‹E°‹ ‰Eì‹EüP…ÀHÂÁø™ÁêЃà)Ѓøu-H‹E¸ó óMØó\ÁóYEôóMàóXÁóEðH‹E¸‹ ‰Eì‹Eè9Eüu9‹Eð‰Eà‹Eì‰EØL‹MÀL‹E¸H‹MÈH‹U°HuØHEàH}èH‰<$H‰Çèo   é‹ýÿÿ‹Eð‰EÜ‹Eì‰EÔL‹MÀL‹E¸H‹MÈH‹U°HuÔHEÜH}äH‰<$H‰Çè6   éRýÿÿ‹EàH‹U¨‰‹EÜH‹U‰‹EØH‹U ‰‹EÔH‹U‰H‹E@Ç    ÉÃUH‰åH‰}øH‰uðH‰UèH‰MàL‰EØL‰MÐH‹EÇ     H‹EøóH‹Eàó .ÁvH‹EÇ    ëH‹Eøó H‹EÐó.Áv
H‹EÇ    H‹EðóH‹EØó .ÁvH‹E‹ PH‹E‰ë&H‹Eðó H‹Eèó.ÁwëH‹E‹ PH‹E‰]ÃUH‰åAUATSHìˆ  H‰½øþÿÿH‰µðþÿÿH‰•èþÿÿH‰àþÿÿL‰…ØþÿÿL‰Ðþÿÿ‹EpH˜I‰ÄA½    ‹ExH˜I‰ÂA»    H‹E
  • 21
    welcome to U&L, this is not a script but a binary (as seen by ELF string). to modify it, you need to edit sources, and recompile it. – Archemar Sep 1 '18 at 9:28
  • 4
    fortran, looks like. – mikeserv Sep 1 '18 at 9:48
  • 2
    @mikeserv How can you tell? – Thorbjørn Ravn Andersen Sep 1 '18 at 12:59
  • 7
    @ThorbjørnRavnAndersen If you scroll to the right there’s some strings like libgfortran.so.3 and _gfortran_transfer_integer. – NobodyNada Sep 1 '18 at 14:26
  • 12
    I'm curious, why did you think this was a script? – pipe Sep 1 '18 at 21:50
41

The "script" is not actually a script at all, but a compiled executable binary file. This is evident from the fact that it's not a text file and that it contains an ELF header.

This means that to change it, you would have to locate its source code (which may not be available on your machine, and in some cases it may not available publicly at all), change it, and recompile the binary executable.

How you do this depends on where you got the program from, what programming language its source is written in (probably Fortran using MPI judging from the library names and paths present in the binary output), and what build system it uses to build.

This may require installing one or several additional pieces of software on your system for rebuilding the executable, along with any dependencies (libraries and headers) that the source may be using.

3

If you don't have the original source code and you are desperate, you can also decompile (reverse engineer) the executable file. It will give you something like assembler or c-code, maybe even fortran.

But you won't get the original source code from it, just some basic code with simple instructions, which compiles into the same binary as the original code.

Might need lots of research to understand it and fix what you want to change. With a lot of refactoring, renaming and extracting functions, you could even get a usuable source code for future development or porting to another platform.

convert executable back to C source code

  • Decompiling and reverse engineering are two very different techniques. To begin with, if Wikipedia can be taken at face value, the former is an automated process, whereas the latter is a manual process. This agrees well with the ways I've seen the terms used in practice. – a CVn Sep 2 '18 at 15:53
  • @MichaelKjörling feel fre to edit the answer, I know almost nothing about it. I only knew that it is possible, other people having the same question might not, so I added that information. – John Mc G. Sep 2 '18 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.