Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
indent_style = space
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

# C/C++ files
[*.{c,h,cpp,hpp}]
indent_size = 4

# CMake files
[CMakeLists.txt,*.cmake]
indent_size = 4

# Markdown files
[*.md]
indent_size = 2
trim_trailing_whitespace = false

# Batch files
[*.bat]
end_of_line = crlf

# Windows resource files
[*.rc]
indent_size = 4
end_of_line = crlf
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2024-08-20

### Added
- Initial release of Decoy Manager
- Support for creating dummy processes mimicking analysis tools
- Interactive mode with S/T/R/Q commands
- Command-line options for immediate start/terminate
- Quiet mode operation
- Safe process management with DecoyIdentifier UUID
- Version information verification before termination
- ANSI color support in Windows console

### Improved
- Modernized CMake build system with target-based approach
- Added configuration header (config.h) for centralized constants
- Enhanced input validation and error handling
- Added bounds checking and buffer overflow protection
- Implemented help system with -h/--help support
- Improved code documentation and function safety
- Added named constants to replace magic numbers
- Better string operation safety with snprintf return checking

### Security
- Added path validation to prevent directory traversal
- Enhanced process verification before termination
- Improved buffer safety in string operations
- Added input parameter validation
65 changes: 45 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
cmake_minimum_required(VERSION 3.30)
project(decoy C)
project(decoy
VERSION 0.1.0
DESCRIPTION "A lightweight Windows utility that creates dummy processes mimicking analysis tools"
LANGUAGES C
)

# Set C standard and require it
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)

# Modern CMake: use target-based approach instead of global include_directories
# include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")

# Specify where to find headers and resources
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
# Create a common library for shared code
add_library(decoy-common STATIC
src/utils.c
src/banner.c
src/args.c
src/process_control.c
)

# Set include directories for the common library
target_include_directories(decoy-common
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src"
)

