using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace WeAreDevsWinForms
{
public partial class Form1 : Form
{
[DllImport("kernel32.dll")]
static extern bool AllocConsole();
[DllImport("wearedevs_exploit_api.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern byte initialize();
[DllImport("wearedevs_exploit_api.dll", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool isAttached();
[DllImport("wearedevs_exploit_api.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void execute([MarshalAs(UnmanagedType.LPStr)] string script);
private System.Windows.Forms.Timer timerAttachChecker;
private Button btnExecute;
private TextBox txtScript;
private Label labelStatus;
public Form1()
{
InitializeComponent();
AllocConsole();
try
{
var initResult = initialize();
Console.WriteLine($"WeAreDevs API initialized with status code: {initResult}");
}
catch (Exception ex)
{
MessageBox.Show($"Failed to initialize WeAreDevs API: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
timerAttachChecker.Start();
}
private void InitializeComponent()
{
btnExecute = new Button();
txtScript = new TextBox();
labelStatus = new Label();
timerAttachChecker = new System.Windows.Forms.Timer();
btnExecute.Location = new Point(12, 220);
btnExecute.Size = new Size(260, 30);
btnExecute.Text = "Execute Script";
btnExecute.Click += BtnExecute_Click;
txtScript.Location = new Point(12, 12);
txtScript.Size = new Size(260, 200);
txtScript.Multiline = true;
txtScript.ScrollBars = ScrollBars.Vertical;
labelStatus.Location = new Point(12, 260);
labelStatus.AutoSize = true;
labelStatus.Text = "Status: Not attached";
labelStatus.ForeColor = Color.Red;
timerAttachChecker.Interval = 1000;
timerAttachChecker.Tick += TimerAttachChecker_Tick;
ClientSize = new Size(284, 290);
Controls.Add(btnExecute);
Controls.Add(txtScript);
Controls.Add(labelStatus);
Text = "WeAreDevs API";
}
private void BtnExecute_Click(object? sender, EventArgs e)
{
try
{
execute(txtScript.Text);
Console.WriteLine("Script executed.");
}
catch (Exception ex)
{
MessageBox.Show($"Failed to execute script: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void TimerAttachChecker_Tick(object? sender, EventArgs e)
{
try
{
bool attached = isAttached();
if (attached)
{
labelStatus.Text = "Status: Attached";
labelStatus.ForeColor = Color.Green;
}
else
{
labelStatus.Text = "Status: Not attached";
labelStatus.ForeColor = Color.Red;
}
}
catch (Exception ex)
{
labelStatus.Text = "Status: Error";
labelStatus.ForeColor = Color.OrangeRed;
Console.WriteLine($"Error checking attachment: {ex.Message}");
}
}
}
}