INE Training Notes - by syselement
🏠 Home BlogGitHub📚 Buy Me a Book
  • INE Training Notes
  • Courses
    • eJPT - PTSv2
      • 📒Penetration Testing Prerequisites
        • Introduction
        • Networking
        • Web Applications
      • 📒1. Assessment Methodologies & Auditing
        • Information Gathering
        • Footprinting & Scanning
        • Enumeration
          • 🔬SMB Enum
          • 🔬FTP Enum
          • 🔬SSH Enum
          • 🔬HTTP Enum
          • 🔬MYSQL Enum
          • 🔬SMTP Enum
        • Vulnerability Assessment
        • Auditing Fundamentals
      • 📒2. Host & Network Penetration Testing
        • System/Host Based Attacks
          • 🪟Windows Attacks
            • 🔬IIS - WebDAV
            • 🔬SMB - PsExec
            • 🔬RDP
            • 🔬WinRM
            • 🔬Win Kernel Privesc
            • 🔬UAC Bypass
            • 🔬Access Token
            • 🔬Alternate Data Stream
            • 🔬Credentials Dumping
          • 🐧Linux Attacks
            • 🔬Bash
            • 🔬FTP
            • 🔬SSH
            • 🔬SAMBA
            • 🔬Cron Jobs
            • 🔬SUID
            • 🔬Hashes Dumping
        • Network Based Attacks
          • 🔬Tshark, ARP, WiFi
        • The Metasploit Framework (MSF)
          • 🔬HFS - MSF Exploit
          • 🔬Tomcat - MSF Exploit
          • 🔬FTP - MSF Exploit
          • 🔬Samba - MSF Exploit
          • 🔬SSH - MSF Exploit
          • 🔬SMTP - MSF Exploit
          • 🔬Meterpreter - MSF
          • 🔬Win Post Exploitation - MSF
          • 🔬Linux Post Exploitation - MSF
        • Exploitation
          • 🔬Fixing Exploits - HFS
          • 🔬Win Workflow Platform - MSF
          • 🔬Win Black Box Pentest
          • 🔬Linux Black Box Pentest
        • Post-Exploitation
          • 🔬Windows Post-Exploitation
          • 🔬Windows Privilege Escalation
          • 🔬Windows Persistence
          • 🔬Linux Post-Exploitation
          • 🔬Linux Privilege Escalation
          • 🔬Linux Persistence
          • 🔬Cracking Hashes
          • 🔬Pivoting
        • Social Engineering
      • 📒3. Web Application Penetration Testing
        • Intro to Web App Pentesting
          • 🔬HTTP Enumeration
          • 🔬Web App Scanning
          • 🔬Web App Attacks
      • 🔬Exam Preparation - Labs
        • PTSv1 Prerequisites Labs
          • 🔬HTTP(S) Traffic Sniffing
          • 🔬Find the Secret Server
          • 🔬Data Exfiltration
          • 🔬Burp Suite Basics - Directory Enumeration
        • PTSv2 Practice Labs
      • 🌐eJPT References
      • 📜eJPT Cheat Sheet
    • ICCA
      • 📒1. Cloud Foundations
      • 📒2. Cloud Management Concepts
      • 📒3. Cloud Identity, Security, and Compliance
      • 🌐Icca References
    • eMAPT
      • 📒Android
      • 📒iOS
      • 🌐eMAPT References
  • 🏠syselement's Blog Home
Powered by GitBook
On this page
  • Linux Vulnerabilities
  • Linux Exploitation
  • Apache - ShellShock
  • FTP
  • SSH
  • SAMBA
  • Linux Privilege Escalation
  • Linux Kernel Exploits
  • Misconfigured Cron Jobs
  • SUID Binaries
  • Linux Credential Dumping
  • Linux Password Hashes

Was this helpful?

Edit on GitHub
  1. Courses
  2. eJPT - PTSv2
  3. 📒2. Host & Network Penetration Testing
  4. System/Host Based Attacks

Linux Attacks

Previous🔬Credentials DumpingNext🔬Bash

Last updated 2 years ago

Was this helpful?

Linux Vulnerabilities

is a free and open source operating system, combination of the Linux kernel and the GNU toolkit software collection, developed by Richard Stallman.

  • Linux kernel is the core of the O.S.

  • Linux distributions are variants of the same O.S.

  • Typically deployed as a server O.S.

    • Linux server services and protocols can provide with an access vector that an attacker can use

Protocol/Service
Ports
Purpose

TCP 80/443

Open source cross-platform web server

TCP 22

Cryptographic remote access protocol, used for operating network services securely over an unsecured network. Secure successor of telnet

TCP 21

Communication protocol used for file sharing between a server and a client, over TCP

TCP 445

Open source implementation of the SMB protocol. Enabled Unix machines to communicate with Windows machines in a network

Linux Exploitation

Apache - ShellShock

GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution, aka ShellShock.

  • Bash shell since v.1.3

  • The Bash mistakenly exectutes trailing commands after a series of characters

  • Apache web servers that run CGI or .sh scripts are also vulnerable