# Add executables
add_executable(dummy
Expand All @@ -14,25 +33,31 @@ add_executable(dummy

add_executable(decoy-manager
src/manager.c
src/process_control.c
src/utils.c
src/banner.c
src/args.c
resources/manager.rc
)

if(MSVC)
# Optimize for size and enable link-time code generation:
set(CMAKE_C_FLAGS_RELEASE "/O1 /GL /Gy /DNDEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /OPT:REF /OPT:ICF")
# Link the common library to decoy-manager
target_link_libraries(decoy-manager PRIVATE decoy-common)

# Windows-specific configuration
if(WIN32)
if(MSVC)
# Optimize for size and enable link-time code generation
target_compile_options(decoy-manager PRIVATE
$<$<CONFIG:Release>:/O1 /GL /Gy>
)
target_link_options(decoy-manager PRIVATE
$<$<CONFIG:Release>:/LTCG /OPT:REF /OPT:ICF>
)
endif()

# Link against required Windows libraries
target_link_libraries(decoy-manager PRIVATE Version Psapi)

# Link against Version.lib and Psapi.lib
target_link_libraries(decoy-manager PRIVATE Version.lib Psapi.lib)
# Set output directory for all configurations
set_target_properties(dummy decoy-manager PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Release"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Debug"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Release"
)
endif()

# Ensure the executables end up in the same directory
set_target_properties(dummy decoy-manager PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Release")

# Link libraries (if needed, none needed here)
# target_link_libraries(decoy-manager ...)
80 changes: 80 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Contributing to Decoy

Thank you for your interest in contributing to Decoy! This document provides guidelines for contributing to the project.

## Getting Started

1. Fork the repository
2. Clone your fork: `git clone https://github.com/your-username/decoy.git`
3. Create a feature branch: `git checkout -b feature/your-feature-name`

## Development Environment

### Prerequisites
- Windows operating system (required for building and testing)
- CMake 3.30 or higher
- Microsoft Visual Studio 2019+ or compatible C compiler
- Git for version control

### Building
```bash
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
```

Or use the provided `build.bat` script.

## Code Style

- Follow existing code style and formatting
- Use consistent naming conventions
- Include proper documentation for new functions
- Add appropriate error handling and input validation
- Use the logging macros (OKAY, INFO, WARN) for status messages
- Use qprintf() for UI output that respects quiet mode

## Adding New Features

### Adding New Process Names
1. Edit `src/process_control.c` and add entries to the `processNames[]` array
2. Ensure the process count doesn't exceed `MAX_PROCESSES` (defined in `config.h`)
3. Test that the new processes can be started and terminated correctly

### Configuration Changes
- Update `src/config.h` for any new constants or configuration values
- Avoid hardcoding values directly in source files

## Testing

- Test on Windows environments with different privilege levels
- Verify that dummy processes start and terminate correctly
- Test command-line arguments and interactive mode
- Ensure quiet mode works as expected
- Test error conditions and edge cases

## Pull Request Guidelines

1. Provide a clear description of the changes
2. Reference any related issues
3. Include testing instructions
4. Update documentation if needed
5. Update CHANGELOG.md with your changes
6. Ensure your code follows the existing style

## Security Considerations

- Be cautious with file operations and path handling
- Validate all user inputs
- Follow the principle of least privilege
- Test for buffer overflows and memory leaks
- Ensure process verification works correctly

## Code Review

All submissions require review. Please be patient and responsive to feedback.

## Questions?

Feel free to open an issue for questions or discussions about contributing.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,15 @@ Run `decoy-manager` without arguments to access the interactive menu:
### Command-Line Options

```bash
decoy-manager [-S|-T|-Q]
decoy-manager [-S|-T|-Q|-h]
```

| Option | Description |
|--------|-------------|
| `-S, -s` | Start all processes and exit |
| `-T, -t` | Terminate all processes and exit |
| `-Q, -q` | Quiet mode: start processes without output |
| `-h, --help` | Show help information |

### Simulated Processes

Expand Down Expand Up @@ -103,7 +104,9 @@ Some applications, particularly games with anti-cheat systems, may detect and re

## Contributing

Contributions are welcome! Please feel free to submit pull requests or create issues for bugs and feature requests.
Contributions are welcome! Please read our [Contributing Guidelines](CONTRIBUTING.md) before submitting pull requests.

For information about changes and releases, see the [Changelog](CHANGELOG.md).

## License

Expand Down
40 changes: 39 additions & 1 deletion src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "args.h"
#include "utils.h"
#include "logger.h"
#include "config.h"
#include "logger.h"

/**
* @file args.c
Expand All @@ -23,12 +25,20 @@
*/
void parseArguments(int argc, char *argv[], BOOL *startImmediate, BOOL *terminateImmediate)
{
// Validate input parameters
if (startImmediate == NULL || terminateImmediate == NULL)
{
WARN("Invalid parameters passed to parseArguments");
return;
}

if (argc > 1)
{
for (int i = 1; i < argc; i++)
{
if (argv[i] != NULL)
{
// Skip empty arguments
if (strlen(argv[i]) == 0)
continue;

Expand All @@ -45,9 +55,15 @@ void parseArguments(int argc, char *argv[], BOOL *startImmediate, BOOL *terminat
setQuietMode(TRUE);
*startImmediate = TRUE;
}
else if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0) ||
(strcmp(argv[i], "-?") == 0) || (strcmp(argv[i], "/?") == 0))
{
printUsage();
exit(0);
}
else
{
WARN("Unrecognized argument '%s'", argv[i]);
WARN("Unrecognized argument '%s'. Use -h for help.", argv[i]);
}
}
else
Expand All @@ -58,6 +74,28 @@ void parseArguments(int argc, char *argv[], BOOL *startImmediate, BOOL *terminat
}
}

/**
* @brief Prints usage information and available command-line options.
*/
void printUsage(void)
{
printf("Decoy Manager v%s\n", DECOY_VERSION_STRING);
printf("A lightweight Windows utility that creates dummy processes mimicking analysis tools.\n\n");
printf("Usage: decoy-manager [OPTIONS]\n\n");
printf("Options:\n");
printf(" -S, -s Start all decoy processes and exit\n");
printf(" -T, -t Terminate all decoy processes and exit\n");
printf(" -Q, -q Quiet mode: start processes without output\n");
printf(" -h, --help, -?, /? Show this help message\n\n");
printf("When run without arguments, enters interactive mode.\n\n");
printf("Interactive Commands:\n");
printf(" [S] Start all processes\n");
printf(" [T] Terminate all processes\n");
printf(" [R] Restart all processes\n");
printf(" [Q] Quit\n\n");
printf("For more information, visit: https://github.com/EvickaStudio/decoy\n");
}

/**
* @brief Enables ANSI color support in Windows console if possible.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
*/
void parseArguments(int argc, char *argv[], BOOL *startImmediate, BOOL *terminateImmediate);

/**
* @brief Prints usage information and available command-line options.
*/
void printUsage(void);

/**
* @brief Enables ANSI escape sequences in the Windows console if possible.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/banner.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include "banner.h"
#include "utils.h"
#include "config.h"

/**
* @file banner.c
Expand All @@ -20,7 +21,7 @@ void printBanner(void)
qprintf("/ _ / -_) __/ _ \\/ // /\n");
qprintf("\\_,_/\\__/\\__/\\___/\\_, / ");
qprintf("\x1b[0m");
qprintf("v0.1.0\n");
qprintf("v%s\n", DECOY_VERSION_STRING);
qprintf("\x1b[35m");
qprintf(" /___/ \n");
qprintf("\x1b[0m\n");
Expand Down
Loading