Logins Outside Working Hours: Catching Stolen Credentials
Nov 19, 2026
Trunc Team

This is a successful SSH login:

Nov 19 10:14:07 web01 sshd[48211]: Accepted password for root from 198.51.100.23 port 40122 ssh2

The password was right and sshd accepted it. Nothing in the line looks like an attack. If that password was stolen, the log reads exactly the same as when its owner uses it.

Two things about it are still odd. The server logs in UTC, so 10:14 there is 02:14 in Los Angeles, where everyone who has that password works. And in this example 198.51.100.23 is an address in the Netherlands, where nobody on the team has ever logged in from.

You can't predict what an attacker will do or which tools they'll bring. You can predict your own users: when they work and where they log in from. Write that down, and any login that doesn't fit it is worth a look.

Write down what normal looks like

Take a small company with offices in California and Florida and a support team in Vancouver. Twenty people use SSH, the VPN and webmail, roughly 6am to 9pm Pacific, Monday to Friday. Two things barely change from one week to the next: when they log in and which country they log in from.

That's the whole profile. Monday to Friday, 06:00 to 21:00, United States and Canada. Once it's set, any login outside it gets a review.

It will be wrong sometimes. Someone on call fixes a full disk at 3am. Someone logs in from a hotel in London. A backup job logs in over SSH every night at 02:30. Each of those is one line in an ignore list or one more country on the list (more on that below).

What an off-hours login looks like in the logs

These are the lines Trunc's behavior rules act on, with the alert title each one produces. The examples use the profile above: time zone America/Los_Angeles, Monday to Friday 06:00-21:00, and Linux hosts that log in UTC.

A normal user, at 02:14

Nov 19 10:14:07 web01 sshd[48211]: Accepted publickey for deploy from 203.0.113.45 port 51544 ssh2

Alert: Behavior: Login outside working hours. Password or key makes no difference. Any successful login counts: SSH (including Dropbear), Windows console and RDP, WordPress, Azure and SharePoint, GlobalProtect and Meraki VPN, and FortiGate admin logins. Dovecot IMAP/POP logins count too if you turn them on.

The same login as root

Nov 19 10:14:07 web01 sshd[48211]: Accepted publickey for root from 203.0.113.45 port 51544 ssh2

Alert: Behavior: Root login outside working hours.

sudo at 23:41

Nov 19 07:41:52 db02 sudo:    alice : TTY=pts/1 ; PWD=/home/alice ; USER=root ; COMMAND=/usr/bin/cat /etc/shadow

Alert: Behavior: sudo outside working hours. Only sudo that actually ran a command as root counts. A wrong password at the sudo prompt is the separate Failed sudo alert.

su to root

Nov 19 07:58:10 db02 su: Successful su for root by alice

Alert: Behavior: su to root outside working hours. This one depends on how su logs on your system. We match Successful su for root by <user> and the + /dev/pts/1 alice:root format. If your su writes neither, this alert won't fire.

An admin over RDP

2026/11/19 03:12:40 WinEvtLog: Security: AUDIT_SUCCESS(4624): Microsoft-Windows-Security-Auditing: ... An account was successfully logged on. ... Logon Type: 10 ... Elevated Token: Yes ... New Logon: ... Account Name: jsmith ... Source Network Address: 203.0.113.45 ...

Logon type 10 is RDP, and Elevated Token: Yes means jsmith logged in with admin rights. Alert: Behavior: Admin login outside working hours. A console or RDP logon as Administrator gets the same title.

Someone at the keyboard

A 4624 with Logon Type: 2 (or 11, cached credentials) on DESKTOP-4K2M9QX is someone sitting at that machine. Alert: Behavior: Desktop login outside working hours.

Windows logs a lot of logons that are not a person. Network logons (type 3, a file share for example) and Kerberos service tickets (4769) never count as logins. SYSTEM, LOCAL SERVICE, NETWORK SERVICE, ANONYMOUS LOGON, the DWM-n and UMFD-n accounts and machine accounts ending in $ are skipped.

