Monday, April 18, 2011

Web Security Tip: How to prevent Denial of Service (DoS) attack?

What is a denial-of-service (DoS) attack?
In a denial-of-service (DoS) attack, an attacker attempts to prevent legitimate users from accessing information or services. By targeting your computer and its network connection, or the computers and network of the sites you are trying to use, an attacker may be able to prevent you from accessing email, websites, online accounts (banking, etc.), or other services that rely on the affected computer.

How it works?

Let's see how it make the problem,"n" is a typical connection, the user sends a message asking the server to authenticate it. The server returns the authentication approval to the user. The user acknowledges this approval and then is allowed onto the server.

In a denial of service attack, the user sends several authentication requests to the server, filling it up. All requests have false return addresses, so the server can,t find the user when it tries to send the authentication approval. The server waits, sometimes more than a minute, before closing the connection. When it does close the connection, the attacker sends a new batch of forged requests, and the process begins again--tying up the service indefinitely.

How to Prevent?
Unfortunately, there are no effective ways to prevent being the victim of a DoS or DDoS attack, but there are steps you can take to reduce the likelihood that an attacker will use your computer to attack other computers:

1.Install a firewall, and configure it to restrict traffic coming into and leaving your computer.

2.One of the more common methods of blocking a "denial of service" attack is to set up a filter, or "sniffer," on a network before a stream of information reaches a site,s Web servers. This filter can set in firewall or pro grammatically.

The filter can look for attacks by noticing patterns or identifiers contained in the information. If a pattern comes in frequently, the filter can be instructed to block messages containing that pattern, protecting the Web servers from having their lines tied up.

3.Follow good security practices for distributing your email address.

Sunday, April 17, 2011

How to save image from direct local URL to File

In my recent project its an requirement to save images from URL to hard disk or any media. After binged I have got several solutions. Now sharing you the right solution which is work for me.

Code(C#):

protected void Page_Load(object sender, EventArgs e)
{
string url = "http://img510.imageshack.us/img510/5523/aspnet4jh.jpg";
string DestinationPath ="C:/temp";
string filename = url.Substring(url.LastIndexOf('/')+1);
byte[] bytes=GetBytesFromUrl(url);
WriteBytesToFile(DestinationPath +"/"+filename, bytes);
}

static public byte[] GetBytesFromUrl(string url)
{
byte[] b;
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url);
WebResponse myResp = myReq.GetResponse();

Stream stream = myResp.GetResponseStream();
//int i;
using (BinaryReader br = new BinaryReader(stream))
{
//i = (int)(stream.Length);
b = br.ReadBytes(500000);
br.Close();
}
myResp.Close();
return b;
}

static public void WriteBytesToFile(string fileName, byte[] content)
{
FileStream fs = new FileStream(fileName, FileMode.Create);
BinaryWriter w = new BinaryWriter(fs);
try
{
w.Write(content);
}
finally
{
fs.Close();
w.Close();
}
}

Hope that it may help other guys. Thanks.

Saturday, April 2, 2011

Achieve MVP award from Microsoft

Yesterday I got an email from Microsoft Community ..

"
Dear Ahsan

Congratulations on getting awarded as an MVP for contributing to the technical communities!

I am Abhishek Kant, your MVP Lead and would facilitate your interaction with Microsoft including administration of award benefits and providing latest information.............

"

Thanks to Microsoft Community to give this reward to the community contributor. It is really inspired the community member to keep up their activities.

I feel lucky to join in MVP community for the first time, hope that this is a great opportunity for me to rich my experience by sharing knowledge with other MVP.

Thanks to all for their co operation.

Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'

Exception: Method 'StartWorkflowOnListItem' in type 'Microsoft.SharePoint.WorkflowServices.FabricWorkflowInstanceProvider'...