🗒️ CGI (Commond Gateway Interface) - Apache executes arbitrary commands on the Linux system and the output displayed on the web server.

ShellShock Exploitation

  1. Locate a script or input vector (legitimate Apache CGI scripts) to communicate with Bash

  2. Input special characters within the HTTP headers (e.g. user-agent)

  3. When CGI is executed, the web server will run it with Bash in a new process

The exploitation can be done manually and automatically.

FTP

  • Port: 21 (TCP) - default

  • User Authentication - username & password

    • anonymous access may be configured on FTP - no credentials needed

FTP Exploitation

  1. Credentials can be brute-forced on the FTP server

  2. Exploit inherent vulnerability within FTP service

SSH

  • Port: 22 (TCP) - default

  • SSH Authentication:

    • User Authentication - username & password

    • Key based, 2 key pairs (public and private keys) - no username and password

SSH Exploitation

  1. Credentials can be brute-forced on the SSH

  2. With SSH legitimate credentials the attacker gain access to a full shell, with the utilized user account's privileges

SAMBA

  • Port: 445 (TCP)

  • Not pre-packed, not a common running service

  • User Authentication - username & password

SAMBA Exploitation

  1. Credentials can be brute-forced

  2. Use SMBMap or smbclient to retrieve information

Linux Privilege Escalation

Linux Kernel Exploits

❗ Targeting Kernel can cause system crashes, data loss, kernel panics etc ❗

Linux kernel vulnerabilities can be targetted to execute arbitrary code and obtain privileged system shell.

  • Kernel version and distribution is important

The Linux Privilege Exploitation process consists of:

  1. Identify kernel vulnerabilities (Linux Exploit Suggester)

  2. Download, compile, transfer kernel exploits onto the target system

  • Assessing kernel exposure on publicly known exploits

  • Verifying state of kernel hardening security measures

wget https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh -O linux-exploit-suggester.sh

chmod +x linux-exploit-suggester.sh

./linux-exploit-suggester.sh
  • Very useful to get Kernel version, possible Exploits with detailed information on the CVEs

Misconfigured Cron Jobs

🗒️ Cron - a time-based daemon/service, scheduler of applications, scripts and commands. It executed non-interactive jobs.

  • Tasks scheduled in cron are called cron jobs

    • e.g. backups, o.s. upgrades, patches, scripts, commands etc

  • Default cron table/configuration file is /etc/crontab

  • Cron Jobs can be run as any user

Cron Jobs Privesc

  • The attacker will target root's privileged Cron Jobs

  • Find and identify cron jobs scheduled by the root user or the files processed by te cron job.

SUID Binaries

  • Allows unprivileged users to run scripts or binaries with root permissions, and it's limited to the execution of that specific binary.

  • This is not privilege escalation, but can be used to obtain an elevated session

    • e.g. the sudo binary

  • The exploitation of SUID binaries to get privesc depends on:

    • the owner of the SUID file - e.g. look for root user's SUID binaries

    • access permissions - x executable permissions are required to execute the SUID binary

Linux Credential Dumping

All the Linux accounts' information is stored in the passwd file stored in /etc/ directory.

Linux has multi-user support, this can increase the overall risk of a server.

cat /etc/passwd

Passwords cannot be viewed because they are encrypted and stored in the shadow file in the /etc/ directory.

  • 📌 Only root account can access shadow file

sudo cat /etc/shadow

The hashed password have a prefix $id value that indicates the type of hashing algorithm that is being used, e.g.:

Value
Hashing Algorithm

$1

MD5 (easy to crack)

$2

Blowfish (easy to crack)

$5

SHA-256 (difficult to crack)

$6

$y


(Secure Shell)

(File Transfer Protocol)

🗒️ - *Nix shell part of the GNU project and default shell for most Linux distros.

🔬 Check the

🗒️ (File Transfer Protocol) - facilitate file sharing between a server and clients. Used for transfering files to and from a web server (e.g. CPanel or FTP credentials).

🔬 Check the

🗒️ (Secure Shell) - cryptographic remote administration protocol, tipically used for servers remote access

🔬 Check the

🗒️ - network file sharing protocol, for file and peripherals sharing on a LAN. It is the Linux implementation of SMB

🔬 Check the

- a tool designed to assist in detecting security deficiencies for given Linux kernel/Linux-based machine.

🔬 Check the

🗒️ (Set owner User ID) - is a type of special access permission given to a file. A file with SUID always executes as its the owner, regardless of the user passing the command.

🔬 Check the

(difficult to crack)

🔬 Check the

🐧
GNU/Linux
CVE-2014-6271
Bash
Bash - ShellShock Lab here
FTP
FTP Brute force Lab here
SSH
SSH Brute force Lab here
SAMBA
SAMBA Brute force Lab here
Linux-Exploit-Suggester
Cron Jobs Lab here
SUID
SUID Lab here
Linux Password Hashes
Dumping Linux Hashes Lab here
Apache Web Server
SSH
FTP
SAMBA
SHA-512
yescrypt
linux-exploit-suggester - Kali Linux
cat /etc/passwd