hacking tutorials 2023All About Hacking

Reverse Engineering Malware Getting Started with Ghidra

Reverse Engineering Malware Getting Started with Ghidra Part 1 There are a number of high-quality tools to be had to apply within the area of reverse engineering (see reverse Engineering.

The capability of Ida pro without the value Reverse Engineering Malware Getting Started with Ghidra:

component 3: Getting started with IDA seasoned and part 5: Getting started out with OllyDbg ), but now we’ve an amazing new option known as Ghidra. Ghidra became developed by means of america country wide safety company (america’s main home secret agent agency and the enterprise chargeable for growing Stuxnet malware and EternalBlue), one of the pinnacle espionage agencies in the international.

We first found out of Ghidra in the Wikileaks Vault 7 leak of 2017 and it was launched as loose and open-supply (underneath the Apache License) software in spring 2019. it is an wonderful opposite engineering tool and unlike Ida seasoned, it is loose!

Ghidra has nearly all of the capability of Ida pro without the value Reverse Engineering Malware Getting Started with Ghidra Part 1:
Reverse Engineering Malware Getting Started with Ghidra 2023

so if you are beginning out in opposite engineering this might be the software to apply.

because of its effectiveness and appealing price point, I might be using Ghidra to do a chain of tutorials in opposite Engineering Malware right here at Hackers-get up.

I strongly advise which you study the subsequent tutorials before intending right here to work with Ghidra:

reverse Engineering Malware, part 1: Getting started out

opposite Engineering Malware, element 2: Assembler fundamentals

reverse Engineering Malware, part 4: home windows Internals

Step #1: download Ghidra

you can download Ghidra here. on account that it’s far written in Java it’s far available for nearly each platform inclusive of Window, Mac OS and Linux. i’ll be using windows 10 to demonstrate Ghidra.

As Ghidra is a Java utility and calls for JDK 11. make sure that your JDK is up to date and, if not, download the it from Oracle.

Step #2: begin Ghidra

once you have got downloaded Ghidra, you could start it via clicking at the .bat document (form of antique school).

Ghidra opens up with the aid of displaying this emblem for a quick time…

…after which shows this window to start your first challenge. projects are just like folders and can contain a couple of files that you are operating on.

click “New task”.

This opens a window like that under. one of the capabilities of Ghidra is the capacity to collaborate on a document or project. if so, click “Shared challenge”. right here we are able to be working for my part on a project, so click on “Non-Shared challenge”. Then click next.

Then, you will be requested for the area and call of your assignment. In windows, by using default, the undertaking might be placed to your C:userghidra directory. i will use that. Then enter your challenge name. here i will name my challenge “MyFirstGhidraProject”.

subsequent, we want to Import a file. this is the software program or malware you need to analyze. go to file –>Import document.

