Sie sind auf Seite 1von 39

Chapter 1 Introduction

1.1 EXISTING SYSTEM


In todays dynamic and information rich environment, information systems have become vital for any organization to survive. With the increase in the dependence of the organization on the information system, there exists an opportunity for the competitive organizations and disruptive forces to gain access to other organizations information system. This hostile environment makes information systems security issues critical to an organization. Current information security literature either focuses on unreliable information by describing the information security attacks taking place in the world or it comprises of the technical literature describing the types of security threats and the possible security systems. In order to secure the transmission of data, Cryptography has to be implemented. Cryptography is the science of devising methods that allow information to be sent in a secure form in such a way that the only person able to retrieve this information is intended recipient. The basic principle is this: A message being sent is known as plaintext. The message is then coded using a Cryptographic Algorithm. This process is called Encryption, an Encrypted message is known as Cipher Text, and is turned back into plaintext by the process of decryption. Encryption can be done using Symmetric or Asymmetric Algorithms. In Symmetric algorithms, only one key is used both to encrypt and decrypt the message. In Asymmetric Algorithms, a key used to encrypt a message is different from the key that is used to decrypt the message. There are several algorithms present in the market for Cryptography. Some of the commonly used on ceare IDEA and RSA that involves Asymmetric or Symmetric methods and also involves private and public keys.

1.2 OBJECTIVES OF NEW SYSTEM


Steganography is the art and science of writing hidden messages in such a way that no one apart from the intended recipient knows of the existence of the message; this is in contrast to cryptography, where the existence of the message itself is not disguised, but the content is obscured. The advantage of steganography over cryptography alone is that messages do not attract attention to themselves, to messengers, or to recipients. Steganographic messages are often first encrypted by some traditional means, and then a cover text is modified in some way to contain the encrypted message, resulting in stego text. For example, the letter size, spacing, typeface, or other characteristics of a cover text can be manipulated to carry the hidden message; only the recipient (who must know the technique used) can recover the message and then decrypt it. Steganography uses in electronic communication include steganographic coding inside of a transport layer, such as an MP3 file, or a protocol, such as UDP.
The project 'Steganography' provides means for secure data transmission and secure data storage network. Hereby, important files carrying confidential information can be stored in the server in an encrypted form. Access to these files is limited to certain authorized people only. Transmission also takes place in an encrypted form so that no intruder can get any useful information from the original file during transit. Further, before trying to access important files, the user has to login to the system using a valid username and password, which is allotted to him by the system administrator. Encryption is the process of encoding a message in such a way as to hide its contents. Modern Cryptography includes several secure algorithms for encrypting and decrypting messages. They are all based on the use of secrets called keys. A cryptographic key is a parameter used in an encryption algorithm in such a way that the encryption cannot be reversed without the knowledge of the key.

1.3 PROPOSED SYSTEM


The algorithms present in the existing system were somewhat complicated. In Cryptography, the meaning of data has been changed. So, it makes intention to the hacker to hack or destroy the data. In our proposed system, we implement a new technology called Steganography for Network security. It not only changes the meaning of data but also hides the presence of data from the hackers. 2

Chapter 2 PRELIMINARY SURVEY

2.1 WHY STEGANOGRAPHY?


This is the big question for a lot of individuals seeing this process for the first time. Let me discuss some of the applications of this technique. Keep in mind that like just about anything you can name, this whole process can be used for legal or illegal purposes depending on who is using it and for what. Legitimate applications of this process include the enforcement of intellectual property such as copyrights by applying what are known as watermarks to an image. In contrast, some of the more nefarious reasons include hiding information for illegal reasons. In fact, organizations such as Al-Qaeda and others are known to use this process to hide information in harmless images hosted on Web sites. So, how can you prevent the use of steganographic techniques for the transmission and storage of illegal information? Well, this is a problematic issue to say the least. In the right hands, one could fairly easily hide information in "plain sight" and get away with it. Remember, if done correctly, information could be hidden in any image, document, or other piece of data and never even be suspect. Although you could never successfully confirm how widespread this technique is in illegal or criminal circles, it is probably safe to say it is in use by criminals, terrorists, and other bad folks for all kinds of mischief. As those on the "light side of the Force," we can use company security policies and a code of honor (so to speak) to prevent the misuse of this technology. Unfortunately, those on the "dark side" don't have such obstacles.

2.2 HISTORY OF STEGANOGRAPHY


For years, people have devised different techniques for encrypting data while others have attempted to break these encrypted codes. For our project we decided to put our wealth of DSP knowledge to use in the art of steganography. Steganography is a technique that allows one to 3

