Many Ways Of Malware Persistence (That You Were Always Afraid To Ask)

quarta-feira, 31 de maio de 2023

TL;DR: Are you into red teaming? Need persistence? This post is not that long, read it ;)
Are you into blue teaming? Have to find those pesky backdoors? This post is not that long, read it ;)

In the previous post, I listed different ways how a Windows domain/forest can be backdoored. In this new post, I am digging a bit deeper, and list the most common/known ways malware can survive a reboot, just using local resources of the infected Windows system. The list is far from complete, and I would like to encourage everyone to comment on new methods, not yet listed here.

From an incident response point of view, one of the best strategies to find malware on a suspicious system is to search for suspicious entries that start with the system. In the good old days, you had to check for 2-3 locations to cover 99% of the infections. Nowadays, there are a thousand ways malware can start. The common ones automatically start whenever Windows starts (or the user logs in), but some tricky ones are triggered by other events.

Autoruns

My favorite choice when it comes to malware persistence is Sysinternals tools, Autoruns. In this paragraph, I mainly quote the official built-in help, but bear with me, it is still interesting.

On a side note, there are some problems with the Autoruns tool: it can only run on a live system. (EDIT: This is not true, Autoruns can analyze offline systems as well! Thanks to a comment from Justin.) And usually, this is not the case - I usually have dd images. And although VBoxManage can convert the dd images to VirtualBox disk image format, usually I don't have the time and storage to do that. This is where xmount awesomeness is here to rescue the day. It can convert dd and Encase images on-the-fly in-memory to Virtualbox format. Just attach the disk image to a new Virtualbox machine as the main boot HDD, modify the CPU/disk/controller settings until Windows starts instead of crashing, and voila, you can boot your forensic image - without modifying a single bit on the original evidence dd file. Another problem with malware analysis on a live system is that a good rootkit can fool the analyst easily. 

For quick wins, I usually filter out Microsoft entries, look for per-user locations only and check for unverified (missing or invalid Authenticode) executables. This usually helps to find 90% of malware easily. Especially if it has a color like purple or pink, it is highly suspicious. To find the rest, well, one has to dig deeper.
Zeus "hiding" in the usual random directory - check the faked timestamp
To implement "poor-mans monitoring", regularly save the output of Autoruns, and during incident response, it will be highly valuable. Howto guide here.

Logon

"This entry results in scans of standard autostart locations such as the Startup folder for the current user and all users, the Run Registry keys, and standard application launch locations." 
There are 42 registry keys/folders at the moment in Autoruns, which can be used to autostart a malware. The most common ways are the HKCU\Software\Microsoft\Windows\CurrentVersion\Run and the C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup folder.
One of my favorite regarding this topic is the file-less Poweliks malware, 100% pure awesomeness. Typical ring 3 code execution.

Explorer

"Select this entry to see Explorer shell extensions, browser helper objects, explorer toolbars, active setup executions, and shell execute hooks". 71 registry keys, OMG. Usually, this is not about auto-malware execution, but some of them might be a good place to hide malware.

Internet explorer

"This entry shows Browser Helper Objects (BHO's), Internet Explorer toolbars and extensions". 13 registry key here. If a malicious BHO is installed into your browser, you are pretty much screwed.

Scheduled tasks

"Task scheduler tasks configured to start at boot or logon." Not commonly used, but it is important to look at this.
I always thought this part of the autostart entries is quite boring, but nowadays, I think it is one of the best ways to hide your malware. There are so many entries here by default, and some of them can use quite good tricks to trigger the start.
Did you know that you can create custom events that trigger on Windows event logs?
Did you know you can create malware persistence just by using Windows tools like bitsadmin and Scheduled tasks?
Scheduler in the old days
Scheduler in the new days

Services

HKLM\System\CurrentControlSet\Services is a very commonplace to hide malware, especially rootkits. Check all entries with special care.

Drivers

Same as services. Very commonplace for rootkits. Unfortunately, signing a driver for 64-bit systems is not fun anymore, as it has to be signed by certificates that can be chained back to "Software Publisher Certificates". Typical startup place for Ring 0 rootkits. 
Starting from Windows 10, even this will change and all drivers have to be signed by "Windows Hardware Developer Center Dashboard portal" and EV certificates.

Codecs

22 registry keys. Not very common, but possible code execution.

Boot execute

