Your Virtual Machines

First steps


There is no better way to learn new stuff than hands-on, right? For a good start, let's analyze your credentials and test the connections. In the e-mail where I sent you VPN creds, you should find also a purplelabs_vadminX_creds.txt file that includes a list of credentials for your OWN dedicated VMs. For simplicity of console listings, we are going to use the above $X = 11 credentials set by default in every lab. Saying that you can assume that whenever you see vadmin11-related logs, then probably it's me :) Anyway, use your own $X credentials set for all the lab instructions. 


Let's see what the credential set looks like for sample identifier X = 11:

  • VADMIN_X:

    • vadmin11

  • PASSWORD_X:

    • vadmin11

  • BECOME ROOT:

    • sudo su -

  • KALI_X:

    • KALI_X_IP = 192.168.38.X

    • KALI_X_HOSTNAME = kali11

  • PRD_X [CentOS 7]:

    • PRD_X_IP = 192.168.38.X

    • PRD_X_HOSTNAME = prd11

  • DEV_X [CentOS 8]:

    • DEV_X_IP = 10.7.0.10 [192.168.39.X]

    • DEV_X_SSH_PORT = XXX

    • DEV_X_HOSTNAME = dev11

  • FUBU_X [Ubuntu 21.04]:

    • FUBU_X_IP = 10.7.0.10 [192.168.39.X]

    • FUBU_X_SSH_PORT = XXX

    • FUBU_X_HOSTNAME = fubu11

  • VPS_X [Ubuntu 20.04 + Katoolin]:

    • VPS_IP = XXX

    • VPS_SSH_PORT = 22

    • VPS_X_USERNAME = root

    • VPS_X_PASSWORD = passw0rd123

    • VPS_X_HOSTNAME = vps

RECOMMENDED SSH/CLI TERMINALS

  • Linux:

    • Terminator

  • Mac OSX:

    • Tabby

  • Windows:

    • MobaXterm


My general advice is to have a group of open tabs per PRD_X / DEV_X, etc as we will really need a huge number of active SSH connections per every single box. For a good start, get initial access to all your boxes:

KALI_X INITIAL ACCESS


A group of KALI_X VMs is running on a physical server #h1 where the default internal network subnet is 192.168.38.0/24:
 
1. Log in to your KALI_X VM via ssh and look around:

# uname -a
Linux kali12 5.18.0-kali5-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.18.5-1kali6 (2022-07-07) x86_64 GNU/Linux

# lsb_release -a             
No LSB modules are available.
Distributor ID:	Kali
Description:	Kali GNU/Linux Rolling
Release:	2021.3
Codename:	kali-rolling

# cat /etc/resolv.conf 
nameserver 8.8.8.8

