How Change senders email address in mutt

February 2nd, 2010 by manoj No comments »

i have created the .muttrc in roots home directory and gave the option

set from = “xyz@domain.com”

but still when i run mutt it gives me the senders address
as
root<xyz@domain.com>
now what???

To change the from email address while using mutt
create a .muttrc in the users home directory if it doesnot exist, then enter the feild
set realname=”username” this will change the name in the senders name .

Thanks
Manoj Chauhan

 

Proposed IT subnetting Infrastructure

January 24th, 2010 by manoj No comments »

Proposed IT subnetting Infrastructure 

  1. For External communication we will use Cisco Router(Cisco ASA5520 firewall)
  2. For internal communication we will use managed switch Dell Power Connect 6248

Why use a Managed Switch?

  • Limit broadcast traffic and increase security using VLANs
  • Remove traffic bottlenecks using port trunking
  • Guarantee bandwidth for time-sensitive voice and video traffic using Traffic Prioritisation
  • We will manage switch for internal communication. I mean to say when one server (Test5) wants to talk to another server (Test) at that time it will use manager switch for the internal communication. It will not forward the traffic to the router.

Switching Services

Unlike bridges that use software to create and manage a filter table, switches use application specific integrated circuits (ASICs) to build and maintain their filter tables. But it’s still okay to think of a layer 2 switch as a multiport bridge because their basic reason for being is the same: to break up collision domains.

Layer 2 switches are faster than routers because they don’t take up time looking at the Network layer header information. Instead, they look at the frame’s hardware addresses before deciding to either forward the frame or drop it. 

Switches create private dedicated collision domains and provide independent bandwidth on each port, unlike hubs. Figure 1.1 shows five hosts connected to a switch—all running 10Mbps half duplex to the server. Unlike a hub, each host has 10Mbps dedicated communication to the server.

nnetwork
FIGURE 1.1 Switches create private domains.

Three Switch Functions at Layer 2 

  1.  
    1. Address learning
    2. Forward/filter decisions
    3. Loop avoidance 

Here’s a list of the basic tasks we’ll be done in the switch Dell Power Connect 6248 

  1. Setting the passwords
  2. Setting the hostname
  3. To configure the switch with different VLANs and other network functions

            Add VLAN and Description

            Configuring the IP address and subnet mask & gateway address

            Assigning switch ports to VLANs.

            Routing between VLANs

  1. Hosts in a VLAN live in their own broadcast domain and can communicate freely. VLANs create network partitioning and traffic separation at layer 2 of the OSI, and as I said when I told you why we still need routers, if you want hosts or any other IP-addressable device to communicate between VLANs, a layer 3 device is absolutely necessary.

What we see in Figure 1.2 is that each router interface is plugged into an access link. This means that each of the routers’ interface IP addresses would then become the default gateway address for each host in each VLAN.

FIGURE 1.2 Router with individual VLAN associations

nnetwork

  1. Router connecting three VLANs together for inter-VLAN communication, one interface for each VLAN.
  2. Remember that a created VLAN is unused until it is assigned to a switch port or ports, and that all ports are always assigned in VLAN 1 unless set otherwise. 

Configuring Inter-VLAN
nnetwork
The first thing we need to do here is figure out which subnets are being used. By looking at the router configuration in the figure, you can see that we’re using 192.168.1.0 with DMZ, 192.168.1.32 with Corporate and 192.168.1.64 with Production. And by looking at the switch configuration, you can see that ports 1,2 and 3 etc are in DMZ, and port 4,5 and 6 etc is in Corporate and port 7 and 8 etc is in Production. This means that Hosts on DMZ are in VLAN 1, hosts in Corporate are in VLAN 2 and hosts on Production are in VLAN 3. Here’s what the hosts’ IP addresses should be: 

DMZ: 192.168.1.0, 255.255.255.224, default gateway 192.168.1.30
Corporate: 192.168.1.32, 255.255.255.224, default gateway 192.168.1.62
Production: 192.168.1.64, 255.255.255.224, default gateway 192.168.1.94 

Inter-VLAN example
nnetwork
Complete Working Flow Diagram

 

nnetwork

Thanks
Manoj Chauhan

SSL Configuration in Apache

January 24th, 2010 by manoj No comments »

Secure Sockets Layer (SSL) enables the HTTP protocol to be secured. This page will show you how to configure SSL in Apache and SquirrelMail.

Generate a Private Key

Make sure you are logged in as the root user when doing steps below.

1. Generate a pass phrase protected private key using the command below. Provide a pass phrase when asked.
2. #openssl genrsa -des3 -out localhost.key 1024
3. Remove the pass phrase protection using the command below. Provide the pass phrase when asked.
4. #openssl rsa -in localhost.key -out localhost.key
5. Type in the command below to ensure that the private key will be readable by the root user only.
6.#chmod 400 localhost.key

Generate a Certificate

Generate a certificate signing request by typing in the command below and filling in your host information.

#openssl req -new -key localhost.key -out localhost.csr

To self sign your certificate request, type in the command below.
#openssl x509 -req -days 365 -in localhost.csr -signkey localhost.key -out localhost.crt

Configuring Apache for SSL

Move the file localhost.key into /etc/pki/tls/private/

Place the certificate file into /etc/pki/tls/certs/ and name the file as localhost.crt. The command below applies to self-signed certificate only.

mv localhost.crt /etc/pki/tls/certs/

Edit the file /etc/httpd/conf.d/ssl.conf and edit the lines below.

DocumentRoot = /usr/share/squirrelmail
ServerName = mail.acme.local:443

Restart web server

Thanks
Manoj Chauhan

SQL Injection Attacks

January 24th, 2010 by manoj No comments »

In this article I’ll attempt to shed some light on this under-documented attack, explaining what an SQL injection attack is and how you can prevent one from occurring within your company. By the end of this article you’ll be able to identify situations where an SQL injection attack may allow unauthorized persons to penetrate your system, and you’ll learn ways to fix existing code to prevent an SQL injection attack.

 

 

What is an SQL Injection Attack?