"Native images (as opposed to Windows images) that run early during the boot process."
5 registry keys here. Good place to hide a rootkit here.

Image hijacks

"Image file execution options and command prompt autostarts." 13 registry key here. I believe this was supposed for debugging purposes originally.
This is where the good-old sticky keys trick is hiding. It is a bit different from the others, as it provides a backdoor access, but you can only use this from the local network (usually). The trick is to execute your code whenever someone presses the SHIFT key multiple times before logging into RDP. The old way was to replace the sethc.exe, the new fun is to set a debug program on sethc.
If you see this, you are in trouble

AppInit

"This has Autoruns shows DLLs registered as application initialization DLLs." Only 3 registry keys here. This is the good old way to inject a malicious DLL into Explorer, browsers, etc. Luckily it is going to be deprecated soon.

Known DLLs

"This reports the location of DLLs that Windows loads into applications that reference them." Only 1 registry key. This might be used to hijack some system DLLs.

Winlogon

"Shows DLLs that register for Winlogon notification of logon events." 7 registry keys. Sometimes used by malware.

Winsock providers

"Shows registered Winsock protocols, including Winsock service providers. Malware often installs itself as a Winsock service provider because there are few tools that can remove them. Autoruns can disable them, but cannot delete them." 4 registry keys. AFAIK this was trendy a while ago. But still, a good place to hide malware.

Print monitors

"Displays DLLs that load into the print spooling service. Malware has used this support to autostart itself." 1 registry key. Some malware writers are quite creative when it comes to hiding their persistence module.

LSA providers

"Shows registers Local Security Authority (LSA) authentication, notification and security packages." 5 registry keys. A good place to hide your password stealer.

Network providers

"Missing documentation". If you have a good 1 sentence documentation, please comment.

WMI filters

"Missing documentation". Check Mandiant for details.

Sidebar gadgets

Thank god MS disabled this a while ago :)
We all miss you, you crappy resource gobble nightmares

Common ways - not in autoruns

Now, let's see other possibilities to start your malware, which won't be listed in Sysinternals Autoruns.

Backdoor an executable/DLL

Just change the code of an executable which is either auto-starting or commonly started by the user. To avoid lame mistakes, disable the update of the file ... The backdoor factory is a good source for this task. But if you backdoor an executable/DLL which is already in Autoruns listed, you will break the Digital Signature on the file. It is recommended to sign your executable, and if you can't afford to steal a trusted certificate, you can still import your own CA into the user's trusted certificate store (with user privileges), and it will look like a trusted one. Protip: Use "Microsoft Windows" as the codesigner CA, and your executable will blend in.
See, rootkit.exe totally looks legit, and it is filtered out when someone filters for "Hide Windows entries".


Hijack DLL load order

Just place your DLL into a directory which is searched before the original DLL is found, and PROFIT! But again, to avoid lame detection, be sure to proxy the legitimate function calls to the original DLL. A good source on this topic from Mandiant and DLL hijack detector.


Here you can see how PlugX works in action, by dropping a legitimate Kaspersky executable, and hijacking the DLL calls with their DLL. 

Hijack a shortcut from the desktop/start menu

Never underestimate the power of lame tricks. Just create an executable which calls the original executable, and meanwhile starts your backdoor. Replace the link, PROFIT! And don't be a skiddie, check the icon ;) I have seen this trick in adware hijacking browsers a lot of times.

IE hijacked to start with http://tinyurl.com/2fcpre6

File association hijack

Choose the user's favorite file type, replace the program which handles the opening with a similar one described in the previous section, and voila!

COM object hijack

The main idea is that some COM objects are scanned for whether they are on the system or not, and when it is registered, it is automatically loaded. See COMpfun for details.

Windows Application Compatibility - SHIM

Not many people are familiar with Windows Application Compatibility and how it works. Think about it as an added layer between applications and the OS. If the application matches a certain condition (e.g. filename), certain actions will take place. E.g. emulation of directories, registry entries, DLL injection, etc. In my installation, there are 367 different compatibility fixes (type of compatibility "simulation"), and some of those can be customized.
Every time IE starts, inject a DLL into IE

Bootkits 

Although bootkits shown here can end up in Autoruns in the drivers section (as they might need a driver at the end of the day), I still think it deserves a different section.

MBR - Master boot record

