Пример #1
0
        private IRDOFolder FindOrCreate(IRDOFolder root, string name, int defKind, bool isDefKindSet = true)
        {
            RDOFolder2 folder;

            try
            {
                folder = (isDefKindSet ? _session.GetDefaultFolder((rdoDefaultFolders)defKind) : root.Folders[name]) as RDOFolder2;
            }
            catch (Exception)
            {
                folder = root.Folders.Add(name) as RDOFolder2;
                if (isDefKindSet)
                {
                    folder?.SetAsDefaultFolder(defKind);
                }
            }
            if (folder == null)
            {
                folder = root.Folders.Add(name) as RDOFolder2;
                if (isDefKindSet)
                {
                    folder?.SetAsDefaultFolder(defKind);
                }
            }
            return(folder);
        }
Пример #2
0
        private void convertButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(pstOutputPath.Text) || string.IsNullOrEmpty(folderInputPath.Text))
            {
                MessageBox.Show("Please select both paths !");
                return;
            }



            RDOSession session = new RDOSession(); // throws exception 1

            session.LogonPstStore(pstOutputPath.Text);
            RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);

            string[] fileEntries = Directory.GetFiles(folderInputPath.Text, "*.eml");


            foreach (string filePath in fileEntries)
            {
                RDOMail mail = folder.Items.Add("IPM.Mail");
                mail.Sent = true;
                mail.Import(filePath, 1024);
                // folder.Items.Add(mail);
                mail.Save();
            }

            session.Logoff();


            MessageBox.Show("Done converting !");
        }
Пример #3
0
        public static void SyncPSTFiles()
        {
            if (Global.isSyncing)
            {
                Log.Append("ERROR: Cannot sync pst files because email synchronization is in progress");
                return;
            }

            TimeSpan startTime = DateTime.Now.TimeOfDay;

            Log.Append("Syncing all available .pst files...");

            string[] pstFiles = Directory.GetFiles(pstSyncDirectoryPath, "*.pst*");

            foreach (string filePath in pstFiles.Where(x => !x.Contains("tmp")))
            {
                string dumpPath = pstDumpDirectoryPath + Path.GetFileName(filePath);
                File.Move(filePath, dumpPath);

                Log.Append(String.Format("  Syncing emails from pst file '{0}'", Path.GetFileName(filePath)));

                RDOSession session = new RDOSession();
                session.LogonPstStore(dumpPath);
                RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);

                // Log-purpose parameters
                int pstEmailCount     = folder.Items.Count;
                int currentEmailCount = 0;

                foreach (RDOMail mail in folder.Items)
                {
                    currentEmailCount++;

                    Email email = new Email()
                    {
                        ID       = Global.GetAttachmentID(),
                        UID      = mail.EntryID,
                        To       = mail.To,
                        From     = mail.SenderEmailAddress,
                        Subject  = mail.Subject,
                        MailDate = mail.SentOn
                    };

                    email.RetrieveMsg();
                    Global.AppendEmail(email, String.Format("{0}/{1}", currentEmailCount, pstEmailCount));
                    mail.SaveAs(Global.messagesDirectoryPath + email.ID + ".eml", rdoSaveAsType.olRFC822);
                }

                session.Logoff();
            }

            pstFiles.Where(x => !x.Contains("tmp")).ForEach(x => Log.Append(String.Format("   Moving pst. file \"{0}\"", x)));

            Log.Append(String.Format("Synced all available PST files. Process took {0}",
                                     Arithmetic.GetStopWatchStr((DateTime.Now.TimeOfDay - startTime).TotalMilliseconds)));
        }
Пример #4
0
        private SortedList <string, Rfc822Message> getOutlookMessages()
        {
            System.Collections.Generic.SortedList <string, Rfc822Message> messages = new System.Collections.Generic.SortedList <string, Rfc822Message>();

            //Dim tempApp As Outlook.Application
            //Dim tempInbox As Outlook.MAPIFolder
            //Dim InboxItems As Outlook.Items
            //Dim tempMail As Object = Nothing
            //Dim objattachments, objAttach

            RDOSession session = null;

            //object inbox = null;
            try {
                //tempApp = New Outlook.Application

                session = (RDOSession)Interaction.CreateObject("Redemption.RDOSession");
                session.Logon();
            } catch (System.Exception ex) {
                GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, "Unable to create Outlook object: " + ex.Message, false);
                return(null);
            }
            //tempInbox = tempApp.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)

            RDOFolder inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);

            //InboxItems = tempInbox.Items
            //Dim msg As Outlook.MailItem
            foreach (MailItem msg in inbox.Items)
            {
                //For Each msg In InboxItems
                if (!string.IsNullOrEmpty(UtilFunctions.findIssueTag((Rfc822Message)msg).Trim()))
                {
                    if (!UtilFunctions.searchUID(msg.EntryID))
                    {
                        // No.  Add to list
                        messages.Add(msg.EntryID, (Rfc822Message)msg);
                    }
                }
                if (!runFlag | !isEnabled)
                {
                    break;                     // TODO: might not be correct. Was : Exit For
                }
            }
            session.Logoff();
            string cnt = messages.Count.ToString();

            cnt += " Outlook messages were found";
            GlobalShared.Log.Log((int)LogClass.logType.Info, cnt, false);

            return(messages);
        }
Пример #5
0
        private RDOFolder GetDefaultFolder(rdoDefaultFolders type, string name)
        {
            RDOFolder folder = null;

            try
            {
                folder = session.GetDefaultFolder(type);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                //if(e.Message.ToUpper().Contains("MAPI_E_NOT_FOUND"))
                folder = session.Stores.DefaultStore.IPMRootFolder.Folders.Add(name, type);
                folder.Save();
            }
            return(folder);
        }
