PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

Revisiting Syslog in PowerShell

I have performed a number of updates to the PowerShell SYSLOG module since this post. You can read the latest post. The module has been renamed to Posh-SYSLOG.

The GitHub location has been moved to https://github.com/poshsecurity/Posh-SYSLOG.

The module is now available on the PowerShell Gallery.


I often wonder, as I am sure most developers do, if people ever actually read and use the code that I post online. Was it helpful to them or was it useless? Did they use it for something interesting? One piece of code which I know people do use, is my PowerShell SYSLOG code.

A few weeks ago, a user opened my very first GitHub issue! This issue appeared at first to be simple, but as the user and I started to delve into the complexities of the various SYSLOG RFCs, I realized it was far from it.

Before we get into the issue, the code and the resolution, it is worth highlighting that there quite a few IETF RFCs that relate to SYSLOG messages. The two primary ones being:

  • RFC 3164 - BSD SYSLOG. This actually wasn't an IETF standard.
  • RFC 5424 - IETF SYSLOG. This is a IETF standard. This obsoletes RFC 3164.

There are also RFCs:

  • RFC 3195 - Reliable Delivery for SYSLOG
  • RFC 5425 - TLS Transport Mapping for 
  • RFC 5426 - Transmission of SYSLOG Messages over UDP
  • RFC 5427 - Textual Conventions for Syslog Management
  • RFC 5848 - Signed Syslog Messages
  • RFC 6012 - Datagram Transport Layer Security (DTLS) Transport Mapping for SYSLOG
  • RFC 6587 - Transmission of SYSLOG Messages over TCP

I want to send a very big thanks out to the user, DFCH for reporting the issue, helping me understand the RFCs in question and also testing the resulting code.

The Issue

So what was the issue? As DFCH stated:

The Cmdlet send-syslog.ps1 states in its description to send a syslog message as defined in RFC 5424. However the generated timestamp in the Cmdlet incorrectly formats a timestamp when none is specified by the caller, nor does it validate or convert the timestamp if specified by the caller.
— https://github.com/kjacobsen/PowerShellSyslog/issues/1

I will admit that I hadn't ready RFC 5424 or RFC 3164 in a huge amount of detail. As soon as I did it was very obvious that the code was not producing an appropriate timestamp, it also become evident that the overall message I was sending did not meet the RFC specification.

From my analysis, it appeared that I had crossed parts of both RFC 5424 and RFC 3164, ending up with code that wasn't fully complaint to either, and in the long run, not entirely useful.

As DFCH reported, the code didn't not generate the appropriate timestamp, with issues in how it was formatted as well as the precision. Resolving these issues was quite simple, the timestamp could be formatted as recommended by DFCH, this not only resolved the format issue but also increased the precision. Validation of the caller specified timestamp was also easy to implement. I simply changed the parameter to take an object of type DateTime instead of a String. 

But this was just the start of the fixes, as I continued to read and understand the RFCs, I realized my messages were incorrectly formatted as well.

Message Formats

There are two valid SYSLOG message structures as defined in RFC 3164 and 5424. 

Firstly, RFC 3164 specifies the message structure to be the following:

<PRI>TIMESTAMP HOSTNAME TAG CONTENT

Where:

  • PRI - Value based on severity and facility
  • TIMESTAMP - What date and time with format MMM dd HH:mm:ss
  • HOSTNAME - Who is sending the message
  • TAG - Name of the process or program generating the message
  • CONTENT - Obviously the message being sent

Next, RFC 5424 specifies the message structure as:

<PRI>VERSION TIMESTAMP HOSTNAME APPNAME PROCID MSGID STRUCTUREDDATA [CONTENT]

Where:

  • PRI - Value based on severity and facility
  • VERSION - Version of the SYSLOG message (typically 1)
  • TIMESTAMP - What date and time with format: yyyy-MM-ddtHH:mm:ss.ffffffzzz
  • HOSTNAME Who is sending the message
  • APPNAME Name of the process or program generating the message
  • PROCID - Process ID of the application or script
  • MSGID - An Identifier to assist in troubleshooting
  • STRUCTUREDDATA - RFC 5424 specifies a method of sending key/value pairs
  • CONTENT - Obviously the content of the message

