Reverse analysis of an Elf file - elf

question:
CrackMe1 is an ELF executable that can be executed independently in Android.
Execute CrackMe1 program in shell and prompt "Input Your Answer"
Input the correct string, press enter, if the program output "True Answer", it means yes, output "Wrong Answer", it means failure
What I need to do is reverse analyze the ELF file and find the correct string to be entered (which can be understood as password here).
I use IDA to decompile but find no string matching information in the decompiled result
Here is the code of the decompiled main function
I would like to ask what method can be used to find the string to be entered for the above situation.
It can be a tutorial or a specific example
file: https://pan.baidu.com/s/1Tfbtk792UgYLj9XxUmb8yg?pwd=49ff
passwd:49ff

Related

Translation from plain English to a set of instruction

I have a set of instructions, for example Linux's "ls", "grep", "cd", etc.
I want the user to be able to execute this commands without knowing the exact names and parameters but rather with something similar to their meaning in plain English, e.g. "show me all folders", "filter all files by name" , "go to directory". Or in other words: the user input is "Show me all files and then show me all that contains 'foo' " to be translated to "ls | grep foo"
I understand that I will need some kind of meta-information about each instruction and do some kind of evaluation how close is the user query term to each instruction. Something like:
<instruction>
<command>ls</command>
<semantic>lists all files</semantic>
<plainEnglish>List all the files in this directory</plainEnglish>
<synonyms>
<synonym>Show all files</synonym>
...etc
</synonyms>
</instruction>
So which is the important information and how to do this evaluation?
Any general guidelines how I can translate the user's input to a specific instruction from my set? (This sounds like quite a challenge to me)

Providing input files during compilation

To run a CUDA C program we build the program and then run the binary file created from the command line as
/.prgm_bin_file
If for example the program needs some input files like for programs to image processing, I want to supply the data files or the input files at the time of compilation.
How can I do that. How the above command can be edited to give the required files.
Thanks in advance.
If your program opens data files to use for input, it's using some file I/O API to do so. For example, one possible method is to use fopen.
Just to use it as an example, if you are using fopen, it expects a filename (a character string) passed as the first parameter.
Many programs will take this filename from a the command line used to invoke the program. But there's nothing that would prevent you from hard-coding the filename:
fp=fopen("mydata", "r");
In that case, the program would always attempt to open the file mydata
But if your program is already designed to use the filename as a command line parameter, it's not clear that this is any more useful than just invoking your program that way:
./prgm_bin_file mydata

FORTRAN input from mouse

What is the FORTRAN input statement (e.g., READ statement, or OPEN statement) to accept input from a mouse? For example, in Windows explorer, it is possible to right-click on a file and then select a FORTRAN executable from the menu that appears. How do I make such a FORTRAN program capture whatever the mouse sends (e.g., capture the name of the file, or whatever the mouse transmits)? Information out there about FORTRAN input seems restricted to input from a file or the keyboard. I cannot find anything about input from a mouse.
I've made progress on my own and, for those interested, here it is:
Firstly, the "fortran standard" does not directly support input from a mouse. But Windows Explorer can be made to pipe a file name into a fortran executable nevetheless.
Under Windows, the right-click generates the full \path\filename as a command line argument. That information can be captured by a fortran using "get_command_argument", as follows:
PROGRAM get_filename
CHARACTER(len=100) :: arg
CHARACTER(len=2000) :: filename
filename = ''
! NB: spaces in a file name define separate arguments, so re-assemble the file name as it comes in
i = 1
DO
CALL get_command_argument(i, arg)
IF (LEN_TRIM(arg) == 0) EXIT
filename = TRIM(filename)//' '//TRIM(arg) ! putting the spaces back in
i = i+1
END DO
WRITE (*,*) 'file= ',TRIM(filename)
read(*,*)
END PROGRAM
A link to the executable can be placed in the Windows right-click menu, as explained here:
http://www.howtogeek.com/107965/how-to-add-any-application-shortcut-to-windows-explorers-context-menu/
You need to add "%1" to the name of the executable to make it accept command line arguments,
e.g., I called my executable "PW_copy.exe", and so the final registry entry was: \path\PW_copy.exe %1
It works!
Dragging the mouse across several files generates separate threads each with a different file name.

