Ver código fonte

MySqlData.Dll 2.0 与MySql Server8.0 (加密方式修复)

分析类框架
Server
Somuns 4 anos atrás
pai
commit
daa8ba7e18
9 arquivos alterados com 243 adições e 47 exclusões
  1. +84
    -4
      StuMgmServer/StuMgmLib/MyNameSpace/DataAnalyze.cs
  2. +118
    -0
      StuMgmServer/StuMgmLib/MyNameSpace/StuMgmSer.cs
  3. +3
    -11
      StuMgmServer/StuMgmLib/MyNameSpace/TcpConn.cs
  4. +9
    -0
      StuMgmServer/StuMgmLib/StuMgmLib.csproj
  5. +11
    -11
      StuMgmServer/StuMgmServer/Server.Designer.cs
  6. +2
    -2
      StuMgmServer/StuMgmServer/Server.cs
  7. +4
    -4
      StuMgmServer/StuMgmServer/Server.resx
  8. +10
    -14
      StuMgmServer/StuMgmServer/StuMgmSer.cs
  9. +2
    -1
      StuMgmServer/StuMgmServer/StuMgmServer.csproj

+ 84
- 4
StuMgmServer/StuMgmLib/MyNameSpace/DataAnalyze.cs Ver arquivo

@@ -1,19 +1,99 @@
using System;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data;
using System.Text; using System.Text;
using System.Windows.Forms;


namespace StuMgmLib.MyNameSpace namespace StuMgmLib.MyNameSpace
{ {
public class DataAnalyze public class DataAnalyze
{ {
public void Analyze(byte[] data)
const string conStr = "data source=localhost; initial catalog=xinje; user id=root; pwd=980505";

public static void GetFunc(byte[] dataRecv)
{ {
short account = 01941;
string psw = "980505";
bool res = LoginVerify(account, psw);
res = !res;


// 对buf数据处理,判断身份验证还是数据库操作
//switch ()
//{
// case :break;
// case :break;
// case :break;
// default:break;
//}
}


public static bool LoginVerify(short account, string psw)
{
string qStu = "select * from user where account = " + account + " and password = '" + psw + "'";
MySqlConnection con = new MySqlConnection(conStr);
try
{
con.Open();
MySqlCommand mCmd = new MySqlCommand(qStu, con);
MySqlDataReader mReader = mCmd.ExecuteReader();
if (mReader.HasRows)
return true;
else
return false;
//DataTable dt = new DataTable();
//dt.Load(mReader);
//Random r = new Random();
}
catch (MySqlException mySqlEx)
{
MessageBox.Show(mySqlEx.Message);
return false;
}
finally
{
con.Close();
}
} }


private void mysqlUse()
private static DataTable mysqlUse()
{ {
// mysql Query // mysql Query
string key = "";
string para = "";
string qStu = "select * from staffs where "; // 验证登录信息
switch (key)
{
case "Id":
qStu += " Id =" + Convert.ToString(para);
break;
case "All":
qStu = "select * from staffs "; break;
default:
qStu += key + "= '" + Convert.ToString(para) + "'";
break;
}
MySqlConnection con = new MySqlConnection(conStr);
try
{
con.Open();
MySqlCommand mCmd = new MySqlCommand(qStu, con);
MySqlDataReader mReader = mCmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(mReader);
return dt;
}
catch (MySqlException mySqlEx)
{
MessageBox.Show(mySqlEx.Message);
return null;
}
finally
{
con.Close();
}
} }

} }
}
}

+ 118
- 0
StuMgmServer/StuMgmLib/MyNameSpace/StuMgmSer.cs Ver arquivo

@@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.IO;
//using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
//using System.Threading.Tasks;

namespace StuMgmLib
{

#region 题目信息
[Serializable]
public class CourseInfo
{
public short Id;
public short Pid;
public int Time;
public string Name;
public string Content;
}
#endregion

#region 学生题目信息一览
public enum CourseStatusEnum
{
undo, // 未开始
doing, // 进行中
waiting, // 等待验收
failed, // 验收失败
preSharing, // 准备分享
pass // 验收通过
}

[Serializable]
public class CourseStatus
{
public short CourseId;
public CourseStatusEnum Status;
}
[Serializable]
public class UserInfo
{
public short JobId;
public string Name;
public List<CourseStatus> CourseStatus;
}
#endregion

#region 学生单题详细信息
public class HistoryInfo
{
DateTime Time;
string Describe;
}
public class DetailInfo
{
public short CourseId;
public short JobId;
List<HistoryInfo> Describes;
}
#endregion



class Server
{
//List<CourseInfo> GetCourseInfo();
//UserInfo GetUserInfo(short jobId);
//DetailInfo GetDetailInfo(short jobId, short courseId);

public byte[] GetUser(short jobId)
{
UserInfo info = new UserInfo();
info.JobId = 111;
info.Name = "aaaa";
info.CourseStatus = new List<CourseStatus>();
CourseStatus aa = new CourseStatus();
aa.CourseId = 222;
aa.Status = CourseStatusEnum.undo; // 做题状态
info.CourseStatus.Add(aa);



MemoryStream ms = new MemoryStream();
BinaryFormatter iFormatter = new BinaryFormatter();
iFormatter.Serialize(ms, info);
byte[] buff = ms.GetBuffer();
return buff;
}

public UserInfo Parse(byte[] bt)
{
MemoryStream ms = new MemoryStream(bt);
BinaryFormatter iFormatter = new BinaryFormatter();
UserInfo obj = (UserInfo)iFormatter.Deserialize(ms);
return obj;
}
}

class StudentInfo
{
//List<CourseInfo> GetCourseInfo();
//UserInfo GetUserInfo(short jobId);
//DetailInfo GetDetailInfo(short jobId, short courseId);
}


class Program
{
//static void Main(string[] args)
//{
// Server s = new Server();
// byte[] buf = s.GetUser(0);
// UserInfo aa = s.Parse(buf);
//}
}
}