As you may know, SQL stands for Structured Query Language. It comes in many different dialects, most of which are based on the SQL-92 ANSI standard. An SQL query comprises one or more SQL commands, such as SELECT, UPDATE or INSERT. For SELECT queries, each query typically has a clause by which it returns data, for example:

 

SELECT * FROM Users WHERE userName = ‘justin’;

 

The clause in the SQL query above is WHERE username = ‘justin’, meaning that we only want the rows from the Users table returned where the userName field is equal to the string value of Justin.

 

It’s these types of queries that make the SQL language so popular and flexible… it’s also what makes it open to SQL injection attacks. As the name suggests, an SQL injection attack “injects” or manipulates SQL code. By adding unexpected SQL to a query, it is possible to manipulate a database in many unanticipated ways.

 

 

One of the most popular ways to validate a user on a Website is to provide them with an HTML form through which they can enter their username and password. Let’s assume that we have the following simple HTML form:

 

<form action=”login.asp” method=”post”>

Username: <input>

Password: <input>

<input>

</form>

 

When the form is submitted, the contents of the username and password fields are passed to the login.asp script, and are available to that script through the Request.Form collection. The easiest way to validate this user would be to build an SQL query, and then check that query against the database to see whether that user exists. We could create a login.asp script like this:

 

 

<%

 

dim userName, password, query

dim conn, rS

 

userName = Request.Form(”userName”)

password = Request.Form(”password”)

 

set conn = server.createObject(”ADODB.Connection”)

set rs = server.createObject(”ADODB.Recordset”)

 

query = “select count(*) from users where userName=’” & 

userName & “‘ and userPass=’” & password & “‘”

 

conn.Open “Provider=SQLOLEDB; Data Source=(local); 

Initial Catalog=myDB; User; Password=”

rs.activeConnection = conn

rs.open query

 

if not rs.eof then

response.write “Logged In”

else

response.write “Bad Credentials”

end if

 

%>

 

In the example above, the user either sees “Logged In” if their credentials matched a record in the database, or “Bad Credentials” if they didn’t. Before we continue, let’s create the database that we have queried in the sample code.

 

 

Let’s also create a users table with some dummy records:

 

create database myDB

go

 

use myDB

go

 

create table users

(

userId int identity(1,1) not null,

userName varchar(50) not null,

userPass varchar(20) not null

)

 

insert into users(userName, userPass) values(’john’, ‘doe’)

insert into users(userName, userPass) values(’admin’, ‘wwz04ff’)

insert into users(userName, userPass) values(’fsmith’, ‘mypassword’)

 

So if I entered a username of john and password of doe, then I would be presented with the text “Logged In”. The query would look something like this:

 

 

select count(*) from users where userName=’john’ and userPass=’doe’

 

There’s nothing insecure or dangerous about this query… is there? Maybe not at first glance, but what about if I entered a username of john and a password of ‘ or 1=1 –

 

The resultant query would now look like this:

 

select count(*) from users where userName=’john’ and userPass=” 

or 1=1 –’

 

In the example above I’ve italicised the username and password so they are a bit easier to read, but basically what happens is that the query now only checks for any user with a username field of john. Instead of checking for a matching password, it now checks for an empty password, or the conditional equation of 1=1. This means that if the password field is empty OR 1 equals 1 (which it does), then a valid row has been found in the users table. Notice how the last quote is commented out with a single-line comment delimiter (–). This stops ASP from returning an error about any unclosed quotations.

 

So with the login.asp script we created above, one row would be returned, and the text “Logged In” would be displayed. We could take this a bit further by doing the same thing to the username field, like this:

 

Username: ‘ or 1=1 —

Password: [Empty]

 

This would execute the following query against the users table:

 

select count(*) from users where userName=” or 1=1 –’ and userPass=”

 

The query above now returns a count of all rows in the user table. This is the perfect example of an SQL injection attack: adding code that manipulates the contents of a query to perform an undesired result.

 

Another popular way to validate a user against a table of logins is to compare their details against the table, and retrieve the valid username from the database, like this:

 

query = “select userName from users where userName=’” & 

userName & “‘ and userPass=’” & password & “‘”

 

conn.Open “Provider=SQLOLEDB; Data Source=(local); 

Initial Catalog=myDB; User; Password=”

rs.activeConnection = conn

rs.open query

 

if not rs.eof then

response.write “Logged In As ” & rs.fields(0).value

else

response.write “Bad Credentials”

end if

 

So, if we entered a username of john and a password of doe, then we would be presented with:

 

Logged In As john

 

However, if we used the following login credentials:

 

Username: ‘ or 1=1 —

Password: [Anything]

 

Then we would also be logged in as John, because the row whose username field is John comes first in the list, based on the insert queries we saw earlier:

 

insert into users(userName, userPass) values(’john’, ‘doe’)

insert into users(userName, userPass) values(’admin’, ‘wwz04ff’)

insert into users(userName, userPass) values(’fsmith’, ‘mypassword’)

 

 

Injection Attack Examples

Forcing a login through a HTML form like the one we just saw on is a typical example of an SQL injection attack, and we’ll look at ways to fix these types of attacks a little later.

 

But first, I want to take a look at some examples of SQL injection attack executions. First of, let’s stick with our example login form, which contains a username and password field.

 

Example #1

 

Microsoft SQL Server has its own dialect of SQL, which is called Transact SQL, or TSQL for short. We can exploit the power of TSQL in a number of ways to show how SQL injection attacks work. Consider the following query, which is based on the users table we created on the last page:

 

select userName from users where userName=” having 1=1

 

If you’re an SQL buff, then you’ll no doubt be aware that this query raises an error. We can easily make our login.asp page query our database with this query by using these login credentials:

 

 

Username: ‘ having 1=1 —

 

Password: [Anything]

 

When I click on the submit button to start the login process, the SQL query causes ASP to spit the following error to the browser:

 

Microsoft OLE DB Provider for SQL Server (0×80040E14)

 

Column ‘users.userName’ is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.

 

/login.asp, line 16

 

