├── .gitignore ├── CryptMyRepl └── __main__.py ├── LICENSE ├── README.md ├── pyproject.toml ├── setup.py └── test.py /.gitignore: -------------------------------------------------------------------------------- 1 | /__pycache__ 2 | *.txt 3 | *.pyc 4 | *.md 5 | -------------------------------------------------------------------------------- /CryptMyRepl/__main__.py: -------------------------------------------------------------------------------- 1 | import os 2 | from shutil import rmtree 3 | from sys import argv 4 | import random 5 | from base64 import b64encode 6 | from zlib import compress 7 | os.system('') 8 | 9 | 10 | def encrypt(stream: bytes) -> tuple[bytes, bytes]: 11 | key = bytes(random.choices(range(255 + 1), k = len(stream))) 12 | return bytes(kc ^ sc for kc, sc in zip(key, stream)), key 13 | 14 | 15 | ansi_esc = u'\u001b' 16 | rgb = lambda r, g, b: f'{ansi_esc}[38;2;%s;%s;%sm' % (r, g, b) 17 | reset = f'{ansi_esc}[0m' 18 | 19 | red = rgb(255, 75, 75) 20 | blue = rgb(75, 75, 255) 21 | green = rgb(0, 255, 0) 22 | 23 | 24 | comments = ''' 25 | This repl is now private, and the source is not visible. 26 | Any user that want to see files of the repl will be blocked by the cryption 27 | 28 | ║ The key is private and if you dont, you need to add repl environ 29 | ╚═> with the key in key.txt of your files generated by CryptMyRepl 30 | 31 | you can delete these comments and CryptMyRepl generated files has no license! 32 | 33 | ║ CryptMyRepl 34 | ║ by BlueRed 35 | ║ - https://github.com/CSM-BlueRed/CryptMyRepl 36 | ╚═> 37 | '''[1:-1] 38 | 39 | 40 | if __name__ == '__main__': 41 | if len(argv) < 2: 42 | print(f'{red}you need to specify a file in the first command argv{reset}') 43 | raise SystemExit 44 | 45 | file = argv[1] 46 | 47 | if not os.path.isfile(file): 48 | print(f'{red}the file {green}{file}{red} doesnt exist{reset}') 49 | raise SystemExit 50 | 51 | if os.path.isdir('repl'): 52 | rmtree('repl') 53 | 54 | elif os.path.isfile('repl'): 55 | os.remove('repl') 56 | 57 | os.mkdir('repl') 58 | 59 | crypted, key = encrypt(open(file, 'rb').read()) 60 | readable_key = b64encode(compress(key)).decode() 61 | 62 | crypt_my_repl_class = r''' 63 | class CryptMyRepl: 64 | key = key 65 | stream = stream 66 | '''[1:-1] 67 | 68 | script = [ 69 | '\n'.join(f'# {comment}' for comment in comments.splitlines()) + '\n', 70 | r'''import os, base64, zlib''', 71 | r'''key: bytes = zlib.decompress(base64.b64decode(os.getenv('CRYPTIONKEY').encode()))''', 72 | r'''stream: bytes = zlib.decompress({!r})'''.format(compress(crypted)) + '\n', 73 | crypt_my_repl_class, 74 | r'''exec(bytes(kc ^ sc for kc, sc in zip(key, stream)), {'CryptMyReplClass': CryptMyRepl})''' 75 | ] 76 | 77 | script = '\n'.join(script) 78 | final = './repl/main.py' 79 | final = os.path.abspath(final) 80 | 81 | with open(final, 'w', encoding = 'utf-8') as f: 82 | f.write(script) 83 | 84 | final = os.path.normpath(final) 85 | for item in ('\\:.'): 86 | final = final.replace(item, f'{reset}{item}{green}') 87 | 88 | key_path = './repl/key.txt' 89 | 90 | with open(key_path, 'w', encoding = 'utf-8') as f: 91 | f.write(readable_key) 92 | 93 | for item in ('./'): 94 | key_path = key_path.replace(item, f'{reset}{item}{green}') 95 | 96 | print(f'finished! Your private script is located in {green}{final}{reset}!') 97 | print(f'now, create tour repl, and add a env key {green}CRYPTIONKEY{reset}, copy the key in {green}{key_path}{reset} and paste it as the value') -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 BlueRed 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CryptMyRepl 2 | CryptMyRepl is a command-line tool to make your [repl](https://replit.com/~) private. 3 | Any user that want to see files of the repl will be blocked by the cryption. 4 | > by BlueRed 5 | > made with 6 | > 7 | > ![](https://skillicons.dev/icons?i=py,vscode) 8 | 9 | ## Previews 10 | > usage 11 | ![](https://cdn.discordapp.com/attachments/976509056774705252/1015652943682359367/code.png) 12 | 13 | > setup 14 | ![](https://cdn.discordapp.com/attachments/976509056774705252/1015653266941558824/code.png) 15 | 16 | > final file 17 | ![](https://cdn.discordapp.com/attachments/976509056774705252/1015651929138921523/code.png) 18 | 19 | ## Usage 20 | 21 | ### Setup 22 | To setup **CryptMyRepl**, you need to lauch **setup.py** as administrator in a command line. Make shure that the directory printed is in your Python modules path. 23 | ```batch 24 | python "./setup.py" 25 | ``` 26 | 27 | ### Create a private repl 28 | Execute this command 29 | ```batch 30 | python -m CryptMyRepl "./path/to/your-py-file.py" 31 | ``` 32 | This will create a new directory nammed **repl** on your current path and print a key and a value that you have to place it on the repl environ 33 | ``` 34 | ╔> curernt dir ./ 35 | ║ ╔> repl 36 | ║ ║ main.py // your obfuscated code 37 | ║ ║ key.txt // the cryption key 38 | ``` 39 | KEY NAME: `CRYPTIONKEY` 40 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | name = "CryptMyRepl" 2 | version = "1.0" 3 | description = "A command-line tool to make your repl private." 4 | license = "MIT" 5 | authors = [ 6 | "BlueRed", 7 | ] 8 | 9 | [tool.poetry] 10 | readme = "README.md" 11 | homepage = "https://github.com/CSM-BlueRed/CryptMyRepl" 12 | repository = "https://github.com/CSM-BlueRed/CryptMyRepl" 13 | keywords = ["replit", "obfuscation", "encryption"] 14 | 15 | [tool.poetry.dependencies] 16 | python = "^3.7" -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from site import getsitepackages 2 | from sys import executable 3 | from os.path import normpath, dirname, isdir, join 4 | from os import system 5 | from shutil import copytree, rmtree 6 | 7 | system('') 8 | 9 | module_dirs = getsitepackages() 10 | python_path = dirname(executable) 11 | module_dir = next(dir for dir in module_dirs if python_path in dir and 'site-packages' in dir) 12 | 13 | ansi_esc = u'\u001b' 14 | rgb = lambda r, g, b: f'{ansi_esc}[38;2;%s;%s;%sm' % (r, g, b) 15 | reset = f'{ansi_esc}[0m' 16 | 17 | red = rgb(255, 75, 75) 18 | 19 | cryptMyReplPath = join(module_dir, 'CryptMyRepl') 20 | 21 | try: 22 | copytree('./CryptMyRepl', cryptMyReplPath) 23 | except PermissionError: 24 | print(f'{red}cannot create the folder in Python module dir. Try to launch this file in administrator{reset}') 25 | raise SystemExit(1) 26 | 27 | except FileExistsError: 28 | try: 29 | rmtree(cryptMyReplPath) 30 | except PermissionError: 31 | print(f'{red}cannot create the folder in Python module dir. Try to launch this file in administrator{reset}') 32 | raise SystemExit(1) 33 | 34 | copytree('./CryptMyRepl', cryptMyReplPath) 35 | 36 | if isdir(cryptMyReplPath): 37 | print(f'Success! Stored in {cryptMyReplPath}') -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | # This is a example file 2 | # try to make a private repl with this command: 3 | # --------------------------- 4 | # 5 | # python -m CryptMyRepl "./test.py" 6 | # 7 | # --------------------------- 8 | # follow the instructions and done! 9 | 10 | from typing import Iterable, Iterator, Any 11 | 12 | 13 | 14 | class Infiniterator: 15 | 16 | def __init__(self, iterable: Iterable) -> None: 17 | self.iterable: Iterable = tuple(iterable) 18 | self._index: int = 0 19 | 20 | 21 | def __iter__(self) -> Iterator: 22 | yield from self.iterable 23 | 24 | 25 | def __len__(self) -> int: 26 | return len(self.iterable) 27 | 28 | 29 | def __next__(self) -> Any: 30 | self._index += 1 31 | 32 | if len(self) <= (self._index - 1): 33 | self._index = 1 34 | 35 | n = list(self)[self._index - 1] 36 | return n 37 | 38 | 39 | def seek(self, offset: int) -> None: 40 | if offset >= len(self): 41 | raise ValueError(f'offset cannot be equal or > of len(self)') 42 | self._index = offset 43 | 44 | 45 | def __mod__(self, other: int) -> Iterator: 46 | new = self.__class__(self) 47 | n = [] 48 | 49 | for _ in range(other): 50 | n.append(next(new)) 51 | yield from n 52 | 53 | 54 | 55 | abc: Infiniterator = Infiniterator('ABC') 56 | count: int = 9 57 | new: Iterator = list(abc % 9) 58 | 59 | print(' '.join(new)) 60 | print(' '.join('^' * count)) 61 | print(' '.join('123456789')) 62 | input() --------------------------------------------------------------------------------