Malware can overwrite the Master boot record, start the boot process with its own code, and continue the boot process with the original one. It is common for rootkits to fake the content of the MBR record, and show the original contents. Which means one just have attached the infected HDD to a clean system, and compare the first 512 bytes (or more in some cases) with a known, clean state, or compare it to the contents shown from the infected OS. SecureBoot can be used to prevent malware infections like this.
There is a slight difference when MBR is viewed from infected OS vs clean OS

VBR - Volume boot record

This is the next logical step where malware can start it's process, and some malware/rootkit prefers to hide it's startup code here. Check GrayFish for details. SecureBoot can be used to prevent malware infections like this.

BIOS/UEFI malware

Both the old BIOS and the new UEFI can be modified in a way that malware starts even before the OS had a chance to run. Although UEFI was meant to be more secure than BIOS, implementation and design errors happens. Check the Computrace anti-theft rootkit for details.

Hypervisor - Ring -1 rootkit

This is somewhat special, because I believe although rootkit can run in this layer but it can't persist only in this layer on an average, physical machine, because it won't survive a reboot See Rutkowska's presentation from 2006 But because the hypervisor can intercept the restart event, it can write itself into one of the other layers (e.g. install a common kernel driver), and simply delete it after it is fully functional after reboot. Update: There is a good paper from Igor Korkin about hypervisor detection here.

SMM (System Management Mode) malware - Ring -2 rootkit

Somehow related to the previous type of attacks, but not many people know that System Management Mode can be used to inject code into the OS. Check the DEITYBOUNCE malware for more details ;) Also, abusing Intel Dual Monitor Mode (DMM) can lead to untrusted code execution, which basically monitors the SMM mode.

Intel® Active Management Technology - Ring -3 rootkit

According to Wikipedia, "Intel Active Management Technology (AMT) is hardware and firmware technology for remote out-of-band management of personal computers, in order to monitor, maintain, update, upgrade, and repair them". You can ask, what could possibly go wrong? See Alexander Tereshkin's and Rafal Wojtczuk's great research on this, or Vassilios Ververis thesis about AMT
As not many people click on links, let me quote the scary stuff about AMT:
  • Independent of the main CPU
  • Can access host memory via DMA (with restrictions)
  • Dedicated link to NIC, and its filtering capabilities
  • Can force host OS to reboot at any time (and boot the system from the emulated CDROM)
  • Active even in S3 sleep!

Other stuff

Create new user, update existing user, hidden admins

Sometimes one does not even have to add malicious code to the system, as valid user credentials are more than enough. Either existing users can be used for this purpose, or new ones can be created. E.g. a good trick is to use the Support account with a 500 RID - see here, Metasploit tool here.

Esoteric firmware malware

Almost any component in the computer runs with firmware, and by replacing the firmware with a malicious one, it is possible to start the malware. E.g. HDD firmware (see GrayFish again), graphic card, etc.

Hidden boot device

Malware can hide in one of the boot devices which are checked before the average OS is loaded, and after the malware is loaded, it can load the victim OS.

Network-level backdoor

Think about the following scenario: every time the OS boots, it loads additional data from the network. It can check for new software updates, configuration updates, etc. Whenever a vulnerable software/configuration update, the malware injects itself into the response, and get's executed. I know, this level of persistence is not foolproof, but still, possible. Think about the recently discovered GPO MiTM attack, the Evilgrade tool, or even the Xensploit tool when we are talking about VM migration.

Software vulnerability

Almost any kind of software vulnerability can be used as a persistent backdoor. Especially, if the vulnerability can be accessed remotely via the network, without any user interaction. Good old MS08-067...

Hardware malware, built into the chipset

I am not sure what to write here. Ask your local spy agency for further information. Good luck finding those!

More links

Tools I highly recommend:
For more information, check this blog post, part 1, part 2

Update 2017-04-29: A very nice list of Office persistence: https://labs.mwrinfosecurity.com/blog/add-in-opportunities-for-office-persistence/

Update 2017-10-23: Persistence via Security Descriptors and ACLs: https://www.youtube.com/watch?v=SeR4QJbaNRg

Update 2018-07-25: Backdooring LAPS https://rastamouse.me/2018/03/laps---part-1/
https://rastamouse.me/2018/03/laps---part-2/ 