hide binary data within an image while adding few noticeable changes. Technological advancements over the past decade or so have brought terms like mp3, jpeg, and mpeg into our everyday vocabulary. These lossy compression techniques lend themselves perfectly for hiding data. We have chosen this project because it gives a chance to study several various aspects of DSP. First, we devised our own compression technique which we loosely based off jpeg. There have been many steganographic techniques created so far, which compelled us to create two of our own strategies for hiding data in the images we compress. Our first method, zero hiding, adds the binary data into the DCT coefficients dropped in compression. Our other method, which we called bit-o-steg, uses a key to change the values of coefficients that remain after compression. Finally, we had to find ways to analyze the success of our data hiding strategies, so through our research we found both DSP and statistical methods to qualitatively measure our work. Steganography, or hidden writing can be traced back to 440 BC in ancient Greece. Often they would write a message on a wooden panel, cover it in wax, and then write a message on the wax. These wax tablets were already used as writing utensils, so the hiding of a message in a commonly used device draws very little suspicion. In addition to use by the Greeks, the practice of steganography was utilized by spies in World War II. There were even rumors that terrorists made use of steganography early in 2001 to plan the attacks of September 11.The first description of the use of steganography dates back to the Greeks. Herodotus tells how a message was passed to the Greeks about Xerses' hostile intentions underneath the wax of a writing tablet, and describes a technique of dotting successive letters in a cover text with a secret ink, due to Aeneas the Tactician. Pirate legends tell of the practice of tattooing secret information, such as a map, on the head of someone, so that the hair would conceal it. Kahn tells of a trick used in China of embedding a code ideogram at a prearranged position in a dispatch; a similar idea led to the grille system used in medieval Europe, where a wooden template would be placed over a seemingly innocuous text, highlighting an embedded secret message. During WWII the grille method or some variants were used by spies. In the same period, the Germans developed microdot technology, which prints a clear, good quality photograph shrinking it to the size of a dot. There are rumors that during the 1980's Margareth Thatcher, then Prime Minister in UK, became so irritated about press leaks of cabinet documents, that she had the word processors programmed to encode the identity of the writer in the word spacing, thus 4

being able to trace the disloyal ministers. During the "Cold War" period, US and USSR wanted to hide their sensors in the enemy's facilities. These devices had to send data to their nations, without being spotted. Today, steganography is researched both for legal and illegal reasons. Among the first ones there is war telecommunications, which use spread spectrum or meteor scatter radio in order to conceal both the message and its source. In the industry market, with the advent of digital communications and storage, one of the most important issues is copyright enforcement, so digital watermarking techniques are being developed to restrict the use of copyrighted data. Another important use is to embed data about medical images, so that there are no problems with matching patient's records and images. Among illegal ones is the practice of hiding strongly-encrypted data to avoid controls by cryptography export laws.

2.3 DETECTION OF STEGANOGRAPHY


Of course, for every measure, there is a countermeasure, and steganography is no different. In this case, the countermeasure is a technique known as steganalysis. The goal of steganalysis is quite simple: Detect suspect data, determine whether information is hidden within the data, and recover that data. On the surface, this process may sound curiously like a companion technique known as cryptanalysis. But the reality is that the processes are not the same. With cryptanalysis, the fact that data is encrypted is obvious: You need only observe the data to determine whether it is encrypted. With steganalysis, the presence of data is only suspected, not confirmed.

2.3.1 HOW DETECTION WORK?


In its simplest and most basic form, steganalysis is performed through the use of statistical analysis techniques. This technique uses methods that compare known, unmodified files with those that are suspect, the idea being that the "fingerprints" of known files can be 5

compared with the suspect files. Through this statistical comparison you can, in theory, detect variations from the normally generated files. The key here is that the known, good files need to originate from the same source as the suspect files (that is, the digital camera or scanner), or as close a match as possible for the comparison to be effective. Some variations in this technique look for deviations from known compression algorithms in play on JPEGs, MP3s, and other files, as the compression algorithm is publicly known. One more advanced technique in use is known as Noise Floor Consistency Analysis. Without making this sound like a doctoral thesis in mathematics, in this method, comparison is made at the bit level between the MSB and the LSB components of a piece of data. Because the MSB and LSB should have a basic correlation between them, the alteration of the LSB by some steganographic techniques can break this relationship, making detection possible. In fact, some applications that perform this technique can detect hidden data within a highly reliable degree of confidence. Something to keep in mind with steganalysis techniques is that another layer of complexity may be added to the detection of hidden data. Consider this: If you want to add another element of protection to your hidden data, you could combine it with encryption before embedding the data. In this case, if detection is successful, decryption must also be performed. Steganalysis tools, like many security tools, are highly specialized, often with a highly specialized price tag. However, if you would like to experiment with some of the techniques, there is an open source project, Stegsecret ,which will begin your exploration.

CHAPTER 3 FEASIBILITY STUDY


3.1FEASIBILITY STUDY
A Feasibility Study is a high-level capsule version of the entire System analysis and Design Process. The study begins by classifying the problem definition. Feasibility is to determine if its worth doing. Once an acceptance problem definition has been generated, the analyst develops a logical model of the system. A search for alternatives is analyzed carefully.In this system we are going to develop a facility to a user that he will not face any difficulty at the time of usage like data missing, one way contacts, and one view contacts. As we are developing this system with an encoding technique of images the user will not be bothered on which camera support is using, as well in sound. As we are maintaining one technique of speed controlling the frame relay will not be a problem for the user like over speed display, hanged display.

3.2 TYPES OF FEASIBILITY STUDY


3.2.1Operational Feasibility:
Question that going to be asked are Will the system be used if it developed and implemented. If there was sufficient support for the project from the management and from the users. Have the users been involved in planning and development of the Project. Will the system produce poorer result in any respect or area?

