turns-00043.parquet:40341
91ef0a5c544e1c852bce028c
turn 2/4gpt-4o-2024-08-06EnglishIndonesia1056 words
degenerate_repetitionAbsentFinal dense release
USER
```
const TelegramBot = require('node-telegram-bot-api');
const axios = require('axios');
// Ganti 'YOUR_BOT_TOKEN' dengan token bot kamu dari BotFather
const BOT_TOKEN = '7546565225:AAFTnt-7u3blye_81XV7UqY4DDwZSD2mzQA';
const bot = new TelegramBot(BOT_TOKEN, { polling: true });
// URL untuk whitelist di Pastebin
const WHITELIST_URL = 'https://pastebin.com/raw/cviCTMq3'; // Ganti dengan URL raw Pastebin Anda
let whitelist = [];
// Simpan state pengguna
const userState = {};
// Fungsi untuk memuat whitelist dari Pastebin
async function loadWhitelist() {
try {
const response = await axios.get(WHITELIST_URL);
console.log("Response from Pastebin:", response.data);
// Pastikan response.data adalah string. Jika tidak, konversikan ke string.
if (typeof response.data === 'string') {
// Pisahkan string berdasarkan newline dan hilangkan spasi
whitelist = response.data.split('\n').map(id => id.trim()).filter(Boolean);
} else if (typeof response.data === 'number') {
// Jika response adalah nomor, konversikan ke string
whitelist = [response.data.toString().trim()];
} else {
throw new Error(`Expected a string or number but got ${typeof response.data}`);
}
console.log("Whitelist loaded:", whitelist);
} catch (error) {
console.error("Error loading whitelist:", error.message);
}
}
// Panggil fungsi loadWhitelist saat bot dimulai
loadWhitelist().catch(console.error);
// Perintah start
bot.onText(/\/start/, (msg) => {
const chatId = msg.chat.id;
bot.sendMessage(chatId, "Halo! Ketik /data untuk mulai ambil data server.");
});
// Perintah data
bot.onText(/\/data/, (msg) => {
const chatId = msg.chat.id;
// Periksa apakah pengguna ada di whitelist
if (!whitelist.includes(chatId.toString())) {
return bot.sendMessage(chatId, "Gak usah sok asik, nyuruh gw kayak kenal aja!");
}
userState[chatId] = {}; // Inisialisasi state pengguna untuk chat ini
bot.sendMessage(chatId, "Tolong kasih tahu IP targetnya:");
});
// Dengar untuk IP target
bot.on('message', async (msg) => {
const chatId = msg.chat.id;
if (userState[chatId] && userState[chatId].ip === undefined) {
userState[chatId].ip = msg.text; // Simpan IP
bot.sendMessage(chatId, "Sekarang, kasih tahu versi (misalnya, 4.7):");
} else if (userState[chatId] && userState[chatId].version === undefined) {
userState[chatId].version = msg.text; // Simpan versi
bot.sendMessage(chatId, "Pilih host:", {
reply_markup: {
inline_keyboard: [
[
{ text: "Host 1", callback_data: "www.growtopia1.com" },
{ text: "Host 2", callback_data: "www.growtopia2.com" }
]
]
}
});
}
});
// Untuk menghandle callback dari tombol inline
bot.on('callback_query', async (callbackQuery) => {
const chatId = callbackQuery.message.chat.id;
// Pastikan userState[chatId] sudah diinisialisasi
if (!userState[chatId]) {
userState[chatId] = {}; // Inisialisasi jika belum ada
}
const host = callbackQuery.data; // Ambil data host dari callback
userState[chatId].host = host; // Simpan host
const { ip, version } = userState[chatId];
// Kirim pesan awal bahwa proses pengambilan data telah dimulai
const initialMessage = await bot.sendMessage(chatId, "Sedang mengumpulkan data...");
try {
const statusMessages = [
"Menghubungi server...",
"Menunggu respons dari server...",
"Memproses data...",
"Data berhasil diambil!"
];
// Fungsi untuk mengupdate status secara berkala
for (let i = 0; i < statusMessages.length; i++) {
await new Promise((resolve) => setTimeout(resolve, 2000)); // Delay 2 detik
await bot.editMessageText(statusMessages[i], {
chat_id: chatId,
message_id: initialMessage.message_id
});
}
// Ambil data server
const response = await getServerData(ip, version, host);
// Kirim data yang diperoleh
await bot.sendMessage(chatId, response);
} catch (error) {
bot.editMessageText(`Error dalam ngambil data: ${error.message}`, {
chat_id: chatId,
message_id: initialMessage.message_id
});
}
// Kosongkan state pengguna
delete userState[chatId];
});
// Fungsi untuk ambil data server
async function getServerData(targetIp, version, host) {
const url = `https://${targetIp}/growtopia/server_data.php`;
const headers = {
"Host": host,
"Accept": "/",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "UbiServices_SDK_2022.Release.9_PC64_ansi_static"
};
const data = new URLSearchParams({
version: version,
platform: '0',
protocol: '210'
});
const agent = new https.Agent({
rejectUnauthorized: false, // Allows self-signed certificates
minVersion: 'TLSv1.3' // Ensure TLSv1.3 is supported
});
const response = await axios.post(url, data, { headers, httpsAgent: agent });
return response.data;
}
// Perintah help
bot.onText(/\/help/, (msg) => {
const chatId = msg.chat.id;
bot.sendMessage(chatId, "Gunakan /data untuk mulai ambil data server. Ikuti petunjuk untuk input IP, versi, dan pilih host.");
});
```
tambahkan command untuk cek targetip menggunakan TLS versi berapaASSISTANT
To add a command that checks which TLS version is supported by a target IP, you'll need to use a library that can handle TLS handshaking, such as Node.js's native `tls` module. This will require a bit of setup to initiate a connection and read the agreed TLS version from the handshake. Here’s how you can do it:
1. You'll first need to create a new bot command to handle the check for the TLS version.
2. Implement the handshake logic to determine the TLS version.
Below is a modified version of your script with a new command `/checktls` added:
```javascript
const TelegramBot = require('node-telegram-bot-api');
const axios = require('axios');
const tls = require('tls');
// Ganti 'YOUR_BOT_TOKEN' dengan token bot kamu dari BotFather
const BOT_TOKEN = 'your-bot-token';
const bot = new TelegramBot(BOT_TOKEN, { polling: true });
// URL untuk whitelist di Pastebin
const WHITELIST_URL = 'https://pastebin.com/raw/cviCTMq3'; // Ganti dengan URL raw Pastebin Anda
let whitelist = [];
// Simpan state pengguna
const userState = {};
// Fungsi untuk memuat whitelist dari Pastebin
async function loadWhitelist() {
try {
const response = await axios.get(WHITELIST_URL);
if (typeof response.data === 'string') {
whitelist = response.data.split('\n').map(id => id.trim()).filter(Boolean);
} else if (typeof response.data === 'number') {
whitelist = [response.data.toString().trim()];
} else {
throw new Error(`Expected a string or number but got ${typeof response.data}`);
}
} catch (error) {
console.error("Error loading whitelist:", error.message);
}
}
// Panggil fungsi loadWhitelist saat bot dimulai
loadWhitelist().catch(console.error);
// Fungsi untuk cek TLS version dari sebuah IP target
function checkTlsVersion(hostname) {
return new Promise((resolve, reject) => {
const options = {
host: hostname,
servername: hostname,
port: 443,
ALPNProtocols: ['http/1.1'], // Protocol negotiation required
};
const socket = tls.connect(options, () => {
const tlsVersion = socket.getCipher().version;
socket.end();
resolve(tlsVersion);
});
socket.on('error', (error) => {
reject(error);
});
});
}
// Perintah checktls
bot.onText(/\/checktls (.+)/, async (msg, match) => {
const chatId = msg.chat.id;
const targetIp = match[1];
try {
const tlsVersion = await checkTlsVersion(targetIp);
bot.sendMessage(chatId, `Target IP ${targetIp} menggunakan TLS version: ${tlsVersion}`);
} catch (error) {
bot.sendMessage(chatId, `Error cek TLS version: ${error.message}`);
}
});
// Perintah start
bot.onText(/\/start/, (msg) => {
const chatId = msg.chat.id;
bot.sendMessage(chatId, "Halo! Ketik /data untuk mulai ambil data server.");
});
// Perintah lain di sini (tidak diubah)
```
### Explanation
- **checkTlsVersion Function**: This function uses the `tls.connect()` method to attempt a TLS connection to the target IP and port 443 (default for HTTPS). It then retrieves the TLS version from the established connection using `socket.getCipher().version`.
- **/checktls Command**: It extracts the target IP from the message and calls `checkTlsVersion()`, then sends the TLS version back to the user.
This solution provides a basic way to check the TLS version supported by the target IP/server. Adjustments can be made based on your server's API and security requirements.