I would like to thank to Gabor Pek from CrySyS Lab for reviewing and completing this post.
Related links
  1. Pentest Tools Review
  2. Hack Apps
  3. Pentest Tools Github
  4. Hack Tools For Pc
  5. Top Pentest Tools
  6. Pentest Box Tools Download
  7. Bluetooth Hacking Tools Kali
  8. Pentest Recon Tools
  9. Pentest Recon Tools
  10. Hack App
  11. Game Hacking
  12. Pentest Tools List
  13. Hacking Tools For Windows
  14. Hacker Hardware Tools
  15. Hacking Tools Online
  16. Hacking Tools Pc
  17. What Is Hacking Tools
  18. Pentest Tools Open Source
  19. Hack Apps
  20. Hack Tools 2019
  21. New Hacker Tools
  22. Hak5 Tools
  23. Hack Tools Online
  24. Pentest Tools Github
  25. Hacking Tools
  26. What Are Hacking Tools
  27. World No 1 Hacker Software
  28. Android Hack Tools Github
  29. Hack Tools For Ubuntu
  30. Pentest Tools For Mac
  31. What Are Hacking Tools
  32. Tools Used For Hacking
  33. Pentest Box Tools Download
  34. Free Pentest Tools For Windows
  35. Hacker Tools For Mac
  36. Hacker Tools Online
  37. Hacking Tools Github
  38. Hack Tool Apk No Root
  39. Hacking Tools And Software
  40. Hacking Tools Kit
  41. Hacker Tools 2020
  42. Pentest Tools Framework
  43. Hacking Tools Free Download
  44. Hack Tools Pc
  45. Pentest Tools Alternative
  46. Hacking Tools Free Download
  47. Hacking Tools And Software
  48. Ethical Hacker Tools
  49. Hacking Tools Pc
  50. World No 1 Hacker Software
  51. Hacking Tools Download
  52. Hack Tools Download
  53. Hacking Tools For Windows
  54. Hacking Tools For Pc
  55. Best Hacking Tools 2019
  56. Hacking Apps
  57. Pentest Tools Apk
  58. What Is Hacking Tools
  59. Best Pentesting Tools 2018
  60. Hacking Tools Name
  61. Hack Tools
  62. Hacker Tools For Mac
  63. Hacker Tool Kit
  64. Hack Tools Download
  65. Hacker Tools 2020
  66. Nsa Hack Tools Download
  67. Physical Pentest Tools
  68. Github Hacking Tools
  69. Pentest Tools Find Subdomains
  70. Hacker Tools List
  71. Hacker Tools Linux
  72. Best Hacking Tools 2020
  73. World No 1 Hacker Software
  74. Hacker Search Tools
  75. Hacker Security Tools
  76. Hack And Tools
  77. Pentest Tools Port Scanner
  78. Hacking Apps
  79. Best Hacking Tools 2020
  80. Hacking Tools 2019
  81. Hack Tool Apk
  82. Nsa Hacker Tools
  83. Nsa Hack Tools
  84. Hacking Tools Software
  85. Hacker Tools Free Download
  86. Pentest Tools Kali Linux
  87. Black Hat Hacker Tools
  88. Hack App
  89. Android Hack Tools Github
  90. Hacker Tools Free Download
  91. Hacker Hardware Tools
  92. Easy Hack Tools
  93. Hacker Tools 2019
  94. Pentest Tools Find Subdomains
  95. Hacking Tools For Mac
  96. Pentest Tools For Windows
  97. Hack Website Online Tool
  98. Hak5 Tools
  99. Hacking Tools Name
  100. Hacking App
  101. Kik Hack Tools
  102. Best Hacking Tools 2020
  103. Computer Hacker
  104. Hacker Security Tools
  105. Hacker Tools Apk Download
  106. Hackrf Tools
  107. Hack Tools Online
  108. Hacking Tools Download
  109. Ethical Hacker Tools
  110. Pentest Tools Bluekeep
  111. Hack Rom Tools
  112. Hacker Tools Software
  113. Hack Tools For Windows
  114. Hacking Tools
  115. Hack Tools For Windows
  116. Hack Tools For Ubuntu
  117. Hacker Tools 2019
  118. Pentest Tools Github
  119. Best Pentesting Tools 2018
  120. Nsa Hacker Tools
  121. Hack Website Online Tool
  122. Pentest Tools Subdomain
  123. How To Hack
  124. Hacker
  125. Hacker Tools Free Download
  126. Usb Pentest Tools
  127. How To Make Hacking Tools
  128. Hacker Security Tools
  129. Pentest Tools Github
  130. Hacker Hardware Tools

