RSS

7. October 2009

0 Comments

Understanding and Preventing Fork Bombs

A fork bomb is just a bash function that gets called recursively. Once a fork bomb is active on a machine it may not be able to preform normally until a reboot is made, as the only solution to the fork bomb is to kill all its processes.

Bash Functions

A fork bomb is really just a bash function, below is an example of a bash function

helloworld() {
echo hello world
};

A fork bomb would be

:(){
 :|:&
};:

Now to explain.
:(){ - Creates the function
:|: - Next it call itself using recursion and pipes the output to another call of the function
& - Puts the function call in the background so child cannot die
}; - Terminate the function
: - Call (run) the function

If you would like a more human readable fork bomb it would be as follows

forkbomb(){
forkbomb | forkbomb &
}; forkbomb

Preventing Fork Bombs

We can prevent users from running fork bombs by limiting the amount of processes they are allowed to run.
We can achive this using /etc/security/limits.conf

To get started open /etc/security/limits.conf

nano /etc/security/limits.conf

In my example I want to limit the user john to 300 processes and any users in the group of students to 250 processes. For this I would put the following into my config file

john hard nproc 300
@students hard nproc 250

Please keep in mind that KDE and Gnome desktop system can lanuch many processes.

Continue reading...

25. September 2009

0 Comments

Installing freedesktop sound theme in debian

I Recently found the 'system sound' tab in gnome-sound-property grayed out my work around to this was to install the freedesktop sound theme.

Firstly remove gnome-audio
sudo apt-get remove --purge gnome-audio

Remove all your old users gconf data related to system sounds
sudo rm -rf /home/*/.gconf/desktop/gnome/sound

Install some needed packages
sudo apt-get install libcanberra-gtk-module libcanberra-gtk0 libcanberra0 gnome-session-canberra build-essential fakeroot dpkg-dev intltool [...]

Continue reading...

23. September 2009

0 Comments

Setting up passworded directories on lighttpd

Open your lighttpd.conf
nano /etc/lighttpd/lighttpd.conf

If mod_auth isn't already in your server.modules list add it e.g
server.modules = (
"mod_alias",
"mod_accesslog",
"mod_fastcgi",
"mod_auth",
"mod_cgi",
"mod_expire",
"mod_redirect"
}

Add the two following [...]

Continue reading...

30. August 2009

0 Comments

IPTables and Bashrc Aliases

We all know IPTables can be difficult. By adding the following lines to your ~/.bashrc you can simplify the tasks of blocking packets from a certian ip.
First your going to need to install IPTables:
Gentoo: emerge iptables   (Must be  Root to use/install iptables)
Ubuntu/Debian: sudo apt-get install iptables
Then edit your .bashrc file and add the following
alias blockedips="iptables [...]

Continue reading...

15. August 2009

0 Comments

Grabbing and Sending files and folders over SSH

SCP allows you to transfer files over ssh between computers
Copying to remote machines
To copy a file to a remote machine run the following
scp ~/file/to/be/transfered username@hostname:~/destinationfolder

If you want to copy a directory you would use -r which would look like this
scp -r /folder/to/be/transfered username@hostname:/path/to/destination

and if you want to specify a SSH port use -P which [...]

Continue reading...
Page 1 of 1212345»10...Last »