服务器后门文件会导致波动吗,该文件中,含有后门木马特征,请谨慎使用

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 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());

}

}

}

}

请问木马特征在哪里啊

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值