Oslo, Norway

FlåM, Norway

Bergen, Norway

Sophos UTM User Portal misconfiguration

While testing a Sophos UTM (formerly known as an Astaro Security Gateway) trying to get the user portal configured on port 443 I locked myself completely out of the system. It caused all websites that where configured by the Web Application Firewall to show the userportal and the admin interface was no longer functioning after it was restarted. So my only option to gain access was on console level. For this I followed steps 1 to 16 of this support article on the Sophos website.

  • Shutdown the UTM.
  • Ensure both a monitor and a keyboard are connected the UTM if it is a physical device. In case of a hypervisor, this will have to supply a console option.
  • Power on the UTM, wait until the GRUB boot loader starts …… and then press the ‘Esc’ key before the short timeout expires.
  • Highlight (do not press enter/return and use only the arrow keys) the version of software the UTM is running that does not mention either ‘previous’ or ‘rescue’.
  • Press the ‘e’ key on the keyboard.
  • Highlight (again do not press enter) the second option in the list shown on screen that starts with the word ‘kernel’.
  • Press the ‘e’ key on the keyboard.
  • Type: ” init=/bin/bash” at the end of the line (with a space before init).
  • Press enter and wait for the screen to reload.
  • Press the ‘b’ key on the keyboard. The UTM will boot up.
  • Type: “passwd loginuser”
  • Enter and re-enter a new password for the ‘loginuser’ account.
  • Type: “passwd root”
  • Enter and re-enter a new password for the root account.
  • Press Ctrl+Alt+Del on the keyboard. The UTM will reboot.
  • Login as root with the newly set password

After these 16 Steps are taken and I’ve logged on as the “root” user and looking around a bit I figured out what I think is the userportal and shut it down with the following command:

  • sh /var/mdw/scripts/uma stop

After running this command the WebAdmin interface was accessible again and I changed the configuration of the User Portal which caused the problem and rebooted the UTM after which everything returned to normal operations.

Zakopane, Poland

Krakow, Poland

Wroclaw, Poland

Password expiration notification 1.2

I was talking to a friend of mine also working in IT and somewhere during the conversation the topic of Windows 7 and balloon popups appeared. As those popups tend to get missed in a lot of cases and depending on how the network is secured this means in case of password expirations the user is locked out of the network. To counter the balloon popup issue we run a script on a daily basis that mails users that their password is about to expire. Took some time to rewrite the script we run so it is more flexible in such you can determine which OUs will be scanned and on what days before expiration a notification is being send. Enjoy.

Version 1.1 Update:
Two things are fixed which came to my attention. The first is if you only had a single OU to be scanned the script wouldn’t work. For those that know powershell it was easy to fix. Now there is a check to see if there is only a single OU entry and the script will behave correctly if there is. The second fix is to check if an account has an e-mail address attached to it, otherwise no mail can be send out. If logging is enabled an additional line will be added to the log file in case no e-mail address was found.

Version 1.2 Update:
Code requires version 3 of Powershell, on version 2 .count does not work.

#requires -version 3