One thing to note with RFC 5424 is that the majority of the fields are optional, you still need to send something to ensure the correct layout however, so the nil value "-" is sent. I should also point out that the RFC states that the CONTENT section at the end is completely optional. If nothing is sent, you don't need to even send the nil value. 

My original code on the other hands, was sending messages with the structure of:

<PRI>TIMESTAMP HOSTNAME CONTENT

Where:

  • PRI - Value based on severity and facility
  • TIMESTAMP - What date and time with format: yyyy:MM:dd:-HH:mm:ss zzz
  • HOSTNAME - Who is sending the message
  • CONTENT - Obviously the message being sent

How did this happen? 

Well, there are a few reasons why this occurred, in no particular order.

  1. I borrowed some of the logic and ideas from other .Net and PowerShell code samples
  2. I didn't read either RFC
  3. The SYSLOG servers I tested against were not stringent in their rendering of messages received.
  4. I referred to Wikipedia when I was checking that my messages were correctly formatted.

In hindsight, the biggest mistakes were using Wikipedia as my guide, and not testing against a more RFC compliant server.

Using Wikipedia as a source for developing compliant code is probably a bad idea, on this occasion it was a great learning experience. Previously the SYSLOG Wikipedia article did not correctly describe the layout and formatting of the full message, crucially missing out the information about the TAG field. The article has been updated since then with corrections ensuring that it is more understandable. It should be noted however that overall, the Wikipedia article is still focused on RFC 3164 and not 5424.

Let’s look at how we clean-up the code.

Additional Parameters

To ensure that we have enough information to support RFC 5424, I needed to add some additional Parameters (which are not mandatory). These include ApplicationName, ProcessID, MessageID, StructuredData and a switch RFC 3164.

The switch RFC 3164 will simply tell the code to send a message in the RFC 3164 format, instead of sending it via RFC 5424 which is its default.

Hostname Generation

Previously, if the hostname parameter was not specified in my code, I simply used the hostname.exe. Whilst there isn't any problems with this, however RFC 5424 actually specifies in some detail how the hostname field should be determined:

  1. The FQDN of the server
  2. A static IP address
  3. The hostname of the server (Windows will always have on of these)
  4. Dynamic IP address
  5. A NILVALUE (-)

I have updated my code to generate the hostname component of the SYSLOG message via the first 3 steps.

Application Name

The Application name can be a little difficult. Typically from within a function we can determine the name of the script which is calling the function via 2 properties of the $myInvocation variable: ScriptName and PSCommandPath. I have used ScriptName with success in the past, and hence decided to use it again. There is one thing to note, if I am sitting at a console and call send-syslogmessage, then ScriptName will be null, and if that is the case, we will simply use “PowerShell”.

Process ID 

The Process ID is new requirement to ensure RFC 5424. We get this simply from the $PID global variable.

Message ID and Structured Data

These two will always be user specified, if the user doesn't specify them, then send the default RFC 5424 nil value of "-".

Message Generation

Now that we have all of the information required for either RFC, we can now look at message generation. When it comes time, I simply have an ‘if’ statement that controls which format we want to use. The script will then format the timestamp and message accordingly.

Message generation looks like the following:

For RFC 3164, I fixed up the timestamp, and also added in the application name. For RFC 5424 there are some significant changes. I now correctly include the SYSLOG version (1), and then included the corrected timestamp, application name, process ID, message ID and structured data.

The Future

If there was a demand, I would be interested in extending the CMDLet to support the transmission of messages via TCP, as well as sending signed messages. Right now, I don't have a need for such things.

Conclusion

Now that all of those changes have been completed and tested, I have pushed the changes up to the PowerShellSyslog GitHub repository.

I want to thank DFCH again for raising the issue and helping me through the development of the fixes.


Kieran Jacobsen

Read More
Presentations, Security Kieran Jacobsen Presentations, Security Kieran Jacobsen

Presenting at CrikeyCon 2015

I wanted to quickly let everyone know that I will be presenting at CrikeyCon again this year. Once again I am excited to be presenting, as well as nervous.

This year I will be doing something a little different from my usual presentations. This year I will be talking about the Hak5 USB Rubber Ducky. This is something I have wanted to show off and get more people interested in for a number of years, and am extremely excited by this opportunity.