# ifconfig -a
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.38.132  netmask 255.255.255.0  broadcast 192.168.38.255
        inet6 fe80::a00:27ff:fee3:fd35  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:e3:fd:35  txqueuelen 1000  (Ethernet)
        RX packets 219093  bytes 237814489 (226.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 122664  bytes 66388962 (63.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# ip r s
default via 192.168.38.1 dev eth1 onlink 
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.38.0/24 dev eth1 proto kernel scope link src 192.168.38.132 

# ps uax
# netstat -antp


PRD_X INITIAL ACCESS


A group of PRD_X VMs is running on a physical server #h1 where the default internal network subnet is 192.168.38.0/24:

1. Log in to your PRD_X VM via ssh and look around:

# uname -a
Linux prd11 3.10.0-1160.25.1.el7.x86_64 #1 SMP Wed Apr 28 21:49:45 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
Codename: Core

# cat /etc/resolv.conf 
nameserver 8.8.8.8

# ifconfig -a
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.38.232  netmask 255.255.255.0  broadcast 192.168.38.255
        inet6 fe80::a00:27ff:fea2:9a1d  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:a2:9a:1d  txqueuelen 1000  (Ethernet)
        RX packets 5040990  bytes 1387587154 (1.2 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8892009  bytes 4640629425 (4.3 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# ip r s
default via 192.168.38.1 dev enp0s8 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
172.18.0.0/16 dev br-139635b83a45 proto kernel scope link src 172.18.0.1 
172.19.0.0/16 dev br-d3fd91bb0118 proto kernel scope link src 172.19.0.1 
172.20.0.0/16 dev br-d30704f23e34 proto kernel scope link src 172.20.0.1 
172.21.0.0/16 dev br-9a473b9f791c proto kernel scope link src 172.21.0.1 
192.168.38.0/24 dev enp0s8 proto kernel scope link src 192.168.38.232 metric 100 

# ps uax
# netstat -antp

DEV_X INITIAL ACCESS


A group of DEV_X VMs are running on a physical server #H2 where the default internal network subnet is 192.168.39.0/24. #H2 is connected to #H1 by VPN, however, there is no direct routing to 192.168.39.0/24 from 192.168.38.0/24 (It works in the opposite). That's the reason why the IP address of DEV_X and FUBU_X is the same IP 10.7.0.10 for everybody but the difference is in ports definition (NAT port-forwarding). Iptables-based port forwarding for SSH service has been configured to get easier access to the private subnet of #H2.

1. Log in to your DEV_X VM via ssh and look around:

# uname -a
Linux dev12 4.18.0-305.3.1.el8.x86_64 #1 SMP Tue Jun 1 16:14:33 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

# cat /etc/redhat-release 
CentOS Linux release 8.4.2105

# cat /etc/resolv.conf 
nameserver 8.8.8.8

# ifconfig -a
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.39.32  netmask 255.255.255.0  broadcast 192.168.39.255
        inet6 fe80::a00:27ff:fe0b:a516  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:0b:a5:16  txqueuelen 1000  (Ethernet)
        RX packets 6193  bytes 512401 (500.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24949  bytes 9485538 (9.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# ip r s
default via 192.168.39.1 dev enp0s8 proto static metric 101 
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.36 metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.38.0/24 via 10.0.2.2 dev enp0s3 proto static metric 100 
192.168.39.0/24 dev enp0s8 proto kernel scope link src 192.168.39.32 metric 101 

# ps uax
# netstat -antp


FUBU_X INITIAL ACCESS


A group of FUBU_X VMs is running on a physical server #H2 where the default internal network subnet is 192.168.39.0/24. #H2 is connected to #H1 by VPN, however, there is no direct routing to 192.168.39.0/24 from 192.168.38.0/24 (It works in the opposite). That's the reason why SSH connections point to the same IP 10.7.0.10 for everybody but to different ports. Iptables-based port forwarding for SSH service has been configured for easier access to the private subnet of #H2.

1. Log in to your FUBU_X VM via ssh and look around:

# uname -a
Linux fubu12 5.11.0-49-generic #55-Ubuntu SMP Wed Jan 12 17:36:34 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 21.04
Release:	21.04
Codename:	hirsute

# cat /etc/resolv.conf 
nameserver 8.8.8.8

# ifconfig -a
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.39.52  netmask 255.255.255.0  broadcast 192.168.39.255
        inet6 fe80::a00:27ff:fe6d:f4b6  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:6d:f4:b6  txqueuelen 1000  (Ethernet)
        RX packets 1858722  bytes 488301094 (488.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2850459  bytes 1664015163 (1.6 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# ip r s
default via 192.168.39.1 dev eth1 onlink 
default via 10.0.2.2 dev eth0 proto dhcp src 10.0.2.15 metric 100 
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 
10.0.2.2 dev eth0 proto dhcp scope link src 10.0.2.15 metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.38.0/24 via 10.0.2.2 dev eth0 
192.168.39.0/24 dev eth1 proto kernel scope link src 192.168.39.52 

# ps uax
# netstat -antp

VPS_X INITIAL ACCESS


1. Log in to your VPS_X via ssh, and look around. You can use this machine as a C2 server whenever you want to egress connection to an external public IP.

# uname -a
Linux vps 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

# ip a s 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether c2:55:80:97:21:5e brd ff:ff:ff:ff:ff:ff
    inet XX.XX.XX.XX/24 brd 185.203.117.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2a07:5741:0:336::1/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::c055:80ff:fe97:215e/64 scope link 
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:39:da:c2:ec brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever


2. Find out what python versions are available by pyenv. 

# pyenv versions
* system (set by /root/.pyenv/version)
  2.7.18

3. Find current connections/port listings:

# ss -antp




Linux Attack and Live Forensics At Scale MATERIALS-ONLY

Buy nowLearn more
  • Course Mindmap - Linux Attack and Forensics Inspection at scale-v3.png1
  • PurpleLABS Cyber Range Network Architecture

0x01. PurpleLabs Hunting Components Dashboard

  • PurpleLabs Dashboard
  • PurpleLabs Components - Helicopter View

0x02. PurpleLabs User Setup Overview

  • Welcome to PurpleLABS!
  • Open Source Community
  • Network Addressing
  • Your Virtual Machines
  • Data sources and SIEM/DFIR components
  • Troubleshooting
  • Rules and policies
  • Threat Detection and Hunting with PurpleLabs #1
  • Threat Detection and Hunting with PurpleLabs #2

0x03. PurpleLabs Default Targets

  • Reverse Shell / Backdoor payloads
  • File transfers
  • Apache Tomcat
  • Apache HTTP CVE-2021-41773
  • NFS no_root_squash
  • Dirty Pipe CVE-2022-0847
  • pkexec CVE-2021-4034
  • CVE-2022-2588
  • CVE-2022-22963: Spring Cloud Function RCE
  • Solr Log4j
  • Samba / CIFS
  • Weblogic SSRF
  • SSH Brute force
  • Docker escape
  • Exiftool CVE-2021-22204
  • Remote Heap Exploitation
  • Attack emulation: Red Canary Atomics against your VMs

0x04. Blue/DFIR Components: SIEM

  • SIEM/HELK introduction
  • SIEM/HELK Data sources
  • SIEM/Splunk introduction
  • SIEM/Splunk Data sources
  • SIEM/Graylog intro
  • SIEM/Graylog Data sources
  • SIEM/Wazuh Data Sources

0x05. Blue/DFIR Components: HOST

  • Host/Syslog
  • Host/Auditd2
  • Host/Falco Runtime Security
  • Host/Tracee Syscall Tracing
  • Host/Sysdig Syscall tracing
  • Host/Sysmon4Linux
  • Host/Velociraptor
  • Host/OSQuery
  • Host/Sandfly
  • Host/Wazuh
  • Host/CatScale
  • Host/UAC
  • Host/varc
  • Host/rkhunter
  • Host/Yara Scanning
  • Host/LKRG
  • Host/SELinux
  • Host/Clamav

0x06. Blue/DFIR Components: NETWORK

  • Network/Zeek
  • Network/Suricata
  • Network/Arkime Full Packet Capture
  • Network/Forward Proxy Squid SSL Decryption
  • Network/WAF Modsecurity

0x07. Introduction to the course

  • About the course
  • Why Linux as a target?
  • Current Linux threat landscape (2022/2023)
  • Linux Appliances Exploitation Cases
  • Purple teaming approach
  • Threat Hunting vs Incident Response
  • Linux MITRE ATT&CK
  • Linux EDR/Security Products1
  • DFIR basics
  • DFIR Preparation
  • Basic TCP/IP stack
  • Basic Linux Investigation tools
  • General rootkits behavior
  • Recommended books1

0x08. Establishing baseline vs Attack Vectors

  • Process names
  • Process arguments
  • Parent-child process relationship
  • /proc/ exploration
  • sysctl
  • Linker / LD_PRELOAD
  • Linux Kernel Modules
  • LKM Off
  • DNS Settings
  • Network profiling
  • Open Ports
  • iptables
  • At / cron / systemd timers
  • Users
  • Shell Configuration
  • Initialization scripts
  • Special File Attributes
  • File Hashing / checksums
  • OS / application logging behavior
  • SSH keys
  • Linux namespaces

0x09. Rule-based Linux Log Analysis

  • Sigma Rules Hands-on Introduction
  • Protections Artifacts from Elastic
  • Detection Rules from Elastic

0x0a. Linux Memory forensics

  • Linux Report Sections
  • Building Volatility 2 Linux Profiles
  • Building Volatility 3 ISF JSON
  • Memory Acquisition
  • Forensics with Volatility2
  • Forensics with Volatility 3
  • Fileless plugin

0x0b. Linux Shells / C2 Implants

  • Sliver C2 Setup
  • Sliver Transports and Pivoting
  • Sliver in details
  • Meterpreter Setup
  • Sliver to Meterpreter Sideload
  • Meterpreter shell_to_meterpreter
  • TLS/sniCAT
  • Merlin Setup
  • Merlin Transports
  • Merlin libprocesshider
  • DNS/AXFR Payload Delivery
  • DNS/Weasel
  • DNS/dnscat2
  • ICMP-based C2 and Exfiltration
  • Port knocking

0x0c. Tunnels / pivots / redirectors

  • SSH Socks Proxy
  • SSH Tunneling
  • Reverse SSH
  • Shootback Protocol Tunneling
  • SSHimpanzee
  • socat
  • Chisel
  • ngrok

0x0d. Incident response

  • IRIS Introduction
  • IR Playbooks2

0x0e. Linux ATTACK/Detection Analysis

  • Evaluation of Linux Rootkits and Detection INTRO SLIDES - Practical Linux Rootkits for Red and Blue .pdf
  • eBPF SLIDES - Practical Linux Rootkits for Red and Blue .pdf
  • [US] Rootkits: Shared Library Injection
  • [US] Rootkits: Oh my Father!
  • [US] Rootkits: Socket Command Injection
  • [US] ELF injection with ptrace()
  • [US] ELF injection without ptrace()
  • [US] Proxy execution with DDexec
  • [US] In-memory execution with memrun
  • [US] memfd_vs_no_exec
  • [US] Fileless Scripting Execution
  • [US] Rootkits: Dynamic Linker Preloading
  • [US] Rootkits: Zombie Ant Farm Pypreloader #1
  • [US] MSF Shellcode from bash
  • [US] Rootkits: sshd injection
  • [US] Rootkits: sshd dummy cipher suite
  • [US] PAM-based Rootkits #1
  • [US] PAM-based Rootkits #2
  • [US] PAM-based Rootkits #3
  • [US] Yum/RPM Persistence
  • [US] Rootkits: Apache mod_authg
  • [US] Rootkits: HTTPD mod_backdoor
  • [US] Webshells: SOCKS from JSP
  • [US] Webshells: meterphp
  • [US] Webshells slopshell
  • [KS] Rootkits: Usermode Helper on ICMP
  • [KS] Rootkits: In-Memory LKM Loading
  • [KS] Rootkits: Reptile Analysis
  • [KS] Rootkits: Suterusu Analysis
  • [KS] Rootkits: Reveng_rtkit Analysis
  • [KS] Rootkits: iptables evil bit
  • [KS] Rootkits: systemtap creds() upgrade
  • [KS] Rootkits: Netfilter hooking #1
  • [KS] Rootkits: xt_conntrack.ko Infection
  • [KS] Rootkits: Ftrace Hooking #1
  • [KS] Rootkits: bad-bpf trip
  • [KS] Rootkits: XDP-UDP-Backdoor
  • [KS] Rootkits: eBPF hooking / TripleCross
  • [KS] Rootkits: eBPF SSL/TLS text capturing
  • [KS] Rootkits: eBPF Raw Tracepoint Interception
  • [KS] Rootkits: eBPF PAM creds stealing
  • [KS] Rootkits: eBPF KoviD Analysis
  • [KS] Rootkits: eBPF bpfdoor
  • [KS] Rootkits: ebpfkit Analysis
  • [KS] Randomized Faulter [RETIRED]

0x0f. Changelog

  • Changelog

0x10. Active Security Research

  • Active Research
  • Rootkits: Syscall hooking
  • Linux Incident Response
  • In-memory Execution
  • Evasion / Bypassing techniques
  • Exploitation
  • Memory Forensics
  • Linux Internals