Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fixed space replacement with version change.

+ Some cleanup
  • Loading branch information...
Splamy committed May 26, 2018
1 parent 8d9b943 commit c3bccdf22cc367b3eb4aa2e7f397c58be9fff2de
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

@@ -16,11 +17,14 @@ static class Program

static void Main(string[] args)
{
DoHax();
Console.ReadKey();
bool autoclose = args.Contains("--autoclose");

var ok = DoHax();
if (!autoclose || !ok)
Console.ReadKey();
}

static void DoHax()
static bool DoHax()
{
Process[] procs;
do
@@ -53,6 +57,7 @@ static void DoHax()
string res = DllInjector.Inject(proc, @"TS3Hook.dll");
Console.WriteLine("Status = {0}", res ?? "OK");
Console.WriteLine("Done");
return res == null;
}
}

@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2008
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TS3Hook", "TS3Hook\TS3Hook.vcxproj", "{568E865A-1CFF-457E-823F-0239A23ED904}"
EndProject
@@ -47,6 +47,15 @@ SIZE_T FindPattern(const LPCWSTR module, const char *pattern, const char *mask)
return NULL;
}

void PatchBytes(const PBYTE pAddress, const BYTE overwrite[], const SIZE_T dwLen)
{
DWORD dwOldProtect, dwBkup;
VirtualProtect(pAddress, dwLen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
for (SIZE_T x = 0x0; x < dwLen; x++)
pAddress[x] = overwrite[x];
VirtualProtect(pAddress, dwLen, dwOldProtect, &dwBkup);
}

#ifdef ENV32
void MakeJMP(const PBYTE pAddress, const PVOID dwJumpTo, const SIZE_T dwLen)
{
@@ -3,4 +3,5 @@
#include <windows.h>

SIZE_T FindPattern(const LPCWSTR module, const char *pattern, const char *mask);
void MakeJMP(const PBYTE pAddress, const PVOID dwJumpTo, const SIZE_T dwLen);
void MakeJMP(const PBYTE pAddress, const PVOID dwJumpTo, const SIZE_T dwLen);
void PatchBytes(const PBYTE pAddress, const BYTE overwrite[], const SIZE_T dwLen);
@@ -71,20 +71,16 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>x86\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)x86\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)x86\$(Configuration)\</OutDir>
<IntDir>x86\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -151,6 +147,7 @@
<ClInclude Include="include\ts3_functions.h" />
<ClInclude Include="main.h" />
<ClInclude Include="PatchTools.h" />
<ClInclude Include="util.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
@@ -169,6 +166,7 @@
</ClCompile>
<ClCompile Include="PatchTools.cpp" />
<ClCompile Include="Ts3Plugin.cpp" />
<ClCompile Include="util.cpp" />
</ItemGroup>
<ItemGroup>
<MASM Include="asmhook.asm">
@@ -20,6 +20,9 @@
<ClInclude Include="include\ts3_functions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="util.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="PatchTools.cpp">
@@ -31,6 +34,9 @@
<ClCompile Include="Ts3Plugin.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<MASM Include="asmhook.asm">
@@ -1,4 +1,4 @@
#include "stdio.h"
#include <cstdio>
#include "main.h"
#include "PatchTools.h"

@@ -1,23 +1,14 @@
// dllmain.cpp : Defines the entry point for the DLL application.
#include "main.h"
#include "include/ts3_functions.h"
#include "util.h"
#include <cstdio>
#include "PatchTools.h"
#include <string>
#include <vector>
#include <sstream>
#include <iterator>
#include <fstream>
#include <algorithm>

#define PLUGINS_EXPORTDLL __declspec(dllexport)

// Plugin exports
extern "C" {
PLUGINS_EXPORTDLL void ts3plugin_setFunctionPointers(const struct TS3Functions funcs);
PLUGINS_EXPORTDLL void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber);
PLUGINS_EXPORTDLL int ts3plugin_onServerErrorEvent(uint64 serverConnectionHandlerID, const char* errorMessage, unsigned int error, const char* returnCode, const char* extraMessage);
}
#ifdef ENV32
#define STD_DECL __cdecl