Someone making themselves at home

Logging in is step one. The next steps tend to be an account or a service that survives a password change.

Nov 19 11:02:44 web01 useradd[51920]: new user: name=sysupd, UID=1002, GID=1002, home=/home/sysupd, shell=/bin/bash, from=/dev/pts/0

03:02 in Los Angeles, and a new account named to look like a system user. Alert: Behavior: User added outside working hours. Windows 4720, new Azure AD users and users created through the Linode API count too. groupadd on its own doesn't.

2026/11/19 01:37:05 WinEvtLog: System: INFORMATION(7045): Service Control Manager: SYSTEM: NT AUTHORITY: FS01: A service was installed in the system. Service Name: RemoteSvc Service File Name: C:\Windows\Temp\rsvc.exe Service Type: user mode service Service Start Type: auto start Service Account: LocalSystem

An auto-start service running from C:\Windows\Temp as LocalSystem deserves a look at any hour. At 01:37 it's Behavior: New service outside working hours. Windows Defender definition updates are left out. We walked through a real 7045 left behind by an attacker in the Cisco breach logs.

Where from: business countries

The second half of the profile is a list of countries. Pick the ones your team works from under Settings > Business countries, and any successful login with a source IPv4 address outside them alerts. This one runs at any hour.

Nov 19 15:02:31 web01 sshd[50112]: Accepted password for deploy from 198.51.100.23 port 40122 ssh2

That's 07:02 in Los Angeles, inside working hours. If 198.51.100.23 is outside the United States and Canada, the alert is Behavior: Login from outside your business countries. When a login is both off-hours and from outside your countries, you get one alert with both in the title:

Behavior: Login outside working hours, from outside your business countries

The country check has limits:

  • Country only. No regions or cities.
  • IPv4 only. IPv6, private and unknown addresses are never checked.
  • Someone on a commercial VPN shows up in the VPN exit's country.
  • Logins from Tor, commercial VPNs and datacenter networks have their own alerts on the same settings page. Those come from Security Insights and also run at any hour.
  • Only the logins ticked under Which logins count are checked. IMAP/POP mail logins are off by default, so a mail login from abroad doesn't alert.

What the alert looks like

With Login outside working hours, root or sudo outside working hours and Login from outside your business countries switched on for one email address, the root login from the top of this article sends this:

Subject: Trunc Alert: Behavior: Root login outside working hours, from outside your business countries

Email Alert triggered for the following event:

Alert name: Behavior: Root login outside working hours, from outside your business countries
Alert description: Someone logged in over SSH as root outside your working hours. A successful login from an IPv4 address outside your business countries.
Location: web01
Log file: /var/log/auth.log


Full log:

Rules: Login outside working hours; root or sudo outside working hours; Login from outside your business countries
User: root
Host: web01
Source: 198.51.100.23 (NL)
Processed: Thu 2026-11-19 02:14 PST (America/Los_Angeles)

Nov 19 10:14:07 web01 sshd[48211]: Accepted password for root from 198.51.100.23 port 40122 ssh2


You can customize your alerts here:

https://my.trunc.org/dashboard?page=logging&subpage=alerts

If you have any questions, please contact us at support@noc.org

Look at the Processed: line. The rules use the time Trunc processed the line, in your account's time zone. That's usually seconds after the host wrote it. The timestamp inside the line isn't used, so a host with its clock in UTC (like this one) or set wrong doesn't change the result.

Slack gets the same title, the host and the log in a code block. Every alert we send is also listed under Alert history (filter by Behavior), kept for 24 months.

Lines that match Login outside working hours, Desktop login outside working hours or Login from outside your business countries also get the MITRE ATT&CK tag T1078 (Valid Accounts).

Keeping it quiet

