好友
阅读权限 25
听众
最后登录 1970-1-1
使用论坛附件上传样本压缩包时必须使用压缩密码保护,压缩密码:52pojie,否则会导致论坛被杀毒软件等误报,论坛有权随时删除相关附件和帖子! 病毒分析分区附件样本、网址谨慎下载点击,可能对计算机产生破坏,仅供安全人员在法律允许范围内研究,禁止非法用途! 禁止求非法渗透测试、非法网络攻击、获取隐私等违法内容,即使对方是非法内容,也应向警方求助!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using System.Xml;
using System.Data.SqlClient;
using System.Data;
using Hd.Common.DEncrypt;
using System.Diagnostics;
namespace Hd.Socket.WpfServer
{
public partial class WindowSet : Window
{
string strFileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Database.config";
string strKeyFileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Key.config";
string strAppFileName = AppDomain.CurrentDomain.BaseDirectory.ToString() + "WpfServer.exe.config";
public WindowSet()
{
InitializeComponent();
this.ResizeMode = ResizeMode.CanMinimize;
Init();
}
private void Init()
{
try
{
if (File.Exists(strKeyFileName))
{
string RegisterCode = "";
RegisterCode = File.ReadAllText(strKeyFileName);
txtRegistration.Text = RegisterCode;
}
else
{
MessageBox.Show("配置文件丢失");
}
if (File.Exists(strFileName))
{
string[] strarray=Hd.DBUtility.PubConstant.ConnectionString.Split(';');
txbServer.Text = strarray[0].Replace("server=", "");
txbDataBase.Text = strarray[1].Replace("database=", "");
txbUser.Text = strarray[2].Replace("uid=", "");
txbPwd.Text = strarray[3].Replace("pwd=", "");
}
else
{
MessageBox.Show("配置文件丢失");
}
List<Model.ServerCodes> serverlist = new Hd.BLL.ServerCodesExt().GetCanUserServerList(Hd.Socket.Server.SocketServer.m_FlagGUID);
cbxServer.ItemsSource = serverlist;
cbxServer.DisplayMemberPath = "ServerName";
cbxServer.SelectedValuePath = "ServerCode";
if (serverlist.Count > 0)
{
cbxServer.SelectedIndex = 0;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnRegistration_Click(object sender, RoutedEventArgs e)
{
try
{
File.WriteAllText(strKeyFileName, txtRegistration.Text.Trim());
MessageBox.Show("修改成功,请重新运行系统!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnTest_Click(object sender, RoutedEventArgs e)
{
if (IsCanConnect())
{
MessageBox.Show("连接成功!");
}
else
{
MessageBox.Show("连接失败!");
}
}
private bool IsCanConnect()
{
string ConnectionString = string.Format("server={0};database={1};uid={2};pwd={3};Connection Timeout=6;", txbServer.Text.Trim(), txbDataBase.Text.Trim(), txbUser.Text.Trim(), txbPwd.Text.Trim());
using (SqlConnection mySqlConnection = new SqlConnection(ConnectionString))
{
bool IsCanConnectioned = false;
try
{
mySqlConnection.Open();
IsCanConnectioned = true;
}
catch
{
IsCanConnectioned = false;
}
finally
{
mySqlConnection.Close();
}
if (mySqlConnection.State == ConnectionState.Closed || mySqlConnection.State == ConnectionState.Broken)
{
return IsCanConnectioned;
}
else
{
return IsCanConnectioned;
}
}
}
private void btnConnection_Click(object sender, RoutedEventArgs e)
{
try
{
if (File.Exists(strFileName))
{
string ConnectionString = string.Format("server={0};database={1};uid={2};pwd={3};Connection Timeout=6;", txbServer.Text.Trim(), txbDataBase.Text.Trim(), txbUser.Text.Trim(), txbPwd.Text.Trim());
string Encrypt = (cbxEncryption.SelectedItem as ComboBoxItem).Tag.ToString();
if (Encrypt.Equals("true"))
{
ConnectionString = DESEncrypt.Encrypt(ConnectionString);
}
XmlDocument doc = new XmlDocument();
doc.Load(strFileName);
XmlNodeList nodes = doc.GetElementsByTagName("add");
for (int i = 0; i < nodes.Count; i++)
{
XmlAttribute att = nodes.Item(i).Attributes["key"];
if (att.Value == "IsEncrypt")
{
XmlAttribute attvalue = nodes.Item(i).Attributes["value"];
attvalue.Value = Encrypt;
}
if (att.Value == "Connection")
{
XmlAttribute attvalue = nodes.Item(i).Attributes["value"];
attvalue.Value = ConnectionString;
}
}
doc.Save(strFileName);
MessageBox.Show("修改成功,请重新运行系统!");
}
else
{
MessageBox.Show("配置文件丢失");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnServer_Click(object sender, RoutedEventArgs e)
{
try
{
if (File.Exists(strAppFileName))
{
Model.ServerCodes server = cbxServer.SelectedItem as Model.ServerCodes;
XmlDocument doc = new XmlDocument();
doc.Load(strAppFileName);
XmlNodeList nodes = doc.GetElementsByTagName("server");
for (int i = 0; i < nodes.Count; i++)
{
XmlAttribute att = nodes.Item(i).Attributes["serverTypeName"];
if (att.Value == "HdScoketServer")
{
nodes.Item(i).Attributes["name"].Value = server.ServerCode;
nodes.Item(i).Attributes["port"].Value = server.Port;
break;
}
}
doc.Save(strAppFileName);
MessageBox.Show("修改成功,请重新运行系统!");
}
else
{
MessageBox.Show("配置文件丢失");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void cbxServer_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Model.ServerCodes server = cbxServer.SelectedItem as Model.ServerCodes;
txbServerInfo.Inlines.Clear();
txbServerInfo.Inlines.Add(string.Format("服务器代码:{0}", server.ServerCode));
txbServerInfo.Inlines.Add(new LineBreak());
txbServerInfo.Inlines.Add(new LineBreak());
txbServerInfo.Inlines.Add(string.Format("服务器名称:{0}", server.ServerName));
txbServerInfo.Inlines.Add(new LineBreak());
txbServerInfo.Inlines.Add(new LineBreak());
txbServerInfo.Inlines.Add(string.Format("服务器端口:{0}", server.Port));
}
private void buttonGet_Click(object sender, RoutedEventArgs e)
{
try
{
string filename = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "SerialNumber.exe";
if (!File.Exists(filename))
{
MessageBox.Show("当前获取机器码程序无法启动!");
}
Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = filename;
p.StartInfo.Arguments = "";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
请问木马特征在哪里啊
发帖前要善用【论坛搜索 】 功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。