@@ -96,23 +87,6 @@ uint64 cid;
printf("%sFor "#var" using: %"#form"\n", prefix, var);\
}

std::string random_string(size_t length)
{
auto randchar = []() -> char
{
const char charset[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
const size_t max_index = (sizeof(charset) - 1);
return charset[rand() % max_index];
};
std::string str(length, 0);
std::generate_n(str.begin(), length, randchar);
return str;
}


template<typename Out>
void split(const std::string &s, const char delim, Out result) {
std::stringstream ss(s);
@@ -218,9 +192,10 @@ void read_config()
printf("\n");
GetPrivateProfileString(lpSection, L"clientversion", L"", splitbuffer, sizeof(splitbuffer), lpFileName);
read_split_list(splitbuffer, clientver, '|');
if (!clientver.empty()) {
replace_all(clientver[0], " ", R"(\s)");
replace_all(clientver[2], "/", R"(\/)");
for (auto &versionpart : clientver)
{
replace_all(versionpart, " ", R"(\s)");
replace_all(versionpart, "/", R"(\/)");
}
GetPrivateProfileString(lpSection, L"bypass_modalquit", L"1", bypass_modalquit, sizeof(bypass_modalquit), lpFileName);
GetPrivateProfileString(lpSection, L"teaspeak_anti_error", L"1", teaspeak_anti_error, sizeof(teaspeak_anti_error), lpFileName);
@@ -265,7 +240,7 @@ void STD_DECL log_in_packet(char* packet, int length)
const auto in_off = find_pos_outject + outjectcmd.size();
auto in_str = std::string(packet + in_off, length - in_off);
replace_all(in_str, std::string("~s"), std::string(" "));
replace_all(in_str, std::string("\\s"), std::string("\s"));
replace_all(in_str, std::string("\\\\s"), std::string("\\s"));
memcpy(packet, in_str.c_str(), in_str.length());
memset(packet + in_str.length(), ' ', length - in_str.length());
modified = true;
@@ -6,6 +6,7 @@
#ifndef MAIN_H
#define MAIN_H
#include <Windows.h>
#include "include/ts3_functions.h"

#if _WIN32 || _WIN64
#if _WIN64
@@ -70,6 +71,9 @@ extern "C" {
PLUGINS_EXPORTDLL const char* ts3plugin_description();
PLUGINS_EXPORTDLL int ts3plugin_init();
PLUGINS_EXPORTDLL void ts3plugin_shutdown();
PLUGINS_EXPORTDLL void ts3plugin_setFunctionPointers(const struct TS3Functions funcs);
PLUGINS_EXPORTDLL void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber);
PLUGINS_EXPORTDLL int ts3plugin_onServerErrorEvent(uint64 serverConnectionHandlerID, const char* errorMessage, unsigned int error, const char* returnCode, const char* extraMessage);
}

#endif // MAIN_H
@@ -0,0 +1,31 @@
#include "util.h"
#include <cstdio>
#include <algorithm>
#include <string>

char const hex_chars[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

void print_hex(const char* data, const int len)
{
const char* p = data;
for (int i = 0; i < len; p++, i++)
{
printf("%c%c ", hex_chars[(*p & 0xF0) >> 4], hex_chars[(*p & 0x0F) >> 0]);
}
}

std::string random_string(size_t length)
{
const auto randchar = []() -> char
{
const char charset[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
const size_t max_index = (sizeof(charset) - 1);
return charset[rand() % max_index];
};
std::string str(length, 0);
std::generate_n(str.begin(), length, randchar);
return str;
}
@@ -0,0 +1,8 @@
#ifndef UTIL_H
#define UTIL_H
#include <string>

void print_hex(const char* data, const int len);
std::string random_string(size_t length);

#endif // UTIL_H

1 comment on commit c3bccdf

@Bluscream

This comment has been minimized.

Copy link
Collaborator

commented on c3bccdf May 26, 2018

Thanks :)

Please sign in to comment.
You can’t perform that action at this time.