Well well. It appears that this error message now tells the unauthorized user the name of one field from the database that we were trying to validate the login credentials against: users.userName. Using the name of this field, we can now use SQL Server’s LIKE keyword to login with the following credentials:

 

Username: ‘ or users.userName like ‘a%’ —

Password: [Anything]

 

Once again, this performs an injected SQL query against our users table:

 

select userName from users where userName=” or 

users.userName like ‘a%’ –’ and userPass=”

 

When we created the users table, we also created a user whose userName field was admin and userPass field was wwz04ff. Logging in with the username and password shown above uses SQL’s like keyword to get the username. The query grabs the userName field of the first row whose userName field starts with a, which in this case is admin:

 

Logged In As admin

 

Example #2

 

SQL Server, among other databases, delimits queries with a semi-colon. The use of a semi-colon allows multiple queries to be submitted as one batch and executed sequentially, for example:

 

select 1; select 1+2; select 1+3;

 

…would return three recordsets. The first would contain the value 1, the second the value 3, and the third the value 4, etc. So, if we logged in with the following credentials:

 

Username: ‘ or 1=1; drop table users; –

Password: [Anything]

 

Then the query would execute in two parts. Firstly, it would select the userName field for all rows in the users table. Secondly, it would delete the users table, so that when we went to login next time, we would see the following error:

 

Microsoft OLE DB Provider for SQL Server (0×80040E37)

Invalid object name ‘users’.

/login.asp, line 16

 

Example #3

 

The last example relating to our login form that we’ll consider is the execution of TSQL specific commands and extended stored procedures. Many Websites use the default system account (sa) user when logging into SQL Server from their ASP scripts or applications. By default, this user has access to all commands and can delete, rename, and add databases, tables, triggers, and more.

 

One of SQL Server’s most powerful commands is SHUTDOWN WITH NOWAIT, which causes SQL Server to shutdown, immediately stopping the Windows service. To restart SQL server after this command is issued, you need to use the SQL service manager or some other method of restarting SQL server.

 

Once again, this command can be exploited through our login example:

 

Username: ‘; shutdown with nowait; –

Password: [Anything]

 

This would make our login.asp script run the following query:

 

select userName from users where userName=”; 

shutdown with nowait; –’ and userPass=”

 

If the user is set up as the default sa account, or the user has the required privileges, then SQL server will shut down, and will require a restart before it will function again.

 

SQL Server also includes several extended stored procedures, which are basically special C++ DLL’s that can contain powerful C/C++ code to manipulate the server, read directories and the registries, delete files, run the command prompt, etc. All extended stored procedures exist under the master database and are prefixed with “xp_”.

 

There are several extended stored procedures that can cause permanent damage to a system. We can execute an extended stored procedure using our login form with an injected command as the username, like this:

 

Username: ‘; exec master..xp_xxx; –

Password: [Anything]

 

All we have to do is pick the appropriate extended stored procedure and replace xp_xxx with its name in the sample above. For example, if IIS was installed on the same machine as SQL Server (which is typical for small one/two man setups), then we could restart it by using the xp_cmdshell extended stored procedure (which executes a command string as an operating-system command) and IIS reset. All we need to do is enter the following user credentials into our getlogin.asp page:

 

Username: ‘; exec master..xp_cmdshell ‘iisreset’; –

Password: [Anything]

 

This would send the following query to SQL Server:

 

select userName from users where userName=”; 

exec master..xp_cmdshell ‘iisreset’; –’ and userPass=”

 

As I’m sure you’ll agree, this can cause serious problems, and with the right commands, can cause an entire Website to malfunction.

 

Example #4

 

OK, time to move away from looking at the login.asp script and onto another common method to perform an SQL injection attack.

 

How many times have you been to a Website that sells you favourite gear and seen a URL like this:

 

 

www.mysite.com/products.asp?productId=2

 

Obviously the 2 is the ID of the product, and a lot of sites would simply build a query around the productId querystring variable, like this:

 

Select prodName from products where id = 2

 

Before we continue, let’s assume that we have the following table and rows setup on our SQL server:

 

create table products

(

id int identity(1,1) not null,

prodName varchar(50) not null,

)

 

insert into products(prodName) values(’Pink Hoola Hoop’)

insert into products(prodName) values(’Green Soccer Ball’)

insert into products(prodName) values(’Orange Rocking Chair’)

 

Let’s also assume that we have created the following ASP script, and called it products.asp:

 

<%

 

dim prodId

prodId = Request.QueryString(”productId”)

 

set conn = server.createObject(”ADODB.Connection”)

set rs = server.createObject(”ADODB.Recordset”)

 

query = “select prodName from products where id = ” & prodId

 

conn.Open “Provider=SQLOLEDB; Data Source=(local); 

Initial Catalog=myDB; User; Password=”

rs.activeConnection = conn

rs.open query

 

if not rs.eof then

response.write “Got product ” & rs.fields(”prodName”).value

else

response.write “No product found”

end if
%>

So if we visited products.asp in the browser with the following URL: 
http://localhost/products.asp?productId=1

…we’d see the following line of text in our browser:

Got product Pink Hoola Hoop
Notice that this time around, product.asp returns a field from the recordset based on the field’s name: 

response.write “Got product ” & rs.fields(”prodName”).value  

Although this may seem more secure, it really isn’t, and we can still manipulate the database just as we have in our last three examples. Notice also that this time the WHERE clause of the query is based on a numerical value: 

query = “select prodName from products where id = ” & prodId 

In order for the products.asp page to function correctly, all that’s required is a numerical product Id passed as the productId querystring variable. Getting around this isn’t too much of a problem, however. Consider the following URL to products.asp:http://localhost/products.asp?productId=0%20or%201=1  

Each %20 in the URL represents a URL-encoded space character, so the URL really looks like this: 

http://localhost/products.asp?productId=0 or 1=1
When used in conjunction with products.asp, the query looks like this: 

select prodName from products where id = 0 or 1=1 

Using a bit of know-how and some URL-encoding, we can just as easily pull the name of the products field from the products table: http://localhost/products.asp?productId=0%20having%201=1 

