Archive for July, 2007

Setting up a SSH tunnel
July 22, 2007Hi again!
If we need a through our LAN to use, for example, a protocol which it’s locked by a BOFH
or send some personal data through a insecure protocol, we would use a SSH Tunnel using a SSH client like PuTTy (On win32) or openSSH (*NIX systems).
Ok, We’re in a LAN which 80 port it’s closed and that really sucks!. We’ve the IP of a server without restriction over the 80 port. Then, we’re going to do a tunnel with this server and send the 80 port data encrypted through the SSH port (I suppose this port is open! [Default port 22]).
We must open PuTTy and go to this screen

After this, we must connect to the server

When we’re connected to the server, we must login in and the tunnel has been stablished
Ok, now we need to say to the internet browser that it needs to connect through the Tunnel, to this, open your favourite browser (Firefox 4ever ;’) ) and open the connection settings. A window like this will be opened.

If you’ve made all the steps, your SSH Tunnel are running now
.

Recovering Unix files in Windows
July 14, 2007If we’ve a hard drive with some windows and Linux partitions, and we’re running on Windows OS, perhaps we want accede to one Linux partition to recover some data. Don’t worry, that it’s very easy.
Depending on the type of partition we’ve, we must use one of this programs.
Obvious, the last supports all usual Linux partitions. To use this, you can manage it from
a command terminal, but if you hate that, you could use a GUI, based on Java or .NET. Just install one and follow the user manual.
Also you could manage it from your web browse, probably, the quick and effective form.

Linux file permissions
July 11, 2007To show the file permissions type:
ls --color -l
This, shows something like this
-rw-r–r– 1 root root 817 2006-06-05 13:20 script
-rw-r–r– 1 peter usuarios 143360 2007-07-11 23:29 typescript
The “-rw-r–r–” line part, shows the file permissions to the OWNER, GROUP and OTHERS. In this example, the OWNER can “read” and “write”, the GROUP can “read”, and OTHERS can “read”. If the first character it’s a”d”, this means, that it’s a directory.
To change permissions, we use “chmod” command. The chmod sintaxis it’s, “chmod [number]“, the number represents the permissions we want to apply. To obtain this, we can use google
or this calculator http://wsabstract.com/script/script2/chmodcal.shtml
Maybe you can use this simple table:
| Value | Permission |
| 0 | — |
| 1 | –x |
| 2 | -w- |
| 3 | -wx |
| 4 | r– |
| 5 | r-x |
| 6 | rw- |
| 7 | rwx |
For example, if we apply a file the command “chmod 777″, that means, ALL users, can READ, WRITE and EXECUTE the file. If we apply “chmod 600″, Only the OWNER can READ and WRITE, the rest of users cannot use the file.

Links: Find all the files extension
July 11, 2007
Shell Script – Restart Process if not found running
July 7, 2007A script to Check if process is running and if not running
then start the process.
You can run this as a cron job in a 5/10 mins interval :
cat chk_if_process_running.sh
_______________________
#!/bin/bash
# check daemon
ps -ef | grep -v grep | grep daemon
# if not found - equals to 1, start it
if [ $? -eq 1 ]
then
/sbin/init.d/daemon start
else
echo "eq 0 - daemon found - do nothing"
fi
________________________
Copy & paste from Unix desk (Linux blog)

Links: Firewall.cx a great networking webpage
July 7, 2007
Compressing/Decompressing files in Linux
July 7, 2007The first thing that we must know, it’s to Compress/Decompress we need some applications, like “unzip” or “unrar”. All of them can be installed using “apt-get” or downloading it from their respective project pages. To find them, can use google
.
But, to compress/decompress we’ll use some commands. I did this table with any (the most important, i think) u/d commands.
|
.tar.gz (Tar + Gzip) |
|
| Pack and compress | tar czvf file.tar.gz /folder1/subfolder/* |
| Unpack and decompress | tar xzvf file.tar.gz |
| To view data | tar tzvf file.tar.gz |
|
.tar (Tar) |
|
| Pack and compress | tar cvf file.tar / folder1/ subfolder /* |
| Unpack and decompress | tar xvf file.tar |
| To view data | ttar tvf file.tar |
|
.bz2 (Bzip2) |
|
| Compress | bzip2 file |
| Decompress | bzip2 -d file.bz2 |
|
.zip (Zip) |
|
| Compress | zip file.zip /folder1/subfolder |
| Decompress | unzip file.zip |
| To view data | unzip -v file.zip |
|
.rar (Rar) |
|
| Compress | rar -a file.rar /folder1/subfolder |
| Decompress | rar -x file.rar |
| To view data | rar -v file.rar |

Interesting hacking videos
July 7, 2007I founded this webpage yesterday, have some videos about tricks of networking, OS, etc
http://www.irongeek.com/i.php?page=security/hackingillustrated

How To: Compile Kernel
July 5, 2007Hey!. Sometimes, we need to compile our Kernel to update drivers or other somethings. Some people thinks that it is a hard task, but not!. It’s simply. In a few steps we can compile our own Kernel in any Linux distribution.
1) We must have installed the following packages:
- kernel-package
- libncurses5-dev
- fakeroot
- wget
- bzip2
- build-essential
If not, try to use apt-get [package name] after a apt-get update
2) Move to /usr/src/ path. To do this, use cd /usr/src
3) Get the Kernel. To this, open your browser and go to http://www.kernel.org and download the latest, or you needed.
You can use “wget” to this. For example if we want to use the 2-6-25 Kernel, we type this in the console wget http://www.eu.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.5.tar.gz
4) When the kernel have been downloaded. Unpack the ‘tar.gz’, using tar xvf [tar.gz package name]
5) Make a simbolic link to the original folder which contains the (Just unpacked) Kernel. Type ln -s [Kernel folder name] linux.
Why we do this? The folder we created with “ln -s” it’s a simply link to the original folder. This folder it’s only to facilitate the work.
6) Move to the symnolic link folder “linux”. Just type cd linux
7) Make sure you’re in /usr/src/linux folder, and now type make clean && make mrproper
8 ) Now, type make menuconfig NOTE: There’s other kinds of compile, but i ever use this. It’s the most easy and secure, i think.
A screen like that will be loaded

In this, you must select the things you need to run your system and the modules you want.
Before this, you must save a configuration file with the settings you’ve selected.
9) Then, you must type the following:
make all
make modules_install
make install
10) We’ve installed out Kernel, but now we should say the system where’s the new Kernel.
To this, type:
depmod [number of kernel] Example -> depmod 2.6.21.5
apt-get install yaird
mkinitrd.yaird -o /boot/initrd.img-[Number of kernel] [Number of kernel]
update-grub
After all, we’ve compiled our own Kernel
. To load it, just reboot the computer.
Sources : HowToForge , Frikis.org

