Since the advent of ASP (Active Server Pages), due to its ability to create healthy and easy maintenance, the ASP technology has received more and more network programmers, and the use of ASP is increasingly involved in Web development. many. However, ASP is just a non-compilation, the scripting language running in the server, using the plain text) method, even if the ASP encryption is encrypted, it is not necessarily guaranteed to the operation environment The ASP application is not illegally copied. For administrators of high-level, you can easily copy the ASP program to other unauthorized websites from the server side. This brings certain difficulties to ASP app commercialization. How to effectively protect the developed ASP program, this article is based on the randomness generated by the disk serial number, combined with the Microsoft's official free ASP script encryption program Screnc.exe, which is well solved this problem.
Disk serial number, referred to as disk ID, is a disc identification information generated randomly generated when it is formatted, is a volume sequence number. The same machine is formatted twice. The same chance is almost zero. The late version of DOS is almost zero. The later version and Windows, WinNT use this disk identification mode, so the disk serial number is often used for commercial software to encrypt. use. Switch from Windows9.x to the MS-DOS mode, type the Dir command and enter, the current volume sequence number information appears in the screen, the serial number similar to "0A48-1CD7" is a 16-based number. Some software used within a limited time, after use, will require the user to apply for a new authorization serial number online (license). This kind of authorization serial number is considerably generated by a static disk serial number combining time. After installation, the program cannot be used even if it is illegally copied into an in-place installation environment.
The above ideas are easy to implement in VC, VB, and Deliphi programming languages, then how do you implement in ASP? VBScript As a robust, secure user language, is limited by the client system, cannot handle the call of the API on the client, and cannot directly manipulate the controls other than the files outside the client. Therefore, this paper uses VBScript and combined with the ASP built-in component FileSystem to achieve the above ideas. The following procedures can be applied to the actual ASP application system based on the specific situation.
As an example of explanation, this article uses the Access database security mechanism, in practical applications, you can store data in other formats. For the convenience, we first build an Access database id.mdb (password "kxj"), build a DriveInfo table, the data structure is as follows:
ID (Auto Number);
Serno (text, 12, disk serial number (10));
Wrimark (number, 1, writer logo,).
Description
The WRIMARK value is 0 represents the legal user is not installed, the value is 1 means that the system is installed. When the value is 1 and the serial number does not match the current disk, it is determined as illegal copying users.
When initialization, first define a new record, each field initial value is 1,12345678,0, respectively.
Under the same directory, for example C: Interpubwwwroot, place the home page default.asp, legitimate user home Success.asp, illegal installation User Tips page fail.htm and id.mdb serial number storage library.
The writing operations of each ASP file are as follows:
1. Use FrontPage (or NOTEPAD), create a new ASP file default.asp, enter the following program code:
HEAD>
<% DIM CONN, FS, F
Set conn = server.createObject ("adoDb.connection")
Conn.open "driver = {Microsoft Access Driver (* .mdb)}; uid =; pwd = kxj; dbq =" & server.mappath ("id.mdb")
SET FS = Server.createObject ("scripting.filesystemobject")
TestDrive = Server.mappath ("/ driveinfo.asp")
'Get the current disk tray by mappath
TestDrive = Left (TestDrive, 3)
Set f = fs.getdrive (testdrive)
'Call the getDrive method to give a variable to the drive
Mysql = "SELECT * from driveInfo where id = 1"
Set Rscheck = Server.createObject ("AdoDb.Recordset")
Rscheck.open mysql, conn, 1, 1
Fser = trim (f.SerialNumber)
'Get the current disk serial number
STRSERNO = Trim (Rscheck.fields ("Serno"))
Strmark = rscheck.fields ("wrimark")
IF strserno <> fser and strmark = 0 THEN
'If it is installed for the first time, the write disk flag is 1
Session ("pass") = TRUE
'Define user sessions, and set to global ASP document identity variables
SET RSMAIN = Server.createObject ("AdoDb.Recordset")
MySQL1 = "Update DriveInfo Set Serno =" & FSer & ", Wrimark = 1"
rsmain.open mysql1, conn, 1, 2
Response.write (" setup
Successful! Welcome to Access The Website! ")
SET RSMAIN = Nothing
Else
If strserno = fser dam
'If a legal user is legally entered again
Session ("pass") = TRUE
Response.write (" you are authorized by the Website Manager, Welcome to Access! ")
Else
'Illegal copy user session ("pass") = false
Response.write (" it is illegal to copy the Website's asp document.you area not rigrt to use the program")
END IF
END IF
Response.write ("
")
Response.write ("Volume Serial Number In Drive" & testDrive)
Response.write (f.SerialNumber)
Response.write ("
")
Response.write ("Volume HEX Serial Number in Drive" & testdrive)
Response.write (HEX (F.SerialNumber)
Response.write ("
")
'As a demonstration, this program lists the current disk serial number (16))
Set f = Nothing
SET FS = Nothing
%>
Html>
2. Add the following code in the heads of the ASP files that can be accessed by legal users.
<% IF session ("pass") = false kil
'Judging the session variable, illegal jumps out of this ASP file
Response.Redirect ("fail.htm")
END IF
%>
3. Use ASP encryption programs (such as Microsoft's Screnc.exe, other ASP encryption programs) to encrypt each ASP file.
Running Screnc -l Vbscript Source.asp Destination.asp in DOS, that is, the source file source.asp generates new file Destination.asp containing Cipheet ASP scripts. Screnc.exe can download free in Microsoft Site (http://www.microsoft.com).
The above program code is passed under Simplified Chinese NT4.0, IIS3.0 and Simplified Chinese PWIN9.8, PWS4.0.