literal string expected error

Please have a look at the following code
with text_io;
use text_io;
procedure hello is
begin
put_line("hello");
new_line(3);
end hello;
When I click "build all" in GPS IDE, I get this error
gnatmake -d -PC:\Users\yohan\firstprogram.gpr
firstprogram.gpr:1:06: literal string expected
firstprogram.gpr:2:01: "end" expected
gnatmake: "C:\Users\yohan\firstprogram.gpr" processing failed
[2013-04-03 13:29:58] process exited with status 4 (elapsed time: 00.47s)
I am very new to Ada, as you can see, this is my first program. Please help.
On the command line, gnatmake will happily compile a file which contains Ada code but has the extension .gpr. GPS knows "better" than that, and insists on treating myfirstprogram.gpr as a GNAT Project file, which of course it isn't.
You'll find life with GNAT much easier if you stick with its file naming conventions: .ads for a spec, .adb for a body, and the file name needs to be the unit name in lower case. In your case, the file should have been called hello.adb.
The simplest approach to creating a GNAT project file in GPS is to go to the Project menu and select New. The only places where you must enter data are on the "Naming the project" page (you might choose firstproject!) and the "Main files" page, where you'd click on the blue + to add hello.adb; you can Forward through the others.
After adding the main file, you can click Apply to install the new project file; now you can Build all and Run.
You may find the GPS tutorial helpful (Help menu, GPS ...)

program to reproduce itself and be useful -- not a quine

I have a program which performs a useful task. Now I want to produce the plain-text source code when the compiled executable runs, in addition to performing the original task. This is not a quine, but is probably related.
This capability would be useful in general, but my specific program is written in Fortran 90 and uses Mako Templates. When compiled it has access to the original source code files, but I want to be able to ensure that the source exists when a user runs the executable.
Is this possible to accomplish?
Here is an example of a simple Fortran 90 which does a simple task.
program exampl
implicit none
write(*,*) 'this is my useful output'
end program exampl
Can this program be modified such that it performs the same task (outputs a string when compiled) and outputs a Fortran 90 text file containing the source?
Thanks in advance
It's been so long since I have touched Fortran (and I've never dealt with Fortran 90) that I'm not certain but I see a basic approach that should work so long as the language supports string literals in the code.
Include your entire program inside itself in a block of literals. Obviously you can't include the literals within this, instead you need some sort of token that tells your program to include the block of literals.
Obviously this means you have two copies of the source, one inside the other. As this is ugly I wouldn't do it that way, but rather store your source with the include_me token in it and run it through a program that builds the nested files before you compile it. Note that this program will share a decent amount of code with the routine that recreates the code from the block of literals. If you're going to go this route I would also make the program spit out the source for this program so whoever is trying to modify the files doesn't need to deal with the two copies.
My original program (see question) is edited: add an include statement
Call this file "exampl.f90"
program exampl
implicit none
write(*,*) "this is my useful output"
open(unit=2,file="exampl_out.f90")
include "exampl_source.f90"
close(2)
end program exampl
Then another program (written in Python in this case) reads that source
import os
f=open('exampl.f90') # read in exampl.f90
g=open('exampl_source.f90','w') # and replace each line with write(*,*) 'line'
for line in f:
#print 'write(2,*) \''+line.rstrip()+'\'\n',
g.write('write(2,*) \''+line.rstrip()+'\'\n')
f.close
g.close
# then complie exampl.f90 (which includes exampl_source.f90)
os.system('gfortran exampl.f90')
os.system('/bin/rm exampl_source.f90')
Running this python script produces an executable. When the executable is run, it performs the original task AND prints the source code.