This would produce the following error in the browser:

Microsoft OLE DB Provider for SQL Server (0×80040E14)

Column ‘products.prodName’ is invalid in the select list because it is not contained in an aggregate 
function and there is no GROUP BY clause.
/products.asp, line 13

Now, we can take the name of the products field (products.prodName) and call up the following URL in the browser:

http://localhost/products.asp?productId=0;insert%20into%20products
(prodName)%20values(left(@@version,50))
Here’s the query without the URL-encoded spaces:

http://localhost/products.asp?productId=0;insert into 

products(prodName) values(left(@@version,50)) 

Basically it returns “No product found”, however it also runs an INSERT query on the products table, adding the first 50 characters of SQL server’s @@version variable (which contains the details of SQL Server’s version, build, etc.) as a new record in the products table. 

In a real-life situation, you would obviously have to exploit the products table more than this as it would contain dozens of other fields, however the methods would remain the same. 

To get to the version, it’s now a simple matter of calling up the products.asp page with the value of the latest entry in the products table, like this:

 http://localhost/products.asp?productId=(select%20max(id)

%20from%20products) 

What this query does is grab the ID of the latest row added to the products table using SQL server’s MAX function. The result outputs the new row that contains the SQL server version details: 

Got product Microsoft SQL Server 2000 – 8.00.534 (Intel X86)

This method of injection can be used to perform numerous tasks. However the point of this article was to give tips on how to prevent SQL injection attacks, which is what we will look at next. 

Preventing SQL Injection Attacks

If you design your scripts and applications with care, SQL injection attacks can be avoided most of the time. There are a number of things that we as developers can do to reduce our site’s susceptibility to attack. Here’s a list (in no particular order) of our options: 

Limit User Access 

 The default system account (sa) for SQL server 2000 should never be used because of its unrestricted nature. You should always setup specific accounts for specific purposes. 

For example, if you run a database that lets users of your site view and order products, then you should set up a user called webUser_public that has SELECT rights on the products table, and INSERT rights only on the orders table.

 If you don’t make use of extended stored procedures, or have unused triggers, stored procedures, user-defined functions, etc, then remove them, or move them to an isolated server. Most extremely damaging SQL injection attacks attempt to make use of several extended stored procedures such as xp_cmdshell and xp_grantlogin, so by removing them, you’re theoretically blocking the attack before it can occur. 

Escape Quotes

 As we’ve seen from the examples discussed above, the majority of injection attacks require the user of single quotes to terminate an expression. By using a simple replace function and converting all single quotes to two single quotes, you’re greatly reducing the chance of an injection attack succeeding.

Using ASP, it’s a simple matter of creating a generic replace function that will handle the single quotes automatically, like this:
<%
function stripQuotes(strWords)
stripQuotes = replace(strWords, “‘”, “””)
end function
%>

Now if we use the stripQuotes function in conjunction with our first query for example, then it would go from this:

select count(*) from users where userName=’john’ and userPass=” or 1=1 –’ 

…to this
select count(*) from users where userName=’john” and 

userPass=”’ or 1=1 –’ 

This, in effect, stops the injection attack from taking place, because the clause for the WHERE query now requires both the userName and userPass fields to be valid.

Remove Culprit Characters/Character Sequences

 As we’ve seen in this article, certain characters and character sequences such as ;, –, select, insert and xp_ can be used to perform an SQL injection attack. By removing these characters and character sequences from user input before we build a query, we can help reduce the chance of an injection attack even further. As with the single quote solution, we just need a basic function to handle all of this for us:

<%
function killChars(strWords) 

dim badChars
dim newChars
badChars = array(”select”, “drop”, “;”, “–”, “insert”, 
“delete”, “xp_”)
newChars = strWords
for i = 0 to uBound(badChars)
newChars = replace(newChars, badChars(i), “”)
next
killChars = newChars
end function
%>

Using stripQuotes in combination with killChars greatly removes the chance of any SQL injection attack from succeeding. So if we had the query:

select prodName from products where; xp_cmdshell ‘format 

c: /q /yes ‘; drop database myDB; –

and ran it through stripQuotes and then killChars, it would end up looking like this:

prodName from products where cmdshell ”format c: 

/q /yes ” database myDB

…which is basically useless, and will return no records from the query.

Limit the Length of User Input

It’s no good having a text box on a form that can accept 50 characters if the field you’ll compare it against can only accept 10. By keeping all text boxes and form fields as short as possible, you’re taking away the number of characters that can be used to formulate an SQL injection attack.

If you’re accepting a querystring value for a product ID or the like, always use a function to check if the value is actually numeric, such as the IsNumeric() function for ASP. If the value isn’t numeric, then either raise an error or redirect the user to another page where they can choose a product.

Also, always try to post your forms with the method attribute set to POST, so clued-up users don’t get any ideas — they might if they saw your form variables tacked onto the end of the URL.

Conclusion
In this article we’ve seen what an SQL injection attack is and also how to tamper with forms and URLs to product the results of an attack. 

It’s not always possible to guard against every type of SQL injection attack, however, hopefully you now know about the various types of SQL injection attacks that exist and have also planned ways to combat them on your servers.  Although we’ve only looked at SQL injection attacks with Microsoft SQL server in this article, keep in mind that no database is safe: SQL injection attacks can also occur on MySQL and Oracle database servers — among others. 

SQL Injection Attacks Linger

To experience Web developers, it’s a cardinal sin: passing user input into a database query without first processing it to escaped special characters is bad! But as a beginner-friendly language, PHP is host to this mistake more often than most. If you don’t understand SQL injection attacks, read this!

The danger is easy to explain. Your site’s security relies on a database query that includes one or more values taken from user input (e.g. login credentials). But, because you neglected to encode special characters in those values, an attacker is able to bypass your site’s security by entering carefully-chosen values that alter the meaning of the query.

PHP’s magic quotes feature is designed to save inexperienced coders from themselves. Values in the $_GET, $_POST, $_COOKIE, and $_REQUEST arrays have backslashes added to them so that they are safe for use in database queries. But magic quotes isn’t enabled on all servers, and not all user input comes through the $_GET, $_POST, $_COOKIE, and $_REQUEST arrays, which magic quotes protects.

