What is SQL Injection?

0 comments
What is SQL Injection?
Acunetix describes it as ” the type of attack that takes advantage of improper coding of your web applications that allows hacker to inject SQL commands into say a login form to allow them to gain access to the data held within your database. In essence, SQL Injection arises because the fields available for user input allow SQL statements to pass through and query the database directly.” Today in this article, we are going to see login bypass using SQL Injection.
To make it more interesting, I am going to divide this article into two parts. First, the Web Programmer part and second the hacker part. I am going to use Wamp server for this.  Imagine a web programmer  has been hired to code a website for a newly formed company named shunya.  He codes the website as below.The first file is the  index.php.  On this page he creates three buttons. He adds functionality to the ‘Login’ button.
Image
Image
So when a user clicks on the Login button, he is  redirected to  another page called action.php which is a login form for the users of shunya.com.
Image
It’s script is given below.
Image
In the above code notice that the form action is set to process.php. This file validates the users. What this script does is, when a user enters the username and password it creates a connection to the database and checks if the user is in the database. If the user is in the database and his authentication is correct, he is taken to the page login_success.php.
Image
The above script is very important to understand SQL Injection. You can see that the username and password are submitted as raw input. Notice also the query underlined.
This is the database the programmer has created  for the website. 
Image
When a user in the database enters the correct password as shown below, he is redirected to the login_success page.
Image
The page below is the page I set for login_success.php.
Image
When a user not listed in the database, or a valid user logs tries to login without password like below,
Image
this happens.
Image
That’s the end of the programmer part. Now it’s time for the hacker part. A hacker happens to find the site of shunya.com. In the Login form, he inserts a single quote to see if the site is vulnerable to SQL Injection.
Image
He gets a below error message. This indicates the site is vulnerable to SQL Injection.
Image
Then he tries a query like the one shown below.
Image

Surprisingly, he gets access to the restricted area.How does the above query work. When a user enters the above query the statement $sql in the process.php works as,
$sql = “SELECT * FROM $tbl_name WHERE username= ” or ’0;’
This  is a valid  SQL query and user is validated even without checking the password. There are some other queries which can work similarly. Two of them are here.
‘ or ’1′=’1;
‘ or ’1′=’1”
When a hacker enters these two queries, the username field becomes
” or ’1′=’1;
which transforms to validate the user if username is empty or 1=1. Now whatever may happen, one will always be equal to one. We can find many more using trial and error. This vulnerability exists because we are supplying raw data to our application. Our web programmer after a short time finds out this vulnerability and patches it as below.
Image

What the mysql_real_escape_string does is it removes any  special characters from the input. Now try the same queries and see what happens. Thank you.

WPA2 Wi-Fi Password hacking guide (BT5/Kali linux)

0 comments
This guide is for penetration testing your own network or someone else's, with permission
using someone elses wifi is theft of service and may or may not  be a criminal offence in your area
Logan nor anyone from tek syndicate is liable for your actions, you are so proceed with caution!
EDIT; kali linux is now out as logan said on the tek a few weeks back, as kali is built from the same tools by the same team this guide work with both BT5 r3 and kali,

1st step you will need a copy of backtrack 5 so go here http://www.backtrack-linux.org/downloads/
or kali linux from here (guide is same for both) http://www.kali.org/downloads/
and get yourself an iso (32 or 64bit depending on your hardware)
either burn to disc using imgburn http://www.imgburn.com/index.php?act=download
or make a live usb of 4gb + then you can save sessions and not have to start over when you power off, its a good idea as i have had attacks take up to a day and a half (because of weak signal) and with a disc once powered down......
to do this i use this http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/ itll do windows too....
or as a third option you could run it as a virtual machine with vmware from within windows, but if you do that you HAVE to use a usb wifi dongle because the internal wifi card of laptops gets seen as ethernet by the guest os, dont know why but i have found it to be true - vmware is not freeware, there maybe a trial or cripple ware version available here  http://www.vmware.com/uk/ but i sailed away from the pirate bay with my copy, i wont link directly to it as i may get in trouble from logan but you're a smart guy you can find it ;)
ok so now you have a disc/usb or virtual machine so power on, into BIOS (del,f11,f2 another key depending on hardware) and set it to boot from disc or usb, (not applicable to vm) and lets have some fun!
when the first menu comes up you want default text mode
when the cursor becomes available type "startx" without the quotes and it will boot into a desktop
go to the top of the screen and click on the little black screen to open a teminal (looks like a windows cmd window)
now to find out what wifi adaptor you have
type "airmon-ng" no quotes
if it doesnt list anything then your wifi adaptor is not compatible with bt5 it probably has no promiscuous mode or is lacking driver support but most laptop internal wifi i have found to work and most full size usb dongles do too the tp link tl wn821n works for definate.
the output from that is normally wlan0 but if you have multiple adaptors you will get more options
type "airmon-ng start wlan0"
assuming wlan0 was the output from previous command if not put what the output was for the adaptor you would like to use it will output monitoring enabled on mon0 most times unless you have multiple adaptors
so now we have set our adaptor to monitor the airwaves we can have a snoop at all the available networks
type "wash -i mon0"
and it will list all available networks signal strength encryption type bssid's and other things, we are looking for networks with wpa2/psk WEP is also dooable and much quicker, but as a security standard it is dead and not in common use any more but if you would like a guide for that too, let me know in the thread and when i have a moment.....
anyway choose your victims bssid and
type "reaver -i mon0 -bBSSIDGOESHERE -vv"
and it will start running through the all the possible wps set up pins randomly, it maybe that you get ap rate limiting detected, this is where a router recognises that it is getting attacked from all the wrong passwords and stops bt5 from accessing it rfor a set amount of time to combat this youi need to add a delay -d command to the reaver command line so it looks something  like this
"reaver -i mon0 -b21.34.56.23.54 -d20 -vv"
if ap rate limiting still detected keep increasing the delay by 5 seconds untill you stop tripping the ap rate limit
by using the -vv comand you get more verbose output from the termional wich allows you to see if it is channel hopping or ap rate limiting or whatever and it also lets you see when it gets caught in a loop on a particular password when this happens i press cntrl+c to stop session then up cursor for last command and enter and it picks up where it left off and normally carries on without stuttering on the same password again
after time passes it will output the password and pin number copy both down as if the password is changed you can run the reaver command line again with a -pPINHERE and it will break new password in less than a minit as the pin doesnot change this would look like
"reaver -i mon0 -b23.56.76.45. -p123456 -vv"
the password will get changed if your found on a network you are not supposed to be on wich is why i put that command there as i have had it happen a few times
if this goes on and the network admin is savvy they may stop changing the password and start banning mac addresses from connecting to the router but dont fear!
i use this http://www.technitium.com/ to change my mac address as i have had to deal with this problem before
as a side note, if you are going to jump on a network that isnt yours change your pc name to something not identifiable to you mine is called vm.lineupdate32 as the target network is on virgin media....see?

Statistik

Powered by Blogger.