Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Using IDA Free - Part 2

views
     
TSTullamarine
post Apr 28 2023, 04:57 AM, updated 3y ago

Getting Started
**
Validating
163 posts

Joined: Apr 2020
Hi, it's me again! Upon encouragement by @KLKS and @junyian in last series, I am keen to explore more in IDA Freeware.

Today I will use a more complex executable, created using Visual C++, I call it "lyn.exe".

This is the output by running "lyn.exe" in command prompt window:
user posted image

Select "lyn.exe" as the file to disassemble.
user posted image

Click OK to confirm the default setting. (Doesn't load resource)
user posted image

Voila, this is the main window.
user posted image

As compared with last time, this time got many function stubs.
The disassembled code is: (I can't paste complete code because forum blocked it)


And this is my original C++ code.
user posted image

The Win32 API GetTickCount function is to "retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days."
https://learn.microsoft.com/en-us/windows/w...pi-gettickcount

"lyn.exe" is a 64-bit portable executable, as seen from the register used (with r prefix), and the stack alignment.

I highlight a "call cs:GetTickCount" instruction in IDA View:
user posted image

And get a corresponding hex bytes in Hex View:
user posted image

Actually if scroll up a little bit the main window, I can see the summary of the executable:
(snipped because forum blocked it)

There is more to explore, like if I click "pre_c_initialization" function stub, this floating window appears:
https://pictr.com/images/2023/04/28/E4E7hv.png
Of course I have no clue what it does...

Now if I right-click the window, this pop-up menu appears:
user posted image

This brings me to another window:
https://pictr.com/images/2023/04/28/E4EaqD.png

Can confirm "lyn.exe" has dependency on MSVCP140.dll.

user posted image
Not just MSVCP140.dll, also dependency on VCRUNTIME140.DLL, and KERNEL32.DLL (Of course).

And many more...
; Imports from api-ms-win-crt-math-l1-1-0.dll
; Imports from api-ms-win-crt-runtime-l1-1-0.dll
...
...


Finally, the Debugger menu and Options menu... (snipped because forum doesn't allow images more than these)
https://pictr.com/images/2023/04/28/E4Eru6.png
https://pictr.com/images/2023/04/28/E4ENXq.png

IDA Free is too powerful, there are many features I don't know yet how to use.
I think it is quite difficult to trace a C++ program, because it has so many function stubs.
junyian
post Apr 28 2023, 06:19 AM

Casual
***
Junior Member
401 posts

Joined: Jan 2003


Function stubs are added by the compiler. It sets up the environment for the executable to run, e.g. getting cmd line arguments and passing to main(), setting up SEH/VEH, clean exit of the executable after main() finishes, etc.

You're already in the right step though. Next, you can explore the debugger, decompiler, IDC scripting, etc.
TSTullamarine
post Apr 28 2023, 07:45 AM

Getting Started
**
Validating
163 posts

Joined: Apr 2020
QUOTE(junyian @ Apr 28 2023, 06:19 AM)
Function stubs are added by the compiler. It sets up the environment for the executable to run, e.g. getting cmd line arguments and passing to main(), setting up SEH/VEH, clean exit of the executable after main() finishes, etc.

You're already in the right step though. Next, you can explore the debugger, decompiler, IDC scripting, etc.
*
I couldn't know if you didn't tell me. And I am glad in the right step! Thanks!
TSTullamarine
post May 8 2023, 04:38 AM

Getting Started
**
Validating
163 posts

Joined: Apr 2020
QUOTE(junyian @ Apr 28 2023, 06:19 AM)
.....Next, you can explore the debugger, decompiler, IDC scripting, etc.
*
Supercool! The cloud decompiler is already good enough, even though I don't have better decompiler that comes with IDA Pro.

Original C code:
CODE
#include <stdio.h>

int main()
{
int i;
int j;
for (i=1;i<10;++i)
{
 for (j=1;j<i;++j)
 {
  printf("*");
 }
 
 printf("\n");
}
}


Decompiled Pseudocode generated by IDA Freeware:
CODE
int __cdecl main(int argc, const char **argv, const char **envp)
{
 int j; // [rsp+28h] [rbp-8h]
 int i; // [rsp+2Ch] [rbp-4h]

 _main(argc, argv, envp);
 for ( i = 1; i <= 9; ++i )
 {
   for ( j = 1; j < i; ++j )
     putchar(42);
   putchar(10);
 }
 return 0;
}


Choose "Generate Pseudocode..."
user posted image

Output of the C program above:
user posted image

IDA Graph view of the program:
user posted image
user posted image

This post has been edited by Tullamarine: May 8 2023, 04:45 AM

 

Change to:
| Lo-Fi Version
0.0155sec    0.86    5 queries    GZIP Disabled
Time is now: 26th November 2025 - 01:33 PM