Essential CSS Hacks

When performing cross-browser page layout with CSS, you have two choices: go with the lowest common denominator, or use CSS hacks to include work-arounds for ornery browsers. The hacks definitely give the best result, but who can remember them all?

When it all boils down, two browsers are responsible for the vast majority of CSS layout incompatibilities: Internet Explorer 5.x for Windows, and Internet Explorer 5.x for Macintosh. With the most recent CSS hacks out there, you can write remedial style sheets for both these browsers and get away with just two CSS hacks!

First of all, you need the Mid Pass Filter for Internet Explorer 5.x for Windows:

<style>
@media tty {
 i{content:”\”;/*” “*/}} @import ‘ie5.css’;
/*”;}
}/* */
</style>

Then, you need the IE5/Mac Band Pass Filter for Internet Explorer 5.x for Macintosh:

<style>
/*\*//*/  @import “ie5mac.css”;/**/
</style>

By taking advantage of various bugs in the CSS processing of these browsers, the above blocks of code ensure that the rules in ie5.css will only affect Internet Explorer 5.x for Windows, and the rules in ie5mac.css will only affect Internet Explorer 5.x for Macintosh. 

By using these two style sheets to work around the browser-specific bugs, you can keep the nice, standards-compliant CSS code destined for other browsers in your main style sheet.

PERL-DATETIME-FORMAT-ICAL RPM PACKAGES

January 24th, 2010 by manoj No comments »

http://dag.wieers.com/rpm/packages/perl-DateTime-Format-ICal/perl-DateTime-Format-ICal-0.08-1.el5.rf.noarch.rpm

rpm -ivh perl-DateTime-Format-Epoch-0.10-1.n0i.2.noarch.rpm –nodeps

yum install perl-DateTime*

Setup NIS Server

January 24th, 2010 by manoj No comments »

NIS Server

Build NIS Server in order to share users’ accounts among virtual networks. Following examples show that NIS Server is built on HostOS in virtual networks like NFS Server. It’s necessary to install ypserv for NIS.
First we need to install the ypserv package, we can install it by using the following command

#yum -y install ypserv
// set domain name
#ypdomainname example.com
// add at the bottom of file
#vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=ns.server-linux.info
GATEWAY=192.168.0.1
NISDOMAIN=example.com

#vi /var/yp/Makefile
# MERGE_PASSWD=true|false
MERGE_PASSWD=false// line 42: change
#
# MERGE_GROUP=true|false
MERGE_GROUP=false// line 46: change
#
all: passwd shadow group hosts rpc services netid protocols   // line 109: add shadow
// create a directory for email automatically when a user is added in the system

[root@ns ~]# mkdir -p /etc/skel/Maildir/cur
[root@ns ~]# mkdir -p /etc/skel/Maildir/new
[root@ns ~]# mkdir -p /etc/skel/Maildir/tmp
[root@ns ~]# chmod -R 700 /etc/skel/Maildir/
[root@ns ~]# useradd cent
[root@ns ~]# passwd cent
Changing password for user cent.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
 [root@ns ~]# /usr/lib/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS servers. ns.server-linux.info is in the list of NIS server hosts. Please continue to add the names for the other hosts, one per line. When you are done with the list, type a <control D>.
next host to add: ns.server-linux.info
next host to add: // push Ctrl + D keys
The current list of NIS servers looks like this:
ns.server-linux.info
Is this correct? [y/n: y] y// input ‘y’ and push Enter key
We need a few minutes to build the databases…
Building /var/yp/server-linux.info/ypservers…
Running /var/yp/Makefile…
gmake[1]: Entering directory `/var/yp/server-linux.info’

Updating passwd.byname…
Updating passwd.byuid…
Updating group.byname…
Updating group.bygid…
Updating hosts.byname…
Updating hosts.byaddr…
Updating rpc.byname…
Updating rpc.bynumber…
Updating services.byname…
Updating services.byservicename…
Updating netid.byname…
Updating protocols.bynumber…
Updating protocols.byname…
Updating mail.aliases…
gmake[1]: Leaving directory `/var/yp/server-linux.info’
ns.server-linux.info has been set up as a NIS master server.
Now you can run ypinit -s ns.server-linux.info on all slave server.
[root@ns ~]# /etc/rc.d/init.d/portmap start
Starting portmap: [  OK  ]
[root@ns ~]# /etc/rc.d/init.d/ypserv start
Starting YP server services: [  OK  ]
[root@ns ~]# /etc/rc.d/init.d/yppasswdd start
Starting YP passwd service: [  OK  ]

[root@ns ~]# chkconfig portmap on
[root@ns ~]# chkconfig ypserv on
[root@ns ~]# chkconfig yppasswdd on
// It’s neccessary to update NIS database with following way if new user is added again
[root@ns ~]# cd /var/yp
[root@ns yp]# make
After building NIS Server, Configure on clients in order to share users’ accounts. Following examples show config on GuestOS ‘www’.

[root@www ~]# vi /etc/sysconfig/network
 
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=www.server-linux.info
GATEWAY=192.168.0.1
NISDOMAIN=server-linux.info// add the line
 
[root@www ~]# vi /etc/sysconfig/authconfig
 
USEWINBINDAUTH=no
USEKERBEROS=no
USESYSNETAUTH=no
FORCESMARTCARD=no
USESMBAUTH=no
USESMARTCARD=no
USELDAPAUTH=no
USELOCAUTHORIZE=no
USEWINBIND=no
USESHADOW=yes
USEDB=no
USEMD5=yes
USEPASSWDQC=no
USELDAP=no
USEHESIOD=no
USECRACKLIB=yes
USENIS=yes// change
 
[root@www ~]# vi /etc/yp.conf
 