My presentation this year will be shorter than usual, with only 15 minutes to perform a quick overview and some warm up demonstrations. I will then move to the events area along side my good friend Ash, and the always exciting Robert Winkel, where I will be showing off some more advanced demonstrations.

There is an amazing list of speakers again this year, and once again Patrick Gray will be the MC.

Last year, tickets sold out quickly, if you want to attend, then visit the Eventbrite page today to secure yours.

Read More
Kieran Jacobsen Kieran Jacobsen

First Impressions: MSI GS30 Shadow Pt3 - The Dock

In this final post, I will talk about the GS30's dock and my overall thoughts on its performance.

Whilst the laptop is cool, everything is really talking about the dock. As I mentioned earlier, the dock consists of a PCI Express x16 slot, a 450 watt power supply, a KillerNIC, audio connectors (speakers and microphone), stereo speakers with sub-woofer and 4 USB3 ports. 

You can install any NVIDIA or ATI card you want into the dock, and from any manufacturer. It should be noted though that MSI has stated that all of their cards will work within the dock. I chose an MSI NVIDIA GeForce GTX 970 not only on the reviews, but also due to the fact I knew I would receive suitable support in such a configuration. The power supply in the dock has two 6/8 pin power plugs to supply power to whatever card you end up selecting. There is also a fan on one side to assist in keeping everything cool.

It is worth noting that MSI wasn't the first to come up with the idea of strapping a desktop graphics card to a laptop. Currently the other well-known vendor is Alienware. Alienware first offered the graphics amplifier to their 13 inch series, and in the latest generation it is available in the 15 and 17 series. MSi claim that the biggest difference between the GS30 and the Alienware is that their dock is a PCI Express x16 solution, whilst the Alienware is only x4. There is a significant bandwidth difference between PCI Express x16 and x4, however these claims haven’t been independently verified. 

Connecting to the dock is a fairly straight forward process. Shutdown the laptop, place the laptop in the cradle and pull the handle to bring the two together. The locking process also ensures that there is now way the laptop could easily come away from the dock. For those who are wondering, the dock connector looks pretty much like a PCI Express connector. To undock, simply shutdown and unlock then push the handle to eject the laptop. You need to shut down, you cannot simply put your laptop to sleep or hibernate. My theory of how everything is working internally, and this is just conjecture, is that when connected, the dock is disconnecting the Intel Iris graphics and the Atheros Ethernet controller. 

I chose to install my Western Digital 2TB Black Edition drive in the dock. This drive has all 240 of my Steam games, and has worked well for me in my previous system. Installation of the drive was also extremely easy, I recommend installing the hard disk prior to installing the video card.

The audio options on the dock are rather disappointing. Whilst it is great to see (hear) the stereo speakers and sub-woofer in the dock, I would have much rather seen a fully fledged sound card included. I previously used optical out to a set of Yamaha speakers, now I am going to have to go back to the drawing board because the GS30 dock only provides a standard headphone/speakers connector.

I have been extremely impressed by the performance of the GS30, dock and GTX970 combination. Whilst I haven’t spent much time playing games, only FireFall and BioShock Infinite, I can confirm the performance is quite remarkable. I was not disappointed running both games with their video settings maxed out. The fans on the laptop will ramp up during this time, but once again, it is nothing too serious.

For a detailed performance breakdown and benchmark, check out the review by Hexus here.

Transforming a thin-and-light 13.3in laptop, the bundled GamingDock opens the door to greater storage, better connectivity, improved audio and a far superior graphics experience.
— http://hexus.net/tech/reviews/laptop/79397-msi-gs30-shadow-gamingdock/?page=16

Conclusion

Overall this is an exceptional laptop, be it as a work PC running virtual machines or visual studio, or at home as a gaming machine. This is a great work machine and a great home machine. I would definitely recommend it to people!

Whilst the laptop would probably struggle competing on its own against the likes of Alienware or the HP Omen, or even a business oriented device like the HP EliteBook Folio, when combined with the dock, it becomes one hell of a system. 

MSI have done an amazing job, their engineers have created something exciting, unique and quite revolutionary. I will be very interested to see how they continue to develop and expand upon this concept in the coming years. Hopefully in 2 years when I am looking for a new laptop, they will have resolved some of my gripes and filled in some of the missing features.

