For example, in sudo -l i discovery that I can run scp through sudo with Makulele user. I would like to know how to execute a bash command using scp. Example:

sudo -u makulele scp executeBASHcommandASmakulele 

Maybe using -S option or -p with suid flag as well... Does anyone have a way to do this?

migrated from security.stackexchange.com Feb 7 '17 at 12:27

This question came from our site for information security professionals.

  • You could use scp to copy a setuid binary and change the user, then you can execute the copied file to obtain the setuid privilege. – wireghoul Feb 7 '17 at 4:40
  • scp doesnt support execution of comands...linux.die.net/man/1/scp – jmingov Feb 7 '17 at 12:57
  • wireghoul catch it. – Guilhermek Feb 7 '17 at 22:53

scp doesn't execute commands. I'm not entirely sure why you think it should.

Perhaps you want to run executeBASHcommandASmakulele on the local system as the makulele user:

sudo -u makulele executeBASHcommandASmakulele

Or if it's a script/program in the current directory,

sudo -u makulele ./executeBASHcommandASmakulele

Or perhaps you want to run executeBASHcommandASmakulele on a remote system as the makulele user:

sudo -u makulele ssh remote_host executeBASHcommandASmakulele
  • in that case the only option I had was to execute commands by scp – Guilhermek Jul 29 '18 at 12:47
  • You can't execute commands through scp. If that's what you think you were doing, you weren't. – roaima Jul 29 '18 at 13:51
  • In hack.me had a challenge that you need to scape from a chroot jail and one level of this jail was the 'scp' as the only disponible command. Whatever, I'm not doing hack.me challenges anymore. Thanks a lot for the reply. – Guilhermek Aug 6 '18 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.