Skip to content

Azure Linux

Overview

Azure Virtual Machines service is developed and managed by Microsoft Corp.

Benefit from SEKOIA.IO built-in rules and upgrade Azure Linux with the following detection capabilities out-of-the-box.

SEKOIA.IO x Azure Linux on ATT&CK Navigator

Address Space Layout Randomization (ASLR) Alteration

ASLR is a security feature used by the Operating System to mitigate memory exploit, attacker might want to disable it

  • Effort: intermediate
Advanced IP Scanner

Detects the use of Advanced IP Scanner. Seems to be a popular tool for ransomware groups.

  • Effort: master
Change Default File Association

When a file is opened, the default program used to open the file (also called the file association or handler) is checked. File association selections are stored in the Windows Registry and can be edited by users, administrators, or programs that have Registry access or by administrators using the built-in assoc utility. Applications can modify the file association for a given file extension to call an arbitrary program when a file with the given extension is opened.

  • Effort: advanced
Commonly Used Commands To Stop Services And Remove Backups

Detects specific commands used regularly by ransomwares to stop services or remove backups

  • Effort: intermediate
Dynamic Linker Hijacking From Environment Variable

LD_PRELOAD and LD_LIBRARY_PATH are environment variables used by the Operating System at the runtime to load shared objects (library.ies) when executing a new process, attacker can overwrite this variable to attempts a privileges escalation.

  • Effort: advanced
ETW Tampering

Detects a command that clears or disables any ETW Trace log which could indicate a logging evasion

  • Effort: intermediate
Exfiltration Domain In Command Line

Detects commands containing a domain linked to http exfiltration.

  • Effort: intermediate
Formbook Hijacked Process Command

Detects process hijacked by Formbook malware which executes specific commands to delete the dropper or copy browser credentials to the database before sending them to the C2.

  • Effort: intermediate
Fortinet Firewall Login In Failure

Detects failed login attemps on firewall administration rule. Prerequisites, check that the firewall logs format corresponds to the rule

  • Effort: master
Fortinet Firewall Successful External Login

Detects succesfull access to administration console of firewall from another IP address than 127.0.0.1. Prerequisites, check that the firewall logs format corresponds to the rule

  • Effort: master
ICacls Granting Access To All

Detects suspicious icacls command granting access to all, used by the ransomware Ryuk to delete every access-based restrictions on files and directories. ICacls is a built-in Windows command to interact with the Discretionary Access Control Lists (DACLs) which can grand adversaries higher permissions on specific files and folders.

  • Effort: elementary
KeePass Config XML In Command-Line

Detects a command-line interaction with the KeePass Config XML file. It could be used to retrieve informations or to be abused for persistence.

  • Effort: intermediate
Lazarus Loaders

Detects different loaders used by the Lazarus Group APT

  • Effort: elementary
MalwareBytes Uninstallation

Detects command line being used by attackers to uninstall Malwarebytes.

  • Effort: intermediate
MavInject Process Injection

Detects process injection using the signed Windows tool Mavinject32.exe (which is a LOLBAS)

  • Effort: intermediate
NTDS.dit File Interaction Through Command Line

Detects interaction with the file NTDS.dit through command line. This is usually really suspicious and could indicate an attacker trying copy the file to then look for users password hashes.

  • Effort: intermediate
NetSh Used To Disable Windows Firewall

Detects NetSh commands used to disable the Windows Firewall

  • Effort: intermediate
Netsh Allowed Python Program

Detects netsh command that performs modification on Firewall rules to allow the program python.exe. This activity is most likely related to the deployment of a Python server or an application that needs to communicate over a network. Threat actors could use it for data extraction, hosting a webshell or else.

  • Effort: intermediate
Netsh Port Forwarding

Detects netsh commands that enable a port forwarding between to hosts. This can be used by attackers to tunnel RDP or SMB shares for example.

  • Effort: elementary
Netsh RDP Port Forwarding

Detects netsh commands that configure a port forwarding of port 3389 used for RDP. This is commonly used by attackers during lateralization on windows environments.

  • Effort: elementary