An alert nobody reads is worse than no alert. These are the defaults and the knobs:

  • Everything starts off. A rule runs only when you tick it for an email address or Slack channel on Settings > Behavior rules.
  • One alert per rule, user and host per hour. alice running 40 sudo commands at midnight is one email. New users and new services are grouped per host for 30 minutes. You can set either from 15 minutes to 24 hours.
  • 20 behavior alerts an hour, then one summary. Past the limit you get a single Behavior: hourly alert limit reached with a count per rule. The events are still stored and searchable. The limit can be 5, 10, 20, 50 or 100, and it's separate from your other alerts' hourly cap.
  • Ignore lists for users, hosts and source IPs, under Advanced:
Never alert for these users:
  svc_backup
  ci-runner*
Never alert for these hosts:
  bastion*
Never alert for these source IPs:
  192.0.2.0/28

A trailing * matches a prefix, and web01 also matches web01.example.com. For sudo and su, the user is the one who ran the command.

  • Noisy sources are off. Windows unlock (logon type 7) and IMAP/POP mail logins don't count until you tick them under Which logins count.
  • Holidays. Up to 60 dates, each counted as a whole day outside hours. One click adds US federal holidays or UK bank holidays for the next 18 months. Holidays apply while Saturday and Sunday have no hours set.

What these rules don't do

  • They use processing time. A log that arrives late is judged by when it arrived, so it can land on the wrong side of your hours. While Trunc is catching up on a past day's file, the time-based rules are paused.
  • Countries are IPv4 only, as above.
  • Linux desktop logins aren't covered yet. Linux servers (SSH, sudo, su, useradd) and Windows desktops and servers are.
  • su depends on the log format, as above.
  • They stop at the login. What the user did next is in your logs. Search category:behavior_* (or one rule, such as category:behavior_offhours_root) to list every match, including the ones the limits held back, then follow the user and the address from there. Threat hunting using your logs has the searches we use. Only rules you've switched on tag events.
  • Email and Slack only. No PagerDuty, no SMS.
  • Saving reloads your parser. Lines that arrive during the reload can be missed, so don't tune rules in the middle of an incident.
  • You set the profile. Trunc doesn't learn your hours or countries from your logs.

Coming soon

These are listed on the settings page and don't fire yet. Some need a per-user history we're still building.

  • Login from a new country for that user
  • Implausible country change
  • Password spraying
  • Dormant account logged in
  • First login to a host
  • USB storage outside working hours
  • Server restart outside working hours
  • Desktop turned on outside working hours
  • Security settings changed outside working hours
  • New scheduled task outside working hours
  • Crontab changed outside working hours

Setting it up in Trunc

  1. Set your account time zone under Settings > Account. The working-hours rules can't be switched on until there is one.
  2. Settings > Working hours. The default is Monday to Friday, 06:00-21:00. Each day has one range, in 15-minute steps. An end time before the start runs past midnight, so Friday 22:00 to 06:00 covers early Saturday. That range replaces Friday's 06:00-21:00, so Friday daytime then counts as outside working hours.
  3. Settings > Business countries. Pick at least one, or the country rule stays off.
  4. Settings > Behavior rules. Tick each rule for the email addresses and Slack channels that should get it.

Behavior rules are on every plan, including the free trial. The full list is on the Behavior rules page.

If a line from your logs should have fired one of these and didn't, send it to us. We'll tell you why and fix the rule if it's ours.

Logging Guides

We love logs. In this section we will share some articles from our team to help you get better at logging.

Trunc Logging

Logging for fun and a good night of sleep.

  • Real time search
  • Google simple
  • Cheap
  • Just works
  • PCI compliance
Contact us!

Do you have an idea for an article that is not here? See something wrong? Contact us at support@noc.org

Tired of price gouging
  • Clear pricing
  • No need to guess
  • Real people
  • Real logging

Simple, Affordable, Log Management and Analysis.

14 days free trial. No credit card required.