1

Okay, I was stupid. I ran a bash script I got off of some forum on the internet, github I think it was, that said a cool matrix would appear in the terminal, which did happen, but it also messed up my keyboard.

In order to write just this help message, I have had to copy-paste every m,w,., and d, or else they look like this: ñ,ü,ç, and ɗ

Is there some way to undo this? I know this looks hilarious, but it really sucks to type.

I was wondering if someone that knew bash scripting could help me reverse the damage these are the problems I have in terminal.

This happens when I try to modify the script:

E325: ATTENTION
Found a swap file by the name ".bash matrix.swp"
          owned by: chris   dated: Thu Jan  8 00:35:25 2015
         file name: ~chris/Documents/pr0grams/bash matrix
          modified: YES
         user name: chris   host name: ubuntu
        process ID: 16416
While opening file "bash matrix"
             dated: Sun Dec  7 23:35:13 2014

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r bash matrix"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".bash matrix.swp"
    to avoid this message.

Swap file ".bash matrix.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

And this is the script itself:

#!/bin/bash
blue="\033[0;34m"
brightblue="\033[1;34m"
cyan="\033[0;36m"
brightcyan="\033[1;36m"
green="\033[0;32m"
brightgreen="\033[1;32m"
red="\033[0;31m"
brightred="\033[1;31m"
white="\033[1;37m"
black="\033[0;30m"
grey="\033[0;37m"
darkgrey="\033[1;30m"
colors=($green $brightgreen)
spacing=${1:-100}
scroll=${2:-0}
screenlines=$(expr `tput lines` - 1 + $scroll)
screencols=$(expr `tput cols` / 2 - 1)
chars=(ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ン)
count=${#chars[@]}
colorcount=${#colors[@]}
trap "tput sgr0; clear; exit" SIGTERM SIGINT && setxkbmap gh fula
if [[ $1 =~ '-h' ]]; then
    echo "Usage:        matrix [SPACING [SCROLL]]"
    exit 0
fi
clear
tput cup 0 0
while :
    do for i in $(eval echo {1..$screenlines})
        do for i in $(eval echo {1..$screencols})
            do rand=$(($RANDOM%$spacing))
                case $rand in
                    0)
                        printf "${colors[$RANDOM%$colorcount]}${chars[$RANDOM%$count]} "
                        ;;
                    1)
                        printf "  "
                        ;;
                    *)
                        printf "\033[2C"
                        ;;
                esac
            done
            printf "\n"
        done
        tput cup 0 0
    done

It then asked to create an encryption key, and I remember it.

Please help, I know I was an idiot and should have tested it in a virtual environment first.

EDIT that formatted terribly, I found the forum I got it from: https://github.com/MKorostoff/bash-sandbox/blob/master/matrix.sh

2
  • I'm not sure I like the encryption key bit, but can't currently see the original script - my work environment bans it!! the .swp file is just a vi temporary file, you can delete it. Jan 8, 2015 at 10:17
  • Having accessed the original by circumventing the work filters, I see the original does not contain that setxkb command - do you know where that came from? Neither does it contain any sinister reference to encryption. I wonder who/what corrupted your copy of it? You probably ought to run chkrootkit NOW (ignoring Suckit which always comes up) Jan 8, 2015 at 10:41

2 Answers 2

1

The setxkbmap command is your problem - try setxkbmap gb (or us, or whatever..) to reset; you're currently in whatever gh fula represents!

2
  • 1
    Also the call to setxkbmap gh fula is not part of the original script, at least not the one that was linked. Searching with google for the altered line brought a few results (for example: archive.rebeccablacktech.com/g/thread/41449414) that have been altered to be more fun™. The version on github looks to be fine.
    – Adaephon
    Jan 8, 2015 at 12:04
  • Yeah, I mentioned that in a comment to the OP, but I didn't like the encryption key bit & wonder if it may have been in some way subverted - if there are versions out there with keyboard mappings then that's perhaps reassuring - but not entirely! Given that there's a vi swap file in existence, the file isn't necessarily in it's original state! Jan 8, 2015 at 12:24
0

I changed the setxbmap gh fula to setxbmap us and that fixed my keyboard. Yeah it seems that I got a modified version rather than the github one. The encryption nonsense first happened when I tried to modify the characters from the Japanese symbols to English letters, and numbers but after I deleted the .swp file I never saw that nonsense again(maybe I messed up with the chmod +??? command?). I ran chkrootkit and the only one it found was the suckit one, but that just seems to be a popular false positive. I also ran rkhunter, which found nothing. Thank you to all answers, which all helped. Also thank you to whoever reformatted my original post, it was a mess beforehand.

You must log in to answer this question.