Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
f3da3fa
Harden parsing and curl escaping
ELF-Nigel Feb 28, 2026
74bf34a
Add periodic integrity check
ELF-Nigel Feb 28, 2026
aea56e3
Add redundant integrity checks
ELF-Nigel Feb 28, 2026
ca78ab7
Harden integrity watchdog
ELF-Nigel Feb 28, 2026
0a349d2
Cleanups and safety hardening
ELF-Nigel Feb 28, 2026
644ecd2
Detect hosts file overrides
ELF-Nigel Feb 28, 2026
13311d9
Harden timestamp and module checks
ELF-Nigel Feb 28, 2026
54e1ace
Add extra module check
ELF-Nigel Mar 1, 2026
01149af
Add module signature and RWX checks
ELF-Nigel Mar 1, 2026
6302206
Add hypervisor detection
ELF-Nigel Mar 1, 2026
f16bfae
Add prologue integrity checks
ELF-Nigel Mar 1, 2026
e5e9dd7
Add function region checks
ELF-Nigel Mar 1, 2026
da1ce7e
Expand prologue and region checks
ELF-Nigel Mar 1, 2026
4ca1d30
Remove integrity watchdog
ELF-Nigel Mar 1, 2026
ed5ab73
Add lightweight periodic checks
ELF-Nigel Mar 1, 2026
1e6b9e2
Add timing anomaly check
ELF-Nigel Mar 1, 2026
835e0a2
Tighten request buffer handling
ELF-Nigel Mar 1, 2026
763a70e
Add session heartbeat
ELF-Nigel Mar 1, 2026
89b9057
Add pre-request guard checks
ELF-Nigel Mar 1, 2026
d0e4c00
Add detour and text hash checks
ELF-Nigel Mar 1, 2026
b5b151f
Add text protection and PE header checks
ELF-Nigel Mar 1, 2026
e5647bf
Add VirtualProtect IAT and module allowlist checks
ELF-Nigel Mar 1, 2026
1390c8c
Use system directory APIs
ELF-Nigel Mar 1, 2026
35e60e3
Remove hardcoded system paths
ELF-Nigel Mar 1, 2026
579a101
Obfuscate success key usage
ELF-Nigel Mar 1, 2026
d02a398
Fix private req references
ELF-Nigel Mar 1, 2026
a620264
Add usage section to README
ELF-Nigel Mar 1, 2026
7ddda6d
Document built-in security features
ELF-Nigel Mar 1, 2026
117cc71
Add security troubleshooting section
ELF-Nigel Mar 1, 2026
fb74069
Fix VirtualProtect IAT check
ELF-Nigel Mar 1, 2026
8ce50a2
Relax VirtualProtect IAT check
ELF-Nigel Mar 1, 2026
8f5d50f
Disable VirtualProtect IAT check
ELF-Nigel Mar 1, 2026
257ccb9
Restore and relax VirtualProtect IAT check
ELF-Nigel Mar 1, 2026
5d6fbf5
Relax import address checks
ELF-Nigel Mar 1, 2026
60cab75
Reduce pre-login check false positives
ELF-Nigel Mar 1, 2026
fed0cdf
Run heavy checks with streak gating
ELF-Nigel Mar 1, 2026
780d393
Zeroize request data buffer
ELF-Nigel Mar 1, 2026
be35571
Wipe sensitive parameters
ELF-Nigel Mar 1, 2026
72c9c60
Add guard page and new module checks
ELF-Nigel Mar 1, 2026
9811d31
Require static libcurl linkage
ELF-Nigel Mar 1, 2026
e4372ae
Reduce debug string exposure
ELF-Nigel Mar 1, 2026
d267d1c
Harden DLL search order
ELF-Nigel Mar 1, 2026
c1dc281
Define securewipe helper
ELF-Nigel Mar 1, 2026
26de74d
Fix double curl cleanup in init
ELF-Nigel Mar 1, 2026
2dbf570
Move securewipe helpers above init
ELF-Nigel Mar 1, 2026
c6f625e
Update overhaul changelog
ELF-Nigel Mar 1, 2026
221877f
Stream POST data to reduce copies
ELF-Nigel Mar 1, 2026
a940b9e
Fix libcurl read callback usage
ELF-Nigel Mar 1, 2026
da6caad
Add content-type header for read callback
ELF-Nigel Mar 1, 2026
bbad234
Improve libcurl POST headers
ELF-Nigel Mar 1, 2026
c9fad4f
Fallback to POSTFIELDS if headers missing
ELF-Nigel Mar 1, 2026
2cf67f8
Format secure wipe helpers
ELF-Nigel Mar 1, 2026
df69c2b
Revert to POSTFIELDS request body
ELF-Nigel Mar 1, 2026
cdfb15f
Remove secure_zero redeclaration
ELF-Nigel Mar 1, 2026
bff03e6
Add inline forward decls for wipe helpers
ELF-Nigel Mar 1, 2026
ee73713
Harden header parsing for signature
ELF-Nigel Mar 1, 2026
cf5165f
Let libcurl infer POST length
ELF-Nigel Mar 1, 2026
ec9729a
Remove VM/IAT/PE/new-module checks from enforcement
ELF-Nigel Mar 1, 2026
8a7c3bd
Remove legacy VM/PE/IAT/module baseline globals
ELF-Nigel Mar 1, 2026
f04ac1b
Remove module allowlist check
ELF-Nigel Mar 1, 2026
8819297
Limit module checks to core signatures
ELF-Nigel Mar 1, 2026
f057ff3
Remove duplicate heartbeat starts
ELF-Nigel Mar 1, 2026
4abd0a9
Remove unnecessary curl headers
ELF-Nigel Mar 1, 2026
d7f3f0b
Document security checks and optional hardening
ELF-Nigel Mar 1, 2026
3d19801
Add security overview documentation
ELF-Nigel Mar 1, 2026
99dba44
Generalize IAT validation doc
ELF-Nigel Mar 1, 2026
d6eecb9
Tidy helpful references formatting
ELF-Nigel Mar 1, 2026
92c8bda
Add usage notes for security checks
ELF-Nigel Mar 1, 2026
2206463
Add GitHub Actions build workflow
ELF-Nigel Mar 2, 2026
722fc6a
Improve input handling and expiry helpers
ELF-Nigel Mar 2, 2026
03765c3
Fix json key access for xorstr
ELF-Nigel Mar 2, 2026
0860267
Add default timing/save constants
ELF-Nigel Mar 2, 2026
18e77a6
Add lockout helpers and delay utilities
ELF-Nigel Mar 2, 2026
1aeb57a
Harden api host resolution checks
ELF-Nigel Mar 2, 2026
0806774
Wipe host strings after checks
ELF-Nigel Mar 2, 2026
76849d3
Add https/proxy guards for api host
ELF-Nigel Mar 2, 2026
1adec9c
Include winhttp for proxy checks
ELF-Nigel Mar 2, 2026
cf78f0c
Trigger example CI on library updates
ELF-Nigel Mar 2, 2026
8e1d6b5
Remove example dispatch workflow
ELF-Nigel Mar 2, 2026
8934712
Add safe network hardening controls
ELF-Nigel Mar 2, 2026
2ba1871
Check .data/.rdata page protections
ELF-Nigel Mar 2, 2026
5040668
Add changelog for network and integrity hardening
ELF-Nigel Mar 2, 2026
412b999
Add threaded ban monitor helper
ELF-Nigel Mar 2, 2026
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
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ci