Hackerhubb.blogspot.com

Hackerhubb.blogspot.com

Related articles


  1. Android Hack Tools Github
  2. Bluetooth Hacking Tools Kali
  3. Black Hat Hacker Tools
  4. What Are Hacking Tools
  5. Pentest Tools Framework
  6. Hacking Tools Kit
  7. Hack Tools Mac
  8. Hack Rom Tools
  9. Pentest Tools Apk
  10. Hacker Tools 2019
  11. Ethical Hacker Tools
  12. Hacking Tools Download
  13. Pentest Tools Apk
  14. Hacking Tools Online
  15. Nsa Hack Tools Download
  16. How To Make Hacking Tools
  17. Android Hack Tools Github
  18. Hacker Tools Free
  19. Nsa Hack Tools Download
  20. Hacking Tools For Windows Free Download
  21. Hacker Tools Apk
  22. Hacker
  23. Hack Tools Github
  24. Hacking App
  25. Black Hat Hacker Tools
  26. Hack App
  27. Pentest Tools Port Scanner
  28. Hacker Tools Linux
  29. Pentest Tools Review
  30. Hacking Tools Kit
  31. Growth Hacker Tools
  32. Wifi Hacker Tools For Windows
  33. Top Pentest Tools
  34. Github Hacking Tools
  35. Pentest Tools Download
  36. Hack Apps
  37. Top Pentest Tools
  38. Hacker Tools
  39. Hack App
  40. Pentest Tools Online
  41. How To Hack
  42. Hack Tools Github
  43. Hack Tools
  44. Pentest Tools Bluekeep
  45. Hacker Techniques Tools And Incident Handling
  46. Nsa Hacker Tools
  47. Hack Rom Tools
  48. Game Hacking
  49. Hack And Tools
  50. Hacking Tools Free Download
  51. Blackhat Hacker Tools
  52. Pentest Tools Android
  53. Hacking Tools Software
  54. Pentest Tools For Windows
  55. Pentest Tools Alternative
  56. Pentest Box Tools Download
  57. Hacking Tools
  58. Pentest Tools Port Scanner
  59. Hacker Tools Windows
  60. Game Hacking
  61. How To Make Hacking Tools
  62. Pentest Tools Free
  63. Pentest Tools Find Subdomains
  64. Hacker Tools Mac
  65. Hacker Tools Github
  66. Hacking Tools Download
  67. Hacking Tools Mac
  68. Hack Tools For Windows
  69. Hacking Tools For Kali Linux
  70. Hacker Tools Apk Download
  71. Hacker Tools Linux
  72. Hack Tools For Pc
  73. Hacking Tools Github
  74. Nsa Hack Tools
  75. Install Pentest Tools Ubuntu
  76. Hacking Tools Windows 10
  77. Hacking Tools Windows 10
  78. Computer Hacker
  79. Pentest Tools For Mac
  80. Pentest Tools For Ubuntu
  81. Pentest Tools Windows
  82. Nsa Hack Tools
  83. New Hacker Tools
  84. Hack Website Online Tool
  85. Hak5 Tools
  86. Ethical Hacker Tools
  87. Computer Hacker
  88. Hack Tool Apk
  89. Hacker Tools Apk
  90. Pentest Recon Tools
  91. Pentest Tools Github
  92. Hacker Tools Software
  93. Pentest Tools Download
  94. Best Hacking Tools 2019
  95. Free Pentest Tools For Windows
  96. Hack Rom Tools
  97. Physical Pentest Tools
  98. How To Make Hacking Tools
  99. Hacking Tools Kit
  100. Free Pentest Tools For Windows
  101. Hacker Tools Linux
  102. Bluetooth Hacking Tools Kali
  103. Hacking Tools For Pc
  104. What Are Hacking Tools
  105. Hack Tools Github
  106. Hacking Tools For Pc
  107. Hacking Tools Github
  108. Physical Pentest Tools
  109. Hacking App
  110. Hack Tools Pc
  111. Hackrf Tools
  112. Hacker Tools
  113. Hacks And Tools
  114. Hack Tools
  115. Hacker Tools
  116. Hacking Tools Pc
  117. Hack Tools For Pc
  118. Hacker Tools Apk Download
  119. Hack Tool Apk
  120. Beginner Hacker Tools
  121. Termux Hacking Tools 2019
  122. Pentest Recon Tools
  123. Hack Tools For Pc
  124. Android Hack Tools Github
  125. Computer Hacker
  126. Hack And Tools
  127. Hacker Tools For Mac
  128. Game Hacking
  129. Hacking Tools Mac
  130. Hacking Tools Kit
  131. Hacking Tools Download
  132. Hackrf Tools
  133. Physical Pentest Tools
  134. Pentest Tools List
  135. Hack Tools For Ubuntu
  136. Pentest Tools Review
  137. Hack Tools For Ubuntu
  138. Hack Tools
  139. Hacking Tools And Software
  140. Easy Hack Tools
  141. Hack Tools For Windows
  142. Hacking Tools For Windows Free Download
  143. Pentest Tools Download
  144. Hacking Tools Kit
  145. Hacking Tools 2019
  146. Hacking Tools Name
  147. Hackers Toolbox
  148. Pentest Reporting Tools
  149. Hacking Tools Hardware
  150. Hacker Tools For Mac
  151. Pentest Tools Github
  152. Tools 4 Hack
  153. Hack Tools For Windows
  154. Nsa Hacker Tools
  155. Hacker Tool Kit
  156. Hacking Tools Online
  157. Hacking Tools
  158. Pentest Tools Port Scanner
  159. Github Hacking Tools