Non-Legitimate Executable Using AcceptEula Parameter

Detects accepteula in command line with non-legitimate executable name. Some attackers are masquerading SysInternals tools with decoy names to prevent detection.

  • Effort: intermediate
Outlook Registry Access

Detection of accesses to Microsoft Outlook registry hive, which might contain sensitive information.

  • Effort: elementary
Phorpiex DriveMgr Command

Detects specific command used by the Phorpiex botnet to execute a copy of the loader during its self-spreading stage. As described by Microsoft, this behavior is unique and easily identifiable due to the use of folders named with underscores "__" and the PE name "DriveMgr.exe".

  • Effort: elementary
Phorpiex Process Masquerading

Detects specific process executable path used by the Phorpiex botnet to masquerade its system process network activity. It looks for a pattern of a system process executable name that is not legitimate and running from a folder that is created via a random algorithm 13-15 numbers long.

  • Effort: elementary
PowerShell EncodedCommand

Detects popular file extensions in commands obfuscated in base64 run through the EncodedCommand option.

  • Effort: advanced
Process Memory Dump Using Comsvcs

Detects the use of comsvcs in command line to dump a specific proces memory. This techinique is widlely used by attackers for privilege escalation and pivot.

  • Effort: elementary
Qakbot Persistence Using Schtasks

Detects possible Qakbot persistence using schtasks.

  • Effort: intermediate
RYUK Ransomeware - martinstevens Username

Detects user name "martinstevens". Wizard Spider is used to add the user name "martinstevens" to the AD of its victims. It was observed in several campaigns; in 2019 and 2020.

  • Effort: elementary
Raccine Uninstall

Detects commands that indicate a Raccine removal from an end system. Raccine is a free ransomware protection tool.

  • Effort: elementary
Rclone Process

Detects Rclone executable or Rclone execution by using the process name, the execution through a command obfuscated or not.

  • Effort: advanced
SEKOIA.IO Intelligence Feed

Detect threats based on indicators of compromise (IOCs) collected by SEKOIA's Threat and Detection Research team.

  • Effort: elementary
SOCKS Tunneling Tool

Detects the usage of a SOCKS tunneling tool, often used by threat actors. These tools often use the socks5 commandline argument, however socks4 can sometimes be used as well. Unfortunately, socks alone (without any number) triggered too many false positives.

  • Effort: intermediate
Spyware Persistence Using Schtasks

Detects possible Agent Tesla or Formbook persistence using schtasks. The name of the scheduled task used by these malware is very specific (Updates/randomstring).

  • Effort: intermediate
Suspicious Cmd File Copy Command To Network Share

Copy suspicious files through Windows cmd prompt to network share

  • Effort: intermediate
Suspicious DLL Loading By Ordinal

Detects suspicious DLL Loading by ordinal number in a non legitimate or rare folders. For example, Sofacy (APT28) used this technique to load their Trojan in a campaign of 2018.

  • Effort: intermediate
Suspicious Netsh DLL Persistence

Detects persitence via netsh helper. Netsh interacts with other operating system components using dynamic-link library (DLL) files. Adversaries may establish persistence by executing malicious content triggered by Netsh Helper DLLs.

  • Effort: elementary
Suspicious Network Args In Command Line

Detection on suspicious network arguments in processes command lines using HTTP schema with port 443.

  • Effort: intermediate
Suspicious PROCEXP152.sys File Created In Tmp

