Add certificate name
This commit is contained in:
parent
9b5b2af214
commit
6efd72cf51
@ -29,39 +29,75 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCertificate));
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.textBox1 = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// richTextBox1
|
||||
// groupBox1
|
||||
//
|
||||
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.richTextBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.richTextBox1.Location = new System.Drawing.Point(0, 0);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.ReadOnly = true;
|
||||
this.richTextBox1.Size = new System.Drawing.Size(565, 146);
|
||||
this.richTextBox1.TabIndex = 0;
|
||||
this.richTextBox1.Text = " \n Certificate is not found.\n Creating a new certificate... Please wait...";
|
||||
this.groupBox1.Controls.Add(this.button1);
|
||||
this.groupBox1.Controls.Add(this.textBox1);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(579, 189);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "New Certificate";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(11, 129);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(149, 39);
|
||||
this.button1.TabIndex = 2;
|
||||
this.button1.Text = "Ok";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.Button1_Click);
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
this.textBox1.Location = new System.Drawing.Point(191, 49);
|
||||
this.textBox1.Name = "textBox1";
|
||||
this.textBox1.Size = new System.Drawing.Size(325, 26);
|
||||
this.textBox1.TabIndex = 1;
|
||||
this.textBox1.Text = "AsyncRAT Server";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(7, 49);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(132, 20);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "-Certificate Name";
|
||||
//
|
||||
// FormCertificate
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(565, 146);
|
||||
this.ClientSize = new System.Drawing.Size(603, 213);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.richTextBox1);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "FormCertificate";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Certificate";
|
||||
this.Load += new System.EventHandler(this.FormCertificate_Load);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
}
|
||||
}
|
@ -24,9 +24,7 @@ namespace AsyncRAT_Sharp.Forms
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void FormCertificate_Load(object sender, EventArgs e)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
private void FormCertificate_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -36,26 +34,13 @@ namespace AsyncRAT_Sharp.Forms
|
||||
MessageBox.Show(this, "Found a zip backup, Extracting (BackupCertificate.zip)", "Certificate backup", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
ZipFile.ExtractToDirectory(backup, Application.StartupPath);
|
||||
Settings.ServerCertificate = new X509Certificate2(Settings.CertificatePath);
|
||||
return;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
Settings.ServerCertificate = CreateCertificateAuthority("AsyncRAT Server CA", 4096);
|
||||
File.WriteAllBytes(Settings.CertificatePath, Settings.ServerCertificate.Export(X509ContentType.Pkcs12));
|
||||
|
||||
using (ZipArchive archive = ZipFile.Open(backup, ZipArchiveMode.Create))
|
||||
{
|
||||
archive.CreateEntryFromFile(Settings.CertificatePath, Path.GetFileName(Settings.CertificatePath));
|
||||
}
|
||||
MessageBox.Show(this, "Created a ZIP backup (BackupCertificate.zip)", "Certificate backup", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(this, ex.Message, "Certificate", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
});
|
||||
this.Close();
|
||||
}
|
||||
|
||||
public static X509Certificate2 CreateCertificate(string certName, X509Certificate2 ca, int keyStrength)
|
||||
@ -124,5 +109,34 @@ namespace AsyncRAT_Sharp.Forms
|
||||
|
||||
return certificate2;
|
||||
}
|
||||
|
||||
private void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBox1.Text)) return;
|
||||
|
||||
button1.Text = "Please wait";
|
||||
button1.Enabled = false;
|
||||
|
||||
string backup = Application.StartupPath + "\\BackupCertificate.zip";
|
||||
Settings.ServerCertificate = CreateCertificateAuthority(textBox1.Text, 4096);
|
||||
File.WriteAllBytes(Settings.CertificatePath, Settings.ServerCertificate.Export(X509ContentType.Pkcs12));
|
||||
|
||||
using (ZipArchive archive = ZipFile.Open(backup, ZipArchiveMode.Create))
|
||||
{
|
||||
archive.CreateEntryFromFile(Settings.CertificatePath, Path.GetFileName(Settings.CertificatePath));
|
||||
}
|
||||
MessageBox.Show(this, "Created a ZIP backup (BackupCertificate.zip)", "Certificate backup", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MessageBox.Show(this, "If you want to use an updated version of AsyncRAT, remember to copy+paste your certificate", "Certificate backup", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
this.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(this, ex.Message, "Certificate", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
button1.Text = "Ok";
|
||||
button1.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user