DDOS Prevention Using ML
DDOS Prevention Using ML
Upon analysis of the provided information, it becomes evident that a segmentation error occurs
within our target program when it receives an input byte stream totaling 70 bytes in length. This
error manifests due to the substitution of the original Return Address with the hexadecimal value
0x44444444, which corresponds to 'DDDDDD' in ASCII representation.
Key Points:
Segmentation error occurrence attributed to the target program's reception of a 70-byte
input byte stream.
The original Return Address is replaced by the hexadecimal value 0x44444444
('DDDDDD' in ASCII).
In essence, the segmentation error signifies a critical deviation from the expected program
behavior, indicating a breach or instability within the program's execution flow. The substitution
of the Return Address with a specific hexadecimal value suggests a deliberate attempt to
manipulate the program's control flow, possibly as part of an exploitation or intrusion strategy.
Analysis of Stack
Following the initial segmentation error encounter, our next course of action involves identifying
the precise location in memory where the stream of byte values is positioned within the stack of
our target program. This step is crucial for determining the offset required to pinpoint the Return
location accurately.
Upon conducting additional investigation, it was discerned that the connection_loop function
within our target application is responsible for allocating the buffer that contains the byte stream.
This function serves as the pivotal point where the byte stream is placed onto the stack.
To facilitate the determination of the offset, it is imperative to set a breakpoint immediately
before the connection_loop function concludes its execution. This strategic breakpoint placement
allows us to introspect the memory state and ascertain the offset value necessary for subsequent
actions.
Key Points:
Objective: Identify memory location housing the byte stream within the target program's
stack.
Importance of determining offset for precise Return location identification.
Identification of connection_loop function as responsible for managing buffer allocation.
Buffer containing byte stream positioned within the stack during execution of
connection_loop function.
Strategic placement of breakpoint before function conclusion to capture memory state
and derive offset value.
By meticulously examining the program's execution flow and memory organization, we aim to
gain deeper insights into its underlying mechanisms. This investigative approach enables us to
acquire crucial information essential for devising effective strategies aimed at addressing
program vulnerabilities and enhancing overall system security.
Run the compiler with the option to "-S msg_machine_code" to view the code_in function's
source code in the object file.
Load Effective Address (Lea): This operation helps in loading an effective address.
Push: This operation decrements the Stack Pointer by 4 bytes and adds a 32-bit integer to the
stack. This integer points to the location of the string intended for printing.
Contact (Add): After the puts call, this function adjusts the Stack Pointer by adding 0x10 (16 in
decimal) to it.
Addition (Add): This operation restores the Stack Pointer, accounting for the 12 bytes from the
sub operation and 4 bytes from the push operation. In total, it deals with 16 bytes of adjustment.
No Operation (Nop), Depart, and Return (Ret): Following the 16 bytes of machine code
generated by printf(), three bytes each are reserved for these instructions.
In total, we're inserting 19 bytes of code. The addresses stored within the code also need careful
consideration for proper execution. We'll delve into that shortly.
\x83\xec\x0c\x68\xss\xss\xss\xss\xe8\xrr\xrr\xrr\xrr\x83\xc4\x10\x90\xc9\xc3
Planning the Overflow
We have ten No Operation (NOP) instructions, which essentially mean the processor does
nothing for a short period.
There are nineteen code instructions, likely related to program functions.
Eight spaces indicate certain gaps or separators within the data.
Additionally, we have sixteen more spaces for other purposes.
Four base pointers are stored, indicating memory addresses used for referencing data.
Four return addresses are also noted, possibly for controlling program flow.
Furthermore, there are four original old EBP (Extended Base Pointer) values stored, which help
with function calls.
Finally, we have four original return addresses, indicating where the program should return after
executing certain functions.
The sequence of characters like '\x90' represents hexadecimal values. For example, '\x90' is a
NOP instruction. The '\xss' and '\xrr' represent placeholders for specific memory addresses or
values.
Lastly, we see some strings like 'Hellooo AAAAAAAAAAAAAAAA', which could be part of
the program's output or input data. The other hexadecimal sequences likely represent memory
addresses or encoded data within the program.
Determine Addresses
Let's analyze the call stack of the target process.
The character buffer overflow begins at memory address 0xf7ff963c.
Sixty bytes later, at memory address 0xf7ff9678, we find the saved base address.
Continuing on the stack, at memory address 0xf7ff967c, we encounter the return address. This
address will be used to fill in the address of the code injection.
At memory address 0xf7ff968c, we have the parameter called ReturnAddressToCode:
\x43\x96\xff\xf7.
Following that, at memory address 0xf7ff9680, the value of OriginalOldEBPStored is saved.
This value helps us return to the original starting point.
The original return address is stored at memory address 0xf7ff9684, noted as 0x0804a21e ->
\x1e\xa2\x04\x08.
Summarizing our byte stream so far: CODE-- \x90AAAAAAAA Hellooo
AAAAAAAAAAAAAAA \x80\x96\xff\xf7 \x46\x96\xff\xf7 \xb8\x96\xff\xf7 \x1e\xa2\x04\x08.
Final Byte Stream
The last bytes of the data stream contain the printed instructions and the resolved addresses of
the puts:
\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x9
0\x90\x90\x90\x90\x90\x90\x90\x90\x83\xec\x0c\x68 \x61\x96\xff\xf7 \xe8
HelloooAAAAAAAAAAAAAA \x80\x96\xff\xf7 \x46\x96\xff\xf7 \xb8\x96\xff\xf7
\x1e\xa2\x04\x08.
Injection
Using the above byte stream on a Python client.
ADVAPI32.dll
GetUserNameA
KERNEL32.dll
CloseHandle GetConsoleMode GetProcAddress
CompareStringW GetConsoleOutputCP GetProcessHeap
CreateFileW GetCPInfo GetStartupInfoW
CreateRemoteThread GetCurrentProcess GetStdHandle
CreateToolhelp32Sna GetCurrentProcessId GetStringTypeW
pshot
SetFilePointerEx VirtualAllocEx
SetLastError VirtualQuery
Job.dll
DllEntryPoint
The code then verifies that it is not currently executing in the debugger. If so, it will come to an
end on its own.
If explorer.exe is identified, it uses the GetFullPathNameA API call to obtain the complete path to
job.dll. If successful, the complete path to job.dll will be saved in the DLL Path.
The OpenProcess API method is used to retrieve the process handle of explorer.exe via its PID.
Following a successful handle to explorer.exe request, a VirtualAllocEx API call is used to allocate
memory.
Using the WriteProcessMemory API function, the job.dll is written to the base address of memory
that has been allotted inside of Explorer.exe.
Use Detect It Easy to extract all of the metadata and search for any packers or cryptors that may
have been utilized.
Filename golf.exe
No. of Sections 0x0003
Import DLLs mscoree.dll
No. of Imported Functions mscoree.dll(1)
Base_Address 0x00400000
Entry_Point Address 0x00402dbe
Extract ASCII & Unicode Strings
Using BinText, pestudio, or string2, examine the strings on a Windows 10 virtual machine.
mscoree.dll
_CorExeMain