+ 3
- 11
StuMgmServer/StuMgmLib/MyNameSpace/TcpConn.cs Ver arquivo

@@ -5,21 +5,12 @@ using System.Net.Sockets;


namespace StuMgmLib.MyNameSpace namespace StuMgmLib.MyNameSpace
{ {
public class TcpConn public class TcpConn
{ {
private IPEndPoint IPP = null; private IPEndPoint IPP = null;
private Socket socket = null; private Socket socket = null;
private Socket socketClient = null; private Socket socketClient = null;
//private Thread tAccept = null;

#region 连接状态字段
private bool my_connect = false;
public bool Connect
{
get { return my_connect; }
set { my_connect = value; }
}
#endregion


private bool my_SocketExist = false; private bool my_SocketExist = false;
/// <summary> /// <summary>
@@ -72,13 +63,14 @@ namespace StuMgmLib.MyNameSpace
#region 接收数据 #region 接收数据
public string acpMsg() public string acpMsg()
{ {
byte[] arrDataRecv = new byte[1024]; // 定义接收数组
byte[] arrDataRecv = new byte[4096]; // 定义接收数组
string reEdPoint = ""; string reEdPoint = "";
try try
{ {
reEdPoint = socketClient.RemoteEndPoint.ToString(); reEdPoint = socketClient.RemoteEndPoint.ToString();
socketClient.ReceiveTimeout = recvTimeOut; socketClient.ReceiveTimeout = recvTimeOut;
int len = socketClient.Receive(arrDataRecv); int len = socketClient.Receive(arrDataRecv);
DataAnalyze.GetFunc(arrDataRecv); // 解析
List<byte> listDataRecv = new List<byte> { }; // 定义截取列表 List<byte> listDataRecv = new List<byte> { }; // 定义截取列表
return reEdPoint + " " + len.ToString() + " 断开连接 \n"; return reEdPoint + " " + len.ToString() + " 断开连接 \n";
} }


+ 9
- 0
StuMgmServer/StuMgmLib/StuMgmLib.csproj Ver arquivo

@@ -11,6 +11,7 @@
<AssemblyName>StuMgmLib</AssemblyName> <AssemblyName>StuMgmLib</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -20,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -28,14 +30,21 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MySql.Data, Version=8.0.21.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="MyNameSpace\DataAnalyze.cs" /> <Compile Include="MyNameSpace\DataAnalyze.cs" />
<Compile Include="MyNameSpace\StuMgmSer.cs" />
<Compile Include="MyNameSpace\TcpConn.cs" /> <Compile Include="MyNameSpace\TcpConn.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>


+ 11
- 11
StuMgmServer/StuMgmServer/Server.Designer.cs Ver arquivo

@@ -30,7 +30,7 @@
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.tlpAll = new System.Windows.Forms.TableLayoutPanel(); this.tlpAll = new System.Windows.Forms.TableLayoutPanel();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.rtxHistory = new System.Windows.Forms.RichTextBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.txtPort = new System.Windows.Forms.TextBox(); this.txtPort = new System.Windows.Forms.TextBox();
this.lblSwiSta = new System.Windows.Forms.Label(); this.lblSwiSta = new System.Windows.Forms.Label();
@@ -47,7 +47,7 @@
this.tlpAll.ColumnCount = 2; this.tlpAll.ColumnCount = 2;
this.tlpAll.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 27.25581F)); this.tlpAll.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 27.25581F));
this.tlpAll.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 72.74419F)); this.tlpAll.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 72.74419F));
this.tlpAll.Controls.Add(this.richTextBox1, 0, 0);
this.tlpAll.Controls.Add(this.rtxHistory, 0, 0);
this.tlpAll.Controls.Add(this.tableLayoutPanel1, 0, 0); this.tlpAll.Controls.Add(this.tableLayoutPanel1, 0, 0);
this.tlpAll.Dock = System.Windows.Forms.DockStyle.Fill; this.tlpAll.Dock = System.Windows.Forms.DockStyle.Fill;
this.tlpAll.Location = new System.Drawing.Point(0, 24); this.tlpAll.Location = new System.Drawing.Point(0, 24);
@@ -58,15 +58,15 @@
this.tlpAll.Size = new System.Drawing.Size(1075, 413); this.tlpAll.Size = new System.Drawing.Size(1075, 413);
this.tlpAll.TabIndex = 0; this.tlpAll.TabIndex = 0;
// //
// richTextBox1
// rtxHistory
// //
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Font = new System.Drawing.Font("Calibri", 10.8F);
this.richTextBox1.Location = new System.Drawing.Point(295, 3);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(777, 407);
this.richTextBox1.TabIndex = 2;
this.richTextBox1.Text = "";
this.rtxHistory.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtxHistory.Font = new System.Drawing.Font("Calibri", 10.8F);
this.rtxHistory.Location = new System.Drawing.Point(295, 3);
this.rtxHistory.Name = "rtxHistory";
this.rtxHistory.Size = new System.Drawing.Size(777, 407);
this.rtxHistory.TabIndex = 2;
this.rtxHistory.Text = "";
// //
// tableLayoutPanel1 // tableLayoutPanel1
// //
@@ -175,7 +175,7 @@
private System.Windows.Forms.Label lblPort; private System.Windows.Forms.Label lblPort;
private System.Windows.Forms.TextBox txtPort; private System.Windows.Forms.TextBox txtPort;
private System.Windows.Forms.Timer tmr; private System.Windows.Forms.Timer tmr;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.RichTextBox rtxHistory;
} }
} }



