Skip to main content

Posts

Showing posts with the label Parsing

Parsing and reporting on hyperlinks in email using EWS and REST (eg looking for baseStriker) in Exchange and Office365

Its been quite a busy week in Email security the pass 7 days with 2 new vulnerabilities released in the last week first BaseStriker  https://www.avanan.com/resources/basestriker-vulnerability-office-365 and now EFail https://searchsecurity.techtarget.com/news/252441096/Efail-flaws-highlight-risky-implementations-of-PGP-and-S-MIME . While its still too early to gauge the implications of both of these flaws what they both have in common is using the HTML body of a message and underlying html markup tags to make these exploits work. With baseStriker its the use of the Base Href tag in a HTML document and with EFail using an Img Src tag to send decrypted email contents to an external server (this is an over simplification). In this post I'm going to look at how you can parse the HTML Links, Image SRC tags from messages that are sitting in a Mailbox (so post any Transport pipeline filtering) and provide a level or reporting on these. Or basically because we are going to be using the...

Parsing out URL's in the body of a Message with EWS and Powershell

Sometimes when your writing an Automation script you might want to parse a certain URL from the Body of a Message. One example would be the Lync Meeting URL from an Online Meeting invitation or another might but a DropBox URL for a shared file. To grab the Body of a Message in the EWS Managed API you need to use either Load() or LoadPropertiesForItems() if you have a number of messages your processing. Using these methods will do a GetItem (or batch GetItem) in EWS. To parse the URL's from the HTML body markup that EWS returns you can use some RegEx to separate out all the links. Then you can use the URI class from .net to parse the matches further and identify the hosts in the URL to see if its the URL your looking for. The following sample will loop through the last 100 emails in a mailbox's and parse any Lync Meeting URL's (for Office365) or Dropbox URL's. I've put a download of this script here The code looks like ## Get the Mailbox to Acce...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.