Reversing Pascal String Object

There are many goodware and malware developed in pascal, and we will see that the binary generated by the pascal compilers is fascinating, not only because the small and clean generated binaries, or the  clarity of the pascal code, but also the good performance. In Linux we have Lazarus which is a good free IDE like Delphi and Kylix the free pascal IDE for windows.

The program:

program strtest;

var
  cstr:  array[0..10] of char;
  s, s2:  ShortString;

begin
  cstr := 'hello world';
  s  := cstr;
  s2 := 'test';
  
  WriteLn(cstr + ' ' + s + ' ' + s2);
end.


We are going to compile it with freepascal and lazarus, and just the binary size differs a lot:

lazarus          242,176 btytes  845 functions
freepascal       32,256 bytes   233 functions
turbopascal      2,928 bytes     80 functions  (wow)

And surprisingly turbopascal binaries are extremely light.
Lets start with lazarus:




Logically it imports from user32.dll some display functions, it also import the kernel32.dll functions and suspiciously the string operations of oleaut32.dll 


And our starting point is a function called entry that calls the console initialization and retrieve some console configurations, and then start a labyrinth of function calls.



On functions 10000e8e0 there is the function that calls the main function.

I named execute_param2 because the second param is a function pointer that is gonna be executed without parameters, it sounds like main calling typical strategy.
And here we are, it's clearly the user code pascal main function.


What it seems is that function 100001800 returns an string object, then is called its constructor to initialize the string, then the string is passed to other functions that prints it to the screen.

This function executes the method 0x1c0 of the object until the byte 0x89 is a null byte.
What the hell is doing here?
First of all let's create the function main:


Simply right button create function:

After a bit of work on Ghidra here we have the main:


Note that the struct member so high like 0x1b0 are not created by default, we should import a .h file with an struct or class definition, and locate the constructor just on that position.

The mysterious function was printing byte a byte until null byte, the algorithm the compiler implemented in asm is not as optimized as turbopascal's.

In Windbg we can see the string object in eax after being created but before being initialized:












Just before executing the print function, the RCX parameter is the string object and it still identical:


Let's see the constructor code.
The constructor address can be guessed on static walking the reverse-cross-references to main, but I located it in debugging it in dynamic analysis.


The constructor reads only a pointer stored on the string object on the position 0x98.

And we have that the pointer at 0x98 is compared with the address of the literal, so now we know that this pointer points to the string.
The sentence *string_x98 = literal confirms it, and there is not memory copy, it only points reusing the literal.



Freepascal

The starting labyrinth is bigger than Lazarus so I had to begin the maze from the end, searching the string "hello world" and then finding the string references:


There are two ways to follow the references in Ghidra, one is [ctrl] + [shift] + F  but there is other trick which is simply clicking the green references texts on the disassembly.

At the beginning I doubted and put the name possible_main, but it's clearly the pascal user code main function.




The char array initialization Is converted by freepascal compiler to an runtime initialization using mov instructions.

