This project contains Windows x86 shellcode written in MASM32.
The shellcode dynamically resolves API functions from kernel32.dll and advapi32.dll without relying on imports.
Its main purpose is to enumerate all running Windows services and dump their names into a file called services.txt.
- The code walks the PEB (Process Environment Block) to locate the base address of
kernel32.dll. - This avoids using imports and keeps the shellcode position-independent.
- A helper routine (
GetExportTableInfo) extracts key information from the PE export table:- Number of exported functions
- Export Address Table
- Name Pointer Table
- Ordinal Table
- Another helper (
FindProcVA) looks up function addresses by name using the previously gathered export structures. - The following functions are resolved from
kernel32.dll:CreateFileAWriteFileLoadLibraryA
- Then
advapi32.dllis loaded dynamically, and from it the code resolves:OpenSCManagerAEnumServicesStatusA
- A file named
services.txtis created in the current directory withCreateFileA. - A handle to the file is saved for writing service names.
- Using
OpenSCManagerA, a handle to the SCM database is obtained with the rightSC_MANAGER_ENUMERATE_SERVICE.
- A 1024-byte buffer is allocated on the stack.
EnumServicesStatusAis called repeatedly to retrieve service entries in pages.- Each service name is extracted from the returned structures.
- For each service name:
- Its length is measured and truncated if needed (respecting a remaining write limit).
- The name is written to
services.txtviaWriteFile. - A
\r\n(CRLF) is appended after each name.
- The loop continues until all services are written or the limit is exceeded.
- On completion or error, the shellcode restores registers and stack state, then returns.
- Position-independent code (no imports, no absolute addresses).
- Null-free strings are constructed on the stack.
- PE structures are parsed manually to resolve function addresses.
- Stealthy API resolution through
PEBand export parsing. - Writes a snapshot of running services into a file.