on:
push:
pull_request:

jobs:
build-windows:
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: setup msvc
uses: ilammy/msvc-dev-cmd@v1

- name: build x64 release
shell: powershell
run: |
if (Test-Path "library.sln") {
msbuild "library.sln" /m /p:Configuration=Release /p:Platform=x64
} elseif (Test-Path "*.sln") {
$sln = Get-ChildItem -Filter *.sln | Select-Object -First 1
msbuild $sln.FullName /m /p:Configuration=Release /p:Platform=x64
} else {
Write-Error "no solution (.sln) found to build"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

## Unreleased
- Network hardening (client-side only): HTTPS-only transport, redirects disabled, and optional host allowlist + public key pinning to reduce the risk of traffic redirection or man-in-the-middle interception.
- Integrity checks: `.text` integrity and page-protection checks, plus non-executable page checks for `.data` and `.rdata` to help detect tampering (transparent, no stealth behavior).

## Notes
- These protections are defensive and transparent; they do not alter the backend or API and are intended to reduce common redirection and tampering risks.
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,121 @@ x86 :

4- Lib Configuration -> Preprocessor definiton for CURL -> CURL_STATICLIB

## **Using The Library**
This section covers a minimal, working integration with the headers in this repo.

1. Add the library headers and sources to your project (or build the `.lib` from this repo).
2. Include `auth.hpp` in your project file.
3. Initialize the API once at startup, then call login/license/upgrade as needed.
4. Keep your build settings on C++17 and link with the same libraries as this repo.

Minimal example:
```cpp
#include "auth.hpp"

using namespace KeyAuth;

std::string name = "your_app_name";
std::string ownerid = "your_owner_id";
std::string version = "1.0";
std::string url = "https://keyauth.win/api/1.3/";
std::string path = ""; // optional

api KeyAuthApp(name, ownerid, version, url, path);

int main() {
KeyAuthApp.init();
if (!KeyAuthApp.response.success) {
return 1;
}
KeyAuthApp.license("your_license_key");
if (!KeyAuthApp.response.success) {
return 1;
}
return 0;
}
```

Notes:
1. If you are using the KeyAuth examples, keep their integrity/session checks intact.
2. Use the same `CURL_STATICLIB` define as shown above when statically linking.
3. Rebuild the library after pulling updates to keep everything in sync.

## **Security Features (Built-In)**
The library ships with security checks enabled by default. You do not need to manually call anything beyond `init()` and a normal login/license call.

What runs automatically:
1. **Integrity checks** (prologue snapshots, function region validation, `.text` hashing, page protections).
2. **Module checks** (core module signature verification + RWX section detection).
3. **Hosts-file checks** for API host tampering.
4. **Timing anomaly checks** to detect time tamper.
5. **Session heartbeat** after successful login/license/upgrade/web login.

## **Security Overview**
This SDK includes lightweight, client-side defenses that raise the cost of common bypass techniques while keeping normal integrations simple.

What it protects against:
1. **Inline patching/NOPs**: prologue snapshots and detour heuristics catch modified function entry points.
2. **Code tamper**: `.text` hashing and page‑protection checks detect modified code pages.
3. **API redirection**: hosts‑file checks flag local DNS overrides of the API host.
4. **Time spoofing**: timing anomaly checks reduce abuse of expired keys by system clock changes.
5. **Tampered system DLLs**: core module signature checks reject patched or unsigned system libraries.

Benefits:
1. **Fail‑closed behavior**: when a check fails, requests are blocked before the API call.
2. **Low integration cost**: no additional calls are required beyond `init()` and a normal login/license flow.
3. **Reduced false positives**: checks are limited to core modules and conservative tamper signals.

Design notes:
1. These are **client‑side** protections. They complement — not replace — server‑side session validation.
2. If you modify or strip checks, you reduce protection. Keep the SDK updated to inherit fixes.
3. Optional hardening ideas are listed below for advanced users who accept higher false‑positive risk.

How to keep security enabled:
1. Always call `KeyAuthApp.init()` once before any other API call.
2. Do not remove the built-in checks or tamper with the library internals.
3. Keep your application linked against the updated library after pulling changes.

How to verify it is running:
1. Use the library normally — the checks are automatic.
2. If a check fails, the library will fail closed with an error message.

## **Optional Hardening Ideas (Not Enabled)**
These are intentionally **not** enabled in the library to avoid false positives, but you can add them if your app needs them.

1. **PE header erase**: wipe PE header pages after load to make casual dumping harder. This is not a check; it simply reduces dump quality.
2. **Module allowlists**: require a strict set of loaded modules; this breaks overlays and many legitimate plugins.
3. **System module path checks**: enforce System32/SysWOW64-only paths; can fail on custom Windows installs.
4. **Hypervisor detection**: block VMs; useful for niche threat models but unfriendly to legit users.
5. **IAT validation**: detect import-table hooks for any imported API; can false-positive in some environments.

## **Security Troubleshooting**
If you see security failures, common causes include:
1. **Modified system DLLs**: non‑Microsoft versions or patched DLLs will be rejected.
2. **Time tampering**: manual clock changes or large time skew can trigger timing checks.
3. **Patched binaries**: inline hooks/NOP patches or modified `.text` will fail integrity checks.

## **Changelog (Overhaul Summary)**
This list summarizes all changes made in the overhaul:
1. **Integrity checks**: prologue snapshots, function region validation, detour detection, `.text` slice hashing, page protections.
2. **Module trust**: Microsoft signature verification for core DLLs, RWX section detection.
3. **Timing checks**: timing anomaly detection to catch clock tamper.
4. **Import checks**: import address validation.
5. **Network hardening**: hosts‑file override detection for API host.
6. **Session hardening**: session heartbeat after successful login/license/upgrade/web login.
7. **DLL search order**: hardened DLL lookup and removed current‑dir hijacking.
8. **String exposure**: request data zeroized after use; sensitive parameters wiped via `ScopeWipe`.
9. **Debug logging**: minimized request/URL logging to reduce in‑memory exposure.
10. **Parsing hardening**: safer JSON parsing and substring handling to avoid crashes.
11. **Curl safety**: fixed cleanup issues; enforced static libcurl linkage.
12. **Module path APIs**: removed hardcoded System32 paths (uses `GetSystemDirectoryW`).
13. **Example/docs**: added usage section, security feature docs, and troubleshooting guidance.

Helpful references:
- https://github.com/KeyAuth/KeyAuth-CPP-Example
- https://keyauth.cc/app/
- https://keyauth.cc/app/?page=forms

## **What is KeyAuth?**

KeyAuth is a powerful cloud-based authentication system designed to protect your software from piracy and unauthorized access. With KeyAuth, you can implement secure licensing, user management, and subscription systems in minutes. Client SDKs available for [C#](https://github.com/KeyAuth/KeyAuth-CSHARP-Example), [C++](https://github.com/KeyAuth/KeyAuth-CPP-Example), [Python](https://github.com/KeyAuth/KeyAuth-Python-Example), [Java](https://github.com/KeyAuth-Archive/KeyAuth-JAVA-api), [JavaScript](https://github.com/mazkdevf/KeyAuth-JS-Example), [VB.NET](https://github.com/KeyAuth/KeyAuth-VB-Example), [PHP](https://github.com/KeyAuth/KeyAuth-PHP-Example), [Rust](https://github.com/KeyAuth/KeyAuth-Rust-Example), [Go](https://github.com/mazkdevf/KeyAuth-Go-Example), [Lua](https://github.com/mazkdevf/KeyAuth-Lua-Examples), [Ruby](https://github.com/mazkdevf/KeyAuth-Ruby-Example), and [Perl](https://github.com/mazkdevf/KeyAuth-Perl-Example). KeyAuth has several unique features such as memory streaming, webhook function where you can send requests to API without leaking the API, discord webhook notifications, ban the user securely through the application at your discretion. Feel free to join https://t.me/keyauth if you have questions or suggestions.
Expand All @@ -46,3 +161,17 @@ of the licensor in the software. Any use of the licensor’s trademarks is subje
to applicable law.

Thank you for your compliance, we work hard on the development of KeyAuth and do not appreciate our copyright being infringed.

## Live ban monitor (threaded)

Optional background check that polls every 45 seconds. Always stop it before exiting.

```cpp
KeyAuthApp.start_ban_monitor(45, false, [] {
std::cout << "Blacklisted, exiting..." << std::endl;
exit(0);
});

// later, before exit
KeyAuthApp.stop_ban_monitor();
```
Loading