Skip to content

Commit

Permalink
Fix black banner
Browse files Browse the repository at this point in the history
  • Loading branch information
iostream authored and iostream committed Apr 23, 2020
1 parent f39caef commit c7f02e2
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 16 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ set Skip_wpad in config.ini to 1 may help.
* if automatic install/uninstall .bat not working please contact (https://github.com/rednek46)

#### Known Issues and Caveats:
* If you can't login set Fix_Black_Banner to 0 in config.ini and turn it back on later.
* False positive - Windows Defender and other product.
0. Not recommended to do whitelist in antivirus software.
1. Do Windows Update/Patch.
Expand Down
5 changes: 1 addition & 4 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
;Log system
Log = 0
;skip proxy
Skip_wpad = 0
;Fix black banner in playlist, if you can't login
;set it to 0 first
Fix_Black_Banner = 1;
Skip_wpad = 0
2 changes: 2 additions & 0 deletions src/BlockTheSpot.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<ItemGroup>
<ClInclude Include="HookApi.h" />
<ClInclude Include="hosts.h" />
<ClInclude Include="Modify.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
Expand All @@ -117,6 +118,7 @@
<ClCompile Include="BlockTheSpot.cpp" />
<ClCompile Include="HookApi.cpp" />
<ClCompile Include="hosts.cpp" />
<ClCompile Include="Modify.cpp" />
<ClCompile Include="stdafx.cpp" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/BlockTheSpot.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Filter>hookapi</Filter>
</ClCompile>
<ClCompile Include="hosts.cpp" />
<ClCompile Include="Modify.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
Expand All @@ -17,6 +18,7 @@
</ClInclude>
<ClInclude Include="hosts.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="Modify.h" />
</ItemGroup>
<ItemGroup>
<None Include="chrome_elf.def" />
Expand Down
50 changes: 50 additions & 0 deletions src/Modify.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "stdafx.h"

// https://www.unknowncheats.me/forum/1064672-post23.html
bool DataCompare (BYTE* pData, BYTE* bSig, char* szMask)
{
for (; *szMask; ++szMask, ++pData, ++bSig)
{
if (*szMask == 'x' && *pData != *bSig)
return false;
}
return (*szMask) == NULL;
}

BYTE* FindPattern (BYTE* dwAddress, DWORD dwSize, BYTE* pbSig, char* szMask)
{
DWORD length = strlen (szMask);
for (DWORD i = NULL; i < dwSize - length; i++)
{
__try
{
if (DataCompare (dwAddress + i, pbSig, szMask))
return dwAddress + i;
}
__except (EXCEPTION_EXECUTE_HANDLER) {
return nullptr;
}
}
return 0;
}

DWORD WINAPI KillBanner (LPVOID)
{
HMODULE hModule = GetModuleHandle (NULL);
MODULEINFO mInfo = { 0 };
if (GetModuleInformation (GetCurrentProcess (), hModule, &mInfo, sizeof (MODULEINFO))) {

LPVOID skipPod = FindPattern ((uint8_t*)hModule, mInfo.SizeOfImage,
(BYTE*)"\x84\xC0\x0F\x85\xA4\x00\x00\x00\x6A\x0D", "xxxxxxxxxx");

if (skipPod)
{
DWORD oldProtect;
VirtualProtect ((char*)skipPod + 2, 6, PAGE_EXECUTE_READWRITE, &oldProtect);
memset ((char*)skipPod + 2, 0x90, 6);
VirtualProtect ((char*)skipPod + 2, 6, oldProtect, &oldProtect);
}

}
return 0;
}
7 changes: 7 additions & 0 deletions src/Modify.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

bool DataCompare (BYTE* pData, BYTE* bSig, char* szMask);

BYTE* FindPattern (BYTE* dwAddress, DWORD dwSize, BYTE* pbSig, char* szMask);

DWORD WINAPI KillBanner (LPVOID);
6 changes: 2 additions & 4 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,18 @@ BOOL APIENTRY DllMain (HMODULE hModule,
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
// block ads request - main process
if (std::string::npos == procname.find ("--type=")) {
// block ads request - main process
InstallHookApi ("Winhttp.dll", "WinHttpOpenRequest", winhttpopenrequesthook);
CreateThread (NULL, NULL, KillBanner, NULL, 0, NULL);
init_log ("main_log.txt");

}
else if (std::string::npos != procname.find ("--type=utility")) {
// block ads banner by hostname - utility process
InstallHookApi ("ws2_32.dll", "getaddrinfo", getaddrinfohook);
init_log ("utility_log.txt");
if (1 == GetPrivateProfileInt ("Config", "Skip_wpad", 0, configFile))
g_skip_wpad = true;
if (1 == GetPrivateProfileInt ("Config", "Fix_Black_Banner", 0, configFile))
g_fix_blackbanner = true;
}
break;
case DLL_PROCESS_DETACH:
Expand Down
7 changes: 1 addition & 6 deletions src/hosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

// Web Proxy Auto-Discovery (WPAD)
bool g_skip_wpad = false;
// Black banner fix
bool g_fix_blackbanner = false;

// Logging system
std::wofstream logging;

Expand All @@ -21,9 +18,7 @@ bool is_blockhost (const char* nodename) {
return true;
if (std::string::npos != nnodename.find ("qualaroo.com"))
return true;
if (std::string::npos != nnodename.find ("login")) {
return g_fix_blackbanner ? true : false;
}

return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
// TODO: reference additional headers your program requires here
#include <winsock2.h>
#include <winhttp.h>
#include <Psapi.h>

#include <fstream>
#include <future>

#include "HookApi.h"
#include "hosts.h"

#include "Modify.h"



0 comments on commit c7f02e2

Please sign in to comment.