Skip to content

Commit

Permalink
chore(vicepp): add more known encryption codes
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed Jul 15, 2024
1 parent 7839a45 commit b0747fc
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 36 deletions.
33 changes: 22 additions & 11 deletions include/vicepp/vicepp.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,36 @@
namespace vicepp {

// https://developer.valvesoftware.com/wiki/ICE
// https://wiki.alliedmods.net/Vice_keys
namespace KnownCodes {

constexpr std::string_view DEFAULT = "x9Ke0BY7";
constexpr std::string_view HL2DM = DEFAULT;
constexpr std::string_view CSS = "d7NSuLq2";
constexpr std::string_view CSGO = CSS;
constexpr std::string_view DODS = "Wl0u5B3F";
constexpr std::string_view TF2 = "E2NcUkG2";
constexpr std::string_view TF2_ITEMS = "A5fSXbf7";
constexpr std::string_view L4D2 = "SDhfi878";
constexpr std::string_view THE_SHIP = "eb3A4m79";

constexpr std::string_view CONTAGION_WEAPONS = "fUk0fF69";
constexpr std::string_view CONTAGION_SCRIPTS = "5!rrFz6p";
constexpr std::string_view ZPS = "5R0ni0pZ";
constexpr std::string_view COUNTER_STRIKE_SOURCE = "d7NSuLq2";
constexpr std::string_view COUNTER_STRIKE_GLOBAL_OFFENSIVE = COUNTER_STRIKE_SOURCE;
constexpr std::string_view COUNTER_STRIKE_2 = COUNTER_STRIKE_GLOBAL_OFFENSIVE;
constexpr std::string_view COUNTER_STRIKE_PROMOD = "H1aRQ0n1";
constexpr std::string_view DAY_OF_DEFEAT_SOURCE = "Wl0u5B3F";
constexpr std::string_view DYSTOPIA_1_2 = "pH3apO8w";
constexpr std::string_view DYSTOPIA_1_3 = "G8stUh3F";
constexpr std::string_view GOLDEN_EYE_SOURCE = "Gr3naDes";
constexpr std::string_view HALF_LIFE_2_CTF = "R1dj3axP";
constexpr std::string_view HALF_LIFE_2_DM = DEFAULT;
constexpr std::string_view INSURGENCY = "DrA5e3EB";
constexpr std::string_view LEFT_4_DEAD_2 = "SDhfi878";
constexpr std::string_view NO_MORE_ROOM_IN_HELL = "lREeeapA";
constexpr std::string_view NUCLEAR_DAWN = "TA+*veh9";
constexpr std::string_view TEAM_FORTRESS_2 = "E2NcUkG2";
constexpr std::string_view TEAM_FORTRESS_2_ITEMS = "A5fSXbf7";
constexpr std::string_view THE_SHIP = "eb3A4m79";
constexpr std::string_view ZOMBIE_PANIC_SOURCE = "5R0ni0pZ";

} // namespace KnownCodes

[[nodiscard]] std::vector<std::byte> encrypt(std::span<const std::byte> data, std::string_view code);
[[nodiscard]] std::vector<std::byte> encrypt(std::span<const std::byte> data, std::string_view code = KnownCodes::DEFAULT);

[[nodiscard]] std::vector<std::byte> decrypt(std::span<const std::byte> data, std::string_view code);
[[nodiscard]] std::vector<std::byte> decrypt(std::span<const std::byte> data, std::string_view code = KnownCodes::DEFAULT);

} // namespace vicepp
34 changes: 22 additions & 12 deletions lang/c/include/viceppc/vicepp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@
#include <sourceppc/Buffer.h>
#include <sourceppc/String.h>

#define VICEPP_KNOWN_CODES_DEFAULT "x9Ke0BY7"
#define VICEPP_KNOWN_CODES_HL2DM VICEPP_KNOWN_CODES_DEFAULT
#define VICEPP_KNOWN_CODES_CSS "d7NSuLq2"
#define VICEPP_KNOWN_CODES_CSGO VICEPP_KNOWN_CODES_CSS
#define VICEPP_KNOWN_CODES_DODS "Wl0u5B3F"
#define VICEPP_KNOWN_CODES_TF2 "E2NcUkG2"
#define VICEPP_KNOWN_CODES_TF2_ITEMS "A5fSXbf7"
#define VICEPP_KNOWN_CODES_L4D2 "SDhfi878"
#define VICEPP_KNOWN_CODES_THE_SHIP "eb3A4m79"
#define VICEPP_KNOWN_CODES_CONTAGION_WEAPONS "fUk0fF69"
#define VICEPP_KNOWN_CODES_CONTAGION_SCRIPTS "5!rrFz6p"
#define VICEPP_KNOWN_CODES_ZPS "5R0ni0pZ"
#define VICEPP_KNOWN_CODES_DEFAULT "x9Ke0BY7";