The GS30 Shadow is definitely one of the more interesting laptops we’ve seen, and for those that don’t need to have a ton of gaming power on the go it offers a nice blend of mobility with the option to hook up to a dedicated display and GPU at home for serious gaming.
— http://www.anandtech.com/show/8817/msi-announces-gs30-shadow-laptop-and-gpu-expansion-dock

Summary

Pros:

  • True Quad Core i7
  • Docking station
  • Lightweight Ultrabook
  • 16Gb of memory
  • Twin 128Gb SSDs
  • Gaming performance when docked is equivalent to desktop systems
  • Excellent option for work/life balance system
  • All of your data in one place
  • Dock features PIC Express 16x and one SATA 3 port

Cons

  • No touch screen
  • No TPM
  • No NFC
  • No KillerNIC Ethernet or WIFI on Laptop, KillerNIC only in dock
  • Screen resolution could be higher
  • Audio options could be better (no optical out)
  • Need external monitor/keyboard/mouse when docked
  • Need to shutdown to dock/undock
  • 3 hours battery life

Improvements I want to see in the future

  • Touch Screen
  • TPM
  • NFC
  • Better audio options in the dock
  • Windows 8.1 pro
  • No Symantec AV
  • Better driver update system

Kieran Jacobsen

Read More
Kieran Jacobsen Kieran Jacobsen

First Impressions: MSI GS30 Shadow Pt2 - A powerful ultrabook

Welcome back! Yesterday I introduced the MSI GS30 Shadow, and today I will be talking about the specifics of the laptop and its performance whilst away from the docking station. Tomorrow I will talk about the dock in more detail.

MSI has come at this new approach to empowering gaming notebooks from a different angle from its competition, focused almost solely on value, performance and design in GS30 Shadow and GamingDock. The result is a machine that can be an Ultrabook in your backpack when you need to get things done and a gaming PC at home that can play with the big boys.
— http://www.techradar.com/reviews/pc-mac/laptops-portable-pcs/laptops-and-netbooks/msi-gs30-shadow-1277918/review

Upon unboxing the laptop, there were a few things that caught my surprise. Firstly, it is packed at the bottom, with the weighty dock on top of it. More importantly however, the laptop looks really well designed, and is extremely light. The styling is quite plain, quite utilitarian, but on the whole very nice to see. This is not a garish looking machine like the Alienware laptops which screen “I AM A GAMMING MACHINE” at the top of their lungs, this is a quite but extremely powerfully little creature which doesn’t like the limelight. The GS30 reminds me of my older Dell Latitude crossed with my old Sony VAIO. I wish I could say that this design allows it to blend into a corporate environment, but MSI then decided the GS30 did need to look a little like its Alienware competitors. The front bezel has a white light along the front of it, not a simple little white light, but a long beam of white light which really does take away from the look. You can’t turn it off, dim it or change the colour. It is rather disappointing, and just drains battery in my opinion. 

The GS30 comes with an interesting array of hardware options, featuring an Intel Core i7 (4th Gen) 4870HQ CPU, 16GB of memory and two 128GB SSDs which are in a RAID0 (stripped) set. 
Having a quad core CPU, whilst there are significant reasons to have reservations about putting a such a  processor into a laptop, MSI appears to have pulled this one off quite well. Most people I have spoken to about the GS30 ask me one thing, “is it noisy?”. The answer to this is, well, sort of. The GS30 does appear to have some very efficient and well-designed cooling, however if you place a quad core i7 processor under load, there will still be quite a bit of heat generated that needs to go somewhere. Unlike many other laptops, which become hot to touch under extreme load, the GS30 remains cool. The fans can be loud, these are not the quite fans in your Surface Pro, I work in an office with quite a few MacBook Pros, and the GS30 fans are extremely comparable to those. 

Coming with 16GB of memory is probably suitable for most developers and gamers, however it would have been really nice to have the option for 32GB. I suspect the limitation here is more around the fact that DDR3 modules for laptops max out at 8GB, and there wasn’t the space to offer 4 memory slots, only 2. 

The storage configuration still seems a little bit of a waste for me. Whilst there does seem to be a performance boost, I don’t think it is significant enough overall, but I wonder what the design and cost implications to this one are. I really have to wonder why MSI chose 128 GB SSDs, this does seem to be a very small size, especially for something targeted towards the gamming community. I realise that I have another SATA3 HDD in the dock, but a little more whilst away from the docking station would have been nice. The good news, these drives are replaceable, if you want to touch the warranty void sticker.