3.2.2 Technical feasibility


Does the necessary technology exist to do what is been suggested Does the proposed equipment have the technical capacity for using the new system? Are there technical guarantees of accuracy, reliability and data security? The project is developed on Pentium IV with 256 MB RAM. 7

The environment required in the development of system is any windows platform The observer pattern along with factory pattern will update the results eventually The language used in the development is .NET(C#)

3.2.3 Financial and Economical Feasibility:


The system developed and installed will be good benefit to the Organization. The system will be developed and operated in the existing hardware and software infrastructure. So there is no need of additional hardware and software for the system.

Figure 3.1 Steganography

Chapter 4 ANALYSIS
4.1 SYSTEM ANALYSIS

Steganography system requires any type of image file and the information or message that is to be hidden .It has two modules encrypt and decrypt. One of .Net tools for pictures and images is auto-converting most types of pictures to BMP format. I used this tool in this software called Steganography that is written in C#.Net language and you can use this software to hide your information in any type of pictures without any converting its format to BMP (software converts inside it).The algorithm used for Encryption and Decryption in this application provides using several layers lieu of using only LSB layer of image. Writing data starts from last layer (8th or LSB layer); because significant of this layer is least and every upper layer has doubled significant from its down layer. So every step we go to upper layer image quality decreases and image retouching transpires. The encrypt module is used to hide information into the image; no one can see that information or file. This module requires any type of imag e and message and gives the only one image file in destination. The decrypt module is used to get the hidden information in an image file. It take the image file as an output, and give two file at destination folder, one is the same image file and another is the message file that is hidden it that. Before encrypting file inside image we must save name and size of file in a definite place of image. We could save file name before file information in LSB layer and save file size and file name size in most right-down pixels of image. Writing this information is needed to retrieve file from encrypted image in decryption state.

4.2. ENCRYPTION PROCESS

IMAGE FILE

INFORMATION FILE

BMP FILE

Figure 4.2 Encryption process.

10

4.3 DECRYPTION PROCESS

BMP FILE

INFORMATION FILE

IMAGE FILE

Figure 4.3 Decryption process

11

4.4 STEGANALYSIS
Steganalysis is the art and science of detecting messages hidden using steganography; this is analogous to cryptanalysis applied to cryptography. The goal of steganalysis is to identify suspected packages, determine whether or not they have a payload encoded into them, and, if possible, recover that payload. Unlike cryptanalysis, where it is obvious that intercepted data contains a message (though that message is encrypted), steganalysis generally starts with a pile of suspect data files, but little information about which of the files, if any, contain a payload. The steganalyst is usually something of a forensic statistician, and must start by reducing this set of data files (which is often quite large; in many cases, it may be the entire set of files on a computer) to the subset most likely to have been altered.
Start Application

Encryption

Decryption

Image

Message file

Image file

Image

Message file

BMP image file

Figure 4.4 Steganalysis.

12

4.5FORMING LOGICAL MODEL OF THE SYSTEM WITH THE HELP OF DATA FLOW DIAGRAM (DFD)

4.5.1 DFD Level 0

Input text, image, audio, video

Hidden Object Program Logic

Encryption Keys

Output File Input+hidden

Figure 4.5.1 DFD Level 0.

13

4.5.2 DFD Level 1

Login Form

Output

Authentication form

Process Main form Execution

Exit

Resources

Figure 4.5.2 DFD Level 1

14

Chapter 5 SYSTEM DESIGN


5.1 INPUT DESIGN
The input design is the process of entering data to the system. The input design goal is to enter to the computer as accurate as possible. Here inputs are designed effectively so that errors made by the operations are minimized. The inputs to the system ha ve been designed in such a way that manual forms and the inputs are coordinated where the data elements are common to the source document and to the input. The input is acceptable and understandable by the users who are using it. The quality of the system input determines the quality for system output. Input specification describes the manner in which data entered the system processing. Input design is the process of converting useroriginated inputs to a computer-based format input data are collected and organized into group of similar data. Once identified, appropriate input media are selected for processing. The input design also determines the user to interact efficiently with the system. Input design is a part of overall system design that requires spec ial attention because it is the common source for data processing error. The goal of designing input data is to make entry easy and free from errors. Five objectives of the input design are: Effectiveness Accuracy Ease to use Consistency Attractiveness

The main objectives that are done during the input design are:

Data are collected from the source Transfer of data to an input form is done 15

Data is converted to a computer acceptable form The converted data are verified. Data are checked for its accuracy. Validation of input data are done

5.2 OUTPUT DESIGN


The output design was done so that results of processing could be communicated to the users. The various outputs have been designed in such a way that they represent the same format that the office and management used to. Computer output is the most important and direct source of information to the user. Efficient, intelligible output design should improve the systems relationships with the u s e r a n d h e l p i n d e c i s i o n m a k i n g . A m a j o r f o r m o f o u t p u t i s t h e h a r d c o p y f r o m t h e printer. Output requirements are designed during system analysis. A good starting point for t h e o u t p u t d e s i g n i s t h e D a t a f l o w D i a g r a m ( D F D ) . H u m a n f a c t o r s e d u c e i s s u e s f o r design involves addressing internal controls to ensure readability. Design is concerned with identifying software components specifying Relationships a m o n g c o m p o n e n t s . Modularity is one the desirable properties of large systems. It implies that the system is divided into several parts. In such a manner, the interaction between parts is minimal clearly specified .Design will explain software components in detail. This will help the implementation of the system. Moreover, this will guide the further changes in the system to satisfy the future requirements. System design is described as a process of planning a new business system or more to replace or to complement an existing system. The system design states how a system will meet the requirements identified during the system analysis .It describes a solution of approaching to the creation of new system. System design is a transmission from a user-oriented document to a document oriented to programmers. It goes through a logical and physical design. The key points followed at the times of designing are: Preparing input and output specification

Data flows and stores 16

Preparing security and control specification

Temporary and permanent collection of data

A walk through before implementation

Process reviewing the study phase activities and making decisions about which functions are to be performed by the hardware, software, and human ware started in the design phase. The output, input and file design for each of the programs was done. Finally, the generalized systems were explained to the management for approval .The steps involved in designing phase were The function to be performed is identified) The input, output and file design is performed . The system and component cost requirements is specified The design phase report is generated.

