ReverseEngineering – Telegram
ReverseEngineering
1.24K subscribers
40 photos
10 videos
55 files
666 links
Download Telegram
Packt.Ghidra.Software.Reverse-Engineering.for.Beginners.pdf
74.7 MB
👾 Ghidra Software

Reverse-Engineering for Beginners, 2nd Edition: Master the art of debugging, from understanding code to mitigating threats (2025)
Author: David Alvarez Perez
🔥73
آنالیز استاتیک ساده

هدف:
یادگیری بررسی یک برنامه بدون اجرا شدن و استخراج اطلاعات مهم: توابع رشته‌ها و نقاط ورودی

ابزارهای مورد نیاز

IDA یا Ghidra

Strings

PEview یا CFF Explorer


مراحل قدم به قدم

بررسی رشته‌ها


تصویر خروجی strings روی برنامه ساده:

Hello World!

Enter your name:

توضیح: این رشته‌ها اطلاعات مهم برنامه رو نشون میدن


دیاسمبل کردن برنامه



متن IDA/Ghidra با نمایش Entry Point و توابع اصلی:

Main
Sub_401000


توضیح: توابع اصلی رو پیدا کنید و ببینید رشته‌ها چگونه استفاده میشن


شناسایی نقاط ورودی



متن PE Header با علامت Entry Point:

Entry Point: 0x401000


توضیح: این نقطه اولین جایی که برنامه اجرا میشه


بررسی Import Table



متن Import Table در PE view:

KERNEL32.dll
  - GetModuleHandleA
  - CreateFileA
  - ReadFile


توضیح: نشون میده برنامه از چه توابع خارجی و منابعی استفاده میکنه


نکات مهم:

هیچ برنامه‌ای اجرا نمیشه پس ریسک آلوده شدن سیستم وجود نداره

همیشه با نسخه کپی یا در ماشین مجازی کار کنید



Simple Static Analysis

Objective:
Learn to examine a program without running it and extract important information: functions strings and entry points

Tools Required

IDA or Ghidra

Strings

PEview or CFF Explorer

Step-by-Step

Examining Strings

Image of the output of strings on a simple program:

Hello World!

Enter your name:


Explanation: These strings show important information about the program

Disassembling the program

IDA/Ghidra text showing the Entry Point and main functions:

Main
Sub_401000


Explanation: Find the main functions and see how the strings are used

Identifying entry points

PE Header text with Entry Point:

Entry Point: 0x401000


Explanation: This is the first place the program is executed

Checking the Import Table

Import Table text in PE view:

KERNEL32.dll
- GetModuleHandleA
- CreateFileA
- ReadFile


Explanation: Shows what external functions and resources the program uses

Important notes:

No program is executed so there is no risk of system infection

Always work with a copy or in a virtual machine
6
دیباگ و آنالیز داینامیک

هدف اینه برنامه رو اجرا میکنیم و توی رفتارش ببینیم چیکار میکنه کجا میره چه رجیسترایی عوض میشن کی فایل میخونه یا به شبکه وصل میشه

ابزار لازم x64dbg یا OllyDbg برای برنامه‌های قدیمی یه ماشین مجازی واسه امن بودن


برنامه رو با x64dbg باز کنید دیباگر معمولا اول کار روی Entry Point متوقف میشه


نقطه توقف بذارید جایی که فکر میکنید مهمه یا رشته دیده شده Breakpoint بذارید تا وقتی رسید اجرا وایسه


مرحله‌ای جلو برید از Step Into (معمولا F7) و Step Over (F8) استفاده کنید Step Into میره داخل تابع Step Over اونو کامل اجرا میکنه و میاد بیرون


رجیستر و حافظه ببین مقدارهای EAX, EBX, ECX, EDX و بقیه رو چک کنید تو قسمت Memory یا Dump میتونید محتوای حافظه رو ببینید


رفتار برنامه رو تحلیل کنید ببینید چه رجیسترهایی تغییر میکنن کی فایل یا شبکه فراخوانی میشه چه رشته‌هایی استفاده میشه



نکات کاربردی:

همیشه توی VM یا محیط ایزوله کار کنید

برنامه ممکنه ضد دیباگ داشته باشه در این صورت باید اون مکانیزم‌ها رو دور بزنید

با دیباگ میتونید راحت تر بفهمید برنامه واقعا چکاری انجام میده و کجاها باید دست بزنید


تمرین ساده:

یه برنامه ساده Hello World بنویسید


با x64dbg بازش کنید و روی printf یا Breakpoint MessageBoxA بذارید


اجرا کنید و ببینید چه رشته‌ای توی رجیسترها و حافظه قرار میگیره


یه مقدار توی رجیستر یا حافظه تغییر بدید و ببینید رفتار برنامه چه تغییری میکنه


Debug and Dynamic Analysis

The goal is to run the program and observe its behavior to see what it does where it goes what registers change when it reads a file or connects to the network

Required tools x64dbg or OllyDbg for old programs A virtual machine to be safe

Open the program with x64dbg The debugger usually stops at the Entry Point first

Place a breakpoint where you think it is important or the string is seen Place a breakpoint until it reaches the execution

Go one step forward Use Step Into (usually F7) and Step Over (F8) Step Into goes into the function Step Over executes it completely and comes out

Look at the registers and memory Check the values of EAX, EBX, ECX, EDX and others You can see the memory content in the Memory or Dump section

Analyze the behavior of the program to see what registers change when the file or network is called what strings are used