The GS30 features a 13 inch, 1920*1200 resolution display with a matte finish. If you like an extremely glossy screen, you might want to look elsewhere. The screen is quite thin, much like any of the high end Sony, Dell and HP laptops, and whilst others have mentioned it seemed “flimsy”, I don’t seem to think it is. This is an extremely nice screen to use and I am very pleased to use it. Viewing angle seems extremely good, and the display is crisp and clear. I do wish for a few things, higher resolution, touch support and a wider opening angle. A higher resolution is always good however it can introduce its own set of issues; touch support seems pretty obvious these days, but it is something you can live without. The last, the opening angle, might seem to be an odd comment, however due to the design of the docking connector, the laptop screen cannot be opened fully and you are limited to about 120 degrees. This isn't a huge issue for me, but I could understand others wanting to open their laptop to almost flat.

The GS30 comes with an Intel Iris Pro 5200 graphics card for times when you are not connected to the dock. This is new from Intel however I have found it to be extremely suitable with a great balance between performance and battery life. I will admit I haven’t tried gaming whilst mobile yet.

There are a bunch of little things that MSI has done really well in the GS30. I really appreciate that internal components like Ethernet, WIFI, Bluetooth and the SD card are not based upon internal USB connections like those found in some low end DELL and HP laptops, and in the Surface PRO. Tight integration with the PCI Express channels provides extremely suitable performance and reliability.

WIFI connectivity is provided by an Intel 7260, and Ethernet is provided (whilst undocked) by a Qualcomm Atheros AR8161. The GS30 doesn’t suffer from the WIFI drop outs suffered by the Surface Pro 1, 2, and 3. My connectivity in the office has improved quite significantly. I am left wondering why MSI didn't package a KillerNIC WIFI and Ethernet controller in the laptop. A significant proportion of MSI’s other devices feature the Killer Double Shot Pro, so why not this one? I thought that would seem pretty logical for their target market, one positive about the use of these two is extremely strong Linux and visualization performance. 

Battery life could be better. The GS30 provides about 3 hours battery life in the limited testing I have performed. This isn't great by any means, but isn't the end of the world.

A quick word on the keyboard. Yes it is back lit, however you do not get any control over the colour, nor are there programmable/macro key support like other MSI laptops. To some this could be a disappointment, however in the grand scheme of things, it is something you can live without.

Now for my big rant. I was quite gutted to see that the GS30 doesn't come with a TPM. I realize that this device is targeted towards gamers, and not the security paranoid let’s encrypt everything crowd that I belong to. This is however 2015, how much effort would have it taken to install one? Seriously, they are tiny chips. I can work around that, but this is the one thing I wish I could get MSI to fix!

Join me tomorrow when I review the GS30's dock, gaming and the performance over all.

Kieran Jacobsen

Read More
Kieran Jacobsen Kieran Jacobsen

First Impressions: MSI GS30 Shadow Pt1 - A work/play laptop

Over the past few weeks I have been looking to purchase a new laptop for work, I have also been on the market for a new gaming system since mine was rendered inoperable by the removalists. I was in a tough spot, requiring a lightweight and portable laptop for work, and then something with the power to play games when at home.

In the past, I always preferred to keep these two distinct usages types separate, there are a number of distinct advantages to this, as well as a number of disadvantages. Now I had been considering finding something that could at least provide the best of both worlds, or close to that as possible. I want my cake and I want to eat it!

What do I actually need in this laptop? Well the requirements are tricky, but not impossible:

  • 12 to 15 inch screen
  • 16Gb to 32Gb of memory
  • Minimum 256Gb SSD
  • Decent graphics performance provided by mid to high end NVIDIA or ATI
  • Have some battery life
  • Good price point

There were a number of systems which met these requirements to varying degrees, including:

Overall, these laptops are very good, however I just wasn’t convinced that they really would be suitable. Then early last week, I was catching up on more CES 2015 coverage, looking for more reviews and stumbled up an AnandTech article, MSI Announces GS30 Shadow Laptop and GPU Expansion Dock. I was immediately intrigued.