5.3 LANGUAGES USED .Net (c#)

17

5.4 HARDWARE AND SOFTWARE SPECIFICATION

5.4.1 Hardware Specification


Processor: Intel P4 288 GHZ Memory Size: 1GB Hard Disc: 160 GB Floppy Disk Drive: 1.44 MB CD-ROM Drive: 52*32 CD-ROM drive Monitor: 15 Color Keyboard: HCL 107 Mouse: 2 Button Mouse

5.4. SOFTWARE SPECIFICATION


Front end: .Net(c#) Operating System: Windows XP

18

Chapter 6 TESTING AND IMPLEMENTATION


In Encryption the secrete information is hiding in with any type of image file. Decryption is getting the secrete information from image file. The objective of the testing is to discover errors. To fulfill this objective a series of test step unit, integration, validation and system tests were planned and executed. The test steps are:

6.1 UNIT TESTING


Unit is the testing changes made in an existing or new program. This test is carried out during the programming and each module is found to be working satisfactory. In the registration form user details are stored in database without any change.

6.2 INTEGRATION TESTING


A comprehensive integration testing is carried out using integrated test plans in the design phase of the development as guide to ensure the behavior of functions with live data. The administrator module can integrate with user module.

6.3 VALIDATION TESTING


Software validation is achieved through the series of tests that demo -nstrate confirmative with requirement. Thus the proposed system and

considerations has been tested by validation and found to be working satisfactorily.

19

6.4 OUTPUT TESTING


Asking the user about the format required by them to test the output generated by the system under considerations. It can be considered in two ways, one on the screen and the other is printed format. The output format on the screen is found to be correct as the format designed in the system design.

6.5 TESTING RESULTS


All tests should be traceable to customer requirements. The focus of testing will shift progressively from programs. Exhaustive testing is not possible. To be more effective, testing should be one, which has probability of finding errors. The following are the attributes of good test:

A good test has a high probability of finding an error. A good test is not redundant. A good test should be best of breeds. A good test should neither too simple nor too complex.

6.5.1 QUALITY ASSURANCE


Quality assurance consists of auditing and reporting functions of management. The goal of quality assurance is to provide management with the data necessary t o b e informed about product quality, thereby gaining insight and confidence that product quality is meeting its goal.

QUALITY ASSURANCE GOALS CORRECTNESS The extent to which the program meets system specifications and user objectives. RELIABILITY- The degree to which the system performs Intended functions overtime. EFFICIENCY- The amount of computer resources required by a program to perform a function. USABILITY- The effort required learning and operating a system. 20

MAINTAINABILITY -To use with which program errors are located and corrected. TESTABILITY -The effort required testing a program to ensure its correct performance. PORTABILITY -The ease of transporting a program from one hardware configuration to another. ACCURACY -The required portion in input editing, computation and output.

6.6 SYSTEM IMPLEMENTATION


Implementation is the stage in the project where the theoretical design is turned a working system. The most crucial stage is achieving a successful new system and giving the user confidence in that the new system will work efficiently and effectively in the implementation stage. The stage consists of

Testing the developed program with simple data.

Detections and corrections.

Creating whether the system is meets user requirements.

Testing whether the system.

Making necessary changes as desired by the user.

Training user personnel

21

Chapter 7 PROGRAMATIC CODE


7.1 CRYPT UTILITY.CS

using System; using System.Drawing; using System.Windows.Forms; using System.Text; using System.IO; namespace PictureKey { public class CryptUtility { /// <summary>Hides a message in a bitmap</summary> /// <param name="messageStream">The message to hide</param> /// <param name="bitmap">The carrier bitmap</param> /// <param name="keyStream">The key to use</param> public static void HideMessageInBitmap(Stream messageStream, CarrierImage[] imageFiles, FilePasswordPair[] keys, bool splitBytes){ HideOrExtract(ref messageStream, imageFiles, keys, splitBytes, false); messageStream = null; } /// <summary>Extracts an hidden message from a bitmap</summary> /// <param name="bitmap">The carrier bitmap</param> /// <param name="keyStream">The key used for hiding the message</param> /// <param name="messageStream">Empty stream to receive the message</param> public static void ExtractMessageFromBitmap(CarrierImage[]imageFiles, FilePasswordPair[] keys, ref Stream messageStream, bool splitBytes){ HideOrExtract(ref messageStream, imageFiles, keys, splitBytes, true); } /// <summary>Steps through the pixels of a bitmap using a key pattern and hides or extracts a message</summary> /// <param name="messageStream">If exctract is false, the message to hide - otherwise an empty stream to receive the extracted message</param> /// <param name="bitmap">The carrier bitmap</param> /// <param name="keyStream">The key specifying the unchanged pixels between two hidden bytes</param> /// <param name="extract">Extract a hidden message (true), or hide a message in a clean carrier bitmap (false)</param> private static void HideOrExtract(ref Stream messageStream, CarrierImage[] imageFiles, FilePasswordPair[] keys, bool splitBytes, bool extract){ //index for imageFiles int indexBitmaps = 0;

22

//load all bitmaps and count available pixels Bitmap[] bitmaps = new Bitmap[imageFiles.Length]; long countPixels = 0; for(indexBitmaps=0; indexBitmaps<imageFiles.Length; indexBitmaps++){ bitmaps[indexBitmaps] = new Bitmap(imageFiles[indexBitmaps].sourceFileName); countPixels += imageFiles[indexBitmaps].countPixels; } //Stores the color of a pixel Color pixelColor; //Length of the message Int32 messageLength; //combine all keys Stream keyStream = GetKeyStream(keys); if(extract){ //Read the length of the hidden message from the first pixel pixelColor = bitmaps[0].GetPixel(0,0); messageLength = (pixelColor.R << 16) + (pixelColor.G << 8) + pixelColor.B; messageStream = new MemoryStream(messageLength); }else{ messageLength = (Int32)messageStream.Length; if(messageStream.Length >= 16777215){ //The message is too long String exceptionMessage = "The message is too long, only 16777215 bytes are allowed."; throw new Exception(exceptionMessage); } } //calculate count of message-bytes to hide in (or extract from) each image long sumBytes = 0; for(int n=0; n<imageFiles.Length; n++){ float pixels = (float)imageFiles[n].countPixels / (float)countPixels; imageFiles[n].messageBytesToHide = (long)Math.Ceiling( (float)messageLength * pixels ); sumBytes += imageFiles[n].messageBytesToHide; } if(sumBytes > messageLength){ //correct Math.Ceiling effects imageFiles[imageFiles.Length-1].messageBytesToHide -= (sumBytes messageLength); } if( ! extract) { //Check size of the carrier image long countRequiredPixels; int readByte; String errorMessage = String.Empty;

23

for(int n=0; n<imageFiles.Length; n++){ //One pixel of the first image is used for the message's length countRequiredPixels = (n==0)?1:0; //Count pixels long countRequiredPixelsImage; if(splitBytes){ //use 8 pixels for a message byte countRequiredPixelsImage = imageFiles[n].messageBytesToHide * 8; }else{ //use one pixel for a message byte countRequiredPixelsImage = imageFiles[n].messageBytesToHide; } for(int countBytes=0; countBytes<countRequiredPixelsImage; countBytes++){ readByte = keyStream.ReadByte(); if(readByte < 0){ keyStream.Seek(0,SeekOrigin.Begin); readByte = keyStream.ReadByte(); } countRequiredPixels += readByte; } if(countRequiredPixels > imageFiles[n].countPixels){ errorMessage += "The images "+imageFiles[n].sourceFileName+" is too small for this message and key. "+countRequiredPixels+" pixels are required.\n"; } } if(errorMessage.Length > 0){ //One or more images are too small throw new Exception(errorMessage); } //Write length of the bitmap into the first pixel int colorValue = messageLength; int red = colorValue >> 16; colorValue -= red << 16; int green = colorValue >> 8; int blue = colorValue - (green << 8); pixelColor = Color.FromArgb(red, green, blue); bitmaps[0].SetPixel(0,0, pixelColor); } //Reset the streams keyStream.Seek(0, SeekOrigin.Begin); messageStream.Seek(0, SeekOrigin.Begin); //Loop over the message and hide each byte if(splitBytes){ HideBits(keyStream, messageStream, messageLength, imageFiles, bitmaps, extract); } else{

24

HideBytes(keyStream, messageStream, messageLength, imageFiles, bitmaps, extract); } for(indexBitmaps=0; indexBitmaps<bitmaps.Length; indexBitmaps++){ if( ! extract ){ SaveBitmap( bitmaps[indexBitmaps], imageFiles[indexBitmaps].resultFileName ); } bitmaps[indexBitmaps].Dispose(); } keyStream.Close(); } private static void MovePixelPosition(CarrierImage[] imageFiles, Bitmap[] bitmaps, int countBytesInCurrentImage, Stream keyStream, ref int indexBitmaps, ref Point pixelPosition, ref int bitmapWidth){ //Repeat the key, if it is shorter than the message if(keyStream.Position == keyStream.Length){ keyStream.Seek(0, SeekOrigin.Begin); } //Get the next pixel-count from the key, use "1" if it's 0 byte currentKeyByte = (byte)keyStream.ReadByte(); int currentStepWidth = (currentKeyByte==0) ? (byte)1 : currentKeyByte; //Perform line breaks, if current step is wider than the image while(currentStepWidth > bitmapWidth){ currentStepWidth -= bitmapWidth; pixelPosition.Y++; } //Move X-position if((bitmapWidth - pixelPosition.X) < currentStepWidth){ pixelPosition.X = currentStepWidth - (bitmapWidth - pixelPosition.X); pixelPosition.Y++; }else{ pixelPosition.X += currentStepWidth; } //Proceed to the next bitmap if(countBytesInCurrentImage == imageFiles[indexBitmaps].messageBytesToHide){ indexBitmaps++; pixelPosition.Y = 0; countBytesInCurrentImage = 0; bitmapWidth = bitmaps[indexBitmaps].Width-1; //bitmapHeight = bitmaps[indexBitmaps].Height-1; if(pixelPosition.X > bitmapWidth){ pixelPosition.X = 0; } } } private static byte GetReverseKeyByte(Stream keyStream){ //jump to reverse-read position and read from the end of the stream long keyPosition = keyStream.Position; keyStream.Seek(-keyPosition, SeekOrigin.End); byte reverseKeyByte = (byte)keyStream.ReadByte(); //jump back to normal read position keyStream.Seek(keyPosition, SeekOrigin.Begin);

25

return reverseKeyByte; } /// <summary>Loop over the message and hide each byte in one pixel</summary> /// <param name="keyStream">The key</param> /// <param name="messageStream">A stream containing the message (extract==false) or an empty stream (extract==true)</param> /// <param name="messageLength">Expected length of the message</param> /// <param name="imageFiles">CarrierImages describing the bitmaps</param> /// <param name="bitmaps">The bitmaps</param> /// <param name="extract">Hide the message (false) or extract it (true)</param> private static void HideBytes(Stream keyStream, Stream messageStream, long messageLength, CarrierImage[] imageFiles, Bitmap[] bitmaps, bool extract){ //Color component to hide the next byte in (0-R, 1-G, 2-B) //Rotates with every hidden byte int currentColorComponent = 0; //Index of the current bitmap int indexBitmaps = 0; //Maximum X and Y position in the current bitmap int bitmapWidth = bitmaps[0].Width-1; //int bitmapHeight = bitmaps[0].Height-1; //Current position in the carrier bitmap //Start with 1, because (0,0) contains the message length Point pixelPosition = new Point(1,0); //Count of bytes already hidden in the current image int countBytesInCurrentImage = 0; //Stores the color of a pixel Color pixelColor; //A value read from the key stream in reverse direction byte currentReverseKeyByte = 0; for(int messageIndex=0; messageIndex<messageLength; messageIndex++){ MovePixelPosition(imageFiles, bitmaps, countBytesInCurrentImage, keyStream, ref indexBitmaps, ref pixelPosition, ref bitmapWidth); currentReverseKeyByte = GetReverseKeyByte(keyStream); countBytesInCurrentImage++; //Get color of the "clean" pixel pixelColor = bitmaps[indexBitmaps].GetPixel(pixelPosition.X, pixelPosition.Y); if(extract){ //Extract the hidden message-byte from the color byte foundByte = (byte)(currentReverseKeyByte ^ GetColorComponent(pixelColor, currentColorComponent)); messageStream.WriteByte(foundByte); //Rotate color components currentColorComponent = (currentColorComponent==2) ? 0 : (currentColorComponent+1); }else{

26

//To add a bit of confusion, xor the byte with a byte read from the keyStream int currentByte = messageStream.ReadByte() ^ currentReverseKeyByte; if(imageFiles[indexBitmaps].useGrayscale){ pixelColor = Color.FromArgb(currentByte, currentByte, currentByte); }else{ //Change one component of the color to the message-byte SetColorComponent(ref pixelColor, currentColorComponent, currentByte); //Rotate color components currentColorComponent = (currentColorComponent==2) ? 0 : (currentColorComponent+1); } bitmaps[indexBitmaps].SetPixel(pixelPosition.X, pixelPosition.Y, pixelColor); } } } private static void HideBits(Stream keyStream, Stream messageStream, long messageLength, CarrierImage[] imageFiles, Bitmap[] bitmaps, bool extract){ //Color component to hide the next byte in (0-R, 1-G, 2-B) //Rotates with every hidden byte int currentColorComponent = 0; //Index of the current bitmap int indexBitmaps = 0; //Maximum X and Y position in the current bitmap int bitmapWidth = bitmaps[0].Width-1; //Current position in the carrier bitmap //Start with 1, because (0,0) contains the message length Point pixelPosition = new Point(1,0); //Count of bytes already hidden in the current image int countBytesInCurrentImage = 0; //Stores the color of a pixel Color pixelColor; //A value read from the key stream in reverse direction byte currentReverseKeyByte = 0; //The current byte of the message stream byte currentByte; for(int messageIndex=0; messageIndex<messageLength; messageIndex++){ currentReverseKeyByte = GetReverseKeyByte(keyStream); if(extract){ currentByte = 0; }else{ currentByte = (byte)messageStream.ReadByte();

27

//To add a bit of confusion, xor the byte with a byte read from the keyStream currentByte = (byte)(currentByte ^ currentReverseKeyByte); } for(byte bitPosition=0; bitPosition<8; bitPosition++){ MovePixelPosition(imageFiles, bitmaps, countBytesInCurrentImage, keyStream, ref indexBitmaps, ref pixelPosition, ref bitmapWidth); //Get color of the "clean" pixel pixelColor = bitmaps[indexBitmaps].GetPixel(pixelPosition.X, pixelPosition.Y); if(extract){ //Extract the hidden message-byte from the color byte foundByte = GetColorComponent(pixelColor, currentColorComponent); bool foundBit = GetBit(foundByte, 0); currentByte = SetBit(currentByte, bitPosition, foundBit); //Rotate color components currentColorComponent = (currentColorComponent==2) ? 0 : (currentColorComponent+1); }else{ bool currentBit = GetBit(currentByte, bitPosition); if(imageFiles[indexBitmaps].useGrayscale){ byte r = SetBit(pixelColor.R, 0, currentBit); byte g = SetBit(pixelColor.G, 0, currentBit); byte b = SetBit(pixelColor.B, 0, currentBit); pixelColor = Color.FromArgb(r, g, b); }else{ //Change one component of the color to the messagebyte byte colorComponentValue = GetColorComponent(pixelColor, currentColorComponent); colorComponentValue = SetBit(colorComponentValue, 0, currentBit); SetColorComponent(ref pixelColor, currentColorComponent, colorComponentValue); //Rotate color components currentColorComponent = (currentColorComponent==2) ? 0 : (currentColorComponent+1); } bitmaps[indexBitmaps].SetPixel(pixelPosition.X, pixelPosition.Y, pixelColor); } } if(extract){ currentByte = (byte)(currentByte ^ currentReverseKeyByte); messageStream.WriteByte(currentByte); }

28

countBytesInCurrentImage++; } } /// <summary>Get the value of a bit</summary> /// <param name="b">The byte value</param> /// <param name="position">The position of the bit</param> /// <returns>The value of the bit</returns> private static bool GetBit(byte b, byte position){ return ((b & (byte)(1 << position)) != 0); } /// <summary>Set a bit to [newBitValue]</summary> /// <param name="b">The byte value</param> /// <param name="position">The position (1-8) of the bit</param> /// <param name="newBitValue">The new value of the bit in position [position]</param> /// <returns>The new byte value</returns> private static byte SetBit(byte b, byte position, bool newBitValue){ byte mask = (byte)(1 << position); if(newBitValue){ return (byte)(b | mask); }else{ return (byte)(b & ~mask); } } /// <summary>Return one component of a color</summary> /// <param name="pixelColor">The Color</param> /// <param name="colorComponent">The component to return (0-R, 1-G, 2-B)</param> /// <returns>The requested component</returns> private static byte GetColorComponent(Color pixelColor, int colorComponent){ byte returnValue = 0; switch(colorComponent){ case 0: returnValue = pixelColor.R; break; case 1: returnValue = pixelColor.G; break; case 2: returnValue = pixelColor.B; break; } return returnValue; } /// <summary>Changees one component of a color</summary> /// <param name="pixelColor">The Color</param> /// <param name="colorComponent">The component to change (0-R, 1-G, 2-B)</param> /// <param name="newValue">New value of the component</param> private static void SetColorComponent(ref Color pixelColor, int colorComponent, int newValue){ switch(colorComponent){ case 0: pixelColor = Color.FromArgb(newValue, pixelColor.G, pixelColor.B); break;

29

case 1: pixelColor = Color.FromArgb(pixelColor.R, newValue, pixelColor.B); break; case 2: pixelColor = Color.FromArgb(pixelColor.R, pixelColor.G, newValue); break; } } private static String UnTrimColorString(String color, int desiredLength){ int difference = desiredLength - color.Length; if(difference > 0){ color = new String('0', difference) + color; } return color; }