Useful tips:

Always work in a VM or isolated environment

The program may have anti-debug, in which case you should bypass those mechanisms

With debugging you can more easily understand what the program is really doing and where you need to touch

Simple exercise:

Write a simple Hello World program

Open it with x64dbg and set a Breakpoint on printf or MessageBoxA

Run it and see what string is placed in the registers and memory

Change a value in a register or memory and see how the program behaves
4
DiffRays

ابزاری پژوهش‌ محور برای مقایسه پچ‌های باینریه که به منظور کمک به تحقیقات آسیب‌پذیری توسعه اکسپلویت و مهندسی معکوس طراحی شده

A research-oriented tool for comparing binary patches designed to aid in vulnerability research, exploit development, and reverse engineering.

https://github.com/pwnfuzz/diffrays

@PfkSecurity
4
3
نمونه کد Python: Hotspot Player شبیه‌ سازی شده

import sys
import ctypes
from PyQt5 import QtWidgets

# --- Anti-Debug ساده ---
if ctypes.windll.kernel32.IsDebuggerPresent():
    sys.exit("Debugger detected! Exiting...")

# --- الگوریتم سریال ساده ---
def check_serial(serial):
    # سریال صحیح (مثال: HSP-1234-5678)
    correct_serial = "HSP-1234-5678"
    return serial == correct_serial

# --- GUI ساده ---
class HotspotPlayer(QtWidgets.QWidget):
    def init(self):
        super().init()
        self.initUI()

    def initUI(self):
        self.setWindowTitle("Hotspot Player (Simulated)")
        self.setGeometry(100, 100, 300, 150)

        # ورودی سریال
        self.serial_input = QtWidgets.QLineEdit(self)
        self.serial_input.setPlaceholderText("Enter Serial")
        self.serial_input.setGeometry(50, 30, 200, 30)

        # دکمه ورود
        self.button = QtWidgets.QPushButton("Activate & Play", self)
        self.button.setGeometry(80, 80, 140, 30)
        self.button.clicked.connect(self.check_activation)

        # Label پیام
        self.label = QtWidgets.QLabel("", self)
        self.label.setGeometry(50, 120, 200, 20)

    def check_activation(self):
        serial = self.serial_input.text()
        if check_serial(serial):
            self.label.setText("Activation successful! Playing...")
        else:
            self.label.setText("Invalid Serial!")

# --- اجرای برنامه ---
if name == "main":
    app = QtWidgets.QApplication(sys.argv)
    player = HotspotPlayer()
    player.show()
    sys.exit(app.exec_())


مرحله بعدی

این برنامه رو میتونیم با PyInstaller به EXE ویندوزی تبدیل کنیم:


pyinstaller --onefile --windowed hotspot_player.py

بعد از ساخت EXE ما میتونیم

مسیر چک سریال رو با x64dbg پیدا کنیم

anti-debug
رو بررسی و دور بزنیم

شرط سریال رو تغییر میدیم تا EXE بدون سریال صحیح اجرا بشه



Python Code Example: Simulated Hotspot Player

import sys
import ctypes
from PyQt5 import QtWidgets

# --- Simple Anti-Debug ---
if ctypes.windll.kernel32.IsDebuggerPresent():
sys.exit("Debugger detected! Exiting...")

# --- Simple serial algorithm ---
def check_serial(serial):
# Correct serial (e.g. HSP-1234-5678)
correct_serial = "HSP-1234-5678"
return serial == correct_serial

# --- Simple GUI ---
class HotspotPlayer(QtWidgets.QWidget):
def init(self):
super().init()
self.initUI()

def initUI(self):
self.setWindowTitle("Hotspot Player (Simulated)")
self.setGeometry(100, 100, 300, 150)

# Serial input
self.serial_input =  QtWidgets.QLineEdit(self)
         self.serial_input.setPlaceholderText("Enter Serial")
         self.serial_input.setGeometry(50, 30, 200, 30)

         # Login button
         self.button = QtWidgets.QPushButton("Activate & Play", self)
         self.button.setGeometry(80, 80, 140, 30)
         self.button.clicked.connect(self.check_activation)

         # Label message
         self.label = QtWidgets.QLabel("", self)
         self.label.setGeometry(50, 120, 200, 20)

     def check_activation(self):
         serial = self.serial_input.text()
         if check_serial(serial):
             self.label.setText("Activation successful! Playing...")
         otherwise:
             self.label.setText("Invalid Serial!")

# --- Run the program ---
if name == "main":
     app =  QtWidgets.QApplication(sys.argv)
player = HotspotPlayer()
player.show()
sys.exit(app.exec_())


Next step

We can convert this program to a Windows EXE with PyInstaller:

pyinstaller --onefile --windowed hotspot_player.py

After building the EXE we can

Find the serial check path with x64dbg

Check and bypass anti-debug

Change the serial condition so that the EXE runs correctly without a serial
7
Forwarded from Sec Note
How to kill AV/EDR (of different kinds) with a couple of clicks

Requirements:
- Admin rights on the machine;
- Ability to deliver procmon.
And then everything is more than straightforward.

1. Enable the "EnableBootLogging" feature;
2. Create a symbolic link:
mklink C:\Windows\Procmon.pmb "<Full path to the file that needs to be overwritten>"
3. Reboot the machine.

Magic happens.

More details:
https://www.zerosalarium.com/2025/09/Break-Protective-Shell-Windows-Defender-Folder-Redirect-Technique-Symlink.html
4