What sets the MSI GS30 Shadow apart from almost every other laptop on the market is its unique docking station. Now you might be thinking, “Kieran I have been using a docking station for 10 to 20 years now, that isn’t something special”, and you could be right at first glance, but the GS30’s dock is very special. For the majority of laptops, their docking stations have become nothing more than glorified port replicators that simply reduce the effort of plugging in all of your accessories. In the past docking stations would provide a significant boost in functionality and often included features like a modular bay for an additional CD drive or Hard Disk, or in the case of the Dell C series, a PCI card. The dock that is packaged with the GS30 is more like the old fashioned docking stations, but on steroids, lots of steroids! The GS30 dock comes with a PCI Express x16 connector, a 450 watt PSU, a 3.5 inch disk drive and SATA3 connector, a KillerNIC network controller and 4 USB3 ports. The dock alone has some serious computing power!

If you’re curious how MSI is interfacing with all of these extra devices and whether there will be sufficient bandwidth, the answer is that the dock uses a full x16 PCIe 3.0 based connector.
— http://www.anandtech.com/show/8817/msi-announces-gs30-shadow-laptop-and-gpu-expansion-dock

Whilst MSI announced the GS30 back in September 2014, little was really known about it till the official launch as part of CES 2015. Whilst there are one or two hands on reviews and videos, there is only one through performance review at this point. Even so, I still wanted to get my hands on one, so the next morning I ordered one, and picked it up the very same day. I also got my hands on an MSI NVIDIA GeForce GTX 970 4GB. I was informed by the owner of my local computer store clerk that I was the first owner of a GS30 in Australia.

Join me, tomorrow for part 2 where I discuss the laptop, its features and performance.

Kieran Jacobsen

Read More
PowerShell Kieran Jacobsen PowerShell Kieran Jacobsen

Posh-CloudFlare managing CloudFlare using PowerShell

The aim of the Posh-CloudFlare module is to simply and automate the management of CloudFlare hosted DNS zones using PowerShell and the CloudFlare Client API. I have made the module available via the PoshSecurity GitHub, here Posh-CloudFlare.

I started looking at CloudFlares API several months ago, as part of another post which I am still working on. Back then I was simply looking at the creation and deletion or records.

Things changed when I found that I needed to spend quite a bit of time working with DNS. Provisioning new infrastructure within cloud environments is something I spend a significant amount of time doing, and am actively investigating the automation of it, and as such, become interested in other parts of the API.

This module now implements all of the Client API, with 22 CMDLets in total. To simplify things, I have documented what CMDLet maps to what API call below:

CMDLets

API Actions

get-CFDNSZoneStatistics

3.1 - "stats" - Retrieve domain statistics for a given time frame

get-CFDNSZone

3.2 - "zone_load_multi" - Retrieve the list of domains

get-CFDNSRecord

3.3 - "rec_load_all" - Retrieve DNS Records of a given domain

get-CFDNSZoneStatus

3.4 - "zone_check" - Checks for active zones and returns their corresponding zids

Get-CFIPThreatScore

3.6 - "ip_lkup" - Check threat score for a given IP

get-CFDNSZoneSettings

3.7 - "zone_settings" - List all current setting values

Set-CFDNSZoneSecurityLevel

4.1 - "sec_lvl" - Set the security level

Set-CFDNSZoneCacheLevel

4.2 - "cache_lvl" - Set the cache level

Set-CFDNSZoneDevMode

4.3 - "devmode" - Toggling Development Mode

Clear-CFDNSZoneCache

4.4 - "fpurge_ts" -- Clear CloudFlare's cache

Clear-CFDNSZoneFileCache

4.5 - "zone_file_purge" -- Purge a single file in CloudFlare's cache

Add-CFBlackListIP

Add-CFWhiteListIP

Remove-CFListIP

4.6 - "wl" / "ban" / "nul" -- Whitelist/Blacklist/Unlist IPs

Set-CFDNSZoneIPVersion

4.7 - "ipv46" -- Toggle IPv6 support

Set-CFDNSZoneRocketLoader

4.8 - "async" -- Set Rocket Loader

Set-CFDNSZoneMinification

4.9 - "minify" -- Set Minification

Set-CFDNSZoneMirage2

4.10 - "mirage2" -- Set Mirage2

New-CFDNSRecord

5.1 - "rec_new" -- Add a DNS record

Update-CFDNSRecord

