Exemplo n.º 1
0
        /// <summary>
        /// Called when an application request to send a file
        /// </summary>
        /// <param name="client"></param>
        private void AcceptFile(Socket client)
        {
            try
            {
                HandshakeData data = this._receiver.Handshake(client);

                if (data == null)
                {
                    return;
                }

                DialogResult result = UIMessage.Ask(this, "A computer " + data.MachineName +
                                                    " wishes to transfer a file " + data.FileName +
                                                    " of size" + this.ToSize(data.FileLen) +
                                                    "\r\nAccept?", "Receive file");

                this._receiver.HandshakeResponse(client, result == DialogResult.Yes);

                ///If user decided to not receive the file
                if (result == DialogResult.No)
                {
                    return;
                }

                ///Fire the delegate that will call the ShowReceiveFileForm method
                this.BeginInvoke(new OpenReceiveFormCallback(this.ShowReceiveFileForm), client, data);
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when background worker completes the task
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            BackgroundWorkerArgs args = e.Result as BackgroundWorkerArgs;

            ///If an error occured during process
            if (e.Error != null)
            {
                string caption = "HideIt";
                if (args != null)
                {
                    caption = ((args.Action == ActionType.Hide) ? "Hide Message" : "Extract Message");
                }
                UIMessage.Error(e.Error.Message, caption);
            }

            if (args != null)
            {
                try
                {
                    args.Message.Dispose();
                    this._processor.Dispose();
                    this._processor = null;
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 3
0
        ///An interface for obtaining an IObject given a moniker string.
        ///A moniker can be used to obtain a particular object using a human-readable string to describe it,
        ///rather than having to know the object's UUID. Human-readable strings are, unfortunately, not
        ///guaranteed to be universally unique, so you might (theoretically) not get the object you want.
        ///It is an object that implements the IMoniker interface. A moniker acts as a name that uniquely
        ///identifies a COM object. In the same way that a path identifies a file in the file system,
        ///a moniker identifies a COM object in the directory namespace.
        ///A COM object that is used to create instances of other objects. Monikers save programmers time
        ///when coding various types of COM-based functions such as linking one document to another (OLE). See COM and OLE.
        /// <summary>
        /// Start capturing
        /// </summary>
        private bool Initialize()
        {
            if (this._selectDevice == null)
            {
                return(false);
            }

            if (this._selectDevice.CaptureDevice == null)
            {
                return(false);
            }

            IMoniker moniker = this._selectDevice.CaptureDevice.Moniker;

            if (moniker == null)
            {
                UIMessage.Info("Please select a capturing device", TITLE);
                return(false);
            }
            if (string.IsNullOrEmpty(this.txt_saveCapturedPath.Text))
            {
                UIMessage.Info("Please select a path to save captured video", TITLE);
                return(false);
            }
            if (string.IsNullOrEmpty(this.txt_keyLive.Text))
            {
                UIMessage.Info("Key lenght must be atleast 4 characters and atmost 256 characters", TITLE);
                return(false);
            }

            this._liveProcessor = new CaptureStegoProcess(moniker);
            this._liveProcessor.Setup(this.txt_saveCapturedPath.Text, this.vidOwner);

            return(true);
        }
Exemplo n.º 4
0
        private void btnStop_Click(object sender, EventArgs e)
        {
            if (this._initialized)
            {
                this._liveProcessor.StopCapturing();
                this._isPlaying = false;

                this.txt_saveCapturedPath.Text = string.Empty;

                if (this._message != null)
                {
                    this._message.Dispose();
                }
                try
                {
                    this._liveProcessor.Dispose();
                }
                catch (Exception exc)
                {
                    UIMessage.Error(exc.Message, TITLE);
                }

                this._initialized = false;
            }
        }
Exemplo n.º 5
0
 void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     ///If any exception occured while running worker_DoWork method
     if (e.Error != null)
     {
         UIMessage.Error(e.Error.Message, TITLE);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Select a bitmap file as stago file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_browseStego_Click(object sender, EventArgs e)
        {
            using (Status status = new Status(null, this.lbl_status, "Open stego file"))
            {
                try
                {
                    string path = AppUtil.SelectFile("Open stego file", "Bitmap (*.bmp)|*.bmp|AVI (*.avi)|*.avi|WAV (*.wav)|*.wav", "bmp").ToLower();

                    if (!string.IsNullOrEmpty(path))
                    {
                        this.txt_stegoObject.Text = path;

                        ///Dispose the previous processor
                        if (this._processor != null)
                        {
                            this._processor.Dispose();
                        }

                        this._processor = StegoProcessorBase.GetProcessor(path, false);
                        this._processor.LoadHost(path, true);

                        if (this._processor.MType == HostMediaType.Bitmap)
                        {
                            ///Let show the pic in preview box. Open the image by giving the path
                            ///The size mode of this image is set to zoom. So if the image is bigger then the
                            ///frame it will automatically adjust it to fit the frame. Same happens if it is smaller
                            ///then the frame
                            this.pic_stegoPreview.Image = new System.Drawing.Bitmap(this.txt_stegoObject.Text);
                        }
                        else if (this._processor.MType == HostMediaType.Wave)
                        {
                            this.pic_stegoPreview.Image = global::HideIt.Properties.Resources.wav;
                        }
                        else
                        {
                            ///setup the Avi icon image
                            this.pic_stegoPreview.Image = global::HideIt.Properties.Resources.avi;
                        }
                    }
                }
                catch (Exception exc)
                {
                    UIMessage.Error(exc.Message, TITLE);

                    if (this._processor != null)
                    {
                        try
                        {
                            this._processor.Dispose();
                        }
                        catch (Exception)
                        {
                        }
                        this._processor = null;
                    }
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Called when the form is first shown
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void HideIt_Shown(object sender, EventArgs e)
 {
     this._receiver = new FileReceiver(this._acceptFile);
     try
     {
         this._receiver.Listen(Options_Form.Port);
     }
     catch (Exception exc)
     {
         UIMessage.Error("An error occured while starting the listener. " +
                         "Application will not be able to receive files.\r\n" +
                         "Error: " + exc.Message, TITLE);
     }
 }
Exemplo n.º 8
0
        private void btn_browseAvi_Click(object sender, EventArgs e)
        {
            this._srcFile        = AppUtil.SelectFile("Open video file", "AVI (*.avi)|*.avi", "avi");
            this.txtLoadAvi.Text = this._srcFile;

            try
            {
                if (this._srcFile != string.Empty)
                {
                    ///Get basic file information
                    Type      t        = Type.GetTypeFromCLSID(ComGuids.MediaDetGuid);
                    IMediaDet mediaDet = (IMediaDet)Activator.CreateInstance(t);

                    ///Set the avi file name for which we have to find information
                    mediaDet.put_Filename(this._srcFile);

                    ///Check for the current stream. If it is audio, set it up for video
                    AMMediaType mediaType = new AMMediaType();
                    mediaDet.get_StreamMediaType(mediaType);

                    ///If format type is not video
                    if (mediaType.formatType != ComGuids.VideoFormatGuid)
                    {
                        mediaDet.put_CurrentStream(1);
                        mediaDet.get_StreamMediaType(mediaType);
                    }

                    double prop = 0;
                    ///Get media length
                    mediaDet.get_StreamLength(out prop);
                    this._totalFrames = prop;

                    ///Get frame rate
                    mediaDet.get_FrameRate(out prop);
                    this._totalFrames = Math.Floor(this._totalFrames * prop);

                    AppUtil.SetupProgressBar(this.progress, 0, (int)this._totalFrames);
                }
            }
            catch (Exception exc)
            {
                UIMessage.Error(exc.Message, TITLE);
            }
        }
Exemplo n.º 9
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            this.FileName = AppUtil.SelectFile("Open video file", "AVI (*.avi)|*.avi", "avi");
            if (this.FileName != string.Empty)
            {
                try
                {
                    this.CloseInterfaces();
                    this.PopulateMediaInformation();
                    this.BuildGraph();

                    ///Get file name from path
                    this.lbl_movieName.Text = Path.GetFileName(this.FileName);
                }
                catch (Exception ex)
                {
                    UIMessage.Error(ex.Message, TITLE);
                }
            }
        }
Exemplo n.º 10
0
        private void btn_start_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this._srcFile))
            {
                UIMessage.Info("Please select source AVI file for decompression.", TITLE);
                return;
            }

            if (string.IsNullOrEmpty(this._dcFile))
            {
                UIMessage.Info("Please specify save path for decompressed AVI file.", TITLE);
                return;
            }

            if (this.worker.IsBusy)
            {
                return;
            }

            this.worker.RunWorkerAsync();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Select a bitmap file as cover object
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_browseCover_Click(object sender, EventArgs e)
        {
            using (Status status = new Status(null, this.lbl_status, "Open cover file"))
            {
                try
                {
                    string path = AppUtil.SelectFile("Open cover file", "Bitmap (*.bmp)|*.bmp|AVI (*.avi)|*.avi|WAV (*.wav)|*.wav", "bmp").ToLower();

                    if (!string.IsNullOrEmpty(path))
                    {
                        this.txt_coverFileName.Text = path;

                        if (this._processor != null)
                        {
                            this._processor.Dispose();
                        }

                        LoadProcessor(path);
                    }
                }
                catch (Exception exc)
                {
                    UIMessage.Error(exc.Message, TITLE);
                    if (this._processor != null)
                    {
                        try
                        {
                            this._processor.Dispose();
                        }
                        catch (Exception)
                        {
                        }
                        this._processor = null;
                    }
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Extract the message from stego object
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_extract_Click(object sender, EventArgs e)
        {
            this.progress.Value = 0;

            if (this._processor == null)
            {
                UIMessage.Info("No stego object selected to extract data from", "Extract Message");
                return;
            }

            ///Check whether user has entered the key
            if (this.txt_stegoKey.Text.Length == 0)
            {
                UIMessage.Info("Please provide the key used to hide the message", "Extract Message");
                return;
            }

            ///Run the extraction process in background worker thread
            this.backgroundWorker.RunWorkerAsync(new BackgroundWorkerArgs()
            {
                Action = ActionType.Extract,
                Key    = this.txt_stegoKey.Text
            });
        }
Exemplo n.º 13
0
        /// <summary>
        /// Hide the message in cover object
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_hide_Click(object sender, EventArgs e)
        {
            this.progress.Value = 0;

            ///If no cover object selected yet
            if (this._processor == null)
            {
                UIMessage.Info("Please select a cover object to hide message in", "Hide Message");
                return;
            }

            ///Check the legth of key
            if (this.txt_key.Text.Length < 4 || this.txt_key.Text.Length > Stego.Message.MAX_KEY_LEN)
            {
                UIMessage.Info("Key lenght must be atleast 4 characters and atmost 256 characters",
                               "Hide Message");
                return;
            }

            ///Check if there is enough room in cover object to store secret message and key in it
            if (this._hidingCapacity < (this.rtxt_message.Text.Length + this.txt_key.Text.Length + 8))
            {
                UIMessage.Error("Message is bigger then hiding capacity", "Hide Message");
                return;
            }

            ///Initialize the porgress bar
            this.progress.Minimum = 0;
            this.progress.Maximum = (int)this._processor.HostObject.Length;

            ///See if user hasn't entered the save path for stego object
            if (string.IsNullOrEmpty(this.txt_saveStego.Text))
            {
                UIMessage.Info("Please select a path to save stego object", "Hide Message");
                return;
            }

            ///Run the hiding process in background worker thread
            this.backgroundWorker.RunWorkerAsync(new BackgroundWorkerArgs()
            {
                Action   = ActionType.Hide,
                Message  = new HideIt.Stego.Message(this.txt_key.Text, this.rtxt_message.Text),
                SinkPath = this.txt_saveStego.Text
            });

            using (new Status(this, this.lbl_status, "Logging information in database..."))
            {
                ///data insertion to maintain log table
                string        _stego_file_name = txt_saveStego.Text;
                string        _key             = txt_key.Text;
                string        _time            = DateTime.Now.ToLongTimeString();
                string        _date            = DateTime.Now.ToShortDateString();
                SqlConnection con = new SqlConnection(DB.DbConnectionStr.conect());
                ///SqlConnection con = new SqlConnection(constr);
                SqlCommand query = new SqlCommand("insert into Log_Table values('" + _stego_file_name + "','" + _key + "', '" + _date + "', '" + _time + "')", con);
                try
                {
                    con.Open();
                    query.ExecuteNonQuery();
                    MessageBox.Show("Record entered successfully.");
                    con.Close();
                }
                catch (SqlException ex)
                {
                    UIMessage.Error(ex.Message, TITLE);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Called when new task is registered with background worker
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorkerArgs args = e.Argument as BackgroundWorkerArgs;

            ///Set the result to args that will be used when operations completes
            e.Result = args;

            if (args != null)
            {
                switch (args.Action)
                {
                case ActionType.Hide:
                    //User has entered a save path for stego object, start hiding
                    using (Status status = new Status(this, this.lbl_status, "Hidding..."))
                    {
                        RC4 encrypt = new RC4(args.Message.Key, args.Message.SecertMessage);

                        HideIt.Stego.Message message = new HideIt.Stego.Message(
                            args.Message.Key, encrypt.ApplyRC4());

                        using (LockUI lockUi = new LockUI(this))
                        {
                            this._processor.Hide(message, args.SinkPath);
                            //"hide" tab selected
                        }
                    }
                    break;

                case ActionType.Extract:

                    using (Status status = new Status(this, this.lbl_status, "Extracting..."))
                    {
                        using (LockUI lockUi = new LockUI(this))
                        {
                            args.Message = this._processor.Extract(args.Key);
                            //"extract" tab selected
                        }
                    }

                    if (args.Message == null)
                    {
                        UIMessage.Info("Cannot extract message from stego object because of one of the following reasons:\r\n" +
                                       "-Stego object do no contain any message\r\n" +
                                       "-Key provided do not match with the key used to hide message",
                                       "Extract Message");
                        return;
                    }

                    RC4 decrypt = new RC4(args.Key, args.Message.SecertMessage);

                    if (this.rtxt_hiddenMsg.InvokeRequired)
                    {
                        this.rtxt_hiddenMsg.Invoke((MethodInvoker)(() => { this.rtxt_hiddenMsg.Text = decrypt.ApplyRC4(); }));
                    }
                    else
                    {
                        this.rtxt_hiddenMsg.Text = decrypt.ApplyRC4();
                    }
                    break;
                }
            }
        }
Exemplo n.º 15
0
        private void LoadWatermarkingStegoProcessor()
        {
            try
            {
                ///Reduce the message length to 256 character
                if (this.cb_watermark.Checked)
                {
                    ///Change summary controls
                    WatermarkSummary summaryControl = new WatermarkSummary();
                    this._currentControl = summaryControl;
                    this.ShowNewSummaryControl(summaryControl);

                    if (this._processor != null)
                    {
                        try
                        {
                            this._processor.Dispose();
                        }
                        catch (Exception)
                        {
                        }
                        this._processor = null;
                    }

                    this._processor = StegoProcessorBase.GetProcessor(this.txt_coverFileName.Text, true);
                    if (this._processor == null)
                    {
                        return;
                    }
                    this._processor.LoadHost(this.txt_coverFileName.Text, true);

                    WatermarkingStegoProcessor processor = (WatermarkingStegoProcessor)this._processor;

                    ///Display the length of video
                    summaryControl.VideoLength = processor.Length.ToString() + " sec";

                    ///Display the framerate
                    summaryControl.FrameRate = processor.FrameRate.ToString();

                    ///Display the dimensions
                    summaryControl.Dimension = processor.Width.ToString() + " x " + processor.Height.ToString() + " px";

                    ///Display the hiding capacity
                    this._hidingCapacity = (int)processor.HidingCapacity / 2;

                    this.rtxt_message.MaxLength = WATERMARK_LEN;

                    ///If there is already text in text box
                    if (rtxt_message.Text.Length > WATERMARK_LEN)
                    {
                        DialogResult result = UIMessage.Ask(this, @"Enabling watermarking allows only " + WATERMARK_LEN.ToString() + " characters for hiding.\r\n"
                                                            + "The current length of message is " + this.rtxt_message.Text.Length.ToString() + ".\r\n"
                                                            + "Do you wish to automatically strip the mssage to " + WATERMARK_LEN.ToString() + " characters?",
                                                            TITLE);

                        if (result == DialogResult.Yes)
                        {
                            this.rtxt_message.Text = this.rtxt_message.Text.Substring(0, WATERMARK_LEN - 1);
                        }
                        else
                        {
                            this.cb_watermark.Checked = false;
                        }
                    }
                }
                else
                {
                    this.LoadProcessor(this.txt_coverFileName.Text);
                }
            }
            catch (Exception exc)
            {
                UIMessage.Error(exc.Message, TITLE);
                if (this._processor != null)
                {
                    try
                    {
                        this._processor.Dispose();
                    }
                    catch (Exception)
                    {
                    }
                    this._processor = null;
                }
            }
        }