+ 2
- 2
StuMgmServer/StuMgmServer/Server.cs Ver arquivo

@@ -24,14 +24,14 @@ namespace StuMgmServer
/// </summary> /// </summary>
private void setText(string text) private void setText(string text)
{ {
if (richTextBox1.InvokeRequired)
if (rtxHistory.InvokeRequired)
{ {
SetTextCallback method = new SetTextCallback(setText); SetTextCallback method = new SetTextCallback(setText);
Invoke(method, new object[] { text }); Invoke(method, new object[] { text });
} }
else else
{ {
richTextBox1.Text += text;
rtxHistory.Text = text + rtxHistory.Text;
} }
} }




+ 4
- 4
StuMgmServer/StuMgmServer/Server.resx Ver arquivo

@@ -112,15 +112,15 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="tmr.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="tmr.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>159, 17</value> <value>159, 17</value>
</metadata> </metadata>
</root> </root>

+ 10
- 14
StuMgmServer/StuMgmServer/StuMgmSer.cs Ver arquivo

@@ -6,7 +6,7 @@ using System.Runtime.Serialization.Formatters.Binary;
using System.Text; using System.Text;
//using System.Threading.Tasks; //using System.Threading.Tasks;


namespace ConsoleApplication1
namespace StuMgmLib
{ {


#region 题目信息 #region 题目信息
@@ -64,9 +64,9 @@ namespace ConsoleApplication1


class Server class Server
{ {
//List<CourseInfo> GetCourseInfo();
//UserInfo GetUserInfo(short jobId);
//DetailInfo GetDetailInfo(short jobId, short courseId);
List<CourseInfo> GetCourseInfo();
UserInfo GetUserInfo(short jobId);
DetailInfo GetDetailInfo(short jobId, short courseId);


public byte[] GetUser(short jobId) public byte[] GetUser(short jobId)
{ {
@@ -95,12 +95,8 @@ namespace ConsoleApplication1
UserInfo obj = (UserInfo)iFormatter.Deserialize(ms); UserInfo obj = (UserInfo)iFormatter.Deserialize(ms);
return obj; return obj;
} }



} }



class StudentInfo class StudentInfo
{ {
//List<CourseInfo> GetCourseInfo(); //List<CourseInfo> GetCourseInfo();
@@ -111,11 +107,11 @@ namespace ConsoleApplication1


class Program class Program
{ {
//static void Main(string[] args)
//{
// Server s = new Server();
// byte[] buf = s.GetUser(0);
// UserInfo aa = s.Prase(buf);
//}
static void Main(string[] args)
{
Server s = new Server();
byte[] buf = s.GetUser(0);
UserInfo aa = s.Prase(buf);
}
} }
} }

+ 2
- 1
StuMgmServer/StuMgmServer/StuMgmServer.csproj Ver arquivo

@@ -22,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@@ -31,6 +32,7 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@@ -49,7 +51,6 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StuMgmSer.cs" />
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>


Carregando…
Cancelar
Salvar