Detects the creation of the PROCEXP152.sys file in the application-data local temporary folder. This driver is used by Sysinternals Process Explorer but also by KDU (https://github.com/hfiref0x/KDU) or Ghost-In-The-Logs (https://github.com/bats3c/Ghost-In-The-Logs), which uses KDU. Note - Clever attackers may easily bypass this detection by just renaming the driver filename. Therefore just Medium-level and don't rely on it.

  • Effort: advanced
Suspicious PowerShell Invocations - Specific

Detects suspicious PowerShell invocation command parameters

  • Effort: intermediate
Suspicious Taskkill Command

Detects rare taskkill command being used. It could be related to Baby Shark malware.

  • Effort: intermediate
Suspicious Windows Installer Execution

Detects suspicious execution of the Windows Installer service (msiexec.exe) which could be used to install a malicious MSI package hosted on a remote server.

  • Effort: intermediate
Usage Of Procdump With Common Arguments

Detects the usage of Procdump sysinternals tool with some common arguments and followed by common patterns.

  • Effort: intermediate
WMI Install Of Binary

Detection of WMI used to install a binary on the host. It is often used by attackers as a signed binary to infect an host.

  • Effort: elementary
WMIC Uninstall Product

Detects products being uninstalled using WMIC command.

  • Effort: intermediate
WiFi Credentials Harvesting Using Netsh

Detects the harvesting of WiFi credentials using netsh.exe, used in particular by Agent Tesla (RAT) and Turla Mosquito (RAT)

  • Effort: elementary
Windows Defender History Directory Deleted

Windows Defender history directory has been deleted. Could be an attempt by an attacker to remove its traces.

  • Effort: elementary
Windows Defender Signatures Removed With MpCmdRun

Detects attempts to remove Windows Defender Signatures using MpCmdRun legitimate Windows Defender executable. No signatures mean Windows Defender will be less effective (or completely useless depending on the option used).

  • Effort: elementary
Windows Firewall Changes

Detects changes on Windows Firewall configuration

  • Effort: master
XCopy Suspicious Usage

Detects the usage of xcopy with suspicious command line options (used by Judgment Panda APT in the past). The rule is based on command line only in case xcopy is renamed.

  • Effort: advanced

Event Categories

The following table lists the data source offered by this integration.

Data Source Description
Authentication logs PAM authentication mechanism
Process command-line parameters Common Linux processes (cron, ssh, sudo)
Process use of network SSH and PAM daemon

Event Samples

Find below few samples of events and how they are normalized by SEKOIA.IO.

{
    "message": "{ \"time\" : \"2019-07-02T13:45:50.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"err\",\"EventTime\" : \"2019-07-02T13:45:50+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"pam_unix(sudo:auth): conversation failed\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-07-02T13:45:50Z\"},\"category\" : \"authpriv\",\"level\" : \"err\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "error",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-07-02T13:45:50.0000000Z",
    "azure_linux": {
        "message": "pam_unix(sudo:auth): conversation failed"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "action": {
        "name": "sudo:auth",
        "type": "open",
        "outcome": "failure"
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-07-02T13:46:32.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"crit\",\"EventTime\" : \"2019-07-02T13:46:32+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"pam_unix(sudo:auth): auth could not identify password for [omsagent]\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-07-02T13:46:32Z\"},\"category\" : \"authpriv\",\"level\" : \"crit\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "critical",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-07-02T13:46:32.0000000Z",
    "azure_linux": {
        "message": "pam_unix(sudo:auth): auth could not identify password for [omsagent]"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "action": {
        "name": "sudo:auth",
        "type": "open",
        "outcome": "failure"
    },
    "user": {
        "name": "omsagent"
    },
    "related": {
        "user": [
            "omsagent"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-06-27T14:50:01.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"CROND\",\"pid\" : \"21188\",\"Ignore\" : \"syslog\",\"Facility\" : \"cron\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:50:01+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"(root) CMD (/usr/lib64/sa/sa1 1 1)\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:50:01Z\"},\"category\" : \"cron\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "info",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-06-27T14:50:01.0000000Z",
    "azure_linux": {
        "message": "(root) CMD (/usr/lib64/sa/sa1 1 1)"
    },
    "process": {
        "parent": {
            "pid": 21188
        },
        "command_line": "/usr/lib64/sa/sa1 1 1",
        "executable": "/usr/lib64/sa/sa1"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "user": {
        "name": "root"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-06-27T14:29:01.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"CROND\",\"pid\" : \"16373\",\"Ignore\" : \"syslog\",\"Facility\" : \"cron\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:29:01+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"(root) CMD ([ -f /etc/krb5.keytab ] && [ \\\\( ! -f /etc/opt/omi/creds/omi.keytab \\\\) -o \\\\( /etc/krb5.keytab -nt /etc/opt/omi/creds/omi.keytab \\\\) ] && /opt/omi/bin/support/ktstrip /etc/krb5.keytab /etc/opt/omi/creds/omi.keytab >/dev/null 2>&1 || true)\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:29:01Z\"},\"category\" : \"cron\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "info",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-06-27T14:29:01.0000000Z",
    "azure_linux": {
        "message": "(root) CMD ([ -f /etc/krb5.keytab ] && [ \\( ! -f /etc/opt/omi/creds/omi.keytab \\) -o \\( /etc/krb5.keytab -nt /etc/opt/omi/creds/omi.keytab \\) ] && /opt/omi/bin/support/ktstrip /etc/krb5.keytab /etc/opt/omi/creds/omi.keytab >/dev/null 2>&1 || true)"
    },
    "process": {
        "parent": {
            "pid": 16373
        },
        "command_line": "[ -f /etc/krb5.keytab ] && [ \\( ! -f /etc/opt/omi/creds/omi.keytab \\) -o \\( /etc/krb5.keytab -nt /etc/opt/omi/creds/omi.keytab \\) ] && /opt/omi/bin/support/ktstrip /etc/krb5.keytab /etc/opt/omi/creds/omi.keytab >/dev/null 2>&1 || true"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "user": {
        "name": "root"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-06-27T14:50:51.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sshd\",\"pid\" : \"14020\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:50:51+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"Received disconnect from 185.122.161.248 port 39070:11: disconnected by user\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:50:51Z\"},\"category\" : \"authpriv\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "info",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-06-27T14:50:51.0000000Z",
    "azure_linux": {
        "message": "Received disconnect from 185.122.161.248 port 39070:11: disconnected by user"
    },
    "process": {
        "pid": 14020
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "source": {
        "ip": "185.122.161.248",
        "port": 39070,
        "address": "185.122.161.248"
    },
    "related": {
        "ip": [
            "185.122.161.248"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-06-27T14:48:18.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"notice\",\"EventTime\" : \"2019-06-27T14:48:18+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"omsagent : TTY=unknown ; PWD=/opt/microsoft/omsconfig/Scripts/2.6x-2.7x ; USER=root ; COMMAND=/opt/microsoft/omsconfig/Scripts/OMSYumUpdates.sh\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:48:18Z\"},\"category\" : \"authpriv\",\"level\" : \"notice\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "info",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-06-27T14:48:18.0000000Z",
    "azure_linux": {
        "message": "omsagent : TTY=unknown ; PWD=/opt/microsoft/omsconfig/Scripts/2.6x-2.7x ; USER=root ; COMMAND=/opt/microsoft/omsconfig/Scripts/OMSYumUpdates.sh"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "user": {
        "name": "root"
    },
    "process": {
        "command_line": "/opt/microsoft/omsconfig/Scripts/OMSYumUpdates.sh",
        "executable": "/opt/microsoft/omsconfig/Scripts/OMSYumUpdates.sh",
        "working_directory": "/opt/microsoft/omsconfig/Scripts/2.6x-2.7x"
    },
    "action": {
        "outcome": "success"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-07-02T13:46:15.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"notice\",\"EventTime\" : \"2019-07-02T13:46:15+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"omsagent : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/test -r /var/lib/docker/containers/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16-json.log\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-07-02T13:46:15Z\"},\"category\" : \"authpriv\",\"level\" : \"notice\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "info",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-07-02T13:46:15.0000000Z",
    "azure_linux": {
        "message": "omsagent : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/test -r /var/lib/docker/containers/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16-json.log"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "user": {
        "name": "root"
    },
    "process": {
        "command_line": "/bin/test -r /var/lib/docker/containers/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16-json.log",
        "executable": "/bin/test",
        "working_directory": "/"
    },
    "action": {
        "outcome": "success"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-06-27T14:48:28.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:48:28+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"pam_unix(sudo:session): session closed for user root\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:48:28Z\"},\"category\" : \"authpriv\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "info",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-06-27T14:48:28.0000000Z",
    "azure_linux": {
        "message": "pam_unix(sudo:session): session closed for user root"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "action": {
        "name": "sudo:session",
        "type": "close",
        "outcome": "success"
    },
    "user": {
        "name": "root"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-06-27T14:48:28.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:48:28+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"pam_unix(sudo:session): session opened for user root by (uid=0)\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:48:28Z\"},\"category\" : \"authpriv\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "info",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-06-27T14:48:28.0000000Z",
    "azure_linux": {
        "message": "pam_unix(sudo:session): session opened for user root by (uid=0)"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "action": {
        "name": "sudo:session",
        "type": "open",
        "outcome": "success"
    },
    "user": {
        "name": "root"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}
{
    "message": "{ \"time\" : \"2019-07-02T14:15:01.0000000Z\",\"resourceId\": \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"systemd\",\"Ignore\" : \"syslog\",\"Facility\" : \"daemon\",\"Severity\" : \"info\",\"EventTime\" : \"2019-07-02T14:15:01+0000\",\"SendingHost\": \"localhost\",\"Msg\" : \"Started Session 13124 of user omsagent.\",\"hostname\": \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-07-02T14:15:01Z\"},\"category\" : \"daemon\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "log": {
        "level": "info",
        "hostname": "LinuxRedhatDesktop"
    },
    "@timestamp": "2019-07-02T14:15:01.0000000Z",
    "azure_linux": {
        "message": "Started Session 13124 of user omsagent."
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "user": {
        "name": "omsagent"
    },
    "action": {
        "type": "open",
        "name": "systemd:session",
        "outcome": "success"
    },
    "related": {
        "user": [
            "omsagent"
        ]
    },
    "host": {
        "name": "LinuxRedhatDesktop"
    }
}

Extracted Fields

The following table lists the fields that are extracted, normalized under the ECS format, analyzed and indexed by the parser. It should be noted that infered fields are not listed.

Name Type Description
@timestamp date Date/time when the event originated.
azure_linux.message keyword The linux message
log.level keyword Log level of the log event.
process.command_line wildcard Full command line that started the process.
process.executable keyword Absolute path to the process executable.
process.parent.pid long Process id.
process.pid long Process id.
process.working_directory keyword The working directory of the process.
source.domain keyword The domain name of the source.
source.ip ip IP address of the source.
source.port long Port of the source.
user.name keyword Short name or login of the user.

Configure

This setup guide will show you how to forward events produced by a Linux Virtual Machine hosted on Azure platform to SEKOIA.IO.

Theses changes have to be made from the Azure Web Portal.

Azure Event Hubs

As a prerequisite, you need to choose an existing “resource group”, or create a new one (e.g. company-resource-group).

Retrieve your Subscription ID

You also need your “Subscription ID” if you don't have a default one. In Azure Web Portal, navigate to: “Home”, “Cost Management + Billing”, ”Subscriptions”. From there, copy the relevant “Subscription ID” that will be used in the command line (e.g. uuid)

Create the Event Hubs

Use Azure PowerShell (within Cloud Shell interface for example) to create a namespace (e.g. company-eventhub) and a specific Event Hub (e.g. linux-event) within your “resource group” (e.g. company-resource-group)

PS Azure:\> az eventhubs namespace create --name company-eventhub --resource-group company-resource-group --enable-kafka true --subscription uuid
PS Azure:\> az eventhubs eventhub create --resource-group company-resource-group --namespace-name company-eventhub --name linux-event --message-retention 3 --partition-count 4 --subscription uuid

Info

Please replace :

  • company-resource-group with the name of your “resource group”.
  • uuid with your subscription ID retrieved previously (see below).

Create “Shared Access Policies”

  1. Navigate to “Home”, “Event Hubs”, “company-eventhub - Shared access policies”. From there, you can create a policy (e.g. RootManageSharedAccessKey) with the claims Manage, Send and Listen, and note the Primary Key that will be used as the SharedAccessKey.
  2. Navigate to “Home”, “Event Hubs”, “company-eventhub”, “linux-event - Shared access policies”. From there, you can create a policy (e.g. sekoiaio) with the claims Listen. Once created, click on the policy and save the Connection string-primary key, to be sent to SEKOIA.IO.
  3. Navigate to “Home”, “Event Hubs”, “company-eventhub”, ”linux-event - Consumer groups”. From there, you can create a consumer group (e.g. sekoiaio).

Create a Blob Storage for Checkpointing

In order to allow SEKOIA.IO keep track of the consumed events, the next step consists in creating a dedicated Azure Blob Storage.

To proceed, you can use Azure PowerShell:

PS Azure:\> az storage account create --name "sekoiaiocheckpoint" --resource-group "company-resource-group"
PS Azure:\> az storage container create --name "linux-event" --account-name "sekoiaiocheckpoint"

Info

The container name, here linux-event should be the same as the Event Hub’s one. You also need to replace company-resource-group with the name of your “resource group”.

Finally, you have to retrieve the connection string from Azure Web Portal by going in “Storage Accounts”, then in the created storage (sekoiaiocheckpoint) and finally in the “Access Keys” section. After clicking on “Show keys”, you can copy the first of the two connection strings.

Linux Virtual Machine

You need to activate and configure the diagnostic extension LinuxDiagnostic.

  1. Navigate to “Home”, “Virtual machines”, “virtual machine name (e.g. company-linux)”, “Settings” and “Extensions”. Install it and note the new StorageAccount name created (e.g. company-storage-account).
  2. Navigate to “Home”, “Storage accounts”, “company-storage-account”, “Access keys”. From there you can note the key value later used as the storageAccountKey.
  3. Navigate to “Home”, “Storage accounts”, “company-storage-account”, “Shared access signature”. From there set the expiration date with caution, then click on “Generate SAS and connection string”. You should note the SAS token value later used (starting with sv?=).

Navigate to “Home”, “All resources”. From there you can note the resourceId associated to your linux virtual machine.

You need to create two configuration files public_settings.json and protected_settings.json.

Once again you need Azure PowerShell to do it using your favorite text editor:

PS Azure:\> vim public_settings.json

Adapt the public settings configuration file with the value of theses variables: StorageAccount, resourceId and sinks and the syslog configuration.

{
  "StorageAccount": "company-storage-account",
  "ladCfg": {
    "diagnosticMonitorConfiguration": {
      "eventVolume": "Medium",
      "metrics": {
        "metricAggregation": [
          {
            "scheduledTransferPeriod": "PT1H"
          },
          {
            "scheduledTransferPeriod": "PT1M"
          }
        ],
        "resourceId": "/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/company-resource-group/providers/Microsoft.Compute/virtualMachines/company-linux"
      },
      "performanceCounters": {
        "performanceCounterConfiguration": []
      },
      "syslogEvents": {
        "sinks": "linux-event",
        "syslogEventConfiguration": {
          "LOG_AUTH": "LOG_INFO",
          "LOG_AUTHPRIV": "LOG_INFO",
          "LOG_CRON": "LOG_INFO",
          "LOG_DAEMON": "LOG_INFO",
          "LOG_FTP": "LOG_INFO",
          "LOG_KERN": "LOG_INFO",
          "LOG_LOCAL0": "LOG_INFO",
          "LOG_LOCAL1": "LOG_INFO",
          "LOG_LOCAL2": "LOG_INFO",
          "LOG_LOCAL3": "LOG_INFO",
          "LOG_LOCAL4": "LOG_INFO",
          "LOG_LOCAL5": "LOG_INFO",
          "LOG_LOCAL6": "LOG_INFO",
          "LOG_LOCAL7": "LOG_INFO",
          "LOG_LPR": "LOG_INFO",
          "LOG_MAIL": "LOG_INFO",
          "LOG_NEWS": "LOG_INFO",
          "LOG_SYSLOG": "LOG_INFO",
          "LOG_USER": "LOG_INFO",
          "LOG_UUCP": "LOG_INFO"
        }
      }
    },
    "sampleRateInSeconds": 15
  }
}

You need to generate an authentication token for the access to the linux-event hub. First we'll convert the expiration date we set before into a unix timestamp. Extract the se= value from storageAccountSasTokenvand use it as a parameter to this command:

PS Azure:\> date -d '2021-07-09T23:09:19' +%s
1625872159

Then you could create this python script:

PS Azure:\> vim get_token.py

Adapt theses variables: sb_name, eh_name, Url, sas_name, sas_value, and expiry:

from urllib.parse import quote_plus, quote
import hmac
import hashlib
import base64

def get_auth_token(sb_name, eh_name, sas_name, sas_value, expiry):
    """
    Returns an authorization token dictionary
    for making calls to Event Hubs REST API.
    """
    uri = quote_plus("https://{}.servicebus.windows.net/{}" \
                                  .format(sb_name, eh_name))
    sas = sas_value.encode('utf-8')
    string_to_sign = (uri + '\n' + expiry).encode('utf-8')
    signed_hmac_sha256 = hmac.HMAC(sas, string_to_sign, hashlib.sha256)
    signature = quote(base64.b64encode(signed_hmac_sha256.digest()))
    return  {"sb_name": sb_name,
             "eh_name": eh_name,
             "token":'SharedAccessSignature sr={}&sig={}&se={}&skn={}' \
                     .format(uri, signature, expiry, sas_name)
            }

print(get_auth_token(sb_name="company-eventhub", eh_name="linux-event", sas_name="RootManageSharedAccessKey", sas_value="base64string", expiry="unix_timestamp"))

Execute this python script and note the token variable value only from the sr=.

PS Azure:\> python get_token.py
{'token': 'SharedAccessSignature sr=https%3A%2F%2Fcompany-eventhub.servicebus.windows.net%2Flinux-event&sig=9%2BOwFlfqBVEcVg2c5G1wztIjG22GtsMZN5g4NYEu6p0%3D&se=1561569146&skn=RootManageSharedAccessKey', 'eh_name': 'linux-event', 'sb_name': 'company-eventhub'}

Then edit the protected settings configuration file:

PS Azure:\> vim protected_settings.json

Adapt the public protected settings configuration file with the value of theses variables: storageAccountName, storageAccountSasToken (starting with sv= and previously refered as SAS token), sasURL (replace the different values, company-eventhub, linux-event, sr=, and RootManageSharedAccessKey), and SharedAccessKeyName:

{
    "storageAccountName": "company-storage-account",
    "storageAccountSasToken": "sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-06-21T15:52:44Z&st=2019-06-21T07:52:44Z&spr=https&sig=Dewc7mP63E4xrwqttVcOrChgDIpm6Trp%2FR4dfvSo4vg%3D",
    "sinksConfig": {
        "sink": [
            {
                "name": "SyslogJsonBlob",
                "type": "JsonBlob"
            },
            {
                "name": "linux-event",
                "type": "EventHub",
                "sasURL": "https://company-eventhub.servicebus.windows.net/linux-event?sr=https%3A%2F%2Fcompany-eventhub.servicebus.windows.net%2Flinux-event&sig=W86ldfWlPKW0sutGWM7shYGlg%2BbwnbtyVJ7eMsBs840%3D&se=1561137701&skn=RootManageSharedAccessKey"
            }
        ]
    }
}

Finally you could push the change of the diagnostic extension configuration (adapt the parameters resource-group, vm-name):

PS Azure:\> az vm extension set --publisher Microsoft.Azure.Diagnostics --name LinuxDiagnostic --version 3.0 --resource-group company-resource-group --vm-name company-linux --protected-settings protected_settings.json --settings public_settings.json --subscription uuid

Forward the Connection Keys to SEKOIA.IO

Finally, please send to SEKOIA.IO the following information:

  • Azure Event Hub’s “Connection string-primary key” (e.g. "Endpoint=sb://company-eventhub.servicebus.windows.net/;SharedAccessKeyName=sekoiaio;SharedAccessKey=XXXXXX;EntityPath=linux-event").
  • Azure Event Hub’s consumer group name (e.g. sekoiaio).
  • Azure Blob Storage’s connection string (e.g. "DefaultEndpointsProtocol=https;AccountName=sekoiaiocheckpoint;AccountKey=XXXXX").

Further Readings