Пример #6
0
        static void Main(string[] args)
        {
            string path = Path.GetFullPath(@"..\..\..\snapshot.pst");

            // Load the PST
            RDOSession session = new RDOSession();
            session.LogonPstStore(path);

            // Grab everything in the inbox
            RDOItems inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Items;

            // Filter out all emails from the flag mailer
            RDOItems spoofed = inbox.Restrict("[SenderEmailAddress]='*****@*****.**'");

            // The flag is hidden in the send date (year),
            // sorted by the delivery date
            string flag = string.Concat(spoofed.OfType<RDOMail>()
                                               .OrderBy(m => m.ReceivedTime) // Sort by delivery date
                                               .Select(m => m.SentOn.Year - 2000) // Get the flag ordinal values
                                               .Select(c => (char) c)); // Convert to char
            Console.Out.WriteLine(flag);
        }
Пример #7
0
        static void Main(string[] args)
        {
            string path = Path.GetFullPath(@"..\..\..\snapshot.pst");

            // Load the PST
            RDOSession session = new RDOSession();

            session.LogonPstStore(path);

            // Grab everything in the inbox
            RDOItems inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox).Items;

            // Filter out all emails from the flag mailer
            RDOItems spoofed = inbox.Restrict("[SenderEmailAddress]='*****@*****.**'");

            // The flag is hidden in the send date (year),
            // sorted by the delivery date
            string flag = string.Concat(spoofed.OfType <RDOMail>()
                                        .OrderBy(m => m.ReceivedTime)      // Sort by delivery date
                                        .Select(m => m.SentOn.Year - 2000) // Get the flag ordinal values
                                        .Select(c => (char)c));            // Convert to char

            Console.Out.WriteLine(flag);
        }
Пример #8
0
        static void Main(string[] args)
        {
            // <3 visual studio
            string origpath   = Path.GetFullPath(@"..\..\..\backup.pst");      // Just full of spam
            string targetpath = Path.GetFullPath(@"..\..\..\..\snapshot.pst"); // This will be the challenge

            // Copy over the original pst
            File.Copy(origpath, targetpath, true);

            // Have to use Redemption for this, since outlook is "secure"
            // Open the PST
            RDOSession session = new RDOSession();

            session.LogonPstStore(targetpath);

            // Load the target inbox
            RDOFolder inboxFolder = session.GetFolderFromPath("PRIVATE INBOX");
            RDOItems  inbox       = inboxFolder.Items;

            inbox.Sort("ReceivedTime", false); // Pre-sort them in ascending order
            Console.WriteLine(inbox.Count);

            // Encode the flag in DateTimes, hiding it in the year (2000 + c)
            // e.g. 3/9/2102 12:45:54 AM ==> 102 => 'f'
            var flag = "flag{w1k1L3ak5_g0T_n0tH1ng_0n_m3}".Select(c => EncodeChar(c)).ToList();

            // fun
            var aliases  = Cycle(aliasStrings).GetEnumerator();
            var subjects = Cycle(subjectStrings).GetEnumerator();

            // Approximately space out the emails
            int range = inbox.Count / flag.Count;

            for (int i = 0; i < flag.Count; i++)
            {
                // Copy the delivery time from a random email in this range
                DateTime recvTime = inbox[rand.Next(i * range, (i + 1) * range)].ReceivedTime;
                DateTime flagtime = flag[i];
                Console.WriteLine($"{flagtime} => {recvTime}");

                // Create a fake email with the two times and other fun stuff
                RDOMail flagmail = inbox.Add("IPM.Note");
                flagmail.Importance   = 1;
                flagmail.ReceivedTime = recvTime;
                flagmail.SentOn       = flagtime;
                flagmail.Subject      = subjects.Next();
                flagmail.To           = "*****@*****.**";
                flagmail.Sender       = session.GetAddressEntryFromID(session.AddressBook.CreateOneOffEntryID(aliases.Next(), "SMTP",
                                                                                                              "*****@*****.**",
                                                                                                              false, false));
                flagmail.Save();
            }

            // Sort the emails by delivery time, scattering the spoofed ones (in order) across the dump
            inbox = inboxFolder.Items;
            Console.WriteLine(inbox.Count);
            inbox.Sort("ReceivedTime", false);

            // Guess we're doing it this way -__-
            Console.WriteLine("Flag is in place, moving to inbox...");
            RDOFolder targetInbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox);

            foreach (RDOMail email in inbox)
            {
                email.CopyTo(targetInbox);
            }
            targetInbox.Save();
            Console.WriteLine("Done!");
        }
        public ActionResult Messages()
        {
            RDOSession Session = new RDOSession();
            Session.Logon();
            RDOExchangeMailboxStore mbStore = (RDOExchangeMailboxStore)Session.Stores.DefaultStore;

            //Evaluate with Drafts folder:
            RDOFolder Inbox = (RDOFolder)Session.GetDefaultFolder(rdoDefaultFolders.olFolderDrafts);

            var listing = new List<Message>();

            foreach (RDOMail item in Inbox.Items)
            {
                var temp = new Message();
                temp.Subject = item.Subject;
                temp.Received = item.ReceivedTime;
                temp.ID = item.EntryID;
                listing.Add(temp);
                temp = null;
            }

            GC.Collect();

            return View(listing.ToList<Message>());
        }