# Valid entries are
#
# domain NISDOMAIN server HOSTNAME
#Use server HOSTNAME for the domain NISDOMAIN.
#
# domain NISDOMAIN broadcast
#Use broadcast on the local net for domain NISDOMAIN
#
# domain NISDOMAIN slp
#Query local SLP server for ypserver supporting NISDOMAIN
#
# ypserver HOSTNAME
#Use server HOSTNAME for the local domain. The
#IP-address of server must be listed in /etc/hosts.
#
# broadcast
#If no server for the default domain is specified or
#none of them is rechable, try a broadcast call to
#find a server.
#
domain server-linux.info server nfs.server-linux.info  // add the line
 
[root@www ~]# vi /etc/nsswitch.conf
 
passwd:files nis// line 33: add
shadow:files nis// add
group:files nis// add
 
#hosts:db files nisplus nis dns
hosts:files dns nis// add
 
[root@www ~]# chkconfig ypbind on
[root@www ~]# chkconfig portmap on
[root@www ~]# reboot
 
www login: cent// user name on NIS
Password:// input password
Last login: Sun Mar 11 22:02:12 on tty1
[cent@www ~]$// could login
[cent@www ~]$ ypwhich
nfs.server-linux.info
[cent@www ~]$ ypcat passwd
cent:x:500:500::/home/cent:/bin/bash
[cent@www ~]$ yppasswd// change password
Changing NIS account information for cent on nfs.server-linux.info.
Please enter old password:// input current password
Changing NIS password for cent on nfs.server-linux.info.
Please enter new password:// input new password
Please retype new password:// verify
 
The NIS password has been changed on nfs.server-linux.info.

Nagios Architecture

January 24th, 2010 by manoj No comments »

Overview 

Nagios is a host and service monitor designed to inform you of network problems before your clients, end-users or managers do. It has been designed to run under the Linux operating system, but works fine under most *NIX variants as well. The monitoring daemon runs intermittent checks on hosts and services you specify using external “plugins” which return status information to Nagios. When problems are encountered, the daemon can send notifications out to administrative contacts in a variety of different ways (email, instant message, SMS, etc.). Current status information, historical logs, and reports can all be accessed via a web browser.

  Architecture

Nagios is built on a server/agents architecture. Usually, on a network, a Nagios server is running on a host, and plugins are running on all the remote hosts that need to be monitored. These plugins send information to the server, which displays them in a GUI.

nagios

Nagios is composed of three parts: 

1) A scheduler: this is the server part of Nagios. At regular interval, the scheduler checks the plugins, and according to their results do some actions.

2) A GUI: the interface of Nagios (with the configuration, the alerts, …). It is displayed in web pages generated by CGI.It can be state buttons (green,OK/red,Error), sounds, MRTG graphs, …

3) The plugins. They are configurable by the user. They check a service and return a result to the Nagios server.

 A soft alert is raised when a plugin returns a warning or an error. Then on the GUI, a green button turns to red, and a sound is emitted. When this soft alert is raised many times (the number is configurable), a hard alert is raised, and the Nagios server sends notifications: email, SMS… 

Nagios Architecture (internal)
nagios
nagios
 
 

 

Nagios functionalities

 Nagios® is an open source tool specially developed to monitor host and service and designed to inform you of network incidents before your clients, end-users or managers do. It has been designed to run under the Linux operating system, but works fine under most *NIX variants as well initially developed for servers and application monitoring, it is now widely used to monitor networks availability. It is possible with the development of specific plugins around Nagios process. Nagios works with a set of “plugins” to provide local and remote service status. The monitoring daemon runs intermittent checks on hosts and services you specify using external “plugins” which return status information to Nagios.  When incidents are detected, the daemon send notifications out to administrative contacts in a variety of different ways (email, instant message, SMS, etc.). Current status information, historical logs, and reports can all be accessed via a Web browser.Custom “plugins” are relatively easy to develop Different methods are provided for remote resource discovery Nagios is freely available from http://www.nagios.org

Requirements

Other things you will need to get Nagios working are:

1) Nagios Plugins (from Nagios download URL)

2) GD – Graphics Libraries

3) JPEG Lib Sources

4) PNG Lib Sources

5) FPing (Fast Ping), this is optional but useful.

6) For SNMP monitoring you will need:

7) net-snmp-tools, and

8 )  net-snmp-utils

9) MySQL database for storing: Elements status logs

Plugins and Extensions

Developments on Nagios can be found at http://www.nagiosexchange.org/

Add-On projects are freely available. They cover subjects on:

1) Charts,

2) Communications,

3) Configuration,

4) Development,

5) Downtimes,

6) FrontEnds,

7) Notifications,

8 )  Misc

Plugins have been developed on:

1) Networking,

2) SNMP,

3) Hardware,

4) Linux,

5) Solaris,

6) Windows, … 

PLUGINS
 
 
 

 

1) A plugin is a small program (in Perl, C, java, python …) that checks a service (a daemon, some free space on a disk …). It must return a value and a small line of text (Nagios will only grab the first line of text). Output should be in the format: METRIC STATUS: information text performance data The allowed METRIC STATUS are 0 (OK), 1 (WARNING), 2 (CRITICAL) or 3 (UNKNOWN) 

2) The warning and critical thresholds are parameters, set by the user, passed as arguments to the plugin.

 3) A plugin can also return performance data in the format: “label1=value1 label2=value2 …”
These data are stored by Nagios and may be later displayed with MRTG (http://people.ee.ethz.ch/~oetiker/webtools/mrtg/)

The plugins can be run:
1) Locally, on the Nagios server. But such a plugin can check remote hosts, for example check_ping which pings remote hosts to check if they are running.
 
 

 

2) Remotely, through a remote Nagios server, with ssh, with snmp, with NRPE (Nagios Remote Plugin Executor), or with NSCA (Nagios Service Check Acceptor). It means that the plugin either waits for a verification request from the Nagios server before sending its result, or executes itself and sends the result to the Nagios server. 

Other useful developments

 Alarm resiliency

1) Nagios gives an immediate status of the monitored elements, it has no memory (except in log). It is useful to keep trace of an  incident until it has been checked and acknowledged by an operator.

 Network Interfaces discovery

