A lightweight and modular C++ library for managing Windows persistence mechanisms through a clean and explicit API.
Designed for low-level developers, cybersecurity practitioners, and system programmers who need precise control over persistence techniques without unnecessary abstraction.
- π§© Modular architecture
- π§ Simple and explicit API
- π Install / Detect / Remove workflow
- πͺ Windows Registry persistence (Run key)
- 𧬠WMI event-based persistence (Filter / Consumer / Binding)
- π¦ Static library (.a) ready for integration
include/
persistence.hpp
src/
core/
persistence.cpp
registry/
registry_install.cpp
registry_detect.cpp
registry_remove.cpp
wmi/
wmi_install.cpp
wmi_detect.cpp
wmi_remove.cpp
utils/
path.cpp
examples/
basic.cpp
build/
libpersistence.a
*.exe
Using MinGW:
mingw32-make
Clean rebuild:
mingw32-make re
g++ main.cpp -Iinclude -Lbuild -lpersistence -o app.exe
-Iincludeβ include headers-Lbuildβ locate the static library-lpersistenceβ link against libpersistence.a
enum PersistType
{
REGISTRY,
WMI
};
bool persist_install(PersistType type, const std::string& path);
β‘οΈ Registers the given executable for persistence.
typeβ persistence methodpathβ absolute path to the executable
bool persist_detect(PersistType type);
β‘οΈ Checks if persistence is currently active.
Returns:
trueβ activefalseβ not present
bool persist_remove(PersistType type);
β‘οΈ Removes previously installed persistence.
#include "persistence.hpp"
int main()
{
std::string path = get_self_path();
persist_install(REGISTRY, path);
persist_install(WMI, path);
if (persist_detect(REGISTRY))
persist_remove(REGISTRY);
if (persist_detect(WMI))
persist_remove(WMI);
return 0;
}
Uses the Windows Run key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
- β‘ No admin privileges required
- π§Ύ Stores executable path
- π Executed at user logon
Implements event-based persistence using:
__EventFilterCommandLineEventConsumer__FilterToConsumerBinding
Trigger example:
SELECT * FROM Win32_LogonSession
- π§ Event-driven execution
- π΅οΈ More stealth than registry-based methods
β οΈ May require elevated privileges depending on environment
- Always use absolute paths
- Ensure the binary exists at runtime
- WMI persistence may be restricted by system policies or security tools
- Designed for extensibility (startup folder, scheduled tasks, etc.)
- π Startup folder persistence
- β± Scheduled task persistence
- 𧬠Multi-method orchestration
- π Improved stealth execution (no PowerShell)
This project is intended for educational purposes, system programming practice, and security research.
Zibgame