choose the report you want to analyze. In this case, i can studying the crackme0x00.exe (these easy crackme’s are to be had at https://github.com/Maijin/radare2-workshop-2015/tree/master/IOLI-crackme).

when you choose your report, Ghidra will reply with the facts underneath. click on good enough.

Ghidra then shows a display screen like beneath with the important thing information about the record.

next, this display pops up with your mission and imported record. you could both double-click on on the document or “drag and drop” the file to the inexperienced Ghidra dragon above it.

Ghidra then starts offevolved its paintings. First, it presentations the assembler language of the program inside the middle list window after which asks whether you need to investigate the document. click on “yes”.

Ghidra will now examine your document and display the information much like the 4 windows below.

thse four home windows are;

Window #1 is the image Tree

This window permits you to look the Imports, Exports, functions, Labels, classes and Namespaces of the binary.

Window #2 is the list Window

This window displays the breakdown of the code in assembler language.

Window #three is the Decompiler Window

The Decompiler enables you to look what the excessive-degree language could possibly appear to be.

Window #4 is the statistics type supervisor Window

The records type manager allows you to peer all of the defined facts sorts.

Now, you are equipped to begin analyzing and opposite engineering this report !


reverse engineering malware is one of the highest level ability sets within the subject of cybersecurity and one of the highest paid. Ghidra is an incredible opposite engineering tool capable of strolling on almost any platform and priced very attractively (unfastened). on this collection on opposite Engineering, we will be the usage of this tool from the usa NSA to opposite engineer a couple of pieces of malware beginning with the simple and progressing to the extra advanced Reverse Engineering Malware Getting Started with Ghidra .

Malware researchers require a diverse ability set generally won through the years thru experience and self-education. reverse engineering (RE) is an fundamental a part of malware evaluation and studies but it is also one of the maximum advanced competencies a researcher may have. that is one of the reasons why groups lack opposite engineering manpower. Many researchers with a lack of experience war to get started out in RE. Gaining a stable starting point in RE with the applicable knowledge and terminologies may be a differentiator for a researcher Reverse Engineering Malware Getting Started with Ghidra .

This collection will offer RE basics for malware researchers,

analysts and IR experts who’ve no opposite engineering experience however want to learn how. In component 1, you’ll learn about primary computing terms and assembly language Reverse Engineering Malware Getting Started with Ghidra .

Intro to Malware reverse Engineering
what is opposite Engineering Reverse Engineering Malware Getting Started with Ghidra ?
In software, RE is knowing the functionalities and abilities of a compiled program.

There are distinct functions for RE, from vulnerability and compiler research, to reconstructing misplaced supply code and enhancing performance. Malware RE focuses specially on expertise malware skills and functionalities that allows you to remediate threats and examine special malware families Reverse Engineering Malware Getting Started with Ghidra .

whilst will you reverse engineer malware?

RE may be very time-consuming. while researching a malware, you will typically not begin reversing it right away. alternatively, you should conduct triage malware analysis via jogging the malware in a sandbox, extracting strings, and more. This preliminary malware analysis segment can provide in addition context for opposite engineering, if wished. as an instance, you could search for specific strings inside the disassembler or count on to see a sure functionality that the malware displays .

in case your goal is to apprehend a malware’s capabilities, reading it dynamically via a sandbox will not be enough. The malware’s Command and control (C2) could cross down, the malware could depend on another file for configuration which does now not exist on the gadget, the malware has sandbox evasion skills, or the malware will most effective run on a certain surroundings. RE, that is part of superior static malware analysis, is a great deal more effective to reap this goal Reverse Engineering Malware Getting Started with Ghidra .

Now, permit’s jmp in

past the Executable
generally speaking, software is evolved the usage of a high-degree human readable programming language including C, C++, Delphi, Golang and so forth. in order for a system to understand it, this system wishes to be compiled to machine code. The compilation method translates the human readable code to a language that can be performed with the aid of the CPU. once a program is compiled, the human readable source code is not available (nicely, not always. .internet is an example but we will now not attention on cases like this). A disassembler is a tool that may convert machine code to meeting language, a human readable form of the machine instructions. The photo beneath describes the waft Reverse Engineering Malware Getting Started with Ghidra .

Reverse Engineering Malware Getting Started with Ghidra
Reverse Engineering Malware Getting Started with Ghidra  2023

assembly: How Low can you move?

The compiler, used to bring together the code to an executable, truly defines which architecture and operating gadget the executable can run on (there is also any other sort of compiler referred to as JIT that’s used for languages together with Java and .net. it really works in another way however we are able to no longer consciousness on it here). each crucial processing unit (CPU) provider (Intel, ARM, MISP, as an example) has its very own architecture. every structure makes use of a exceptional training set because of this that every series of bytes can be interpreted in a different way by way of the CPU. using a disassembler, those sequences of bytes can be translated to a language called assembly Reverse Engineering Malware Getting Started with Ghidra .

assembly is a human readable illustration of the low-degree gadget code used for conversation among the executable and the gadget’s hardware (CPU). because every CPU has a one of a kind coaching set, the machine code will fluctuate among architectures Reverse Engineering Malware Getting Started with Ghidra .

The modern home windows architectures are x86_64 and x86, 64-bit and 32-bit respectively. we will focus on assembly for x86. To find out about how these architectures vary, check out this article.

To higher understand meeting language, permit’s give an explanation for the shape of the CPU Reverse Engineering Malware Getting Started with Ghidra.

The CPU is a bit of hardware, an digital circuit that processes bits with basic logic. It holds temporary reminiscence and communicates with the Random-access memory (RAM). RAM is used to shop records and the CPU is used to control that records. The CPU has 3 fundamental components: manipulate Unit, Registers, and mathematics and Logical Unit (ALU) Reverse Engineering Malware Getting Started with Ghidra .

Diagram of a fundamental CPU. From Wikipedia

control Unit (CU)
The CU is in fee of integrating all of the CPU’s operations, which includes ALU, records motion inside the CPU, and records exchange throughout outside CPU interfaces. It extracts the information and instructions from memory and decodes them to commands.

mathematics and Logical Unit (ALU)
ALU is a virtual circuit that plays mathematics and logical operations including upload, subtract, and, or, and XOR. ALU’s Wikipedia web page is first-rate in case you need to read more about its structure and how it works.

Registers are integrated variables which are used to shop brief records inside the CPU. the following table lists the overall cause registers for x86 structure Reverse Engineering Malware Getting Started with Ghidra .


purpose of Use

Accumulator check in


mathematics operations and feature’s return cost

Counter register


used in shift/rotate commands and loops

statistics register


arithmetic operations and input output operations

Base sign up


A pointer to information

source index


points to a source in circulation operations

destination index


points to a destination in flow operations

Stack pointer


points to the pinnacle of the stack

Stack base pointer


factors to the bottom of the stack

*In 64-bit CPUs, the sign up name will start with an “R” as opposed to an “E” (EAX → RAX) and the sign in may be 64-bit in size Reverse Engineering Malware Getting Started with Ghidra .

even as the registers are 32-bit in length, you may also use subsections of the EAX, ECX, EDX and EBX registers through smaller sized registers. for example, the least substantial 2 bytes of EAX may be used as a 16-bit sign up referred to as AX. The least large byte of AX can be used as AL and the most significant byte of AX may be used as AH. See underneath Reverse Engineering Malware Getting Started with Ghidra .

x86 register subsections

most of the registers are not always used for his or her historic motive in the modern guidance set. ESP (the stack pointer) and EBP (the stack base pointer) are registers which have reserved their purpose. we will see them in use within the subsequent section Reverse Engineering Malware Getting Started with Ghidra .

The Stack
The stack is a records structure used to save local feature variables associated with a program and is located as a temporary garage vicinity inside the RAM. The stack is built as a LIFO (closing in first out) queue and its memory deal with hierarchy is constructed to flow from a higher address to a decrease one. which means that the stack grows down Reverse Engineering Malware Getting Started with Ghidra .

As mentioned within the preceding segment, ESP will usually point to the top of the stack. If a cost is added (driven) to the stack, ESP can be decremented. If a cost is study from the stack (poped), then ESP might be incremented. The memory unit’s size is four bytes, so the lower and boom in memory region will take vicinity in jumps of 4.

typically, every characteristic in the program could have its very own stack frame. All features may have a prologue and an epilogue. The prologue is is incharge of making the stack frame Reverse Engineering Malware Getting Started with Ghidra :

push ebp – adds the authentic EBP fee to the stack so that it could be restored on the cease of the feature.

mov ebp, esp – movements the pinnacle of the stack pointer to EBP, in order that EBP, aka the base of the stack pointer, will point to the pinnacle of the stack.

The characteristic’s epilogue is incharge of clearing the stack and reversing the prologue, and returns to the calling function Reverse Engineering Malware Getting Started with Ghidra :

mov esp, ebp – assigns the price in EBP to ESP, so that ESP will factor to the bottom of the function.

pop ebp – pops the authentic stack base pointer again to the EBP so that the base of the stack is restored to its value before the prologue (the EBP of the calling characteristic).

ret – jumps to the subsequent preparation inside the calling characteristic.

clock equipment accuracy gadget engineer


The national safety organisation (NSA), the equal agency that introduced you blockbuster malware Stuxnet, has now launched Ghidra, an open-source reverse engineering framework, to develop the variety of opposite engineers analyzing malware. The circulate disrupts the reverse engineering market, which top dog IDA pro has lengthy ruled, and allows greater people to discover ways to reverse engineer while not having to pay for an IDA seasoned license, which can be prohibitively high priced for most beginners to the sector Reverse Engineering Malware Getting Started with Ghidra .

existing IDA pro users are not rushing to make the switch, however, as the effort and time required to port their present workflow and customizations into Ghidra aren’t well worth it for maximum, Reverse Engineering Malware Getting Started with Ghidra  at least no longer inside the immediate destiny. That stated, because the Ghidra ecosystem continues to increase it is probably the open-source tool will cannibalize IDA pro’s market proportion and hasten the decline of the also-rans within the market.

released below the Apache License at RSA in March, Ghidra — stated “ghee-dra” with a tough ‘g’ — can also be effortlessly modified to fit your desires, and security researchers were short to begin hacking at the Ghidra supply code. No need to maintain track of what number of computer systems have an authorized reproduction installed; installation Ghidra on as many workstations (or servers) as you need Reverse Engineering Malware Getting Started with Ghidra.

[ Learn 8 pitfalls that undermine security program success and 12 tips for effectively presenting cybersecurity to the board. | Sign up for CSO newsletters. ]
Ghidra has been to be had for a few brief months, but in that point has come to be broadly regarded as a worthy opportunity to IDA seasoned. right here’s what you need to know to get commenced Reverse Engineering Malware Getting Started with Ghidra.

what is Ghidra?

Ghidra is a opposite engineering framework advanced in-residence by means of the U.S. government. In 2017, Wikileaks broke the news of Ghidra’s lifestyles as a part of its Vault 7 research, and the NSA officially launched the supply code at RSA in 2019 in a pass visible by using many as a public family members workout Reverse Engineering Malware Getting Started with Ghidra.

porup ghidra 1
J.M. PorupGhidra hooked up
no matter the NSA’s motives for releasing Ghidra, its usefulness is indeniable. Its functions encompass a opposite compiler, contextual assist menus, and a person interface geared towards less-than-professional customers. This reporter, who has no preceding opposite engineering experience, changed into capable of get Ghidra up and walking in less than an hour, and became editing meeting and recompiling binaries with little hassle.

porup ghidra 2
J.M. PorupGhidra’s auto-analyze capability
even as the framework is move-platform and runs on home windows, Linux and Mac, most person reports to this point recommend that the OS X model is a piece flaky and to apply Linux or windows if possible. (We used Linux to take Ghidra for a spin.)

porup ghidra 3
J.M. Porup
facet-by way of-facet assembly and decompiled C code
Ghidra helps headless mode, permitting researchers to spin up any number of cloud times and reverse engineer at scale — some thing that would be each technically hard and really high-priced to do in IDA seasoned. Ghidra also can be deployed in headless mode as a server to allow institution collaboration while reverse engineering huge binaries, a feature IDA seasoned does now not offer Reverse Engineering Malware Getting Started with Ghidra Reverse Engineering Malware Getting Started with Ghidra .

Getting started with Ghidra

We located getting started with Ghidra to be quite clean, although mastery of opposite engineering as a subject has a steep learning curve. beginners new to reverse engineering will discover numerous “crackmes” on line, binaries constructed as education gear for self-take a look at newbie opposite engineers. plenty of crackme tutorials and walkthroughs are available for those with the Google-fu to locate them Reverse Engineering Malware Getting Started with Ghidra .

novice programming experience beneficial. knowledge of C beneficial. some assembly required.

some meeting required.
one of the maximum beneficial features for newbies to reverse engineering is Ghidra’s decompiler, Steven Patterson, a vulnerability researcher at Shogun Lab, tells CSO. “if you have a part of assembly selected, then the decompiled code in the decompiler window is likewise highlighted. that offers you with a terrific way of information how high-degree code maps to the disassembled code.”

“in case you’re looking to get started with reverse engineering, [Ghidra is] a very low barrier to access,” he adds.

skilled reverse engineers will find the workout files protected in Ghidra beneficial to quick learn the Ghidra manner to do things. folks that need to bend Ghidra to their will can script or in any other case customise how the open-source software works, unlike IDA seasoned’s proprietary code base Reverse Engineering Malware Getting Started with Ghidra .

How does Ghidra compare to IDA pro?

the decision from skilled reverse engineers has been mixed to date. whilst Ghidra is a mature, properly-developed software program venture utilized in manufacturing at NSA, and might in many cases replace IDA pro, shops with present infrastructure and workflows can also find the time required to retool more pricey than retaining their current IDA pro licenses Reverse Engineering Malware Getting Started with Ghidra .

“The tools, helpers and scripts you’re the use of on your contemporary solution won’t be to be had for Ghidra. in case you or your business enterprise relies on them and also you don’t have time to port the whole thing over to Ghidra, i can absolutely recognize,” Michael Gruhn (@0x6d696368) wrote in a weblog post final week Reverse Engineering Malware Getting Started with Ghidra .

“It’s a majority of these small simple matters lacking that upload up to making Ghidra unusable for many entities,” Gruhn writes. “the ones entities regularly also have placed a big quantity of engineering work into their present tool chains. believe endless plugins, extensions, workflows, beyond analysis, skilled private, … All that is lacking from Ghidra and might require starting from 0 again Reverse Engineering Malware Getting Started with Ghidra . ”

Reverse Engineering Malware Getting Started with Ghidra
Reverse Engineering Malware Getting Started with Ghidra 2023

For some reverse engineers, even though, Ghidra’s collaboration tool is impossible to resist. “Collaboration is the killer function for us,” Ralf-Philipp Weinmann, coping with director of Comsecuris, tells CSO. “we’re a disbursed keep, and we all live in extraordinary towns. it’s critical to us to have software program that allows us to collaborate efficiently, and IDA isn’t that software program, sorry Reverse Engineering Malware Getting Started with Ghidra .”

whilst in the close to term Ghidra is unlikely to disrupt how many current stores work, it does decrease the barrier to entry and could assist educate a new era of reverse engineers. in the medium-to-long time, it seems almost inevitable that this loose, open-supply device will cannibalize IDA seasoned’s marketplace proportion. it is able to properly be a Ghidra consumer who identifies and reverse engineers NSA malware one day Reverse Engineering Malware Getting Started with Ghidra .



Leave a Reply

Your email address will not be published. Required fields are marked *