-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CryptMeBot.php
166 lines (162 loc) · 8.06 KB
/
CryptMeBot.php
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
<?php
error_reporting(0);
set_time_limit(0);
ob_start();
$channel = "iNeoTeam";
$api = "https://api.ineo-team.ir";
if(!file_exists("iTelegram.php")){
copy('https://raw.githubusercontent.com/iNeoTeam/iTelegram/main/iTelegram.php', 'iTelegram.php');
}
if(!file_exists("CryptMe.php")){
copy('https://raw.githubusercontent.com/iNeoTeam/CryptMe/main/CryptMe.php', 'CryptMe.php');
}
if(!file_exists("redirector.php")){
copy($api."/redirector.txt", "redirector.php");
}
require_once('iTelegram.php');
require_once('CryptMe.php');
use iTelegram\Bot;
define('API_KEY', "YOUR-TELEGRAM-BOT-TOKEN");
$bot = new Bot();
$crypt = new CryptMe();
$bot->Authentification(API_KEY);
$text = $bot->Text();
$update = $bot->getUpdate();
$chat_id = $bot->getChatId();
$username = $bot->getChatUsername();
$firstname = $bot->getChatFirstname();
$message_id = $bot->MessageId();
$chatID = $bot->getInlineChatId();
$messageID = $bot->InlineMessageId();
$data = $update['callback_query']['data'];
$sign = "➖➖➖➖➖➖➖➖\n📣 @$channel";
if(!file_exists("index.php")){ copy("redirector.php", "index.php"); }
if(!file_exists("data/index.php")){
mkdir("data"); copy("redirector.php", "data/index.php");
}
if(!file_exists("codes/index.php")){
mkdir("codes"); copy("redirector.php", "codes/index.php");
}
if(!file_exists("data/$chat_id/index.php")){
mkdir("data/$chat_id"); copy("redirector.php", "data/$chat_id/index.php");
}
if($text == "/start"){
$message = "🖐<b>Hello <a href='tg://user?id=$chat_id'>$firstname</a> :D</b>
✏️Please send me a text message for EnCrypt or DeCrypt :D. <a href='https://t.me/iNeoTeam/201'>[Read More]</a>
🌀<b>Bot Source Code:</b> <a href='https://github.com/iNeoTeam/TelegramBots/blob/main/CryptMeBot.php'>Download</a>
🔐<b>CryptMe GitHub:</b> <a href='https://github.com/iNeoTeam/CryptMe'>iNeoTeam/CryptMe</a>\n$sign";
$r = $bot->sendMessage($chat_id, $message, "HTML", true);
###########################################################################
###########################################################################
}elseif(strpos($text, "/setpass") !== false){
$password = str_replace(array("/setpass", " "), null, $text);
$count = strlen($password);
$bot->deleteMessage($chat_id, $message_id);
if($password != null && $count >= 8 and $count <= 32){
$message = "✅<b>Set Password Successfully.</b>\n\n🔓<b>Delete Password:</b> /delpass\n$sign";
file_put_contents("data/$chat_id/cmepass.cme", $crypt->encode($password));
}else{
$message = "❌<b>Error occurred data.</b>
• The password may be empty.
• The password may not be between 8 to 32 characters.
⚙️<b>Example Set Password:</b>\n🔨<code>/setpass MY_PASSWORD</code>\n$sign";
}
$bot->sendMessage($chat_id, $message, "HTML", true, null, null);
###########################################################################
###########################################################################
}elseif($text == "/mypass"){
if(file_exists("data/$chat_id/cmepass.cme")){
$password = $crypt->decode(file_get_contents("data/$chat_id/cmepass.cme"));
$message = "✅<b>Your password DeCrypted.</b>\n\n🔐<b>Password:</b> <tg-spoiler>$password</tg-spoiler>\n$sign";
}else{
$message = "❗️<b>Your service does not have a password.</b>\n$sign";
}
$bot->sendMessage($chat_id, $message, "HTML", true, $message_id, null);
###########################################################################
###########################################################################
}elseif($text == "/delpass"){
if(file_exists("data/$chat_id/cmepass.cme")){
unlink("data/$chat_id/cmepass.cme");
$message = "✅<b>Your service password has been removed.</b>\n\n🔐<b>Set Password:</b> /setpass\n$sign";
}else{
$message = "❗️<b>Your service does not have a password.</b>\n$sign";
}
$bot->sendMessage($chat_id, $message, "HTML", true, $message_id, null);
###########################################################################
###########################################################################
}elseif(strpos($data, "decrypt_") !== false){
$code = str_replace("decrypt_", null, $data);
$password = null;
if(file_exists("data/$chatID/cmepass.cme")){
$password = $crypt->decode(file_get_contents("data/$chatID/cmepass.cme"));
}
$base64 = file_get_contents("codes/$code.cme");
$decrypt = $crypt->decode(base64_decode($base64), $password);
if($decrypt == "fail" or $decrypt == null){
$message = "❗️<b>Ooooppss, can't decrypt this text :(</b>\n$sign";
$bot->editMessage($chatID, $messageID, $message, "HTML", true, null);
exit;
}
$pass = "Without Password.";
if($password != null){ $pass = "<tg-spoiler>$password</tg-spoiler>"; }
unlink("codes/$code.cme");
if(strlen($decrypt) >= 300){
file_put_contents("codes/DeCrypted-$code-[CryptMe].cme", $decrypt);
$bot->deleteMessage($chatID, $messageID);
$message = "✅<b>DeCrypted text is long and is sent as a file.</b>\n🔢<b>Code:</b> <code>$code</code>\n🔐<b>Password:</b> $pass\n$sign";
$bot->sendDocument($chatID, new CURLFILE(realpath("codes/DeCrypted-$code-[CryptMe].cme")), $message, null, "HTML", null, null, null);
unlink("codes/DeCrypted-$code-[CryptMe].cme");
}else{
$message = "✅<b>Your text message DeCrypted!</b>\n🔢<b>Code:</b> <code>$code</code>\n🔐<b>Password:</b> $pass\n\n⚙️<b>DeCrypted Text:</b> <code>$decrypt</code>\n$sign";
$bot->editMessage($chatID, $messageID, $message, "HTML", true, null);
}
###########################################################################
###########################################################################
}elseif(strpos($data, "encrypt_") !== false){
$code = str_replace("encrypt_", null, $data);
$password = null;
if(file_exists("data/$chatID/cmepass.cme")){
$password = $crypt->decode(file_get_contents("data/$chatID/cmepass.cme"));
}
$base64 = file_get_contents("codes/$code.cme");
$encrypt = $crypt->encode(base64_decode($base64), $password);
if($encrypt == "fail" or $encrypt == null){
$message = "❗️<b>Ooooppss, can't encrypt this text :(</b>\n$sign";
$bot->editMessage($chatID, $messageID, $message, "HTML", true, null);
exit;
}
$pass = "Without Password.";
if($password != null){ $pass = "<tg-spoiler>$password</tg-spoiler>"; }
unlink("codes/$code.cme");
if(strlen($encrypt) >= 300){
file_put_contents("codes/EnCrypted-$code-[CryptMe].cme", $encrypt);
$bot->deleteMessage($chatID, $messageID);
$message = "✅<b>EnCrypted text is long and is sent as a file.</b>\n🔢<b>Code:</b> <code>$code</code>\n🔐<b>Password:</b> $pass\n$sign";
$bot->sendDocument($chatID, new CURLFILE(realpath("codes/EnCrypted-$code-[CryptMe].cme")), $message, null, "HTML", null, null, null);
unlink("codes/EnCrypted-$code-[CryptMe].cme");
}else{
$message = "✅<b>Your text message EnCrypted!</b>\n🔢<b>Code:</b> <code>$code</code>\n🔐<b>Password:</b> $pass\n\n⚙️<b>EnCrypted Text:</b> <code>$encrypt</code>\n$sign";
$bot->editMessage($chatID, $messageID, $message, "HTML", true, null);
}
###########################################################################
###########################################################################
}elseif(isset($text)){
$bot->deleteMessage($chat_id, $message_id);
$code = rand(10000, 99999);
$base64 = base64_encode($text);
file_put_contents("codes/$code.cme", $base64);
$message = "✅<b>Ok, your text was saved !</b>\n🔢<b>Code:</b> <code>$code</code>\n\n🖥What do you want to do with this text?\n$sign";
$button = json_encode(['inline_keyboard' => [
[['text' => "🔐EnCrypt", 'callback_data' => "encrypt_".$code], ['text' => "🔓DeCrypt", 'callback_data' => "decrypt_".$code]],
]]);
$bot->sendMessage($chat_id, $message, "HTML", true, null, $button);
###########################################################################
###########################################################################
}else{
$message = "❌<b>Command not found :(</b>\n$sign";
$bot->sendMessage($chat_id, $message, "HTML", true, $message_id, null);
###########################################################################
###########################################################################
}
unlink("error_log");
?>