Honhar Engineer

Honhar Engineer
Thanks for visiting,stay connected for more updates !

Sunday, February 23, 2014

SQL Injection Attack

An SQL Injection can destroy your database.

SQL in Web Pages

In the previous chapters, you have learned to retrieve (and update) database data, using SQL.
When SQL is used to display data on a web page, it is common to let web users input their own search values.
Since SQL statements are text only, it is easy, with a little piece of computer code, to dynamically change SQL statements to provide the user with selected data:

Server Code

txtUserId = getRequestString("UserId");
txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;
The example above, creates a select statement by adding a variable (txtUserId) to a select string. The variable is fetched from the user input (Request) to the page.
The rest of this chapter describes the potential dangers of using user input in SQL statements.

SQL Injection

SQL injection is a technique where malicious users can inject SQL commands into an SQL statements, via web page input.
Injected SQL commands can alter SQL statement and compromises the security of a web application.

SQL Injection Based on 1=1 is Always True

Look at the example above, one more time.
Let's say that the original purpose of the code was to create an SQL statement to select a user with a given user id.
If there is nothing to prevent a user from entering "wrong" input, the user can enter some "smart" input like this:
UserId:

Server Result

SELECT * FROM Users WHERE UserId = 105 or 1=1
The SQL above is valid. It will return all rows from the table Users, since WHERE 1=1 is always true.
Does the example above seem dangerous? What if the Users table contains names and passwords?
The SQL statement above is much the same as this:
SELECT UserId, Name, Password FROM Users WHERE UserId = 105 or 1=1
A smart hacker might get access to all the user names and passwords in a database by simply inserting 105 or 1=1 into the input box.

SQL Injection Based on ""="" is Always True

Here is a common construction, used to verify user login to a web site:
User Name:
Password:

Server Code

uName = getRequestString("UserName");
uPass = getRequestString("UserPass");

sql = "SELECT * FROM Users WHERE Name ='" + uName + "' AND Pass ='" + uPass + "'"
A smart hacker might get access to user names and passwords in a database by simply inserting " or ""=" into the user name or password text box.
The code at the server will create a valid SQL statement like this:

Result

SELECT * FROM Users WHERE Name ="" or ""="" AND Pass ="" or ""=""
The result SQL is valid. It will return all rows from the table Users, since WHERE ""="" is always true.

SQL Injection Based on Batched SQL

Most databases support batched SQL statement, separated by semicolon.

Example

SELECT * FROM Users; DROP TABLE Suppliers
The SQL above will return all rows in the Customers table, and then delete the table called Suppliers.
If we had the following server code:

Server Code

txtUserId = getRequestString("UserId");
txtSQL = "SELECT * FROM Users WHERE UserId = " + txtUserId;
And the following input:
User id:
The code at the server would create a valid SQL statement like this:

Result

SELECT * FROM Users WHERE UserId = 105; DROP TABLE Suppliers


Parameters for Protection

Some web developers use a "blacklist" of words or characters to search for in SQL input, to prevent SQL injection attacks.
This is not a very good idea. Many of these words (like delete or drop) and characters (like semicolons and quotation marks), are used in common language, and should be allowed in many types of input.
(In fact it should be perfectly legal to input an SQL statement in a database field.)
The only proven way to protect a web site from SQL injection attacks, is to use SQL parameters.
SQL parameters are values that are added to an SQL query at execution time, in a controlled manner.

ASP.NET Razor Example

txtUserId = getRequestString("UserId");
txtSQL = "SELECT * FROM Users WHERE UserId = @0";
db.Execute(txtSQL,txtUserId);
Note that parameters are represented in the SQL statement by a @ marker.
The SQL engine checks each parameter to ensure that it is the correct for its column, and are treated literally, and not as part of the SQL to be executed.

Another Example

txtNam = getRequestString("CustomerName");
txtAdd = getRequestString("Address");
txtCit = getRequestString("City");
txtSQL = "INSERT INTO Customers (CustomerName,Address,City) Values(@0,@1,@2)";
db.Execute(txtSQL,txtNam,txtAdd,txtCit);

NoteYou have just learned to avoid SQL injection. One of the top website vulnerabilities.


Examples