1) Within big networks, it is useful to « compare » real configuration with database configuration. An external program can check every day (auto-discovery) the real network configuration versus Nagios database.
2) If differences appear, notify network administrator of the change.

 

Semi-automatic configuration
1) For each new element, multiple identified checking have to be configured and started
2) Semi-automatic configuration tool will write Nagios configuration files based on higher level network description files
 
 

 

References

1) Nagios source program
 http://www.nagios.org/download/

2) Nagios Extra developments
 http://www.nagiosexchange.org/

3) Official plugins
 http://nagiosplug.sourceforge.net/

4) Conferences
 http://www.nagios.org/propaganda/conferences/

Jopr Monitoring Tool – Installation

January 24th, 2010 by manoj No comments »

1. Please installed the postgresql by using the following command, the general installation. As root install postgres core:

yum install postgresql*

2. Now create postgres user:
adduser postgres

3. Create the datafile for the database:
mkdir -p /usr/local/pgsql/data

4. Change ownership of the data files to the postgres user:
chown postgres /usr/local/pgsql/data

5. Now assume the role of a postgres user:
su – postgres

6. Important note: Installation of the postgres executables on Centos 5 / RHEL 5 is /usr/bin not /usr/local as Postgres official documentation suggests. Initialize the datafiles for the database:
/usr/bin/initdb -D /usr/local/pgsql/data

7. Start the database with initialized datafiles as the background process (&) and log all messages and errors (2&1) in the logfile:
/usr/bin/postgres -D /usr/local/pgsql/data > logfile 2>&1 &

8. Create the test database:
/usr/bin/createdb rhq

Install a database like PostgreSQL (version 8.2.4 +, please choose C locale for initdb), create a database instance called ‘rhq’ in it and a user ‘rhqadmin’ that owns this ‘rhq’ database.
#create user rhqadmin password ‘rhqadmin’;
#create database rhq owner rhqadmin;

9. Log in to the rhq database:
/usr/bin/psql rhq

10. You should see “Welcome to Postgres 8…” intro message and prompt:
rhq=#

11. Now make the following changes in this file
vi /var/lib/pgsql/data/pg_hba.conf
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# “local” is for Unix domain socket connections only
local   all         all                               trust #sameuser
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust #sameuser
# IPv6 local connections:
host    all         all         ::1/128               trust #sameuser

12. Restart the postgresql service
/etc/init.d/postgresql restart

13. Test the newly created database i.e. rhq
#psql -d rhq -U rhqadmin -W (-d = databasename, -U = username, -W=password)

14. Unzip the Jopr server
#unzip jopr-server-2.1.0.GA.zip

15. Set the java path or Eventually set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH env variables appropriately.
#set RHQ_SERVER_JAVA_HOME=/usr/java/jdk1.6.0_11/
OR
#export RHQ_SERVER_JAVA_HOME=/usr/java/jdk1.6.0_11/

16. cd into the jopr-server-*/ directory and start the server:
bin/rhq-server.sh console

17. After a few seconds, the messages on the console will stop. When this happens, point your browser to http://localhost:7080/ and run the installer.

18. When this is done and you can log in (default user / pass are: rhqadmin/rhqadmin), it is time to start the agent. Start a second shell for this.

19. cd into the agent directory.

20. start the agent by issuing
bin/rhq-agent.sh
(Answer the questions asked by the agent.)

21. Go back to the Server GUI and to its Dashboard. Watch resources show up in the upper right in the Autodiscovery portlet and import them.

22. Write script for agent and server
Start-agent
export RHQ_AGENT_JAVA_HOME=/usr/java/jdk1.6.0_11/
nice /usr/jopr-agent-2.1.0.GA/bin/rhq-agent.sh &

Start-jopr
export RHQ_SERVER_JAVA_HOME=/usr/java/jdk1.6.0_11/
nice /usr/jopr-server-2.1.0.GA/bin/rhq-server.sh console &

22. Done :-)  
 
http://172.16.0.16:7080/installer/start.jsf
psql -U rhqadmin -d rhq -W

Installing SSL Certificate – Apache 2.x

January 24th, 2010 by manoj No comments »

Once your SSL certificate has been signed and issued,Go Daddy® will send you an e-mail message that allows you to download the signed certificate and our intermediate certificate bundle, both of which must be installed on your Web site.

Note: You must use the provided certificate-download link within three days of receiving the certificate-issuance e-mail message. If the download link is allowed to expire, you must request a certificate re-key in order to retrieve your signed SSL certificate.

Follow the instructions below to download and install an SSL certificate on your Web server.

Note: Before you install your issued SSL certificate you must install our intermediate certificate bundle (null) on your Web server. You may also download the intermediate certificate bundle from the repository. 

Once your SSL certificate has been signed and issued,Go Daddy® will send you an e-mail message that allows you to download the signed certificate and our intermediate certificate bundle, both of which must be installed on your Web site.

Note: You must use the provided certificate-download link within three days of receiving the certificate-issuance e-mail message. If the download link is allowed to expire, you must request a certificate re-key in order to retrieve your signed SSL certificate.

Follow the instructions below to download and install an SSL certificate on your Web server.

Note: Before you install your issued SSL certificate you must install our intermediate certificate bundle (null) on your Web server. You may also download the intermediate certificate bundle from the repository.

Installing SSL Certificate and the Intermediate Certificate
i. Copy your issued certificate, intermediate certificate and key file (generated when you created the Certificate Signing Request (CSR)) into the directory that you will be using to hold your certificates.
ii. Open the Apache ssl.conf file and add the following directives:
  o SSLCertificateFile /path to certificate file/your issued certificate
  o SSLCertificateKeyFile /path to key file/your key file
  o SSLCertificateChainFile /path to intermediate certificate/null
iii. Save your ssl.conf file and restart Apache.

Restarting Your Web Server
You may use SSH to access your server. If you are using Windows on your computer, you can use the free, downloadable putty SSH/Telnet client to access your Linux server.

