惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
量子位
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
U
Unit 42
IT之家
IT之家
F
Fortinet All Blogs
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Register - Security
The Register - Security
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
A
Arctic Wolf
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
P
Palo Alto Networks Blog
Y
Y Combinator Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AWS News Blog
AWS News Blog
有赞技术团队
有赞技术团队
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
aimingoo的专栏
aimingoo的专栏
Know Your Adversary
Know Your Adversary
Cyberwarzone
Cyberwarzone
Martin Fowler
Martin Fowler
The Hacker News
The Hacker News
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
博客园 - 聂微东
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
S
Securelist
T
The Exploit Database - CXSecurity.com
T
Threatpost
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
F
Full Disclosure

Black Hills Information Security, Inc.

Bad Habits: An ANTISOC Operation Same Problem, Different Angles: When Red Team and Blue Team Actually Talk to Each Other How to Identify and Exploit New Vulnerabilities Swapper – A Pure Regex Match/Replace Burp Extension A Practical Guide to BloodHound Data Collection Network Engineering Basics Signed, Trusted, and Abused: Proxy Execution via WebView2 Getting Started In Pentesting – Advice From The BHIS Pentest Lead Cloud Security: Tips and Resources for Securing the Cloud Lessons From A Chatbot Incident How to Lead Effective Tabletops Understanding GRC: How to Navigate Risks and Compliance Standards The “P” in PAM is for Persistence: Linux Persistence Technique Malware Analysis: How to Analyze and Understand Malware OSINT: How to Find, Use, and Control Open-Source Intelligence What to Do with Your First Home Lab When the SOC Goes to Deadwood: A Night to Remember Social Engineering and Microsoft SSPR: The Road to Pwnage is Paved with Good Intentions Common Cyber Threats Finding the Right Penetration Testing Company Deceptive-Auditing: An Active Directory Honeypots Tool The Curious Case of the Comburglar How to Set Smart Goals (That Actually Work For You) Inside the BHIS SOC: A Conversation with Hayden Covington Abusing Delegation with Impacket (Part 3): Resource-Based Constrained Delegation Why You Got Hacked – 2025 Super Edition Abusing Delegation with Impacket (Part 2): Constrained Delegation Abusing Delegation with Impacket (Part 1): Unconstrained Delegation GoSpoof – Turning Attacks into Intel Model Context Protocol (MCP) Bypassing WAFs Using Oversized Requests Getting Started with AI Hacking Part 2: Prompt Injection Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 2) DomCat: A Domain Categorization Tool Wrangling Windows Event Logs with Hayabusa & SOF-ELK (Part 1) Microsoft Store and WinGet: Security Risks for Corporate Environments Default Web Content MailFail Commonly Abused Administrative Utilities: A Hidden Risk to Enterprise Security Stop Spoofing Yourself! Disabling M365 Direct Send Bypassing CSP with JSONP: Introducing JSONPeek and CSP B Gone Offensive Tooling Cheatsheets: An Infosec Survival Guide Resource DNS Triage Cheatsheet GraphRunner Cheatsheet Burp Suite Cheatsheet Impacket Cheatsheet Wireshark Cheatsheet Hashcat Cheatsheet EyeWitness Cheatsheet Nmap Cheatsheet Netcat (nc) Cheatsheet Hunt for Weak Spots in Your Wireless Network with Airodump-ng from the Aircrack-ng Suite Detecting ADCS Privilege Escalation Vulnerability Scanning with Nmap Getting Started with NetExec: Streamlining Network Discovery and Access How to Use Dirsearch Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 3: Arcanum Cyber Security Bot How to Design and Execute Effective Social Engineering Attacks by Phone Abusing S4U2Self for Active Directory Pivoting Why Use a Macro Pad? Caging Copilot: Lessons Learned in LLM Security Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 2: Copilot Augmenting Penetration Testing Methodology with Artificial Intelligence – Part 1: Burpference Intercepting Traffic for Mobile Applications that Bypass the System Proxy How to Root Android Phones Communicating Security to the C-Suite: A Strategic Approach Offline Memory Forensics With Volatility Getting Started with AI Hacking: Part 1 Go-Spoof: A Tool for Cyber Deception How to Test Adversary-in-the-Middle Without Hacking Tools Canary in the Code: Alert()-ing on XSS Exploits How to Hack Wi-Fi with No Wi-Fi Why Your Org Needs a Penetration Test Program Burp Suite Extension: Copy For Light at the End of the Dark Web Wi-Fi Forge: Practice Wi-Fi Security Without Hardware Avoiding Dirty RAGs: Retrieval-Augmented Generation with Ollama and LangChain Gone Phishing: Installing GoPhish and Creating a Campaign 5 Things We Are Going to Continue to Ignore in 2025 John Strand’s 5 Phase Plan For Starting in Computer Security Questions From a Beginner Threat Hunter GRC for Security Managers: From Checklists to Influence AI Large Language Models and Supervised Fine Tuning Attack Tactics 9: Shadow Creds for PrivEsc w/ Kent & Jordan One Active Directory Account Can Be Your Best Early Warning Introduction to Zeek Log Analysis Indecent Exposure: Your Secrets are Showing Creating Burp Extensions: A Beginner’s Guide Pitting AI Against AI: Using PyRIT to Assess Large Language Models (LLMs) The Top Ten List of Why You Got Hacked This Year (2023/2024) ICS Hard Knocks: Mitigations to Scenarios Found in ICS/OT Backdoors & Breaches Intro to Data Analytics Using SQL Finding Access Control Vulnerabilities with Autorize The Detection Engineering Process Cyber Risk Lessons We Can Learn From Hurricane Preparedness Intro to Desktop Application Testing Methodology What Is Penetration Testing? Adversary in the Middle (AitM): Post-Exploitation Pentesting, Threat Hunting, and SOC: An Overview QEMU, MSYS2, and Emacs: Open-Source Solutions to Run Virtual Machines on Windows
Espanso: Text Replacement, the Easy Way
BHIS · 2025-05-28 · via Black Hills Information Security, Inc.

Chris has been working in security for 30 years, mainly doing penetration testing in both consulting and corporate environments. Chris is the author of the Nikto web scanner, founder of the RVAsec conference, and has been involved in many OSS projects and community efforts.

Espanso is a powerful cross-platform and open-source text replacement (or text expander) tool. At a simple level: it replaces what you type with something else. For example, imagine typing three characters and having your full email address magically appear? Microsoft Word’s autocorrect and smart completion on phones can do a few of these things, but with Espanso, it can be quite powerful when combined with advanced features such as running shell commands.

This blog focuses on using Espanso on Linux (shell commands) for the purposes of assisting with a penetration tester’s common tasks, although it can be used for just about anything.

Why Use a Text Expander?

While some of our work might become automated using LLMs, a lot of grunt work will never die. Sending emails, writing commands, getting your external IP address—heck, even typing your phone number or mailing address—are an inefficient waste of time. In addition, a text expander will cut down on errors from typos and reduce the overall number of mistakes.

Installation

Espanso has installation packages for Windows, macOS, and Linux on their website. It can also be installed manually using the source code located on GitHub. After installation, the program uses a configuration file and a match file; both are YAML and easily updated for your needs.

By default, Espanso doesn’t need much configuration to operate successfully. The matches are where the money is, so to speak.

Match & Replace

The base.yaml file, located in the Espanso config directory, contains the match-and-replace rules. You can also add your own YAML files to make management of the rules easier.

The project’s extensive documentation explains how to locate this file on your system, but Espanso itself contains a handy shortcut which will open the file with your default editor. The command below will open the file for editing:

espanso edit

The basic idea is that it will match a text string that you type, known as a trigger, and replace it with something else. A simple example of this is:

- trigger: ":me"
    replace: "Chris"

In almost any location on my system, if I type :me then Espanso will replace it with Chris.

As in the default Espanso examples, I tend to use a colon before triggers as it’s not a common pattern in English. If you’re in camp vim like me, just be careful and don’t clobber things you’ll need!

The previous example only saves me 5 characters of typing and isn’t really that useful. But writing out my entire signature is really useful, so I have this (well, very close to this at least):

  - trigger: ":me"
    replace: "Chris Sullo | [email protected] | 555-867-5309"

I have simple replacements for my phone number, address, email address, and others. Even with the most basic usage, Espanso can save you time. But with some additional features, it can get much more powerful.

An important note about YAML: whitespace matters (like Python 😔). If you aren’t comfortable with the format, simply copy and edit existing lines to retain the indentation.

Advanced Usage

Variables

Espanso can use internal variables to make matching a little more dynamic without resorting to full shell commands. The example below replaces the {{time}} value with the current hour and minute.

  - trigger: :now
    replace: It's {{time}}
    vars:
      - name: time
        type: date
        params:
          format: "%H:%M"

When I type :now it is replaced with It’s 15:53.

Prompt for Value

If you write the same email a lot—for example, a penetration test start notification—you could add this to Espanso and have it prompt you for the recipient’s name, then spell out your text. The Espanso team has an example of this:

- trigger: :greet
    form: |
      Hey [[name]],
      Happy Birthday!

Now, anywhere I type :greet Espanso will open this dialog:

Espanso Prompt

And then will output the complete text:

Hey Nikto,
Happy Birthday!

The command can have multiple [[]] strings and each will have a field in the dialog box.

Regex Values

The prompt is handy, but I don’t really like dialog boxes. Fortunately, Espanso can use regular expressions in the trigger and capture the contents that you type as a variable. Extending the documentation’s example, we can pass a name directly when typing.

  - regex: :greet\((?P<person>.*)\)
    replace: "Hey {{person}},\nHappy Birthday!"

To use this, I can now type :greet(Nikto) and it will take the value passed and replace it in the output, which will look like:

Hey Nikto,
Happy Birthday!

You can pass multiple values if they have unique names, such as “person” in the example above.

Shell Commands

Another powerful feature of Espanso is the ability to run shell commands. While as security people, we should be wary of letting programs call out to a shell, in this case we can control the input and output to keep it safe and make life easier. (Let’s not talk about how this is basically a keylogger, ok? You can look at the source code and watch network traffic if you like!).

Here’s one I frequently to add my external IP address to documents, etc.

  - trigger: :myip
    replace: "{{output}}"
    vars:
      - name: output
        type: shell
        params:
          cmd: "curl ifconfig.me" 

When I type :myip now, it will make a curl request to the http://ifconfig.me/ website, which returns only the source IP address.

Another shell command use case (I find using the shell easier than learning Espanso’s internal variables) is to write email subjects for status reports.

  - trigger: :ps
    replace: "Pentest Status: {{output}}"
    vars:
      - name: output
        type: shell
        params:
          cmd: "date '+%B %d, %Y'"

Now, when I open a new email, I put the cursor in the subject line and type :ps to write it out:

Pentest Status: April 15, 2025

Another handy one is encoding—base64 encode anything anywhere with a combination of a regex matcher and a shell command.

  - regex: :b64\((?P<val>.*?)\)
    replace: "{{output}}"
    vars:
      - name: output
        type: shell
        params:
          cmd: "echo '{{val}}' | base64 | tr -d '\n'"

Now, no matter where I am in Burp, command line, or wherever, I can type :b64(text) and get my replaced version back like dGV4dAo=.

Other Uses

Espanso can be used for a ton of things. Common usage for me includes:

  • Email subjects
  • Email contents
  • Notes templates for tests
  • Contact information
  • Long shell commands
  • Injection strings
  • And more…

In fact, there is a dedicated web site to share uses, such as my new favorite, :dadjoke. Nick Aliferopoulos has even shared a collection of pentest commands & strings.

Summary

Espanso has a lot of features not covered here, such as full word replacements (fix your typos automatically in any app!). A handy one for me, because I always mistype it, is:

  - trigger: namp
    replace: nmap
    word: true

So, now I can use the nmap scanner and not the namp one that doesn’t exist. Note the word: true element ensures that it’s the full word “namp” and not, say, when I’m writing to NAMPA about some curious mold I found in the fridge.

Using global variables can also aid in building complex workflows—there is a ton of functionality built into this simple-seeming program.

Diving further into these features, you can customize and automate to your heart’s content and save yourself a lot of time. If you add a lot of replacements, you can even split them up into different YAML files for easier management.

Happy :replacements!



Ready to learn more?

Level up your skills with affordable classes from Antisyphon!

Pay-What-You-Can Training

Available live/virtual and on-demand