- Posted by Admin on July 3, 2009
There are several domain whois checking websites available today. For example, who.is and domaintools.com are broadly used. It is very easy to develop such web application of your own. All you need to query the whois server for a domain in question. Here is the sample code, that fetches the whois information associated with the domain provided in the query.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Sockets;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string domainname = Request.QueryString["domain"].ToString();
TcpClient objTCPC = new TcpClient();
objTCPC.Connect("whois.enom.com", 43);
string strDomain = domainname;// +"\\r\\n";
byte[] arrDomain = Encoding.ASCII.GetBytes(strDomain);
Stream objStream = objTCPC.GetStream();
objStream.Write(arrDomain, 0, strDomain.Length);
StreamReader objSr = new StreamReader(objTCPC.GetStream(),Encoding.ASCII);
string strServerResponse = objSr.ReadToEnd();
strServerResponse = Regex.Replace(strServerResponse, "\n", "<br>");
Response.Write(strServerResponse);
objTCPC.Close();
}
}
Above code will query the whois server whois.enom.com to get the whois information of ask4asp.net. You can use any whois servers. I am listing some of them below.
whois.arin.net
whois.ripe.net
whois.apnic.net
whois.lacnic.net
whois.afrinic.net
whois.enom.com, etc.
- Posted by Admin on June 27, 2009
Why shouldn’t we allow any domain to run Asp.Net application under the Full Trust level? Below are the reasons:
If the Asp.Net application is allowed to run under Full Trust level then it can:
1. Browse(create/edit and delete too) files in the Windows directory using the System.IO namespace.
2. Browse(create/edit and delete too) folders in the Program Files directory using the System.IO namespace.
3. Browse(create/edit and delete too) files in the System32 directory using the System.IO namespace.
4. Output of the OS name and version number using the System.Environment class.
5. Output of the server's local IP address using server variables, etc.
In short, full trust Asp.Net application can do anything with the server since it gains the full access of the server when run under the Full Trust.
Therefore, do not ever offer any domain a full trust level in the shared server if your are a shared hosting provider. :)
- Posted by Admin on May 17, 2009
Changing the IP address of the computer automatically is very easy. Microsoft trickily stores the IP information in registry. Refer the below code that changes the IP address of the host server. This can be used in windows application or windows services to change the IP address of the local computer and can also be used in asp.net to change the IP address of the server that hosts your asp.net application. Make sure that Microsoft.Win32 namespace is visible to the below code wherever it is placed because Win32 is needed for manipulating Windows registry. Server restart is needed for new IP addresses to come into the effect.
RegistryKey key = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", true);
// Registry key where IP information is stored.
foreach (string s in key.GetSubKeyNames())
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\" + s, true);
if (rk.ValueCount >= 12) // In general, active network card will have more than 12 setting values
{
try
{
string[] s1 = { "12.24.36.48", "13.26.39.64" }; // Array of IP addresses to set.
rk.SetValue("IPAddress", s1);
}
catch (Exception exc)
{
// Error message logic here.
}
}
rk.Close();
}
NOTE: Do not use this code uniethically.
Moreover, it requires Full Trust level enabled for the ASP.NET website to run above code, otherwise security exception will occur.
Security Exception
Description:
The application attempted to perform an operation not allowed by the
security policy. To grant this application the required permission please
contact your system administrator or change the application's trust level in the
configuration file.
Exception Details:
System.Security.SecurityException: Requested registry access is not
allowed.