CiscoCXSecurity / linikatz

linikatz is a tool to attack AD on UNIX
BSD 3-Clause "New" or "Revised" License
527 stars 79 forks source link

Flag useable kernel keyrings #19

Open timb-machine opened 3 years ago

timb-machine commented 3 years ago

Need to dig into this to see what we can do from a shell script perspective. We'll continue to track the wider re-engineering under #6.

X-C3LL commented 3 years ago

Hi!

In the original paper a .sh is provided ("Heracles.sh"). This .sh is called from each user session using GDB:

sudo gdb -p <shell_pid> -batch -ex 'call system("./heracles.sh")

In reality, gdb is just using ptrace under the hood to attach to the process and do the magic. I don't know if there is a way to do it with pure bash... but as alternative you can build a one liner in perl and use the syscall function to call ptrace and add your call to system("/tmp/your-script-that-uses-keyctl) in any process. I guess python + ctypes would do the job too.

It is not pure bash... but is the closest thing you can do I guess.

I just noticed this exists in perl => https://metacpan.org/pod/Sys::Ptrace (but I am not sure if it is installed by default)