SQL Server和MySQL的安全性分析
2007-11-09 11:06:32 来源:IT专家网 ecitnet
二.外部网络安全性分析
1.数据库服务的探测
为了安全,可以让mysql服务运行在内网,但是如果你的机器有外网的接口,mysql也会自动被绑定在外网上面,暴露在internet中,而且系统会在TCP的3306端口监听,非常容易被端口扫描工具发现,不能保证数据安全。如果默认,mssql则会打开TCP的1433端口监听。虽然mssql可以人为的改变监听端口,但是通过微软未公开的1434端口的UDP探测可以很容易知道SQL Server使用的什么TCP/IP端口了。往UDP1434端口
网页教学网
发送一个1个字节的内容为02的数据包,被探测的系统则会返回安装的mssql服务信息,这些信息包括:主机名称、实例名称、版本、管道名称以及使用的端口等。这个端口是微软自己使用,而且不象默认的1433端口那样可以改变,1434是不能改变的。一个典型的返回的信息如下:
ServerName;Sky;InstanceName;sky;IsClustered;No;Version;8.00.194;tcp;3341;np;\\sky\pipe\MSSQL$XHT310\sql\query; 可以发现mssql的tcp端口改成了3341,为攻击者打开了方便之门!只要会一点socket编程知识,很容易就可以写出扫描mssql服务的程序,而且,由于利用了udp端口,一般的过滤是很难防范的。 补天的awen写了个探测程序,用的是c#语言,代码如下:
网页教学网
| using System; using System.Net.Sockets; using System.Net; using System.Text; using System.Threading; namespace ConsoleApplication3 { class Class1 { //创建一个UDPCLIENT实例 private static UdpClient m_Client; //LISTEN用来获取返回的信息 public static string Listen(string hostip) { string HostIP = hostip; IPAddress thisIP = IPAddress.Parse(HostIP); IPEndPoint host = new IPEndPoint(thisIP,1434); byte [] data = m_Client.Receive(ref host); Encoding ASCII = Encoding.ASCII; String strData = ASCII.GetString(data); return strData; } //SEND public static void Send(string hostip) { string HostIP = hostip; byte [] buffer = {02}; //02为要发送的数据,只有02、03、04有回应 int ecode = m_Client.Send(buffer,1,HostIP,1434); //ecode用来返回是否成功发送 if(ecode <= 0) { Console.WriteLine("发送时出错:" + ecode); } } //对返回的信息的简单的处理 public static void OutputInfo(string strdata) { string str = strdata; //str.le char [] that = {‘;‘,‘;‘}; string [] strofthis =str.Split(that); //int i= 0 for(int i=0;i{ Console.Write(strofthis); Console.Write(‘ ‘); } } //输入IP public static string InputHostIP() { Console.Write("enter the ip you want to scan: "); string hostip =Console.ReadLine(); Console.Write(‘ ‘); return hostip; } //EXIT public static void Exit() { Console.WriteLine("if you want to exit ,just input 1 "); int a = Console.Read(); if(a!= 1) { Console.WriteLine("if you want to exit ,just input 1 "); Console.Read(); } else { } } [STAThread] static void Main(string[] args) { string HostIP; HostIP = InputHostIP(); Console.WriteLine("Begin to send udp to the host"); m_Client = new UdpClient(); Send(HostIP); string strData=Listen(HostIP); OutputInfo(strData); Exit(); } } } |
上一篇:教你快速掌握常见的9种数据库对象
下一篇:C#学习之类的访问修饰符






文章评论
共有 0 位网友发表了评论 查看完整内容