To restart your server:
i. Start Putty
ii. Select the “SSH” protocol option; then type in your IP address in the “Host Name” field.
iii. Click “Open.” This will connect you to your server.
iv. Log in as “root”; or enter “su:root”
v. Once logged in, you can restart the Web server by entering the following command: /usr/local/sbin/apachectl graceful

Note: Reissued certificates are not delivered via e-mail. Instead, the reissued certificate is displayed on the certificate-reissuance page of this site. In order to enable installation, please cut/copy the contents of the reissued certificate into a text file and save it. Once you have created the certificate file you may go ahead and install the reissued certificate.

Installing Lighttpd With PHP5 And MySQL Support On CentOS 5.0

January 24th, 2010 by manoj No comments »

Installing Lighttpd With PHP5 And MySQL Support On CentOS 5.0

 Lighttpd is a secure, fast, standards-compliant web server designed for speed-critical environments. This tutorial shows how you can install Lighttpd on a CentOS 5.0 server with PHP5 support (through FastCGI) and MySQL support.

 

In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100. These settings might differ for you, so you have to replace them where appropriate.

2 Installing MySQL 5.0

 

First we install MySQL 5.0 like this:

yum install mysql mysql-server

Then we create the system startup links for MySQL (so that MySQL starts automatically whenever the system boots) and start the MySQL server:

chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start

Create a password for the MySQL user root (replace yourrootsqlpassword with the password you want to use):

mysqladmin -u root password yourrootsqlpassword

Then check with

netstat -tap | grep mysql

on which addresses MySQL is listening. If the output looks like this:

tcp        0      0 localhost.localdo:mysql *:*                     LISTEN     2713/mysqld

which means MySQL is listening on localhost.localdomain only, then you’re safe with the password you set before. But if the output looks like this:

tcp        0      0 *:mysql *:*                     LISTEN     2713/mysqld
you should set a MySQL password for your hostname, too, because otherwise anybody can access your database and modify data:

mysqladmin -h server1.example.com -u root password yourrootsqlpassword

3 Installing Lighttpd

Lighttpd is not available from the official CentOS 5.0 repositories, but from the RPMforge repositories (see http://dag.wieers.com/rpm/FAQ.php#B2 for instructions). We install the RPMforge package for RHEL 5 which works for CentOS 5.0 as well:

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Afterwards, we can install Lighttpd like this:

yum install lighttpd

Then we create the system startup links for Lighttpd (so that Lighttpd starts automatically whenever the system boots) and start it:

chkconfig –levels 235 lighttpd on
/etc/init.d/lighttpd start

Now direct your browser to http://192.168.0.100, and you should see the Lighttpd placeholder page:

Lighttpd’s default document root is /srv/www/lighttpd on CentOS 5.0, and the configuration file is /etc/lighttpd/lighttpd.conf.

 

4 Installing PHP5

We can make PHP5 work in Lighttpd through FastCGI. Therefore we install the packages lighttpd-fastcgi and php-cli:

yum install lighttpd-fastcgi php-cli

 

5 Configuring Lighttpd And PHP5

To enable PHP5 in Lighttpd, we must modify two files, /etc/php.ini and /etc/lighttpd/lighttpd.conf. First we open /etc/php.ini and add the line cgi.fix_pathinfo = 1 right at the end of the file:

vi /etc/php.ini

[...]
cgi.fix_pathinfo = 1

Then we open /etc/lighttpd/lighttpd.conf and uncomment “mod_fastcgi”, in the server.modules stanza:

vi /etc/lighttpd/lighttpd.conf

[...]
server.modules              = (
#                               "mod_rewrite",
#                               "mod_redirect",
#                               "mod_alias",
                                "mod_access",
#                               "mod_cml",
#                               "mod_trigger_b4_dl",
#                               "mod_auth",
#                               "mod_status",
#                               "mod_setenv",
                                "mod_fastcgi",
#                               "mod_proxy",
#                               "mod_simple_vhost",
#                               "mod_evhost",
#                               "mod_userdir",
#                               "mod_cgi",
#                               "mod_compress",
#                               "mod_ssi",
#                               "mod_usertrack",
#                               "mod_expire",
#                               "mod_secdownload",
#                               "mod_rrdtool",
                                "mod_accesslog" )

 

and then , further down the file, there’s a fastcgi.server stanza which we uncomment as well – make sure you use /usr/bin/php-cgi instead of /usr/local/bin/php in the “bin-path” line::

[...]
#### fastcgi module
## read fastcgi.txt for more info
fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => "/tmp/php-fastcgi.socket",
                                   "bin-path" => "/usr/bin/php-cgi"
                                 )
                               )
                            )
[…]

 

Then we restart Lighttpd:

/etc/init.d/lighttpd restart

 

6 Testing PHP5 / Getting Details About Your PHP5 Installation

The document root of the default web site is /srv/www/lighttpd. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

vi /srv/www/lighttpd/info.php

<?php
phpinfo();?>

 

Now we call that file in a browser (e.g. http://192.168.0.100/info.php):

 

As you see, PHP5 is working, and it’s working through FastCGI, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don’t have MySQL support in PHP5 yet.

7 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php-mysql package. It’s a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

yum search php

Pick the ones you need and install them like this:

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

Now restart Lighttpd:

/etc/init.d/lighttpd restart

Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module:

 

 

To enable SSL for the whole server you have to provide a valid certificate and have to enable the SSL engine. If you want to use chained certificates you must also include the CA file, without it browsers will pop up an unknown certificate authority or some such error.

# cd /etc/lighttpd (go to this directory)
Generate the certificate
#openssl req -new -x509 -keyout server.pem -out server.pem -days 365 –nodes
(This certificate is valid for one year (365 days))

#vim /etc/lighttpd/lighttpd.conf

Locate ssl.engine in the /etc/lighttpd/lighttpd.conf and add the following

#### SSL engine
ssl.engine                 = “enable”
ssl.pemfile                = “/etc/lighttpd/server.pem” (Path of newly created certificate)

To check that your config is ok:
# lighttpd -t -f lighttpd.conf

You need to restart the web server, we can restart it by using the following command
/etc/init.d/lighttpd restart

For more details please check the below URLS