Skip to content

Instantly share code, notes, and snippets.

@pardo
Last active February 18, 2020 01:45
Show Gist options
  • Save pardo/e800bad7ca9850e055485174dfed3266 to your computer and use it in GitHub Desktop.
Save pardo/e800bad7ca9850e055485174dfed3266 to your computer and use it in GitHub Desktop.
#!/snap/bin/fades
import logging
from functools import wraps
from IPython import embed # fades
import sh # fades
import sys
import os
import stat
import datetime
from telegram import ( # fades python-telegram-bot
ReplyKeyboardMarkup,
ReplyKeyboardRemove
)
from telegram.ext import (
Updater,
CommandHandler,
MessageHandler,
Filters,
ConversationHandler
)
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger()
logger.setLevel(logging.INFO)
TOKEN = "1060213591:AAFs8cZDLYNC2CvuFkFk41hULBSmWyPAAQU"
# TOKEN = "207568259:AAGsuV6VfyzkPUmRRt47xe1w-5JrbTH-iTY"
logged_in = set()
# https://github.com/elisescu/tty-share/files/4048523/tty-share.lin.zip
# Crontab install
# echo "*/5 * * * * [ \$(ps ax | grep rat.py | grep -v grep | wc -l) -gt 0 ] || /root/rat.py" | crontab -
def secure(func):
@wraps(func)
def wrapper(bot, update):
if update.message.from_user.id not in logged_in:
update.message.reply_text(
'Decime la contraseña que te dijo pardo que me digas, sino andate'
)
return
return func(bot, update)
return wrapper
def login_store(bot, update):
logged_in.add(update.message.from_user.id)
update.message.reply_text(
'No podría esperar menos de mí.'
)
@secure
def update_bot(bot, update):
def process_output(line):
try:
update.message.reply_text(line)
except Exception:
pass
update.message.reply_text("Starting")
# wget -O /root/rat.py https://gist.githubusercontent.com/pardo/e800bad7ca9850e055485174dfed3266/raw/
sh.Command("wget")("-O", "/root/rat.py", "https://gist.githubusercontent.com/pardo/e800bad7ca9850e055485174dfed3266/raw/", _out=process_output)
os.chmod("/root/rat.py", 0o770)
update.message.reply_text("Downloaded going to kill myself try /ping to see if up")
sh.Command("bash")("-c", 'ps ax -o ppid:1,cmd | grep rat.py | grep -v grep | cut -d " " -f 1 | xargs -L 1 kill')
# bash -c 'ps ax -o ppid:1,cmd | grep rat.py | grep -v grep | cut -d " " -f 1 | xargs -L 1 kill'
def ping(bot, update):
update.message.reply_text(f"Pong {datetime.datetime.now()}")
@secure
def secret_shell(bot, update):
def process_output(line):
try:
update.message.reply_text(line)
if "Web termina" in line:
return True
except Exception:
pass
update.message.reply_text("Starting")
sh.Command("./tty-share.lin")(_out=process_output, _bg=True)
def main():
# Create the Updater and pass it your bot's token.
# Make sure to set use_context=True to use the new context based callbacks
# Post version 12 this will no longer be necessary
updater = Updater(TOKEN)
# Get the dispatcher to register handlers
dp = updater.dispatcher
dp.add_handler(CommandHandler('secret', secret_shell))
dp.add_handler(CommandHandler('update', update_bot))
dp.add_handler(CommandHandler('ping', ping))
dp.add_handler(MessageHandler(
Filters.regex('^pardo login$'), login_store)
)
# Start the Bot
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment