Skip to content

Shared library implementations that transform the containing process into a shell when loaded (useful for privilege escalation, argument injection, file overwrites, LD_PRELOAD, etc.). This fork fixes two issues. One where ssh-keygen will not load the library and another one when SUID needs to be preserved.

License

Notifications You must be signed in to change notification settings

jonasheschl/lib2shell-ssh-keygen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lib2shell

Author: Sean Pesce
Modified by Jonas Heschl

Why this fork?

This fork fixes two issues when attemtping code execution using lib2shell.

  1. ssh-keygen makes a rudimentary check when loading libraries using ssh-keygen -D. If the check fails (eg. ssh-keygen does not think the provided library is really a pkcs11 library) the library will never be loaded and thus the code never be executed.

  2. This fork preserves the effective user id when spawning a shell. This is mostly useful when ssh-keygen/openssl has SUID set.

Overview

Shared library implementations that transform the containing process into a shell on load (useful for privilege escalation, argument injection, file overwrites, etc.). A write-up of the original version found on Sean Pesces blog.

Usage

(Many examples on GTFOBins)

Examples for Unix operating systems:

ssh-keygen -D ./lib2shell.so
openssl req -engine ./lib2shell.so

Compiling

Unix:

cd unix

make

Windows

Note that this fork drops Windows support. Feel free to open a PR if you know your way around that operating system!

About

Shared library implementations that transform the containing process into a shell when loaded (useful for privilege escalation, argument injection, file overwrites, LD_PRELOAD, etc.). This fork fixes two issues. One where ssh-keygen will not load the library and another one when SUID needs to be preserved.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 82.5%
  • Makefile 17.5%