private static void SaveBitmap(Bitmap bitmap, String fileName){ String fileNameLower = fileName.ToLower(); System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Bmp; if((fileNameLower.EndsWith("tif"))||(fileNameLower.EndsWith("tiff"))){ format = System.Drawing.Imaging.ImageFormat.Tiff; }else if(fileNameLower.EndsWith("png")){ format = System.Drawing.Imaging.ImageFormat.Png; } //copy the bitmap Image img = new Bitmap(bitmap); //close bitmap file bitmap.Dispose(); //save new bitmap img.Save(fileName, format); img.Dispose(); } //--------------------------------------------- combining the keys /// <summary>Combines key file and password using XOR</summary> /// <param name="key">The key/password pair to combine</param> /// <returns>The stream created from key and password</returns> public static MemoryStream CreateKeyStream(FilePasswordPair key){ FileStream fileStream = new FileStream(key.fileName, FileMode.Open); MemoryStream resultStream = new MemoryStream(); int passwordIndex = 0; int currentByte = 0; while( (currentByte = fileStream.ReadByte()) >= 0 ){ //combine the key-byte with the corresponding password-byte currentByte = currentByte ^ key.password[passwordIndex]; //add the result to the key stream resultStream.WriteByte((byte)currentByte);

30

//proceed to the next letter or repeat the password passwordIndex++; if(passwordIndex == key.password.Length){ passwordIndex = 0; } } fileStream.Close(); resultStream.Seek(0, SeekOrigin.Begin); return resultStream; } /// <summary>Combines all key files and passwords into one key stream</summary> /// <param name="keys">The keys to combine</param> /// <returns>The resulting key stream</returns> private static MemoryStream GetKeyStream(FilePasswordPair[] keys){ //Xor the keys an their passwords MemoryStream[] keyStreams = new MemoryStream[keys.Length]; for(int n=0; n<keys.Length; n++){ keyStreams[n] = CreateKeyStream(keys[n]); } //Buffer for the resulting stream MemoryStream resultKeyStream = new MemoryStream(); //Find length of longest stream long maxLength = 0; foreach(MemoryStream stream in keyStreams){ if( stream.Length > maxLength ){ maxLength = stream.Length; } } int readByte = 0; for(long n=0; n<=maxLength; n++){ for(int streamIndex=0; streamIndex<keyStreams.Length; streamIndex++){ if(keyStreams[streamIndex] != null){ readByte = keyStreams[streamIndex].ReadByte(); if(readByte < 0){ //end of stream - close the file //the last loop (n==maxLength) will close the last stream keyStreams[streamIndex].Close(); keyStreams[streamIndex] = null; }else{ //copy a byte into the result key resultKeyStream.WriteByte( (byte)readByte ); } } } } return resultKeyStream; }}}

31

Chapter 8 USER MANUAL


8.1 INSTALLATION AND SETUP
For this project firstly we will have to install Visual Studio 2008

8.2 HOW TO RUN THE PROJECT?


1. Open Visual Studio 2008 click on File tab in Menu bar. 2. Then select Open and load our project by browsing. 3. Then click on the Build tab from Menu bar, check if any errors occur. 4. Then press F5.

8.3 USER INTERFACE


1. Firstly we will have to select the file that we want to hide. 2. Then select the key file for accessing that file and provide that file with a password. 3. Select Bitmap image through which we will hide that image and then save that image with some other name with .bmp extension. 4. Then click on the Hide Message Button. 5. The same procedure now for extracting the file. 6. Select the key file, the password given while hiding should match with password given while extracting. 7. Select a file where we will save the extracted message. 8. Then select the Bitmap image. 9. Click on the Extract Button. We will now be able to see the Extracted message in the file that we saved the message.

32

8.4 ERROR MESSAGES


There can errors occur in the following way: If the bitmap image is smaller than the file we want to hide following error will occur:

If the password doesnt match then the following error will occur:

33

Chapter 9 CONCLUSION AND FUTURE SCOPE

9.1 CONCLUSION
Steganography is not intended to replace cryptography but rather to supplement it. If a message is encrypted and hidden with a steganographic method it provides an additional layer of protection and reduces the chance of the hidden message being detected. Steganography is still a fairly new concept to the general public although this is likely not true in the world of secrecy and espionage. Digital watermark technology is currently being used to track the copyright and ownership of digital content. Efforts to improve the robustness of the watermarks are necessary to ensure that the watermarks and embedded information can securely defend against watermarking attacks. With continuous advancements in technology it is expected that in the near future more efficient and advanced techniques in steganalysis will emerge that will help law enforcement to better detect illicit materials transmitted through the Internet. The tutorial introduces a tiny part of the art of steganography. Steganography goes well beyond simply hiding text information in an image. Steganography applies not only to digital images but to other media as well, such as audio files, communication channels, and other text and binary files.

9.2 FUTURE SCOPE


This project is developed for hiding information in any image file. The scope of the project is implementation of steganography tools for hiding information includes any type of information file and image files and the path where the user wants to save Image and extruded file. Modification and enhancement can be made affecting any other part of the program because of the user friendliness and understandability of the project. The data screens can be upgraded and menus can be easily added when required. Items can be added to the forms when there comes necessity of new data.

34

Chapter 10 ACTUAL SCREEN LAYOUT


10.1SCREEN LAYOUT FOR HIDING IMAGE

35

10.2 SCREEN LAYOUT FOR KEYFILES

10.3 SCREEN LAYOUT FOR ADDING BITMAP IMAGE

36

10.4 SCREEN LAYOUT FOR HIDING THE FILE

37

10.5 SCREEN LAYOUT FOR EXTRACTING

10.6

SCREEN

LAYOUT

FOR

EXTRACTING

FILES

38

REFERNCES
Websites Following websites are referring to create this project reports. http://www.microsoft.com http://www.programmer2programmer.net http://www.codeproject.com http://www.asp.net http://www.asp123.com http://www.wikipedia.org http://www.jjtc.com http://www.scribd.com

Books Following books and eBook are used to complete this project reports. Mastering C# .NET Black Book Professional C#, 2nd Edition

39

Das könnte Ihnen auch gefallen