Skip to content

Commit

Permalink
Fix facebook friend, ads in newer spotify/alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
iostream authored and iostream committed Apr 20, 2021
1 parent c4bccb3 commit b9dc225
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<h4 align="center">A multi-purpose adblocker and skip-bypass for the <strong>Windows</strong> Spotify desktop application.</h4>
<h5 align="center">Please support Spotify by purchasing premium</h5>
<p align="center">
<strong>Last updated:</strong> 24 March 2020<br>
<strong>Last tested version:</strong> 1.1.56.595.g2d2da0de
<strong>Last updated:</strong> 21 April 2021<br>
<strong>Last tested version:</strong> 1.1.57.443.ga029a6c4(-a)
</p>
</center>

Expand Down
2 changes: 1 addition & 1 deletion src/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Logger {

void Log (std::string_view log) {
if (m_active)
m_log << log << std::endl;
m_log << log << '\n';
}

private:
Expand Down
50 changes: 40 additions & 10 deletions src/Modify.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Modify.h"
#include "Logger.h"

extern Logger g_Logger;
extern Logger *g_Logger;

// https://www.unknowncheats.me/forum/1064672-post23.html
bool DataCompare (BYTE* pData, BYTE* bSig, char* szMask)
Expand Down Expand Up @@ -31,17 +31,15 @@ BYTE* FindPattern (BYTE* dwAddress, DWORD dwSize, BYTE* pbSig, char* szMask)
return 0;
}

