dimanche 27 juin 2010

Useful Bash login script

Managing multiple Oracle instances on multiple servers can become a hard task if you don't standardize and organize.
How great could it be if you could get informations about your server & database displayed directly when you connect using SSH?
Information such as...

  • The name of the server you are connected to 
  • The $ORACLE_SID variable 
  • The status of the database 


You want it, you have it!... Here is a small script that will test the status of your instance when you connect.
That is the code you have to use in your .bash_profile.


started=`sqlplus -s login/passwd @/home/oracle/test.sql | grep "ACTIVE"`
stop=`sqlplus -s login/passwd @/home/oracle/test.sql | grep "ERROR"`



echo -e ""
echo -e "---------------------------------"
echo -en "Welcome to "
echo  $HOSTNAME
echo -e "---------------------------------"
echo -e "Database informations:"
echo -n " -  SID: "
echo   $ORACLE_SID
echo -n " -  Status: "
if test -n "$started"
        then
                echo "Started"
elif test -n "$stop"
        then
                echo "Stopped"
else
                echo "Unknown"
fi



Next, just create a file named test.sql file in the home folder of the user.
The file will contain this query:

SELECT STATUS, 
       DATABASE_STATUS 
FROM   V$INSTANCE;
EXIT

And you're done! Just in time for the coffee.

lundi 21 juin 2010

Oracle listener statistics

When you want to look for some random hacks, the first tool that comes to you mind would obviously be Nmap.
It's a very powerful tool for scanning a remote host for open ports.

I recently found an article about Nmap statistics when looking for open TNS Listeners.
Here is an extract of the article:
For experiment, I and my friends ran nmap with -iR 0 -p1521 options, meaning checking for open port 1521 on randomly generated IP addresses, infinitely.
Result: one working Oracle TNS Listener among nearly 69,000 random IP addresses.


Here is the detail of the experiment:

Top 3 operational systems:

  1. 52% - Windows
  2. 37% - Linux
  3.   6% - Solaris


Oracle TNS Listener versions:

55% - 10.2
23% - 9.2
7% - 11.1
5% - 8.1
4% - 10.1
2% - 8.0
2% - 9.0

So I decided to run the test myself, and tried the Nmap command previously shown.
After 4 hours of random IP scanning, here's my personal contribution to this analysis:

I found 6144 hosts with an Oracle TNS listener.
On the 6144 ports, 4266 were closed, 1780 were filtered and the 98 remaining were simply open.

dimanche 20 juin 2010

Downloading a Youtube video using only Safari 5

To download a Youtube video, there is a plethora of plugins, extensions, javascript...
But why do we need such softwares in order to simply download an internet ressource? In this article, I'll explain you how to achieve this with nothing more than your standard-issued web browser!

Go on the webpage of the video you want to download.

Display the Web Inspector. This option is located under the Developer menu, which must be activated in Safari's preference panel.

The Web Inspector gives you a detailed output of the webpage, along with the location of every element of the page.
Now it shouldn't be any problem finding an element named videoplayback.flv who weights a lot more than every other element on the page. This is the video you want to download.

A simple drag'n drop will give you the address of the resource to get.

The .flv file is readable with VLC, or can be easily converted to the format you prefer.