Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bf8407640 | |||
| a8b5e0148f | |||
| 50413eb420 | |||
| ea49c39e53 | |||
| f599a9a648 | |||
| b8b24a5c30 | |||
| 4a71bc6f1b | |||
| cfd52b8e05 | |||
| b2ca193aa4 | |||
| 491daebf06 | |||
| 9799c2babe | |||
| 27b8a0e497 | |||
| 3f9409b8c6 | |||
| 1fdc7450cd | |||
| 75338b10ff | |||
| 5e8f059c49 | |||
| 11a9447e05 | |||
| 911c4d199a | |||
| 167e5ee696 | |||
| 7e6797b6c7 | |||
| c8b3104b4b | |||
| 785d4a3ff2 | |||
| c09ce8b02a | |||
| 0af818fc0f | |||
| 6e62bcb1dc | |||
| 1a05ef2742 | |||
| 642c1c80fa | |||
| 32525c1566 | |||
| 75171b4557 | |||
| fe71decd38 | |||
| acfdf7b3ef | |||
| e8d387e520 | |||
| 03a1841b8e | |||
| e61c20bb5a | |||
| 105f8b6df0 | |||
| 0300ced79c | |||
| 83ac8615ba | |||
| 697bff9752 | |||
| 0fa2e0540b | |||
| a1a123054f | |||
| 76d581c419 | |||
| 4f91ab9cff | |||
| e6111f8dbd | |||
| 7ec6e385a0 | |||
| 7427357bc5 | |||
| 6b63d54eb8 | |||
| a3df782245 | |||
| d4650aac84 | |||
| 73b1c95257 | |||
| 93fe999249 | |||
| 393a591485 | |||
| 2b8cbafa19 | |||
| 623542046a | |||
| 90a6ab1ba8 | |||
| 2c795a335f | |||
| 015a13eb86 | |||
| b0524c0589 | |||
| abd3c18040 | |||
| afb4a9c157 | |||
| 9c83499f0f | |||
| cd6d8df243 | |||
| 64ded73f89 | |||
| 022c67cab9 | |||
| cc07cd139c | |||
| 490feb1be7 | |||
| b5a8477ba2 | |||
| e933515e45 | |||
| ff7284dfbf | |||
| 7a710f2e17 | |||
| b36d47a8fb | |||
| 6e2c709426 | |||
| 8929c0e39b |
+22
-20
@@ -22,36 +22,31 @@ jobs:
|
|||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git fetch --tags || true
|
git fetch --tags --force
|
||||||
|
|
||||||
# Determine last tag and log range
|
if LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null); then
|
||||||
if git describe --tags --abbrev=0 >/dev/null 2>&1; then
|
|
||||||
LAST_TAG=$(git describe --tags --abbrev=0)
|
|
||||||
RANGE="${LAST_TAG}..HEAD"
|
RANGE="${LAST_TAG}..HEAD"
|
||||||
else
|
else
|
||||||
LAST_TAG="v0.1.9"
|
LAST_TAG="v0.1.9"
|
||||||
RANGE="HEAD"
|
RANGE="HEAD"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculate next version
|
|
||||||
IFS='.' read -r major minor patch <<< "${LAST_TAG#v}"
|
IFS='.' read -r major minor patch <<< "${LAST_TAG#v}"
|
||||||
NEW_VERSION="$major.$minor.$((patch + 1))"
|
NEW_VERSION="$major.$minor.$((patch + 1))"
|
||||||
NEW_TAG="v$NEW_VERSION"
|
|
||||||
|
|
||||||
# Log commits
|
|
||||||
CHANGELOG=$(git log $RANGE --oneline | sed 's/^/* /')
|
CHANGELOG=$(git log $RANGE --oneline | sed 's/^/* /')
|
||||||
[ -z "$CHANGELOG" ] && CHANGELOG="Maintenance build."
|
if [ -z "$CHANGELOG" ]; then
|
||||||
|
CHANGELOG="Re-run of version $NEW_VERSION or maintenance build."
|
||||||
|
fi
|
||||||
|
|
||||||
# Tag and push back to Gitea
|
|
||||||
git tag $NEW_TAG
|
|
||||||
git push origin $NEW_TAG
|
|
||||||
|
|
||||||
# Set outputs for next steps
|
|
||||||
echo "version-string=$NEW_VERSION" >> $GITHUB_OUTPUT
|
echo "version-string=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
echo "new-tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
echo "## What's Changed" >> $GITHUB_OUTPUT
|
{
|
||||||
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
echo "changelog<<EOF"
|
||||||
echo "EOF" >> $GITHUB_OUTPUT
|
echo "## What's Changed"
|
||||||
|
echo "$CHANGELOG"
|
||||||
|
echo "EOF"
|
||||||
|
} >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Setup Tools Cache
|
- name: Setup Tools Cache
|
||||||
id: tools-cache
|
id: tools-cache
|
||||||
@@ -124,11 +119,18 @@ jobs:
|
|||||||
name: unlocker-build
|
name: unlocker-build
|
||||||
path: unlocker.zip
|
path: unlocker.zip
|
||||||
|
|
||||||
|
- name: Finalize Version and Push Tag
|
||||||
|
if: ${{ github.event_name == 'push' && success() }}
|
||||||
|
run: |
|
||||||
|
git tag ${{ steps.calculate-version.outputs.new-tag }}
|
||||||
|
git push origin ${{ steps.calculate-version.outputs.new-tag }}
|
||||||
|
|
||||||
- name: Create Gitea Release
|
- name: Create Gitea Release
|
||||||
if: ${{ github.event_name == 'push' }}
|
if: ${{ github.event_name == 'push' && success() }}
|
||||||
uses: akkuman/gitea-release-action@v1
|
uses: akkuman/gitea-release-action@v1
|
||||||
with:
|
with:
|
||||||
files: unlocker.zip
|
files: unlocker.zip
|
||||||
tag_name: v${{ steps.calculate-version.outputs.version-string }}
|
tag_name: ${{ steps.calculate-version.outputs.new-tag }}
|
||||||
name: Release v${{ steps.calculate-version.outputs.version-string }}
|
name: Release ${{ steps.calculate-version.outputs.new-tag }}
|
||||||
body: ${{ steps.calculate-version.outputs.changelog }}
|
body: ${{ steps.calculate-version.outputs.changelog }}
|
||||||
|
|
||||||
@@ -8,3 +8,4 @@ for /r "src" %%f in (*.cpp *.h *.cs) do (
|
|||||||
|
|
||||||
echo done
|
echo done
|
||||||
pause
|
pause
|
||||||
|
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
+105
-109
@@ -1,111 +1,107 @@
|
|||||||
{
|
{
|
||||||
"Camper": {
|
"Campers": [
|
||||||
"Items": [
|
"Father_Key_Card",
|
||||||
"Father_Key_Card",
|
"FireflyLantern",
|
||||||
"FireflyLantern",
|
"Item_Camper_AlexsToolbox",
|
||||||
"Item_Camper_AlexsToolbox",
|
"Item_Camper_AnniversaryToolbox",
|
||||||
"Item_Camper_AnniversaryToolbox",
|
"Item_Camper_BeigeMap",
|
||||||
"Item_Camper_BeigeMap",
|
"Item_Camper_BrokenKey",
|
||||||
"Item_Camper_BrokenKey",
|
"Item_Camper_CommodiousToolbox",
|
||||||
"Item_Camper_CommodiousToolbox",
|
"Item_Camper_ContaminationSerum",
|
||||||
"Item_Camper_ContaminationSerum",
|
"Item_Camper_DullKey",
|
||||||
"Item_Camper_DullKey",
|
"Item_Camper_EngineerToolbox",
|
||||||
"Item_Camper_EngineerToolbox",
|
"Item_Camper_FadedMap",
|
||||||
"Item_Camper_FadedMap",
|
"Item_Camper_Firecracker_Anniversary2019",
|
||||||
"Item_Camper_Firecracker_Anniversary2019",
|
"Item_Camper_Firecracker_Chinese",
|
||||||
"Item_Camper_Firecracker_Chinese",
|
"Item_Camper_Firecracker_Flashbang",
|
||||||
"Item_Camper_Firecracker_Flashbang",
|
"Item_Camper_Firecracker_WinterEvent",
|
||||||
"Item_Camper_Firecracker_WinterEvent",
|
"Item_Camper_Flashlight",
|
||||||
"Item_Camper_Flashlight",
|
"Item_Camper_Flashlight_Anniversary2020",
|
||||||
"Item_Camper_Flashlight_Anniversary2020",
|
"Item_Camper_Flashlight_Anniversary2022",
|
||||||
"Item_Camper_Flashlight_Anniversary2022",
|
"Item_Camper_Flashlight_Random",
|
||||||
"Item_Camper_Flashlight_Random",
|
"Item_Camper_Flashlight02",
|
||||||
"Item_Camper_Flashlight02",
|
"Item_Camper_Flashlight03",
|
||||||
"Item_Camper_Flashlight03",
|
"Item_Camper_Flashlight04",
|
||||||
"Item_Camper_Flashlight04",
|
"Item_Camper_JerryCan_Spring2025",
|
||||||
"Item_Camper_JerryCan_Spring2025",
|
"Item_Camper_K29InfectionRemover",
|
||||||
"Item_Camper_K29InfectionRemover",
|
"Item_Camper_K32Emp",
|
||||||
"Item_Camper_K32Emp",
|
"Item_Camper_K33Turret",
|
||||||
"Item_Camper_K33Turret",
|
"Item_Camper_K36MagicItem_Boots",
|
||||||
"Item_Camper_K36MagicItem_Boots",
|
"Item_Camper_K36MagicItem_Bracers",
|
||||||
"Item_Camper_K36MagicItem_Bracers",
|
"Item_Camper_K36MagicItem_VecnaEye",
|
||||||
"Item_Camper_K36MagicItem_VecnaEye",
|
"Item_Camper_K36MagicItem_VecnaHand",
|
||||||
"Item_Camper_K36MagicItem_VecnaHand",
|
"Item_Camper_Key",
|
||||||
"Item_Camper_Key",
|
"Item_Camper_Key_Random",
|
||||||
"Item_Camper_Key_Random",
|
"Item_Camper_LunarToolbox",
|
||||||
"Item_Camper_LunarToolbox",
|
"Item_Camper_Map_Random",
|
||||||
"Item_Camper_Map_Random",
|
"Item_Camper_Map_Spring2024",
|
||||||
"Item_Camper_Map_Spring2024",
|
"Item_Camper_MechanicsToolbox",
|
||||||
"Item_Camper_MechanicsToolbox",
|
"Item_Camper_MedKit",
|
||||||
"Item_Camper_MedKit",
|
"Item_Camper_Medkit_Anniversary2020",
|
||||||
"Item_Camper_Medkit_Anniversary2020",
|
"Item_Camper_Medkit_Anniversary2022",
|
||||||
"Item_Camper_Medkit_Anniversary2022",
|
"Item_Camper_MedKit_Random",
|
||||||
"Item_Camper_MedKit_Random",
|
"Item_Camper_MedKit02",
|
||||||
"Item_Camper_MedKit02",
|
"Item_Camper_MedKit03",
|
||||||
"Item_Camper_MedKit03",
|
"Item_Camper_MedKit04",
|
||||||
"Item_Camper_MedKit04",
|
"Item_Camper_Medkit05",
|
||||||
"Item_Camper_Medkit05",
|
"Item_Camper_OnryoTape",
|
||||||
"Item_Camper_OnryoTape",
|
"Item_Camper_RainbowMap",
|
||||||
"Item_Camper_RainbowMap",
|
"Item_Camper_Toolbox",
|
||||||
"Item_Camper_Toolbox",
|
"Item_Camper_Toolbox_Anniversary2022",
|
||||||
"Item_Camper_Toolbox_Anniversary2022",
|
"Item_Camper_Toolbox_Random",
|
||||||
"Item_Camper_Toolbox_Random",
|
"Item_Camper_VoidBomb_Halloween2024",
|
||||||
"Item_Camper_VoidBomb_Halloween2024",
|
"Item_Camper_WornoutToolbox",
|
||||||
"Item_Camper_WornoutToolbox",
|
"Item_FragileObject",
|
||||||
"Item_FragileObject",
|
"Item_LamentConfiguration",
|
||||||
"Item_LamentConfiguration",
|
"Item_Survivor_CalamariContaminationAntidote",
|
||||||
"Item_Survivor_CalamariContaminationAntidote",
|
"Item_Survivor_K41Mushroom",
|
||||||
"Item_Survivor_K41Mushroom",
|
"Item_Survivor_MakeshiftFogVial",
|
||||||
"Item_Survivor_MakeshiftFogVial",
|
"Item_Survivor_PrototypeFogVial",
|
||||||
"Item_Survivor_PrototypeFogVial",
|
"Item_Survivor_VigosFogVial"
|
||||||
"Item_Survivor_VigosFogVial"
|
],
|
||||||
]
|
"Slashers": [
|
||||||
},
|
"Item_Blighted_Serum",
|
||||||
"Slasher": {
|
"Item_Slasher_Beartrap",
|
||||||
"Powers": [
|
"Item_Slasher_Blinker",
|
||||||
"Item_Blighted_Serum",
|
"Item_Slasher_Chainsaw",
|
||||||
"Item_Slasher_Beartrap",
|
"Item_Slasher_CloakBell",
|
||||||
"Item_Slasher_Blinker",
|
"Item_Slasher_DreamInducer",
|
||||||
"Item_Slasher_Chainsaw",
|
"Item_Slasher_Frenzy",
|
||||||
"Item_Slasher_CloakBell",
|
"Item_Slasher_GasBomb",
|
||||||
"Item_Slasher_DreamInducer",
|
"Item_Slasher_GhostPower",
|
||||||
"Item_Slasher_Frenzy",
|
"Item_Slasher_HarpoonRifle",
|
||||||
"Item_Slasher_GasBomb",
|
"Item_Slasher_Hatchet",
|
||||||
"Item_Slasher_GhostPower",
|
"Item_Slasher_K21Power",
|
||||||
"Item_Slasher_HarpoonRifle",
|
"Item_Slasher_K22Power",
|
||||||
"Item_Slasher_Hatchet",
|
"Item_Slasher_K24Power",
|
||||||
"Item_Slasher_K21Power",
|
"Item_Slasher_K25Power",
|
||||||
"Item_Slasher_K22Power",
|
"Item_Slasher_K26Power",
|
||||||
"Item_Slasher_K24Power",
|
"Item_Slasher_K27Power",
|
||||||
"Item_Slasher_K25Power",
|
"Item_Slasher_K28Power",
|
||||||
"Item_Slasher_K26Power",
|
"Item_Slasher_K29Power",
|
||||||
"Item_Slasher_K27Power",
|
"Item_Slasher_K30Power",
|
||||||
"Item_Slasher_K28Power",
|
"Item_Slasher_K31Power",
|
||||||
"Item_Slasher_K29Power",
|
"Item_Slasher_K32Power",
|
||||||
"Item_Slasher_K30Power",
|
"Item_Slasher_K33Power",
|
||||||
"Item_Slasher_K31Power",
|
"Item_Slasher_K34Power",
|
||||||
"Item_Slasher_K32Power",
|
"Item_Slasher_K35Power",
|
||||||
"Item_Slasher_K33Power",
|
"Item_Slasher_K36Power",
|
||||||
"Item_Slasher_K34Power",
|
"Item_Slasher_K37Power",
|
||||||
"Item_Slasher_K35Power",
|
"Item_Slasher_K38Power",
|
||||||
"Item_Slasher_K36Power",
|
"Item_Slasher_K39Power",
|
||||||
"Item_Slasher_K37Power",
|
"Item_Slasher_K40Power",
|
||||||
"Item_Slasher_K38Power",
|
"Item_Slasher_K41Power",
|
||||||
"Item_Slasher_K39Power",
|
"Item_Slasher_K42Power",
|
||||||
"Item_Slasher_K40Power",
|
"Item_Slasher_Kanobo",
|
||||||
"Item_Slasher_K41Power",
|
"Item_Slasher_Killer07Item",
|
||||||
"Item_Slasher_K42Power",
|
"Item_Slasher_LFChainsaw",
|
||||||
"Item_Slasher_Kanobo",
|
"Item_Slasher_PhantomTrap",
|
||||||
"Item_Slasher_Killer07Item",
|
"Item_Slasher_PhaseWalker",
|
||||||
"Item_Slasher_LFChainsaw",
|
"Item_Slasher_PlaguePower",
|
||||||
"Item_Slasher_PhantomTrap",
|
"Item_Slasher_QatarKillerPower",
|
||||||
"Item_Slasher_PhaseWalker",
|
"Item_Slasher_ReverseBearTrap",
|
||||||
"Item_Slasher_PlaguePower",
|
"Item_Slasher_Stalker",
|
||||||
"Item_Slasher_QatarKillerPower",
|
"Item_Slasher_ThrowingKnives",
|
||||||
"Item_Slasher_ReverseBearTrap",
|
"Item_Slasher_TormentMode"
|
||||||
"Item_Slasher_Stalker",
|
]
|
||||||
"Item_Slasher_ThrowingKnives",
|
|
||||||
"Item_Slasher_TormentMode"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
+8
-8
@@ -13,9 +13,9 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
class DumpByDaylight
|
class DumpByDaylight
|
||||||
{
|
{
|
||||||
private const string _pakDir = "E:\\Program Files (x86)\\Steam\\steamapps\\common\\Dead by Daylight\\DeadByDaylight\\Content\\Paks";
|
private const string _pakDir = "D:\\XboxGames\\Dead By Daylight\\Content\\DeadByDaylight\\Content\\Paks";
|
||||||
private const string _aesKey = "0x22B1639B548124925CF7B9CBAA09F9AC295FCF0324586D6B37EE1D42670B39B3";
|
private const string _aesKey = "0x22B1639B548124925CF7B9CBAA09F9AC295FCF0324586D6B37EE1D42670B39B3";
|
||||||
private const string _mappingURL = "https://github.com/Masusder/FModel-DbdMappings/raw/refs/heads/main/Mappings/9.5.0/5.4.4-3172922+++DeadByDaylight+Quiche_REL-DeadByDaylight.usmap";
|
private const string _mappingURL = "https://git.neru.rip/neru/UnlockedByDaylight/raw/branch/main/res/mappings/latest-xbox.usmap";
|
||||||
|
|
||||||
public static async Task<string?> DownloadMappingFileAsync(string url, string savePath)
|
public static async Task<string?> DownloadMappingFileAsync(string url, string savePath)
|
||||||
{
|
{
|
||||||
@@ -67,7 +67,7 @@ class DumpByDaylight
|
|||||||
|
|
||||||
Console.WriteLine("\nProvider Initialized. Extracting Databases...");
|
Console.WriteLine("\nProvider Initialized. Extracting Databases...");
|
||||||
|
|
||||||
var dataPak = provider.GetArchive("pakchunk4-Windows.utoc");
|
var dataPak = provider.GetArchive("pakchunk4-WinGDK.utoc");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* itemdb dump
|
* itemdb dump
|
||||||
@@ -104,8 +104,8 @@ class DumpByDaylight
|
|||||||
|
|
||||||
var itemsSerialized = new
|
var itemsSerialized = new
|
||||||
{
|
{
|
||||||
Camper = new { Items = camperItems.OrderBy(x => x).ToList() },
|
Campers = camperItems.OrderBy(x => x).ToList(),
|
||||||
Slasher = new { Powers = slasherPowers.OrderBy(x => x).ToList() }
|
Slashers = slasherPowers.OrderBy(x => x).ToList()
|
||||||
};
|
};
|
||||||
File.WriteAllText("items.json", JsonConvert.SerializeObject(itemsSerialized, Formatting.Indented));
|
File.WriteAllText("items.json", JsonConvert.SerializeObject(itemsSerialized, Formatting.Indented));
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ class DumpByDaylight
|
|||||||
*/
|
*/
|
||||||
searchPaths = dataPak.Files.Keys.Where(x => x.Contains($"/ItemAddonDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
searchPaths = dataPak.Files.Keys.Where(x => x.Contains($"/ItemAddonDB.uasset", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||||
var camperAddons = new List<string>();
|
var camperAddons = new List<string>();
|
||||||
var slaherAddons = new List<string>();
|
var slasherAddons = new List<string>();
|
||||||
|
|
||||||
foreach (var path in searchPaths)
|
foreach (var path in searchPaths)
|
||||||
{
|
{
|
||||||
@@ -135,7 +135,7 @@ class DumpByDaylight
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isSlasherAddon)
|
if (isSlasherAddon)
|
||||||
slaherAddons.Add(row.Key.Text);
|
slasherAddons.Add(row.Key.Text);
|
||||||
else
|
else
|
||||||
camperAddons.Add(row.Key.Text);
|
camperAddons.Add(row.Key.Text);
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ class DumpByDaylight
|
|||||||
|
|
||||||
var addonsSerialized = new
|
var addonsSerialized = new
|
||||||
{
|
{
|
||||||
Slashers = slaherAddons.OrderBy(x => x).ToList(),
|
Slashers = slasherAddons.OrderBy(x => x).ToList(),
|
||||||
Campers = camperAddons.OrderBy(x => x).ToList()
|
Campers = camperAddons.OrderBy(x => x).ToList()
|
||||||
};
|
};
|
||||||
File.WriteAllText("addons.json", JsonConvert.SerializeObject(addonsSerialized, Formatting.Indented));
|
File.WriteAllText("addons.json", JsonConvert.SerializeObject(addonsSerialized, Formatting.Indented));
|
||||||
|
|||||||
@@ -1,222 +0,0 @@
|
|||||||
#include "cert_manager.h"
|
|
||||||
#include <nerutils/log.h>
|
|
||||||
#include <openssl/bio.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#include <openssl/pem.h>
|
|
||||||
#include <openssl/x509v3.h>
|
|
||||||
#include <openssl/bn.h>
|
|
||||||
#include <openssl/rsa.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
#include <processthreadsapi.h>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
std::string randomizeString(size_t length)
|
|
||||||
{
|
|
||||||
const char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
||||||
std::string result;
|
|
||||||
result.resize(length);
|
|
||||||
for (size_t i = 0; i < length; ++i)
|
|
||||||
result[i] = charset[rand() % (sizeof(charset) - 1)];
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
CertManager::CertManager() : _sessionPkey(nullptr) {}
|
|
||||||
|
|
||||||
CertManager::~CertManager()
|
|
||||||
{
|
|
||||||
if (_caPkey) EVP_PKEY_free(_caPkey);
|
|
||||||
if (_caCert) X509_free(_caCert);
|
|
||||||
if (_sessionPkey) EVP_PKEY_free(_sessionPkey);
|
|
||||||
|
|
||||||
for (auto& pair : _hostContexts)
|
|
||||||
SSL_CTX_free(pair.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CertManager::Init()
|
|
||||||
{
|
|
||||||
EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
|
|
||||||
if (pctx)
|
|
||||||
{
|
|
||||||
EVP_PKEY_keygen_init(pctx);
|
|
||||||
EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048);
|
|
||||||
EVP_PKEY_keygen(pctx, &_sessionPkey);
|
|
||||||
EVP_PKEY_CTX_free(pctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LoadCA())
|
|
||||||
{
|
|
||||||
Log::verbose("Loaded existing CA certificate.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::verbose("No CA found. Generating new CA certificate.");
|
|
||||||
return GenerateCA();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CertManager::LoadCA()
|
|
||||||
{
|
|
||||||
BIO* keyBio = BIO_new_file("ca_key.pem", "r");
|
|
||||||
if (!keyBio) return false;
|
|
||||||
|
|
||||||
_caPkey = PEM_read_bio_PrivateKey(keyBio, nullptr, nullptr, nullptr);
|
|
||||||
BIO_free(keyBio);
|
|
||||||
|
|
||||||
if (!_caPkey) return false;
|
|
||||||
|
|
||||||
BIO* certBio = BIO_new_file("ca_cert.pem", "r");
|
|
||||||
if (!certBio) return false;
|
|
||||||
|
|
||||||
_caCert = PEM_read_bio_X509(certBio, nullptr, nullptr, nullptr);
|
|
||||||
BIO_free(certBio);
|
|
||||||
|
|
||||||
if (!_caCert) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CertManager::GenerateCA()
|
|
||||||
{
|
|
||||||
srand(static_cast<unsigned int>(time(nullptr)));
|
|
||||||
|
|
||||||
EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
|
|
||||||
if (!pctx) return false;
|
|
||||||
EVP_PKEY_keygen_init(pctx);
|
|
||||||
EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048);
|
|
||||||
EVP_PKEY_keygen(pctx, &_caPkey);
|
|
||||||
EVP_PKEY_CTX_free(pctx);
|
|
||||||
|
|
||||||
_caCert = X509_new();
|
|
||||||
X509_set_version(_caCert, 2);
|
|
||||||
ASN1_INTEGER_set(X509_get_serialNumber(_caCert), 1);
|
|
||||||
X509_gmtime_adj(X509_get_notBefore(_caCert), 0);
|
|
||||||
X509_gmtime_adj(X509_get_notAfter(_caCert), 31536000L); // 1 year
|
|
||||||
|
|
||||||
std::string org = randomizeString(16);
|
|
||||||
std::string cn = randomizeString(16);
|
|
||||||
|
|
||||||
X509_NAME* name = X509_get_subject_name(_caCert);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char*)"US", -1, -1, 0);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, (unsigned char*)org.c_str(), -1, -1, 0);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char*)cn.c_str(), -1, -1, 0);
|
|
||||||
X509_set_issuer_name(_caCert, name);
|
|
||||||
X509_set_pubkey(_caCert, _caPkey);
|
|
||||||
|
|
||||||
X509V3_CTX ctxV3;
|
|
||||||
X509V3_set_ctx_nodb(&ctxV3);
|
|
||||||
X509V3_set_ctx(&ctxV3, _caCert, _caCert, nullptr, nullptr, 0);
|
|
||||||
X509_EXTENSION* extCA = X509V3_EXT_conf_nid(nullptr, &ctxV3, NID_basic_constraints, "critical,CA:TRUE");
|
|
||||||
if (extCA)
|
|
||||||
{
|
|
||||||
X509_add_ext(_caCert, extCA, -1);
|
|
||||||
X509_EXTENSION_free(extCA);
|
|
||||||
}
|
|
||||||
|
|
||||||
X509_sign(_caCert, _caPkey, EVP_sha256());
|
|
||||||
|
|
||||||
BIO* keyBioOut = BIO_new_file("ca_key.pem", "w");
|
|
||||||
if (keyBioOut)
|
|
||||||
{
|
|
||||||
PEM_write_bio_PrivateKey(keyBioOut, _caPkey, nullptr, nullptr, 0, nullptr, nullptr);
|
|
||||||
BIO_free(keyBioOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
BIO* certBioOut = BIO_new_file("ca_cert.pem", "w");
|
|
||||||
if (certBioOut)
|
|
||||||
{
|
|
||||||
PEM_write_bio_X509(certBioOut, _caCert);
|
|
||||||
BIO_free(certBioOut);
|
|
||||||
}
|
|
||||||
|
|
||||||
Log::info("Generated new CA key and certificate files. Installing to Windows Root CA store automatically...");
|
|
||||||
|
|
||||||
STARTUPINFOA si;
|
|
||||||
memset(&si, 0, sizeof(si));
|
|
||||||
si.cb = sizeof(si);
|
|
||||||
PROCESS_INFORMATION pi;
|
|
||||||
memset(&pi, 0, sizeof(pi));
|
|
||||||
char cmd[] = "certutil.exe -user -addstore root ca_cert.pem";
|
|
||||||
if (CreateProcessA(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
|
|
||||||
{
|
|
||||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
||||||
CloseHandle(pi.hProcess);
|
|
||||||
CloseHandle(pi.hThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSL_CTX* CertManager::CreateHostContext(const std::string& host)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(_mutex);
|
|
||||||
|
|
||||||
auto it = _hostContexts.find(host);
|
|
||||||
if (it != _hostContexts.end())
|
|
||||||
{
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
EVP_PKEY* pkey = _sessionPkey;
|
|
||||||
if (!pkey) return nullptr;
|
|
||||||
|
|
||||||
X509* cert = X509_new();
|
|
||||||
X509_set_version(cert, 2);
|
|
||||||
ASN1_INTEGER_set(X509_get_serialNumber(cert), static_cast<long>(std::hash<std::string>{}(host) & 0x7FFFFFFF));
|
|
||||||
X509_gmtime_adj(X509_get_notBefore(cert), 0);
|
|
||||||
X509_gmtime_adj(X509_get_notAfter(cert), 31536000L);
|
|
||||||
|
|
||||||
std::string dynamicOrg = randomizeString(16);
|
|
||||||
|
|
||||||
X509_NAME* name = X509_get_subject_name(cert);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char*)"US", -1, -1, 0);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, (unsigned char*)dynamicOrg.c_str(), -1, -1, 0);
|
|
||||||
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char*)(host.c_str()), -1, -1, 0);
|
|
||||||
X509_set_issuer_name(cert, X509_get_subject_name(_caCert));
|
|
||||||
X509_set_pubkey(cert, pkey);
|
|
||||||
|
|
||||||
X509V3_CTX ctxV3;
|
|
||||||
X509V3_set_ctx_nodb(&ctxV3);
|
|
||||||
X509V3_set_ctx(&ctxV3, _caCert, cert, nullptr, nullptr, 0);
|
|
||||||
std::string san = "DNS:" + host;
|
|
||||||
X509_EXTENSION* extSAN = X509V3_EXT_conf_nid(nullptr, &ctxV3, NID_subject_alt_name, san.c_str());
|
|
||||||
if (extSAN)
|
|
||||||
{
|
|
||||||
X509_add_ext(cert, extSAN, -1);
|
|
||||||
X509_EXTENSION_free(extSAN);
|
|
||||||
}
|
|
||||||
|
|
||||||
X509_sign(cert, _caPkey, EVP_sha256());
|
|
||||||
|
|
||||||
SSL_CTX* ctx = SSL_CTX_new(TLS_server_method());
|
|
||||||
|
|
||||||
SSL_CTX_set_alpn_select_cb(
|
|
||||||
ctx,
|
|
||||||
[](SSL* /*ssl*/, const unsigned char** out, unsigned char* outlen, const unsigned char* in, unsigned int inlen,
|
|
||||||
void* /*arg*/) -> int {
|
|
||||||
for (unsigned int i = 0; i < inlen;)
|
|
||||||
{
|
|
||||||
unsigned int len = in[i];
|
|
||||||
if (len == 8 && memcmp(&in[i + 1], "http/1.1", 8) == 0)
|
|
||||||
{
|
|
||||||
*out = &in[i + 1];
|
|
||||||
*outlen = (unsigned char)len;
|
|
||||||
return SSL_TLSEXT_ERR_OK;
|
|
||||||
}
|
|
||||||
i += len + 1;
|
|
||||||
}
|
|
||||||
return SSL_TLSEXT_ERR_NOACK;
|
|
||||||
},
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
SSL_CTX_use_certificate(ctx, cert);
|
|
||||||
SSL_CTX_use_PrivateKey(ctx, pkey);
|
|
||||||
|
|
||||||
X509_free(cert);
|
|
||||||
|
|
||||||
_hostContexts[host] = ctx;
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <mutex>
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
|
|
||||||
class CertManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CertManager();
|
|
||||||
~CertManager();
|
|
||||||
|
|
||||||
bool Init();
|
|
||||||
SSL_CTX* CreateHostContext(const std::string& host);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool GenerateCA();
|
|
||||||
bool LoadCA();
|
|
||||||
|
|
||||||
EVP_PKEY* _caPkey = nullptr;
|
|
||||||
X509* _caCert = nullptr;
|
|
||||||
EVP_PKEY* _sessionPkey = nullptr;
|
|
||||||
|
|
||||||
std::mutex _mutex;
|
|
||||||
std::unordered_map<std::string, SSL_CTX*> _hostContexts;
|
|
||||||
};
|
|
||||||
+36
-35
@@ -5,46 +5,45 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wininet.h>
|
#include <wininet.h>
|
||||||
//#include <fstream>
|
#include <ctime>
|
||||||
//#include <iostream>
|
|
||||||
//#include <string>
|
|
||||||
//#include <string_view>
|
|
||||||
//#include <vector>
|
|
||||||
//#include <format>
|
|
||||||
//#include <mutex>
|
|
||||||
//#include <ctime>
|
|
||||||
//#include <regex>
|
|
||||||
//#include <unordered_set>
|
|
||||||
//#include <simdjson.h>
|
|
||||||
|
|
||||||
|
bool setProxyAddress(bool enable, const std::string& proxyAddr)
|
||||||
bool setProxy(bool enable, const std::string& proxyAddr)
|
|
||||||
{
|
{
|
||||||
INTERNET_PER_CONN_OPTION_LIST list;
|
INTERNET_PER_CONN_OPTION_LIST list;
|
||||||
INTERNET_PER_CONN_OPTION options[3];
|
INTERNET_PER_CONN_OPTION options[3];
|
||||||
unsigned long listSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
|
|
||||||
|
ZeroMemory(&list, sizeof(list));
|
||||||
|
ZeroMemory(options, sizeof(options));
|
||||||
|
|
||||||
options[0].dwOption = INTERNET_PER_CONN_FLAGS;
|
options[0].dwOption = INTERNET_PER_CONN_FLAGS;
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
|
{
|
||||||
|
if (proxyAddr.empty()) return false;
|
||||||
|
|
||||||
options[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
|
options[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
|
||||||
|
|
||||||
|
options[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
||||||
|
options[1].Value.pszValue = const_cast<char*>(proxyAddr.c_str());
|
||||||
|
|
||||||
|
options[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
|
||||||
|
options[2].Value.pszValue = (char*)"<local>";
|
||||||
|
|
||||||
|
list.dwOptionCount = 3;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
options[0].Value.dwValue = PROXY_TYPE_DIRECT;
|
options[0].Value.dwValue = PROXY_TYPE_DIRECT;
|
||||||
|
list.dwOptionCount = 1;
|
||||||
options[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
|
}
|
||||||
options[1].Value.pszValue = const_cast<char*>(proxyAddr.c_str());
|
|
||||||
|
|
||||||
options[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS;
|
|
||||||
options[2].Value.pszValue = const_cast<char*>("<local>");
|
|
||||||
|
|
||||||
list.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
|
list.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
|
||||||
list.pszConnection = NULL;
|
list.pszConnection = NULL;
|
||||||
list.dwOptionCount = 3;
|
|
||||||
list.dwOptionError = 0;
|
|
||||||
list.pOptions = options;
|
list.pOptions = options;
|
||||||
|
|
||||||
if (!InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, listSize))
|
if (!InternetSetOption(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, sizeof(list)))
|
||||||
{
|
{
|
||||||
Log::error("Failed to set proxy options, Err: {}", GetLastError());
|
Log::error("Failed to set proxy options - error: {}", GetLastError());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +54,7 @@ bool setProxy(bool enable, const std::string& proxyAddr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
Proxy* g_Proxy = nullptr;
|
Proxy* proxy = nullptr;
|
||||||
|
|
||||||
void cleanup()
|
void cleanup()
|
||||||
{
|
{
|
||||||
@@ -65,14 +64,14 @@ void cleanup()
|
|||||||
if (cleaned) return;
|
if (cleaned) return;
|
||||||
cleaned = true;
|
cleaned = true;
|
||||||
|
|
||||||
if (g_Proxy)
|
Log::info("Restoring system proxy settings");
|
||||||
|
setProxyAddress(false, "");
|
||||||
|
|
||||||
|
if (proxy)
|
||||||
{
|
{
|
||||||
Log::info("Shutting down proxy");
|
Log::info("Shutting down proxy");
|
||||||
g_Proxy->Shutdown();
|
proxy->shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::info("Restoring system proxy settings");
|
|
||||||
setProxy(false, "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI consoleHandler(DWORD dwType)
|
BOOL WINAPI consoleHandler(DWORD dwType)
|
||||||
@@ -83,13 +82,14 @@ BOOL WINAPI consoleHandler(DWORD dwType)
|
|||||||
running = false;
|
running = false;
|
||||||
cleanup();
|
cleanup();
|
||||||
exit(0);
|
exit(0);
|
||||||
//return TRUE;
|
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
srand(static_cast<unsigned int>(time(NULL)));
|
||||||
|
|
||||||
Log::createConsole();
|
Log::createConsole();
|
||||||
SetConsoleCtrlHandler(consoleHandler, TRUE);
|
SetConsoleCtrlHandler(consoleHandler, TRUE);
|
||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
@@ -100,13 +100,14 @@ int main()
|
|||||||
proxy setup
|
proxy setup
|
||||||
*/
|
*/
|
||||||
Log::info("Starting proxy");
|
Log::info("Starting proxy");
|
||||||
g_Proxy = new Proxy();
|
proxy = new Proxy();
|
||||||
if (!g_Proxy->Init())
|
if (!proxy->init())
|
||||||
{
|
{
|
||||||
Log::error("Proxy failed to start");
|
Log::error("Proxy failed to start");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
setProxy(true, std::format("127.0.0.1:{}", PROXY_PORT));
|
proxy->addWhitelistDomain("bhvrdbd.com");
|
||||||
|
setProxyAddress(true, std::format("127.0.0.1:{}", PROXY_PORT));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Spoofer setup
|
Spoofer setup
|
||||||
@@ -114,7 +115,7 @@ int main()
|
|||||||
Log::info("Spoofer init");
|
Log::info("Spoofer init");
|
||||||
Spoofer* spoofer = new Spoofer();
|
Spoofer* spoofer = new Spoofer();
|
||||||
|
|
||||||
spoofer->init(g_Proxy);
|
spoofer->init(proxy);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
pause
|
pause
|
||||||
|
|||||||
+687
-532
File diff suppressed because it is too large
Load Diff
+17
-3
@@ -3,9 +3,13 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <queue>
|
||||||
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#include "cert_manager.h"
|
#include "ssl.h"
|
||||||
#include <nerutils/callback.h>
|
#include <nerutils/callback.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -13,6 +17,7 @@
|
|||||||
use random port, test availability
|
use random port, test availability
|
||||||
*/
|
*/
|
||||||
#define PROXY_PORT 58421
|
#define PROXY_PORT 58421
|
||||||
|
#define PROXY_THREAD_COUNT 256
|
||||||
|
|
||||||
typedef unsigned __int64 SOCKET;
|
typedef unsigned __int64 SOCKET;
|
||||||
|
|
||||||
@@ -22,12 +27,14 @@ class Proxy
|
|||||||
Proxy();
|
Proxy();
|
||||||
~Proxy();
|
~Proxy();
|
||||||
|
|
||||||
bool Init();
|
bool init();
|
||||||
void Shutdown();
|
void shutdown();
|
||||||
|
|
||||||
CallbackEvent<std::string&, const std::string&, std::string&> OnClientRequest;
|
CallbackEvent<std::string&, const std::string&, std::string&> OnClientRequest;
|
||||||
CallbackEvent<const std::string&, std::string&, std::string&> OnServerResponse;
|
CallbackEvent<const std::string&, std::string&, std::string&> OnServerResponse;
|
||||||
|
|
||||||
|
void addWhitelistDomain(const std::string& domain);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loop();
|
void loop();
|
||||||
void handleClient(SOCKET clientSocket);
|
void handleClient(SOCKET clientSocket);
|
||||||
@@ -39,6 +46,13 @@ class Proxy
|
|||||||
std::thread _workerThread;
|
std::thread _workerThread;
|
||||||
std::atomic<bool> _running = false;
|
std::atomic<bool> _running = false;
|
||||||
|
|
||||||
|
std::vector<std::thread> _poolThreads;
|
||||||
|
std::queue<SOCKET> _clientQueue;
|
||||||
|
std::mutex _queueMutex;
|
||||||
|
std::condition_variable _queueCond;
|
||||||
|
|
||||||
CertManager _certManager;
|
CertManager _certManager;
|
||||||
SSL_CTX* _clientCtx = nullptr;
|
SSL_CTX* _clientCtx = nullptr;
|
||||||
|
|
||||||
|
std::vector<std::string> _whitelistDomains;
|
||||||
};
|
};
|
||||||
|
|||||||
+545
-371
File diff suppressed because it is too large
Load Diff
+30
-4
@@ -5,8 +5,17 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include <nlohmann/json_fwd.hpp>
|
#include <nlohmann/json_fwd.hpp>
|
||||||
|
|
||||||
|
struct SpooferConfig
|
||||||
|
{
|
||||||
|
bool spoofCharacterOwnership = false;
|
||||||
|
bool spoofInventory = true;
|
||||||
|
bool spoofCustomization = true;
|
||||||
|
};
|
||||||
|
|
||||||
class Spoofer
|
class Spoofer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -15,15 +24,29 @@ class Spoofer
|
|||||||
private:
|
private:
|
||||||
void registerListeners(Proxy* proxy);
|
void registerListeners(Proxy* proxy);
|
||||||
void loadData();
|
void loadData();
|
||||||
|
void loadConfig();
|
||||||
|
|
||||||
void parseCatalog(std::string data);
|
bool parseCatalog(std::string data);
|
||||||
|
bool parseStackable(std::string data, std::unordered_set<std::string>& camperSet,
|
||||||
|
std::unordered_set<std::string>& slasherSet);
|
||||||
|
|
||||||
void parseAndDumpCatalog(std::string& data);
|
std::string getRandomItem();
|
||||||
|
int getRandomQuantity();
|
||||||
|
|
||||||
|
void generateBloodweb(nlohmann::json& data);
|
||||||
void modifyCharacterData(nlohmann::json& js);
|
void modifyCharacterData(nlohmann::json& js);
|
||||||
|
|
||||||
|
void onGetCatalogItems(std::string& body);
|
||||||
|
void onGetAll(std::string& body);
|
||||||
|
void onInventoryAll(std::string& body);
|
||||||
|
void onMessageList(std::string& body);
|
||||||
|
void onBloodweb(std::string& body, std::string& respHeaders);
|
||||||
|
|
||||||
void serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders);
|
void serverResponseHandler(const std::string& url, std::string& body, std::string& respHeaders);
|
||||||
void clientRequestHandler(std::string& url, const std::string& body, std::string& reqHeaders);
|
void clientRequestHandler(std::string& url, const std::string& body, std::string& reqHeaders);
|
||||||
|
|
||||||
|
SpooferConfig _config;
|
||||||
|
|
||||||
std::unordered_set<std::string> _camperItemIds;
|
std::unordered_set<std::string> _camperItemIds;
|
||||||
std::unordered_set<std::string> _slasherPowerIds;
|
std::unordered_set<std::string> _slasherPowerIds;
|
||||||
|
|
||||||
@@ -33,11 +56,14 @@ class Spoofer
|
|||||||
std::unordered_set<std::string> _camperAddonIds;
|
std::unordered_set<std::string> _camperAddonIds;
|
||||||
std::unordered_set<std::string> _slasherAddonIds;
|
std::unordered_set<std::string> _slasherAddonIds;
|
||||||
|
|
||||||
std::unordered_set<std::string> _slasherPerkIds;
|
|
||||||
std::unordered_set<std::string> _camperPerkIds;
|
std::unordered_set<std::string> _camperPerkIds;
|
||||||
|
std::unordered_set<std::string> _slasherPerkIds;
|
||||||
|
|
||||||
std::unordered_set<std::string> _catalogOutfitIds;
|
std::unordered_set<std::string> _catalogOutfitIds;
|
||||||
std::unordered_set<std::string> _catalogItemIds;
|
std::unordered_set<std::string> _catalogItemIds;
|
||||||
|
|
||||||
std::string _lastBloodWebChar = "Ace";
|
std::unordered_set<std::string> _unownedCharacters;
|
||||||
|
|
||||||
|
std::string _lastBloodWebChar = "";
|
||||||
|
std::mutex _mtx;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,232 @@
|
|||||||
|
#include "ssl.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <nerutils/log.h>
|
||||||
|
|
||||||
|
#include <openssl/bio.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/pem.h>
|
||||||
|
#include <openssl/x509v3.h>
|
||||||
|
#include <openssl/bn.h>
|
||||||
|
#include <openssl/rsa.h>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
|
#include <random>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <ctime>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <wincrypt.h>
|
||||||
|
#include <processthreadsapi.h>
|
||||||
|
|
||||||
|
template <typename T, void (*f)(T*)> struct Deleter
|
||||||
|
{
|
||||||
|
void operator()(T* p) const { f(p); }
|
||||||
|
};
|
||||||
|
|
||||||
|
using EVP_PKEY_ptr = std::unique_ptr<EVP_PKEY, Deleter<EVP_PKEY, EVP_PKEY_free>>;
|
||||||
|
using X509_ptr = std::unique_ptr<X509, Deleter<X509, X509_free>>;
|
||||||
|
using SSL_CTX_ptr = std::unique_ptr<SSL_CTX, Deleter<SSL_CTX, SSL_CTX_free>>;
|
||||||
|
using BIO_ptr = std::unique_ptr<BIO, Deleter<BIO, BIO_vfree>>;
|
||||||
|
|
||||||
|
CertManager::CertManager() : _caPkey(nullptr), _caCert(nullptr), _sessionPkey(nullptr) {}
|
||||||
|
|
||||||
|
CertManager::~CertManager()
|
||||||
|
{
|
||||||
|
if (_caPkey) EVP_PKEY_free(_caPkey);
|
||||||
|
if (_caCert) X509_free(_caCert);
|
||||||
|
if (_sessionPkey) EVP_PKEY_free(_sessionPkey);
|
||||||
|
|
||||||
|
for (auto& pair : _hostContexts)
|
||||||
|
SSL_CTX_free(pair.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CertManager::init()
|
||||||
|
{
|
||||||
|
EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
|
||||||
|
if (!pctx) return false;
|
||||||
|
|
||||||
|
EVP_PKEY_keygen_init(pctx);
|
||||||
|
EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048);
|
||||||
|
|
||||||
|
EVP_PKEY* rawPkey = nullptr;
|
||||||
|
if (EVP_PKEY_keygen(pctx, &rawPkey) <= 0)
|
||||||
|
{
|
||||||
|
Log::error("Failed to generate session key");
|
||||||
|
EVP_PKEY_CTX_free(pctx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_sessionPkey = rawPkey;
|
||||||
|
EVP_PKEY_CTX_free(pctx);
|
||||||
|
|
||||||
|
if (loadCA())
|
||||||
|
{
|
||||||
|
Log::verbose("Loaded existing CA certificate");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::verbose("No CA found, generating");
|
||||||
|
return generateCA();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CertManager::loadCA()
|
||||||
|
{
|
||||||
|
std::string path = utils::getExePath();
|
||||||
|
|
||||||
|
BIO_ptr keyBio(BIO_new_file((path + "/key.pem").c_str(), "r"));
|
||||||
|
if (!keyBio) return false;
|
||||||
|
_caPkey = PEM_read_bio_PrivateKey(keyBio.get(), nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
|
BIO_ptr certBio(BIO_new_file((path + "/cert.pem").c_str(), "r"));
|
||||||
|
if (!certBio) return false;
|
||||||
|
_caCert = PEM_read_bio_X509(certBio.get(), nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
|
return (_caPkey && _caCert);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CertManager::installCert(X509* cert)
|
||||||
|
{
|
||||||
|
if (!cert) return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
X509 to DER
|
||||||
|
*/
|
||||||
|
int derLen = i2d_X509(cert, nullptr);
|
||||||
|
if (derLen < 0) return;
|
||||||
|
|
||||||
|
unsigned char* derBuf = new unsigned char[derLen];
|
||||||
|
unsigned char* p = derBuf;
|
||||||
|
i2d_X509(cert, &p);
|
||||||
|
|
||||||
|
PCCERT_CONTEXT certCtx = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, derBuf, derLen);
|
||||||
|
if (certCtx)
|
||||||
|
{
|
||||||
|
HCERTSTORE rootStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, 0, CERT_SYSTEM_STORE_CURRENT_USER, L"Root");
|
||||||
|
if (rootStore)
|
||||||
|
{
|
||||||
|
BOOL success = CertAddCertificateContextToStore(rootStore, certCtx, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
|
||||||
|
|
||||||
|
if (success)
|
||||||
|
Log::info("CA certificate installed");
|
||||||
|
else
|
||||||
|
Log::error("Failed to install CA certificate");
|
||||||
|
|
||||||
|
CertCloseStore(rootStore, 0);
|
||||||
|
}
|
||||||
|
CertFreeCertificateContext(certCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] derBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CertManager::generateCA()
|
||||||
|
{
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 gen(rd());
|
||||||
|
|
||||||
|
/*
|
||||||
|
key
|
||||||
|
*/
|
||||||
|
EVP_PKEY_CTX* pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, nullptr);
|
||||||
|
EVP_PKEY_keygen_init(pctx);
|
||||||
|
EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048);
|
||||||
|
EVP_PKEY* rawCaKey = nullptr;
|
||||||
|
EVP_PKEY_keygen(pctx, &rawCaKey);
|
||||||
|
_caPkey = rawCaKey;
|
||||||
|
EVP_PKEY_CTX_free(pctx);
|
||||||
|
|
||||||
|
/*
|
||||||
|
cert
|
||||||
|
*/
|
||||||
|
X509_ptr cert(X509_new());
|
||||||
|
X509_set_version(cert.get(), 2);
|
||||||
|
ASN1_INTEGER_set(X509_get_serialNumber(cert.get()), 1);
|
||||||
|
X509_gmtime_adj(X509_get_notBefore(cert.get()), 0);
|
||||||
|
X509_gmtime_adj(X509_get_notAfter(cert.get()), 31536000L); // 1 year
|
||||||
|
|
||||||
|
X509_name_st* subjName = X509_get_subject_name(cert.get());
|
||||||
|
std::string randomCN = utils::randomizeString(16);
|
||||||
|
X509_NAME_add_entry_by_txt(subjName, "CN", MBSTRING_ASC, (unsigned char*)randomCN.c_str(), -1, -1, 0);
|
||||||
|
X509_set_issuer_name(cert.get(), subjName);
|
||||||
|
X509_set_pubkey(cert.get(), _caPkey);
|
||||||
|
|
||||||
|
/*
|
||||||
|
CA constraints
|
||||||
|
*/
|
||||||
|
X509V3_CTX v3ctx;
|
||||||
|
X509V3_set_ctx(&v3ctx, cert.get(), cert.get(), nullptr, nullptr, 0);
|
||||||
|
X509_EXTENSION* ext = X509V3_EXT_conf_nid(nullptr, &v3ctx, NID_basic_constraints, "critical,CA:TRUE");
|
||||||
|
X509_add_ext(cert.get(), ext, -1);
|
||||||
|
X509_EXTENSION_free(ext);
|
||||||
|
|
||||||
|
if (X509_sign(cert.get(), _caPkey, EVP_sha256()) <= 0) return false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
out
|
||||||
|
*/
|
||||||
|
std::string path = utils::getExePath();
|
||||||
|
BIO_ptr kOut(BIO_new_file((path + "/key.pem").c_str(), "w"));
|
||||||
|
PEM_write_bio_PrivateKey(kOut.get(), _caPkey, nullptr, nullptr, 0, nullptr, nullptr);
|
||||||
|
|
||||||
|
BIO_ptr cOut(BIO_new_file((path + "/cert.pem").c_str(), "w"));
|
||||||
|
PEM_write_bio_X509(cOut.get(), cert.get());
|
||||||
|
|
||||||
|
/*
|
||||||
|
install and release
|
||||||
|
*/
|
||||||
|
installCert(cert.get());
|
||||||
|
|
||||||
|
_caCert = cert.release();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSL_CTX* CertManager::createHostContext(const std::string& host)
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(_mutex);
|
||||||
|
if (_hostContexts.count(host)) return _hostContexts[host];
|
||||||
|
|
||||||
|
/*
|
||||||
|
cert base
|
||||||
|
*/
|
||||||
|
X509_ptr cert(X509_new());
|
||||||
|
X509_set_version(cert.get(), 2);
|
||||||
|
|
||||||
|
ASN1_INTEGER_set(X509_get_serialNumber(cert.get()), static_cast<long>(std::hash<std::string>{}(host) & 0x7FFFFFFF));
|
||||||
|
|
||||||
|
X509_gmtime_adj(X509_get_notBefore(cert.get()), 0);
|
||||||
|
X509_gmtime_adj(X509_get_notAfter(cert.get()), 31536000L);
|
||||||
|
|
||||||
|
X509_name_st* subjName = X509_get_subject_name(cert.get());
|
||||||
|
X509_NAME_add_entry_by_txt(subjName, "CN", MBSTRING_ASC, (unsigned char*)host.c_str(), -1, -1, 0);
|
||||||
|
X509_set_issuer_name(cert.get(), X509_get_subject_name(_caCert));
|
||||||
|
X509_set_pubkey(cert.get(), _sessionPkey);
|
||||||
|
|
||||||
|
/*
|
||||||
|
SAN
|
||||||
|
*/
|
||||||
|
X509V3_CTX v3ctx;
|
||||||
|
X509V3_set_ctx(&v3ctx, _caCert, cert.get(), nullptr, nullptr, 0);
|
||||||
|
std::string altName = "DNS:" + host;
|
||||||
|
X509_EXTENSION* ext = X509V3_EXT_conf_nid(nullptr, &v3ctx, NID_subject_alt_name, altName.c_str());
|
||||||
|
X509_add_ext(cert.get(), ext, -1);
|
||||||
|
X509_EXTENSION_free(ext);
|
||||||
|
|
||||||
|
/*
|
||||||
|
sign & ctx load
|
||||||
|
*/
|
||||||
|
if (X509_sign(cert.get(), _caPkey, EVP_sha256()) <= 0) return nullptr;
|
||||||
|
|
||||||
|
SSL_CTX* ctx = SSL_CTX_new(TLS_server_method());
|
||||||
|
if (!ctx) return nullptr;
|
||||||
|
|
||||||
|
if (SSL_CTX_use_certificate(ctx, cert.get()) <= 0 || SSL_CTX_use_PrivateKey(ctx, _sessionPkey) <= 0)
|
||||||
|
{
|
||||||
|
SSL_CTX_free(ctx);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hostContexts[host] = ctx;
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
struct x509_st;
|
||||||
|
struct X509_name_st;
|
||||||
|
struct ssl_st;
|
||||||
|
struct ssl_ctx_st;
|
||||||
|
struct evp_pkey_st;
|
||||||
|
|
||||||
|
typedef struct x509_st X509;
|
||||||
|
typedef struct ssl_st SSL;
|
||||||
|
typedef struct ssl_ctx_st SSL_CTX;
|
||||||
|
typedef struct evp_pkey_st EVP_PKEY;
|
||||||
|
|
||||||
|
class CertManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CertManager();
|
||||||
|
~CertManager();
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
SSL_CTX* createHostContext(const std::string& host);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool generateCA();
|
||||||
|
bool loadCA();
|
||||||
|
|
||||||
|
void installCert(X509* cert);
|
||||||
|
|
||||||
|
EVP_PKEY* _caPkey = nullptr;
|
||||||
|
X509* _caCert = nullptr;
|
||||||
|
EVP_PKEY* _sessionPkey = nullptr;
|
||||||
|
|
||||||
|
std::mutex _mutex;
|
||||||
|
std::unordered_map<std::string, SSL_CTX*> _hostContexts;
|
||||||
|
};
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <minwindef.h>
|
||||||
|
#include <libloaderapi.h>
|
||||||
|
|
||||||
|
std::string utils::getExePath()
|
||||||
|
{
|
||||||
|
char buffer[MAX_PATH];
|
||||||
|
GetModuleFileNameA(NULL, buffer, MAX_PATH);
|
||||||
|
std::string path(buffer);
|
||||||
|
size_t pos = path.find_last_of("\\/");
|
||||||
|
if (pos != std::string::npos) return path.substr(0, pos + 1);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string utils::randomizeString(size_t length)
|
||||||
|
{
|
||||||
|
const char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
std::string result;
|
||||||
|
result.resize(length);
|
||||||
|
for (size_t i = 0; i < length; ++i)
|
||||||
|
result[i] = charset[rand() % (sizeof(charset) - 1)];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
std::string getExePath();
|
||||||
|
std::string randomizeString(size_t length);
|
||||||
|
} // namespace utils
|
||||||
Reference in New Issue
Block a user