Example #1
0
        public static bool LoadSession(string path, out WipeSession session)
        {
            // check the parameters
            if(path == null) {
                throw new ArgumentNullException("path");
            }

            session = null;

            try {
                // create the store
                FileStore.FileStore store = new FileStore.FileStore();
                store.Encrypt = true; // use encryption
                store.UseDPAPI = true; // use default encryption

                // load store
                if(store.Load(path) == false) {
                    Debug.ReportError("Error while loading store from path {0}", path);
                    return false;
                }

                // deserialize
                session = DeserializeSession(store.ReadFile("session.dat"));
                return true;
            }
            catch(Exception e) {
                Debug.ReportError("Error while loading session. Exception: {0}", e.Message);
                return false;
            }
        }
Example #2
0
        public static bool SaveSession(WipeSession session, string path)
        {
            // check the parameters
            if(session == null || path == null) {
                throw new ArgumentNullException("session | path");
            }

            try {
                // create the store
                FileStore.FileStore store = new FileStore.FileStore();
                store.Encrypt = true;
                store.UseDPAPI = true;

                // add the file
                FileStore.StoreFile file = store.CreateFile("session.dat");
                byte[] data = SerializeSession(session);

                if(data == null) {
                    return false;
                }

                // write the file contents
                store.WriteFile(file, data, FileStore.StoreMode.Encrypted);
                return store.Save(path);
            }
            catch(Exception e) {
                Debug.ReportError("Error while saving session. Exception: {0}", e.Message);
                return false;
            }
        }
Example #3
0
        public static byte[] SerializeSession(WipeSession session)
        {
            BinaryFormatter serializer = new BinaryFormatter();
            MemoryStream stream = new MemoryStream();

            try {
                // serialize in memory
                serializer.Serialize(stream, session);
                return stream.ToArray();
            }
            catch(Exception e) {
                Debug.ReportError("Error while serializing session. Exception: {0}", e.Message);
                return null;
            }
            finally {
                if(stream != null) {
                    stream.Close();
                }
            }
        }
Example #4
0
 public StatusDialog()
 {
     InitializeComponent();
     session = new WipeSession();
     fileCopy = new FileCopy();
 }