5.2 - "rec_edit" -- Edit a DNS record

Remove-CFDNSRecord

5.3 - "rec_delete" -- Delete a DNS record

The Client API can be a little tricky at first, I have developed the CMDLets in a manner to simplify the learning curve. Typically any API call which modifies or removes a DNS record, would require a rec_id to be specified. This field can be found by querying all of the records in the zone. I have simplified things by performing the search and other API queries for you. You can still specify a rec_id if you like.

Switches and parameter validation sets have been used to simplify some of the other CMDLets, particularly those around minification, security and other zone wide settings.

Finally I have tried where possible to make good use of the Pipeline. There are still a number of areas that could be improved.

Getting Started

The first thing you will need to do, is obtain your API Token. This can be found on your Account page. You will need this, and the email address you use to sign into CloudFlare for the majority of the CMDLets. For CMDLets which modify DNS Zones or records, you will need to specify the zone as well.

To obtain the module, simply perform a git clone to your preferred module location as below:

I have included a demo script, Posh-CloudFlare-Demo.ps1 at the root level of the module, which you can run on the namespace of your choice. I recommend not using your corporate production domain. At the top of this script, simply update the API Token, Email and domain name fields as required.

You can then run the script, and see it manipulate the DNS zone. I am not responsible if this breaks production. This script shows you each CMDLet and it's output. I don't recommend simply running the script, I recommend stepping through each line so you gain more of an understanding.

Potential Uses

The automatic provisionment of cloud hosted environments is why this was developed as well as another project I will announce in the coming future. For now, I see myself working on at least one module to support the automation of Office 365 provisioning, including creating the TXT, MX and SRV required.

Warnings

Firstly, I haven’t finished up the PowerShell help – Naughty! I will work on this one as I go.

Secondly, there might be some bugs. Whilst I have tried to test the majority of the permutations of the code, I can’t be fully sure I haven’t missed something. If you find one, please feel free to contact me and I will make the required fixes, or even better, push your updates up to GitHub.


Kieran Jacobsen

Read More
News/Links Kieran Jacobsen News/Links Kieran Jacobsen

Welcome to Posh Security

I am thrilled to welcome everyone to my new website. This is something that I have been thinking about and working on for a number of months now, and am very glad to see it all finally coming together.

Why Posh Security?

My aim for this blog is, as it always was, to discuss what I am passionate about. My two biggest passions within the industry have always been automation with PowerShell and Security.

To all those that know me or have worked with me, it is pretty obvious that my first passion is PowerShell. I first starting working with PowerShell back in the code-name Monad days when the entire project was just a small concept from Jeffrey Snover (@jsnover); since then I have spent a considerable amount of time working with it, and have seen it develop and flourish into a truly amazing platform.

My second passion is the information security field. For a number of years I have been an avid follower of all movements within the information security industry, and I will admit that I spend a significant portion of my free time keeping up with the latest trends, tools and exploits. I have always been a big believer that security starts with those deploying and supporting systems, including system administrators, architects and developers. These employees should be highly skilled in various security concepts thus ensuring that they are actively working to ensure the security of an organisation and that an organisations security posture does not simply rest on the security and compliance teams.

I also believe that right now, there is a significant level of interest in PowerShell in the security community, and over the past few years, there have been a number of people who have had mode significant process in this field, including Matt Graeber (@mattifestation), Carlos Perez (@darkoperator), and Matt Johnson (@mwjcomputing). I was presented with my own opportunity to further the discussion on PowerShell and its security implications in 2014, when I was asked to present at  CrikeyCon. I was encouraged to do so by the always amazing Ash (@Ashd_au) and Wade Alcorn. I was then, and still am astounded by the feedback from that presentation, and my follow on appearance on Risky.Biz.

I have since been working on a number of project which I hope to present to the greater community over the coming months.

Why a new blog now?

There were so many reasons to start a new blog at this time.

I actually started down the path several months ago, however things prevented me from launching the site earlier. Whilst I feel that launching a new site on the 1st of January is a touch cliché, like a New Year's resolution, overall it feels like the best time to do so.