DWORD WINAPI KillBanner (LPVOID conf)
DWORD WINAPI KillBanner (LPVOID)
{
auto config = static_cast<Config*>(conf);
auto* logger = new Logger (config);
HMODULE hModule = GetModuleHandle (NULL);
MODULEINFO mInfo = { 0 };
if (GetModuleInformation (GetCurrentProcess (), hModule, &mInfo, sizeof (MODULEINFO))) {
logger->Log ("GetModuleInformation OK!");
g_Logger->Log ("GetModuleInformation OK!");
LPVOID skipPod = FindPattern ((uint8_t*)hModule, mInfo.SizeOfImage, (BYTE*)"\x83\xC4\x08\x84\xC0\x0F\x84\x00\x04\x00\x00", "xxxxxxxxxxx");

if (skipPod)
if (skipPod) // spotify
{
DWORD oldProtect;
VirtualProtect ((char*)skipPod + 5, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
Expand All @@ -51,15 +49,47 @@ DWORD WINAPI KillBanner (LPVOID conf)
VirtualProtect ((char*)skipPod + 6, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
memset ((char*)skipPod + 6, 0xE9, 1);
VirtualProtect ((char*)skipPod + 6, 1, oldProtect, &oldProtect);
logger->Log ("main process - patch success!");
g_Logger->Log ("main process#1 - patch success!");
}
else {
logger->Log ("main process - patch failed!");
g_Logger->Log ("main process#1 - patch failed!");
}

skipPod = FindPattern ((uint8_t*)hModule, mInfo.SizeOfImage, (BYTE*)"\x83\xC4\x08\x84\xC0\x0F\x84\xE5\x03\x00\x00", "xxxxxxxxxxx");

if (skipPod) // spotify alpha
{
DWORD oldProtect;
VirtualProtect ((char*)skipPod + 5, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
memset ((char*)skipPod + 5, 0x90, 1);
VirtualProtect ((char*)skipPod + 5, 1, oldProtect, &oldProtect);

VirtualProtect ((char*)skipPod + 6, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
memset ((char*)skipPod + 6, 0xE9, 1);
VirtualProtect ((char*)skipPod + 6, 1, oldProtect, &oldProtect);
g_Logger->Log ("main process#2 - patch success!");
}
else {
g_Logger->Log ("main process#2 - patch failed!");
}

//skipPod = FindPattern ((uint8_t*)hModule, mInfo.SizeOfImage, (BYTE*)"\x48\x83\xF8\x03\x77", "xxxxx");

//if (skipPod)
//{
// DWORD oldProtect;
// VirtualProtect ((char*)skipPod + 4, 1, PAGE_EXECUTE_READWRITE, &oldProtect);
// memset ((char*)skipPod + 4, 0xEB, 1);
// VirtualProtect ((char*)skipPod + 4, 1, oldProtect, &oldProtect);
// g_Logger->Log ("main process#3 - patch success!");
//}
//else {
// g_Logger->Log ("main process#3 - patch failed!");
//}
}
else {
logger->Log ("GetModuleInformation failed!");
g_Logger->Log ("GetModuleInformation failed!");
}

g_Logger->~Logger ();
return 0;
}
2 changes: 1 addition & 1 deletion src/Modify.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#include "stdafx.h"


DWORD WINAPI KillBanner (LPVOID config);
DWORD WINAPI KillBanner (LPVOID);
16 changes: 9 additions & 7 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

extern _getaddrinfo getaddrinfo_orig;


Config g_Config;
Logger *g_Logger = new Logger (&g_Config);

BOOL APIENTRY DllMain (HMODULE hModule,
DWORD ul_reason_for_call, LPVOID lpReserved)
{
Expand All @@ -17,25 +21,23 @@ BOOL APIENTRY DllMain (HMODULE hModule,
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
auto *config = new Config();
if (std::string_view::npos == procname.find ("--type=") && false == config->getConfig("Block_BannerOnly")) {
if (std::string_view::npos == procname.find ("--type=") && false == g_Config.getConfig("Block_BannerOnly")) {
// block ads request - main process
CreateThread (NULL, NULL, KillBanner, config, 0, NULL);
CreateThread (NULL, NULL, KillBanner, NULL, 0, NULL);
//g_Logger.setLogfile ("main_log.txt");
}
else if (std::string_view::npos != procname.find ("--type=utility")) {
// block ads banner by hostname - utility process
//g_Logger.setLogfile ("utility_log.txt");
auto *log = new Logger (config);
getaddrinfo_orig = getaddrinfo;
if (getaddrinfo_orig) {
Mhook_SetHook ((PVOID*)&getaddrinfo_orig, getaddrinfo_hook);
log->Log ("Mhook_SetHook - getaddrinfo success!");
g_Logger->Log ("Mhook_SetHook - getaddrinfo success!");
}
else {
log->Log ("Mhook_SetHook - getaddrinfo failed!");
g_Logger->Log ("Mhook_SetHook - getaddrinfo failed!");
}
log->~Logger ();
g_Logger->~Logger ();
}
break;
}
Expand Down
28 changes: 7 additions & 21 deletions src/hosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
#include "Config.h"
#include "Logger.h"

//extern Logger g_Logger;
//extern Config g_Config;
extern Logger *g_Logger;
extern Config g_Config;

_getaddrinfo getaddrinfo_orig;

auto *config = new Config ();
auto *logger = new Logger (config);
static constexpr std::array<std::string_view, 2> dnscheck = { "dns.google", "cloudflare" };
static constexpr std::array<std::string_view, 4> blockList = { "google", "doubleclick", "qualaroo.com", "fbsbx.com" };
static const bool wpad = config->getConfig ("Skip_wpad");
static constexpr std::array<std::string_view, 5> blockList = { "googletag", "doubleclick", "qualaroo.com",/* "fbsbx.com", */ "dns.google", "cloudflare" };
static const bool wpad = g_Config.getConfig ("Skip_wpad");

// check if ads hostname
bool is_blockhost (std::string_view nodename) {
//static bool wpad = config->getConfig ("Skip_wpad");


if (0 == nodename.compare ("wpad"))
return wpad ? true : false;
for (auto &hostname : blockList) {
Expand Down Expand Up @@ -49,21 +43,13 @@ int WSAAPI getaddrinfo_hook (
auto ipv4 = reinterpret_cast<sockaddr_in*>(ptr->ai_addr);
ipv4->sin_addr.S_un.S_addr = INADDR_ANY;
}
logger->Log ("blocked - " + nnodename);
g_Logger->Log ("blocked - " + nnodename);
}
else {
logger->Log ("allowed - " + nnodename);
}
}
if (true == logger->is_active() &&
true == wpad)
{
for (auto &hostname : dnscheck) {
if (std::string_view::npos != nnodename.find (hostname))
logger->Log ("custom dns currently in use - " + nnodename +
" turn on Skip_wpad in config.ini or switch to adguard dns");
g_Logger->Log ("allowed - " + nnodename);
}
}

return result;
}

0 comments on commit b9dc225

Please sign in to comment.