Example #5
0
        private void Export()
        {
            FileStore.FileStore store = new FileStore.FileStore();
            FileStore.StoreFile file = null;
            FileStore.StoreMode storeMode = FileStore.StoreMode.Normal;

            if(EncryptCheckbox.Checked) {
                SHA256Managed passwordHash = new SHA256Managed();
                store.Encrypt = true;
                store.EncryptionKey = passwordHash.ComputeHash(Encoding.ASCII.GetBytes(PasswordTextbox.Text));
                storeMode = FileStore.StoreMode.Encrypted;
            }

            // general settings
            if(GeneralCheckbox.Checked) {
                file = store.CreateFile("options.dat");
                store.WriteFile(file, SDOptionsFile.SerializeOptions(_options), storeMode);
            }

            // default plugin settings
            if(PluginCheckbox.Checked) {
                file = store.CreateFile("pluginSettings.dat");
                if(store.WriteFile(file, SecureDeleteLocations.GetPluginDefaultSettingsFilePath(), storeMode) == false) {
                    actionErrors.Add("Failed to export default plugin settings");
                }
            }

            // add methods
            if(MethodsCheckbox.Checked) {
                store.CreateFolder("methods");
                Dictionary<int, string> methodList = new Dictionary<int, string>();

                // add methods
                foreach(ListViewItem item in MethodList.Items) {
                    if(item.Checked) {
                        int id = (int)item.Tag;
                        string methodFile = Path.Combine(SecureDeleteLocations.GetMethodsFolder(),
                                                         id.ToString() + WipeMethodManager.MethodFileExtension);

                        file = store.CreateFile("methods\\" + Path.GetFileName(methodFile));
                        if(store.WriteFile(file, methodFile, storeMode) == false) {
                            actionErrors.Add("Failed to export wipe method " + item.Text);
                        }

                        // add to methd list
                        methodList.Add(id, item.Text);
                    }
                }

                // store the method list
                file = store.CreateFile("methods\\list.dat");
                store.WriteFile(file, SerializeMethodList(methodList), storeMode);
            }

            // scheduled tasks
            if(TasksCheckbox.Checked) {
                store.CreateFolder("tasks");

                // add task list
                file = store.CreateFile("tasks\\list.dat");
                store.WriteFile(file, SerializeTaskList(_options.SessionNames), storeMode);

                foreach(ListViewItem item in TaskList.Items) {
                    if(item.Checked) {
                        Guid taskId = (Guid)item.Tag;
                        string taskFile = SecureDeleteLocations.GetTaskFile(taskId);
                        string sessionFile = SecureDeleteLocations.GetSessionFile(taskId);

                        file = store.CreateFile("tasks\\" + Path.GetFileName(taskFile));
                        ScheduledTask task = new ScheduledTask();
                        TaskManager.LoadTask(taskFile, out task);
                        store.WriteFile(file, TaskManager.SerializeTask(task), storeMode);

                        file = store.CreateFile("tasks\\" + Path.GetFileName(sessionFile));
                        WipeSession session = new WipeSession();
                        SessionLoader.LoadSession(sessionFile, out session);
                        store.WriteFile(file, SessionSaver.SerializeSession(session), storeMode);
                    }
                }
            }

            // save
            if(store.Save(ExportPath.Text) == false) {
                actionErrors.Add("Failed to export to file " + ExportPath.Text);
            }
        }
        private void AddTask()
        {
            WipeSession session = new WipeSession();
            session.GenerateGuid();
            ScheduledTask task = new ScheduledTask();
            task.TaskId = session.SessionId;
            task.Schedule = new OneTimeSchedule();
            task.Name = "Untitled task";
            task.Enabled = true;

            // show the dialog
            ScheduleOptions options = new ScheduleOptions();
            options.Options = _options;
            options.EditMode = false;
            options.Task = task;

            if(options.ShowDialog() == DialogResult.OK) {
                task = options.Task;
                manager.LoadOptions();
                manager.AddTask(task, true);

                SessionSaver.SaveSession(session, SecureDeleteLocations.GetSessionFile(task.TaskId));
                ListViewItem item = CreateTaskItem(task);
                UpdateTaskItem(item);

                // add to the <guid,taskName> mapping
                _options.SessionNames.Add(task.TaskId, task.Name);
                SDOptionsFile.TrySaveOptions(_options);
                TaskList.Items[TaskList.Items.Count - 1].Selected = true;
            }

            _actionManager.StateChanged();
        }
Example #7
0
 public WipeModule()
 {
     InitializeComponent();
     _session = new WipeSession();
     loadStopped = true;
     _async = true;
     InitializeActions();
 }
Example #8
0
        private void LoadSessionImpl(string path)
        {
            WipeSession session;

            if(SessionLoader.LoadSession(path, out session) == false) {
                MessageBox.Show("Failed to open _session.", "SecureDelete",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else {
                Session = session;
                sessionFile = path;
            }
        }
Example #9
0
        private void HandleNewSession()
        {
            if(_session == null) {
                _session = new WipeSession();
                return;
            }

            // clear the category
            this.Invoke((MethodInvoker)delegate() {
                ObjectList.Items.Clear();
            });

            // add the new items
            List<IWipeObject> wipeObjects = _session.Items;

            if(wipeObjects != null) {
                if(_async) {
                    int count = wipeObjects.Count;
                    int start = 0;
                    InsertObjectsDelegate del = new InsertObjectsDelegate(InsertObjects);

                    while(count > 0 && !loadStopped) {
                        int objectCount = Math.Min(32, count);
                        this.Invoke(del, wipeObjects, start, objectCount);
                        Thread.Sleep(30);

                        count -= objectCount;
                        start += objectCount;
                    }

                    // task completed
                    if(loadStopped == false) {
                        this.Invoke(new EventHandler(LoadTaskCompleted), null, null);
                    }
                }
                else {
                    ObjectList.BeginUpdate();
                    int count = wipeObjects.Count;

                    for(int i = 0; i < count; i++) {
                        InsertObject(wipeObjects[i]);
                    }

                    ObjectList.EndUpdate();
                }
            }
        }
Example #10
0
 private void CreateNewSession()
 {
     Session = new WipeSession();
     sessionFile = null;
 }
Example #11
0
 public bool DeserializeSession(string file, out WipeSession session)
 {
     session = null;
     return false;
 }
Example #12
0
 public ExampleBridge(WipeSession session, bool afterWipe)
 {
     _session = session;
     _afterWipe = afterWipe;
 }