Reducing the coverage on dynamic we arrive to the writeln function:


EAX helds  a pointer to a struct, and the member 0x24 performs the printing. In this cases the function can be tracked easily in dynamic executing the sample.

And lands at 0x004059b0 where we see the WriteFile, the stdout descriptor, the text and the size supplied by parameter.


there is an interesting logic of what happens if WriteFile() couldn't write all the bytes, but this is other scope.
Lets see how this functions is called  and how text and size are supplied to figure out the string object.



EBX helds the string object and there are two pointers, a pointer to the string on 0x18 and the length in 0x18, lets verify it on windbg.


And here we have the string object, 0x0000001e is the length, and 0x001de8a68 is the pointer.


Thanks @capi_x for the pascal samples.

Related articles


  1. Hack Tool Apk
  2. Hack Tools Download
  3. Free Pentest Tools For Windows
  4. Ethical Hacker Tools
  5. Hacker Tools Linux
  6. Hacker Tools Mac
  7. Pentest Tools Windows
  8. Hackers Toolbox
  9. Pentest Tools Free
  10. Hacker Tools Online
  11. Hacking Tools Download
  12. Hacks And Tools
  13. Underground Hacker Sites
  14. Hacker
  15. Best Hacking Tools 2020
  16. Hackers Toolbox
  17. Pentest Tools Website
  18. Pentest Tools Github
  19. Hack Tools For Windows
  20. Hacker Tools Hardware
  21. Hack Tools Pc
  22. Pentest Tools For Android
  23. Ethical Hacker Tools
  24. Hacker Tools 2020
  25. Hacking Tools Github
  26. New Hacker Tools
  27. Hacking Tools For Mac
  28. Pentest Tools Port Scanner
  29. Hacker Tools Apk
  30. Hack Tools Mac
  31. Hack Tools 2019
  32. Hacking Tools Download
  33. Hackers Toolbox
  34. Pentest Tools Nmap
  35. Hacking Tools Mac
  36. Pentest Reporting Tools
  37. Hack Tools For Windows
  38. Hacker Tools Online
  39. Pentest Recon Tools
  40. Hacker Tools 2020
  41. Hacking Tools For Pc
  42. Hacking Tools Mac
  43. Pentest Tools For Ubuntu
  44. Hack Tools For Windows
  45. Wifi Hacker Tools For Windows
  46. Pentest Tools Port Scanner
  47. Hack Tools Download
  48. Pentest Tools
  49. Hacker Tools For Windows
  50. Termux Hacking Tools 2019
  51. Pentest Tools Port Scanner
  52. Pentest Tools Subdomain
  53. Tools For Hacker
  54. Pentest Automation Tools
  55. Hacking Tools 2020
  56. Pentest Tools Review
  57. Hacking App
  58. Hacker Hardware Tools
  59. Nsa Hacker Tools
  60. Pentest Tools Alternative
  61. Hacking Tools For Games
  62. Pentest Tools Apk
  63. Easy Hack Tools
  64. Best Pentesting Tools 2018
  65. Hack Rom Tools
  66. How To Hack
  67. Pentest Tools Apk
  68. Hack Tools
  69. What Are Hacking Tools
  70. Best Pentesting Tools 2018
  71. Hacking Tools Windows
  72. Hacking Tools Github
  73. Blackhat Hacker Tools
  74. Hacking Tools For Windows
  75. Pentest Tools Apk
  76. Hacker Tool Kit
  77. Hack Tools Download
  78. Pentest Tools For Windows
  79. Pentest Tools Url Fuzzer
  80. Hacking App
  81. Github Hacking Tools
  82. Hackrf Tools
  83. Growth Hacker Tools
  84. Hacker Tools Apk
  85. Hacker Hardware Tools
  86. Pentest Tools Website
  87. Hacking Tools Name
  88. Black Hat Hacker Tools
  89. Hack Tools Download
  90. Hackrf Tools
  91. Pentest Tools Download
  92. Hack Tools For Ubuntu
  93. Hacker Search Tools
  94. Pentest Tools Github
  95. Hack App
  96. Hacker Tools Github
  97. Hacking Tools For Beginners
  98. Hack Tools For Ubuntu
  99. Hacking Tools For Beginners
  100. World No 1 Hacker Software
  101. Install Pentest Tools Ubuntu
  102. Pentest Tools Website