Multi-Cast Delegates

Removed a great deal of incredibly-repetitive code by implementing
multi-cast delegates to handle a changed setting.
This commit is contained in:
yankejustin 2015-06-01 00:04:09 -04:00
parent 3f39d86d47
commit b9c6caa95d
2 changed files with 36 additions and 140 deletions

View File

@ -131,7 +131,7 @@
this.txtDelay.Size = new System.Drawing.Size(66, 22); this.txtDelay.Size = new System.Drawing.Size(66, 22);
this.txtDelay.TabIndex = 8; this.txtDelay.TabIndex = 8;
this.txtDelay.Text = "5000"; this.txtDelay.Text = "5000";
this.txtDelay.TextChanged += new System.EventHandler(this.txtDelay_TextChanged); this.txtDelay.TextChanged += new System.EventHandler(this.HasChangedSetting);
this.txtDelay.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtDelay_KeyPress); this.txtDelay.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtDelay_KeyPress);
// //
// lblDelay // lblDelay
@ -161,7 +161,7 @@
this.txtPassword.PasswordChar = '•'; this.txtPassword.PasswordChar = '•';
this.txtPassword.Size = new System.Drawing.Size(201, 22); this.txtPassword.Size = new System.Drawing.Size(201, 22);
this.txtPassword.TabIndex = 5; this.txtPassword.TabIndex = 5;
this.txtPassword.TextChanged += new System.EventHandler(this.txtPassword_TextChanged); this.txtPassword.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblPassword // lblPassword
// //
@ -179,7 +179,7 @@
this.txtPort.Name = "txtPort"; this.txtPort.Name = "txtPort";
this.txtPort.Size = new System.Drawing.Size(66, 22); this.txtPort.Size = new System.Drawing.Size(66, 22);
this.txtPort.TabIndex = 3; this.txtPort.TabIndex = 3;
this.txtPort.TextChanged += new System.EventHandler(this.txtPort_TextChanged); this.txtPort.TextChanged += new System.EventHandler(this.HasChangedSetting);
this.txtPort.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPort_KeyPress); this.txtPort.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPort_KeyPress);
// //
// lblPort // lblPort
@ -197,7 +197,7 @@
this.txtHost.Name = "txtHost"; this.txtHost.Name = "txtHost";
this.txtHost.Size = new System.Drawing.Size(201, 22); this.txtHost.Size = new System.Drawing.Size(201, 22);
this.txtHost.TabIndex = 1; this.txtHost.TabIndex = 1;
this.txtHost.TextChanged += new System.EventHandler(this.txtHost_TextChanged); this.txtHost.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblHost // lblHost
// //
@ -271,7 +271,7 @@
this.rbSystem.Text = "System"; this.rbSystem.Text = "System";
this.tooltip.SetToolTip(this.rbSystem, "Administrator Privileges are required to install the client in System."); this.tooltip.SetToolTip(this.rbSystem, "Administrator Privileges are required to install the client in System.");
this.rbSystem.UseVisualStyleBackColor = true; this.rbSystem.UseVisualStyleBackColor = true;
this.rbSystem.CheckedChanged += new System.EventHandler(this.rbSystem_CheckedChanged); this.rbSystem.CheckedChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
// //
// rbProgramFiles // rbProgramFiles
// //
@ -284,7 +284,7 @@
this.rbProgramFiles.Text = "Program Files"; this.rbProgramFiles.Text = "Program Files";
this.tooltip.SetToolTip(this.rbProgramFiles, "Administrator Privileges are required to install the client in Program Files."); this.tooltip.SetToolTip(this.rbProgramFiles, "Administrator Privileges are required to install the client in Program Files.");
this.rbProgramFiles.UseVisualStyleBackColor = true; this.rbProgramFiles.UseVisualStyleBackColor = true;
this.rbProgramFiles.CheckedChanged += new System.EventHandler(this.rbProgramFiles_CheckedChanged); this.rbProgramFiles.CheckedChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
// //
// txtRegistryKeyName // txtRegistryKeyName
// //
@ -292,7 +292,7 @@
this.txtRegistryKeyName.Name = "txtRegistryKeyName"; this.txtRegistryKeyName.Name = "txtRegistryKeyName";
this.txtRegistryKeyName.Size = new System.Drawing.Size(201, 22); this.txtRegistryKeyName.Size = new System.Drawing.Size(201, 22);
this.txtRegistryKeyName.TabIndex = 18; this.txtRegistryKeyName.TabIndex = 18;
this.txtRegistryKeyName.TextChanged += new System.EventHandler(this.txtRegistryKeyName_TextChanged); this.txtRegistryKeyName.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblRegistryKeyName // lblRegistryKeyName
// //
@ -323,7 +323,7 @@
this.chkHide.TabIndex = 15; this.chkHide.TabIndex = 15;
this.chkHide.Text = "Hide File"; this.chkHide.Text = "Hide File";
this.chkHide.UseVisualStyleBackColor = true; this.chkHide.UseVisualStyleBackColor = true;
this.chkHide.CheckedChanged += new System.EventHandler(this.chkHide_CheckedChanged); this.chkHide.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
// //
// btnMutex // btnMutex
// //
@ -359,7 +359,7 @@
this.txtInstallsub.Name = "txtInstallsub"; this.txtInstallsub.Name = "txtInstallsub";
this.txtInstallsub.Size = new System.Drawing.Size(201, 22); this.txtInstallsub.Size = new System.Drawing.Size(201, 22);
this.txtInstallsub.TabIndex = 12; this.txtInstallsub.TabIndex = 12;
this.txtInstallsub.TextChanged += new System.EventHandler(this.txtInstallsub_TextChanged); this.txtInstallsub.TextChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
this.txtInstallsub.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInstallsub_KeyPress); this.txtInstallsub.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInstallsub_KeyPress);
// //
// lblInstallsub // lblInstallsub
@ -391,7 +391,7 @@
this.rbAppdata.TabStop = true; this.rbAppdata.TabStop = true;
this.rbAppdata.Text = "Application Data"; this.rbAppdata.Text = "Application Data";
this.rbAppdata.UseVisualStyleBackColor = true; this.rbAppdata.UseVisualStyleBackColor = true;
this.rbAppdata.CheckedChanged += new System.EventHandler(this.rbAppdata_CheckedChanged); this.rbAppdata.CheckedChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
// //
// txtMutex // txtMutex
// //
@ -400,7 +400,7 @@
this.txtMutex.Name = "txtMutex"; this.txtMutex.Name = "txtMutex";
this.txtMutex.Size = new System.Drawing.Size(201, 22); this.txtMutex.Size = new System.Drawing.Size(201, 22);
this.txtMutex.TabIndex = 1; this.txtMutex.TabIndex = 1;
this.txtMutex.TextChanged += new System.EventHandler(this.txtMutex_TextChanged); this.txtMutex.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblMutex // lblMutex
// //
@ -426,7 +426,7 @@
this.txtInstallname.Name = "txtInstallname"; this.txtInstallname.Name = "txtInstallname";
this.txtInstallname.Size = new System.Drawing.Size(168, 22); this.txtInstallname.Size = new System.Drawing.Size(168, 22);
this.txtInstallname.TabIndex = 5; this.txtInstallname.TabIndex = 5;
this.txtInstallname.TextChanged += new System.EventHandler(this.txtInstallname_TextChanged); this.txtInstallname.TextChanged += new System.EventHandler(this.HasChangedSettingAndFilePath);
this.txtInstallname.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInstallname_KeyPress); this.txtInstallname.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtInstallname_KeyPress);
// //
// lblInstallname // lblInstallname
@ -459,7 +459,7 @@
this.chkIconChange.Text = "Change Icon"; this.chkIconChange.Text = "Change Icon";
this.tooltip.SetToolTip(this.chkIconChange, "Custom social engineering tactic to elevate Admin privileges."); this.tooltip.SetToolTip(this.chkIconChange, "Custom social engineering tactic to elevate Admin privileges.");
this.chkIconChange.UseVisualStyleBackColor = true; this.chkIconChange.UseVisualStyleBackColor = true;
this.chkIconChange.CheckedChanged += new System.EventHandler(this.chkIconChange_CheckedChanged); this.chkIconChange.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
// //
// chkElevation // chkElevation
// //
@ -471,7 +471,7 @@
this.chkElevation.Text = "Enable Admin Elevation"; this.chkElevation.Text = "Enable Admin Elevation";
this.tooltip.SetToolTip(this.chkElevation, "Custom social engineering tactic to elevate Admin privileges."); this.tooltip.SetToolTip(this.chkElevation, "Custom social engineering tactic to elevate Admin privileges.");
this.chkElevation.UseVisualStyleBackColor = true; this.chkElevation.UseVisualStyleBackColor = true;
this.chkElevation.CheckedChanged += new System.EventHandler(this.chkElevation_CheckedChanged); this.chkElevation.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
// //
// btnBuild // btnBuild
// //
@ -526,7 +526,7 @@
this.txtFileVersion.Name = "txtFileVersion"; this.txtFileVersion.Name = "txtFileVersion";
this.txtFileVersion.Size = new System.Drawing.Size(201, 22); this.txtFileVersion.Size = new System.Drawing.Size(201, 22);
this.txtFileVersion.TabIndex = 16; this.txtFileVersion.TabIndex = 16;
this.txtFileVersion.TextChanged += new System.EventHandler(this.txtFileVersion_TextChanged); this.txtFileVersion.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblFileVersion // lblFileVersion
// //
@ -543,7 +543,7 @@
this.txtProductVersion.Name = "txtProductVersion"; this.txtProductVersion.Name = "txtProductVersion";
this.txtProductVersion.Size = new System.Drawing.Size(201, 22); this.txtProductVersion.Size = new System.Drawing.Size(201, 22);
this.txtProductVersion.TabIndex = 14; this.txtProductVersion.TabIndex = 14;
this.txtProductVersion.TextChanged += new System.EventHandler(this.txtProductVersion_TextChanged); this.txtProductVersion.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblProductVersion // lblProductVersion
// //
@ -560,7 +560,7 @@
this.txtOriginalFilename.Name = "txtOriginalFilename"; this.txtOriginalFilename.Name = "txtOriginalFilename";
this.txtOriginalFilename.Size = new System.Drawing.Size(201, 22); this.txtOriginalFilename.Size = new System.Drawing.Size(201, 22);
this.txtOriginalFilename.TabIndex = 12; this.txtOriginalFilename.TabIndex = 12;
this.txtOriginalFilename.TextChanged += new System.EventHandler(this.txtOriginalFilename_TextChanged); this.txtOriginalFilename.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblOriginalFilename // lblOriginalFilename
// //
@ -577,7 +577,7 @@
this.txtTrademarks.Name = "txtTrademarks"; this.txtTrademarks.Name = "txtTrademarks";
this.txtTrademarks.Size = new System.Drawing.Size(201, 22); this.txtTrademarks.Size = new System.Drawing.Size(201, 22);
this.txtTrademarks.TabIndex = 10; this.txtTrademarks.TabIndex = 10;
this.txtTrademarks.TextChanged += new System.EventHandler(this.txtTrademarks_TextChanged); this.txtTrademarks.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblTrademarks // lblTrademarks
// //
@ -594,7 +594,7 @@
this.txtCopyright.Name = "txtCopyright"; this.txtCopyright.Name = "txtCopyright";
this.txtCopyright.Size = new System.Drawing.Size(201, 22); this.txtCopyright.Size = new System.Drawing.Size(201, 22);
this.txtCopyright.TabIndex = 8; this.txtCopyright.TabIndex = 8;
this.txtCopyright.TextChanged += new System.EventHandler(this.txtCopyright_TextChanged); this.txtCopyright.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblCopyright // lblCopyright
// //
@ -611,7 +611,7 @@
this.txtCompanyName.Name = "txtCompanyName"; this.txtCompanyName.Name = "txtCompanyName";
this.txtCompanyName.Size = new System.Drawing.Size(201, 22); this.txtCompanyName.Size = new System.Drawing.Size(201, 22);
this.txtCompanyName.TabIndex = 6; this.txtCompanyName.TabIndex = 6;
this.txtCompanyName.TextChanged += new System.EventHandler(this.txtCompanyName_TextChanged); this.txtCompanyName.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblCompanyName // lblCompanyName
// //
@ -628,7 +628,7 @@
this.txtDescription.Name = "txtDescription"; this.txtDescription.Name = "txtDescription";
this.txtDescription.Size = new System.Drawing.Size(201, 22); this.txtDescription.Size = new System.Drawing.Size(201, 22);
this.txtDescription.TabIndex = 4; this.txtDescription.TabIndex = 4;
this.txtDescription.TextChanged += new System.EventHandler(this.txtDescription_TextChanged); this.txtDescription.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblDescription // lblDescription
// //
@ -645,7 +645,7 @@
this.txtProductName.Name = "txtProductName"; this.txtProductName.Name = "txtProductName";
this.txtProductName.Size = new System.Drawing.Size(201, 22); this.txtProductName.Size = new System.Drawing.Size(201, 22);
this.txtProductName.TabIndex = 2; this.txtProductName.TabIndex = 2;
this.txtProductName.TextChanged += new System.EventHandler(this.txtProductName_TextChanged); this.txtProductName.TextChanged += new System.EventHandler(this.HasChangedSetting);
// //
// lblProductName // lblProductName
// //
@ -677,7 +677,7 @@
this.chkKeylogger.TabIndex = 2; this.chkKeylogger.TabIndex = 2;
this.chkKeylogger.Text = "Enable Keylogger"; this.chkKeylogger.Text = "Enable Keylogger";
this.chkKeylogger.UseVisualStyleBackColor = true; this.chkKeylogger.UseVisualStyleBackColor = true;
this.chkKeylogger.CheckedChanged += new System.EventHandler(this.chkKeylogger_CheckedChanged); this.chkKeylogger.CheckedChanged += new System.EventHandler(this.HasChangedSetting);
// //
// FrmBuilder // FrmBuilder
// //
@ -696,7 +696,6 @@
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "FrmBuilder"; this.Name = "FrmBuilder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "xRAT 2.0 - Builder"; this.Text = "xRAT 2.0 - Builder";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBuilder_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBuilder_FormClosing);
this.Load += new System.EventHandler(this.FrmBuilder_Load); this.Load += new System.EventHandler(this.FrmBuilder_Load);