#define VICEPP_KNOWN_CODES_CONTAGION_WEAPONS "fUk0fF69"
#define VICEPP_KNOWN_CODES_CONTAGION_SCRIPTS "5!rrFz6p"
#define VICEPP_KNOWN_CODES_COUNTER_STRIKE_SOURCE "d7NSuLq2"
#define VICEPP_KNOWN_CODES_COUNTER_STRIKE_GLOBAL_OFFENSIVE VICEPP_KNOWN_CODES_COUNTER_STRIKE_SOURCE
#define VICEPP_KNOWN_CODES_COUNTER_STRIKE_2 VICEPP_KNOWN_CODES_COUNTER_STRIKE_GLOBAL_OFFENSIVE
#define VICEPP_KNOWN_CODES_COUNTER_STRIKE_PROMOD "H1aRQ0n1"
#define VICEPP_KNOWN_CODES_DAY_OF_DEFEAT_SOURCE "Wl0u5B3F"
#define VICEPP_KNOWN_CODES_DYSTOPIA_1_2 "pH3apO8w"
#define VICEPP_KNOWN_CODES_DYSTOPIA_1_3 "G8stUh3F"
#define VICEPP_KNOWN_CODES_GOLDEN_EYE_SOURCE "Gr3naDes"
#define VICEPP_KNOWN_CODES_HALF_LIFE_2_CTF "R1dj3axP"
#define VICEPP_KNOWN_CODES_HALF_LIFE_2_DM VICEPP_KNOWN_CODES_DEFAULT
#define VICEPP_KNOWN_CODES_INSURGENCY "DrA5e3EB"
#define VICEPP_KNOWN_CODES_LEFT_4_DEAD_2 "SDhfi878"
#define VICEPP_KNOWN_CODES_NO_MORE_ROOM_IN_HELL "lREeeapA"
#define VICEPP_KNOWN_CODES_NUCLEAR_DAWN "TA+*veh9"
#define VICEPP_KNOWN_CODES_TEAM_FORTRESS_2 "E2NcUkG2"
#define VICEPP_KNOWN_CODES_TEAM_FORTRESS_2_ITEMS "A5fSXbf7"
#define VICEPP_KNOWN_CODES_THE_SHIP "eb3A4m79"
#define VICEPP_KNOWN_CODES_ZOMBIE_PANIC_SOURCE "5R0ni0pZ"

// REQUIRES MANUAL FREE: sourcepp_buffer_free
SOURCEPP_API sourcepp_buffer_t vicepp_encrypt(const unsigned char* buffer, size_t bufferLen, const char* code);
Expand Down
32 changes: 21 additions & 11 deletions lang/csharp/src/vicepp/vicepp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,32 @@ internal static unsafe partial class Extern

public static class KnownCodes {
public const string DEFAULT = "x9Ke0BY7";
public const string HL2DM = DEFAULT;
public const string CSS = "d7NSuLq2";
public const string CSGO = CSS;
public const string DODS = "Wl0u5B3F";
public const string TF2 = "E2NcUkG2";
public const string TF2_ITEMS = "A5fSXbf7";
public const string L4D2 = "SDhfi878";
public const string THE_SHIP = "eb3A4m79";

public const string CONTAGION_WEAPONS = "fUk0fF69";
public const string CONTAGION_SCRIPTS = "5!rrFz6p";
public const string ZPS = "5R0ni0pZ";
public const string COUNTER_STRIKE_SOURCE = "d7NSuLq2";
public const string COUNTER_STRIKE_GLOBAL_OFFENSIVE = COUNTER_STRIKE_SOURCE;
public const string COUNTER_STRIKE_2 = COUNTER_STRIKE_GLOBAL_OFFENSIVE;
public const string COUNTER_STRIKE_PROMOD = "H1aRQ0n1";
public const string DAY_OF_DEFEAT_SOURCE = "Wl0u5B3F";
public const string DYSTOPIA_1_2 = "pH3apO8w";
public const string DYSTOPIA_1_3 = "G8stUh3F";
public const string GOLDEN_EYE_SOURCE = "Gr3naDes";
public const string HALF_LIFE_2_CTF = "R1dj3axP";
public const string HALF_LIFE_2_DM = DEFAULT;
public const string INSURGENCY = "DrA5e3EB";
public const string LEFT_4_DEAD_2 = "SDhfi878";
public const string NO_MORE_ROOM_IN_HELL = "lREeeapA";
public const string NUCLEAR_DAWN = "TA+*veh9";
public const string TEAM_FORTRESS_2 = "E2NcUkG2";
public const string TEAM_FORTRESS_2_ITEMS = "A5fSXbf7";
public const string THE_SHIP = "eb3A4m79";
public const string ZOMBIE_PANIC_SOURCE = "5R0ni0pZ";
}

public static class VICE
{
public static byte[] Decrypt(byte[] buffer, string code)
public static byte[] Decrypt(byte[] buffer, string code = KnownCodes.DEFAULT)
{
unsafe
{
Expand All @@ -43,7 +53,7 @@ public static byte[] Decrypt(byte[] buffer, string code)
}
}

public static byte[] Decrypt(IEnumerable<byte> buffer, string code)
public static byte[] Decrypt(IEnumerable<byte> buffer, string code = KnownCodes.DEFAULT)
{
unsafe
{
Expand Down
4 changes: 2 additions & 2 deletions test/vicepp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TEST(vicepp, decrypt) {
auto encrypted = fs::readFileBuffer(ASSET_ROOT "vicepp/weapon_pistol.enc");
auto decrypted = fs::readFileBuffer(ASSET_ROOT "vicepp/weapon_pistol.dec");

auto test = decrypt(encrypted, KnownCodes::HL2DM);
auto test = decrypt(encrypted);
ASSERT_EQ(test.size(), decrypted.size());

for (int i = 0; i < test.size(); i++) {
Expand All @@ -22,7 +22,7 @@ TEST(vicepp, encrypt) {
auto encrypted = fs::readFileBuffer(ASSET_ROOT "vicepp/weapon_pistol.enc");
auto decrypted = fs::readFileBuffer(ASSET_ROOT "vicepp/weapon_pistol.dec");

auto test = encrypt(decrypted, KnownCodes::HL2DM);
auto test = encrypt(decrypted);
ASSERT_EQ(test.size(), encrypted.size());

for (int i = 0; i < test.size(); i++) {
Expand Down

0 comments on commit b0747fc

Please sign in to comment.