In early November, I joined an amazing team at Readify as a Technical Lead. My focus in this role is in supporting the infrastructure that allows all of our wonderful consultants and developers to achieve the best for Readify's customers. I am extremely excited at the amount of potential PowerShell development I have ahead of me, as well as working within the Microsoft Azure space. Special thanks goes out to  Tatham Oddie for his encouragement during the application process and over the past few weeks. Readify is an amazing place to work, and I recommend that people take a look at the  Readify Recruiting process, including the  Knock Knock challenge. Completing the challenge was extremely interesting and a lot of fun.

The new role also lead me to move to a new city! I have recently moved from hot and sunny Brisbane to beautiful Melbourne. With a new job, city and year, everything seemed right for a new website!

Moving Forward

You should have already started to see that my old site, aperturescience.su is now redirecting to poshsecurity.com, all of the content and addresses should have been migrated from the old to the new site.

I have setup @poshsecurity on Twitter with the aim to keep this to simply new post notifications and associated commentary. I will also post to this whenever a new GitHub repository is created or when I make major updates to my code. I wanted to have a Twitter address that people could follow and receive updates about the site and not have to also receive unwanted or unrelated messages/re-tweets. You can follow@poshsecurity  for site and code updates, for follow my personal account at @kjacobsen.

Speaking of code, I have created a GitHub organisation called PoshSecurity. This is where all the associated code for posts will go from now on. As code is improved and redeveloped, it will most likely be moved from my GitHub over to the PoshSecurity organisation. I will leave some personal repositories directly under my account.

One minor improvement is that I am planning on switching from code comments hosting with PasteBin to using Gists. Whilst they pretty much provide like-for-like functionality, the ability to clone Gists, leave comments and also maintain reversion history, makes them more useful.

Another change is that I have decided to make use of Disqus for comments. I know that the platform can be a pain, however there are some really neat things it can do. I feel that it might encourage more discussion, whilst discouraging some of the spam I have previously had to manage.

I will look at Tumblr/Facebook pages/Google+ down the track, but I think for now, this is enough to get started. In the future I am going to also look at putting up video guides on YouTube etc.

A very big thanks goes out to my Partner, Daniel and his sister Eileen. The two have greatly assisted in the development of the new site including the name, themes, layout and so much more. I highly recommend that people check out Eileen’s site, The Food Avenue, where she writes about food and fashion.

Once again, I would like to welcome everyone to the new site. I hope that people enjoy everything that I have planned for the future on this site. I welcome people to provide feedback on what they would like to see on this site. Leave a comment down below or use the Contact page.

Read More
Kieran Jacobsen Kieran Jacobsen

Tips For Managing Microsoft SQL 2012 Always On Availability Groups

Recently I have been spending a significant amount of time working with high availability and disaster recovery solutions. A large amount of this work has been around the deployment and use of SQL2012 AlwaysOn Availability Groups.

Availability Groups should not be confused with SQL Clusters, whilst both technologies make use of Windows Fail-over Clustering; they achieve their goals in some very different ways.

I am not going to go into specifics around the design and deployment of an AlwaysOn Availability Group solution; however, I have some design tips that should help you suffer any serious setbacks.

Firstly, confirm vendor application support. This might seem obvious but it is extremely important. There are a number of applications that do not support AlwaysOn AGs, the list includes Microsoft SCCM2012R2 (and other products in the System Centre Family) as well as some products from Citrix (patches on their way). If you are running any of the products that do not support these features, then you will need to revert back to a normal Fail-over Cluster (or in my case, a geo-cluster).

Secondly, find a reliable place for a File Share based Witness, preferably a second side. This tip is of particular importance if you are running across multiple sites. You should be also aware that the server hosting the share must to be in the same domain as the SQL servers.

Next, check the implications of using AlwaysOn AGs on your Microsoft Licensing. All of the new features come at a cost; you need ensure that you do not affect your overall solution costs. Remember, with AlwaysOn AGs, SQL is actually running on all of your nodes, all the time and this could affect you license requirements.

One annoying thing, you cannot easily create our listeners if you do not have any databases. My tip to bypass this is to simply create an empty database, and then create the AlwaysOn AG and its associated listener based on that database. Once you have that done, then your applications installers can be run against the listener. REMEMBER though, that if an application creates databases via the listener name, they are not configured as part of the AlwaysOn Group, you will need to go and do that manually! I was caught with this one.

I had some issues when creating AlwaysOn AG and the associated listener. These two articles really helped me out:

Read More