View File

@ -153,41 +153,6 @@ namespace xServer.Forms
e.Handled = ((e.KeyChar == '\\' || illegal.Any(illegalChar => (illegalChar == e.KeyChar))) && !char.IsControl(e.KeyChar)); e.Handled = ((e.KeyChar == '\\' || illegal.Any(illegalChar => (illegalChar == e.KeyChar))) && !char.IsControl(e.KeyChar));
} }
private void txtInstallname_TextChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void rbAppdata_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void rbProgramFiles_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void rbSystem_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void txtInstallsub_TextChanged(object sender, EventArgs e)
{
HasChanged();
RefreshExamplePath();
}
private void btnMutex_Click(object sender, EventArgs e) private void btnMutex_Click(object sender, EventArgs e)
{ {
HasChanged(); HasChanged();
@ -368,94 +333,26 @@ namespace xServer.Forms
return match.Success; return match.Success;
} }
private void txtHost_TextChanged(object sender, EventArgs e) /// <summary>
/// Handles a basic change in setting.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HasChangedSetting(object sender, EventArgs e)
{ {
HasChanged(); HasChanged();
} }
private void txtPort_TextChanged(object sender, EventArgs e) /// <summary>
/// Handles a basic change in setting, also refreshing the example file path.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void HasChangedSettingAndFilePath(object sender, EventArgs e)
{ {
HasChanged(); HasChanged();
}
private void txtPassword_TextChanged(object sender, EventArgs e) RefreshExamplePath();
{
HasChanged();
}
private void txtDelay_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtMutex_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void chkHide_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtRegistryKeyName_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void chkElevation_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
}
private void chkIconChange_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtProductName_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtDescription_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtCompanyName_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtCopyright_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtTrademarks_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtOriginalFilename_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtProductVersion_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void txtFileVersion_TextChanged(object sender, EventArgs e)
{
HasChanged();
}
private void chkKeylogger_CheckedChanged(object sender, EventArgs e)
{
HasChanged();
} }
} }
} }