The following examples shows how to build parameterized queries in some common web languages.
ASP.NET SELECT
txtUserId = getRequestString("UserId");
sql = "SELECT * FROM Customers WHERE CustomerId = @0";
command = new SqlCommand(sql);
command.Parameters.AddWithValue("@0",txtUserID);
command.ExecuteReader();
ASP.NET INSERT INTO
txtNam = getRequestString("CustomerName");
txtAdd = getRequestString("Address");
txtCit = getRequestString("City");
txtSQL = "INSERT INTO Customers (CustomerName,Address,City) Values(@0,@1,@2)";
command = new SqlCommand(txtSQL);
command.Parameters.AddWithValue("@0",txtNam);
command.Parameters.AddWithValue("@1",txtAdd);
command.Parameters.AddWithValue("@2",txtCit);
command.ExecuteNonQuery();
PHP INSERT INTO
$stmt = $dbh->prepare("INSERT INTO Customers (CustomerName,Address,City)
VALUES (:nam, :add, :cit)");
$stmt->bindParam(':nam', $txtNam);
$stmt->bindParam(':val', $txtAdd);
$stmt->bindParam(':cit', $txtCit);
$stmt->execute();

Wednesday, February 19, 2014

E-mail Spoofing: Anonymous Mail Through php

        email
Hi friends! Few weeks back I have got few mails asking me to write on tracing anonymous mails. So I thought today to get started with the topic of anonymous mailing. Before you learn to trace an email you must know to create an anonymous mail. Using this technique you can email any user from any email service you wish. You don’t even need the access to the email id from which you want the email to be sent. Today I am gonna introduced to a website service and will give you a basic idea on how it works!
After reading this article you will be able to send an email from any email address. This is also known as Email Spoofing. This can be cone in many methods, in this post I will describe to do it with a fake mailer php script.
Note: If you send an email from an id of a particular server to the id that corresponds to the same server then your email may alert the user! That is, if you mail from a Gmail id to another Gmail id using fake mailer script then there would be a warning message that would be displayed at the bottom of the email.
So let’s start the email spoofing…!
  1. Go to http://emkei.cz
  2. Fill the From NameFrom Email and To fields.
  3. Write the message in the Text field.
  4. Enter the CAPTCHA and click Send!
  5. Agree the T&C and your mail is sent!
So what is happening here?
This webpage contains a PHP code similar to the one which is given below. This script generates an email that is to be sent with the provided from email address and then it confirms whether the mail is successfully sent or not.
echo” Enter the ’To’ email address:”;
$to = $_GET[email];
echo”Enter the ‘Subject’ of email”;
$subject = $_GET[header];
echo”Enter the ‘From’ email address:”;
$fake = $_GET[from];
echo”Enter the ‘Message’”;
$message = $_GET[message];
}
$headers = “MIME-Version: 1.0″ . “\r\n”;
$headers .= “Content-type:text/html;charset=iso-8859-1″ . “\r\n”;
$headers .= “From: ” . $fake . ” <” . $fake . “>” . “\r\n”;
if (mail($to, $subject, $message, $headers))
{
echo”The e-mail was successfully sent to ” . $to . “
\n”;
echo”From: ” . $fake . “
\n”;
echo”Subject: ” . $subject . “
\n”;
echo”Message:
\n”;
echo”” . $message . “
“;
}
else
{
echo”Opps there was a problem sending the email\n”;
}
?>
To get this script into action you will have to host this PHP script at a web hosting server. Then you have to make a webpage using HTML and in the form of action=fakemailer.php has to be written. The fakemailer.php is the name of the hosted PHP file with the above code.
Remember, the email which is sent will be associated with an IP address of the web server where you hosted your PHP script. Therefore this makes the fake make traceable!
A detailed description on creating such kind of webpages and tracing the anonymous mails will be provided in my upcoming articles.
Till then have fun experimenting with fake mailing!
Feel free to comment below… Your response is most precious to us!

Wednesday, January 8, 2014

C Program to Print India's Map

#include<stdio.h>
int main()
{
int a,b,c;
int count = 1;
for (b=c=10;a="- FIGURE?, UMKC,XYZHello Folks,\
TFy!QJu ROo TNn(ROo)SLq SLq ULo+\
UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^\
NBELPeHBFHT}TnALVlBLOFAkHFOuFETp\
HCStHAUFAgcEAelclcn^r^r\\tZvYxXy\
T|S~Pn SPm SOn TNn ULo0ULo#ULo-W\
Hq!WFs XDt!" [b+++21]; )
for(; a-- > 64 ; )
putchar ( ++c=='Z' ? c = c/ 9:33^b&1);
getch();
return 0;
}



NOTE: Above program may have some error if any then comment.....!!!

How to disable the time in computer on internet cafe and use unlimited time

1. goto run and type regedit

2. than navigate to "HKEY_CURRENT_USER>Appevents>software>classes>microsoft>windows>current version>internet settings>policies>system"

3. than on the right pane it show Disable Taskmanager, right click on it and scroll down to modify

4. and change the value on it 0

5. Open taskmanager by holding "ALT+CTRL+DELETE" Than disable the internet cafe timer.
Now you will get unlimited timer on internet cafe.

Wednesday, December 25, 2013

Why 32 bit processor are called as x86 ?

The original x86 CPU was the Intel 8086. This was followed by the
80186 and the 80286. All three were actually
16-bit. They were followed by the Intel 486,
the Pentium, the Pentium 2, etc.
These days, x86 usually refers to the 32 bit
version of the hardware architecture, although
it occasionally is used in reference to the x86
processors, regardless of their “bit size”. The
64 bit version is most often referred to by
x86-64 or AMD64, the latter due to AMD
beating Intel to market with 64-bit x86 based
hardware.And not all 32-bit processors are
x86.
There are some non x86 32-bit processors. The
term x86 actually signifies backward
compatibility with the original 8086 instruction
set. The 32 bit x86,actually x86-32 became so
popular that they were referenced as x86. The
exact names would be x86-16 , x86-32 and
x86-64(or x64) for the x86 chips.

Thursday, December 12, 2013

How to Find Serial Key of Any Software

The key 94FBR is a part of Office 2000 Pro CD activation key that is widely distributed as it bypasses the activation requirements of Office 2000 Pro. By searching for 94fbr and the product name, you are guarantee that the pages that are returned are pages dealing specifically with the product you're wanting a serial for. Follow simple steps given below to learn this trick

    1. Go to Google
    2. Then type  Software Name 94FBR

  • Replace Software Name with the name of software whose serial key you want to find
  • Eg: To find serial key of Nero i will type Nero 94fbr
    3. Now press Enter and you will find serial key of software you are looking for as shown below.
google trick to find serial key