<#
Program  : PWExpNoticeMailer.ps1 - Password Expiration Notice Mailer
Author   : Eugene Dullaard (https://eugene.dullaard.nl/?p=409)
Date     : 27-Aug-2013 - version 1.0
           - Initial Script
Update   : 22-Dec-2014 - version 1.1
           - Check for existence of emailaddress and add none-existence to logfile if enabled
           - Check for Array in case of a single line entry, script didn't work for single OU
Update   : 13-May-2015 - version 1.2
           - Changed the required version of powershell to 3.0 due to use of .count

To Do's before running this script in your environment:
- This script should be scheduled on a daily basis in order to run the check once a day.
- You should modify the values of $LogFile,$DaysAdvWarn,$MailServer,$MailSender to what
  is required in your environment
- Change and/or add Organizational Units to be searched
- Change and/or add the above OUs into $ArrOU
- Change the $Subject and $Message so they contain what you require
- For testing purposes, change $_.EmailAddress to your own so you see the results
#>

Import-Module ActiveDirectory

$LogFile = ".\PWExpNoticeMailer.log"       # Logfile location, use "" to disable logging
$DaysAdvWarn = 21,14,7,4,2,1               # Days before expiration to send warning
$MailServer = "mailserver.domain.tld"      # FQDN or IP of mailserver to be used
$MailSender = "itnotification@domain.tld"  # Mail address of sender

# Enter Organizational Units to search for user accounts in LDAP notation
# Name them as you wish and use these names in ArrOU variable as per example
$ou0 = "OU=Abusers,OU=Beavis Corp,DC=domain,DC=tld"
$ou1 = "OU=Loosers,OU=Butthead Inc,DC=domain,DC=tld"

# Build the array of Organizational Units stated above, keep them in sync if you want to use them all
$ArrOU = $ou0,$ou1

# Get the maximum password age and exit if not set
$MaxPWAge = ((Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge).Days
if ($MaxPWAge -eq 0) {Throw "No Domain Password Policy Present"}

# Loop to run through all the Organizational Units to search
for ($a=0;$a -lt ($ArrOU).count;$a++) {

  #Check if Array exists and change searchbase properly in case of a single OU entry
  if ($ArrOU.count -eq 1) {$SearchBase = $ArrOU} else {$SearchBase = $ArrOU[$a]}

  #Get All Users within one of the Organizational Units
  #Not taking people that have disabled or non-expiring accounts
  Get-ADUser -Filter {(Enabled -eq $true) -and (PasswordNeverExpires -eq $false)} -SearchBase $SearchBase `
  -Properties PasswordLastSet,EmailAddress | ForEach-Object {

    # Set variables
    $GivenName = $_.GivenName
    $Name = $_.Name

    # Calculate days left before password change is required
    $PWTimeLeft = (($_.PasswordLastSet - (Get-Date)).Days)+$MaxPWAge

    #Check if Password Time Left equals Advance Warning Days
    if ($DaysAdvWarn -contains $PWTimeLeft) {

      # Add entry in logfile if enabled
      if ($LogFile -ne "") {Add-Content $LogFile "$Name,$PWTimeLeft"}

      # Build up message if mailaddress is present
      # You can add instructions or change the content as you see fit
      if ($_.EmailAddress -ne $null) {
        $Subject = "IT Notification: Your password expires in $PWTimeLeft days"
        $Message = "Dear $GivenName,

Your password is about to expire in $PWTimeLeft days.
Please take the appropiate action bofore your password expires.

Kind Regards,

Your IT Department

(This message is automatically generated, please contact your support desk if you have any questions.)
"

        # Sending Message (Hint: Change $_.EmailAddress to your own for testing purposes)
        Send-MailMessage -to $_.EmailAddress -from $MailSender -Subject $Subject -body $Message `
        -SmtpServer $MailServer
      }
      else {
        if ($LogFile -ne "") {Add-Content $LogFile "$Name,Failure : No Mail Address"}
      }
    }
  }
}

Q & A

Location of log-file?

In the example above the location is set to .\, which means current folder. If you are running this as a scheduled task without a folder set this usually ends up in the System32 folder.

Testing FC-28 Hygrometer with Arduino

A simple sketch to check what the values are that are recorded on the analog pins of one or more FC-28 Hygrometer(s), it might work with any other sensor that delivers analog output as well. In respect to the Hygrometer you might record the values it gives when dry and when soaked/wet. Then you can use those to calculate the trigger values for your own sketch. These units tend to corrode which does affect the values produced so this sketch can be used to recalculate them.

fc28fc28sketch

//Sketch to test for analog hygrometer values with FC28 Hygrometer
//for one or more FC28 units. Output is visible through serial monitor.

//This code is free to use.
//Author : Eugene Dullaard
//https://eugene.dullaard.nl/?p=690

//Setting variables
int analogStartPin = 0;  //Analog Start Pin, usually 0 for A0.
int units = 3;           //Amount of FC28 units to test,
                         //these units need to be connected on
                         //the analog ports following StartPin.
//temp variables
int x;
int y;

void setup (){
  Serial.begin(9600);
  Serial.println("Soil moisture sensor input");
}

void loop ()
{
  Serial.println();

  for (x = analogStartPin; x < analogStartPin + units; x++) {
    y=analogRead(x);
    Serial.print("Analog "); Serial.print(x); Serial.print(":");
    Serial.println(y);
  }

  delay (1000);
}

Varazdin, Croatia

@dullaard.nl