SunshineCTF 2019: Wrestler Book (Explicit SQL Injection)

John Hammond · Intermediate ·🔐 Cybersecurity ·7y ago

Key Takeaways

The video demonstrates an explicit SQL injection vulnerability in the Wrestler Book challenge, using Union Select statements and GROUP_CONCAT to exploit the vulnerability and retrieve a flag from the database.

Full Transcript

[Music] hello everybody welcome back from the YouTube video my name is John Hammond and we're looking at the sunshine CTF we've moved into the web category this challenge is called wrestler book and I'm kind of excited to show it to you I really like this kind of challenge I think it's some fun sequel injection so let's get right to it wrestler book is the social network for wrestlers by wrestlers wrestle book is exclusively for wrestlers so if you didn't get an invite don't bother trying to view our profiles rude all right so let's check out what this link is and welcome to wrestler book sign in to view your profile cool ok let's just see if we can login with anything guest guest nope thanks LastPass I don't need that extra security right now your login name or password is invalid try again okay what about admin admin still nothing admin password still nothing LastPass is just gonna keep trying dude give up are they all right this is a CTF challenge so let's try some sequel injection right we got iterations or some possible combinations but we can use be using here the string might be with a single quote the string might be with a double quote and that would cover the terminating string you've also got the comment the comment might be two hyphens or it might be a hash tag or it might be about forward slash star if we can get away with that so let's just try some of them we can try like admin and then - let's do or one equals one and then comment that - - and I'll paste that in for the passage as well okay it looks like that got me in that or one equals one is going to just straight-up return the first result in fines looks like that happens to be Hulk Hogan we retreat some information from him we've got Hulk Hogan username Hulk Hogan age 65 and then a title and then flag is not available ok dang so can we reproduce that without an or 1 equals 1 or will we just straight-up fail like will our sequel injection work even without that ok we get a login password that's fine good so now we can try now we know we have in our minds we got a valid sequel injection some kind of vulnerability so what that means is we may or may not have explicit results returned to us as and we can see some of our some of our requests displayed on the screen because that's very very valuable that means we don't have to do any crazy tricks like a blind sequel injection where we only get a threshold we can control a yes or a No whether or not something actually returns or doesn't return so well that's the next step now that we found the sequel injection vulnerability we can pretty much always do blind except it requires some scripting and some more logic and some hardcore stuff so the other option is check do we have explicit and the way you can just test for that is to see if you can actually run another query alongside the Select statement that's already happening so a union select and then see if you can actually get any result returned back to you so let's try that Union Select and then let's just say one column to see what we've got and I'll copy and paste that in that errors but that means we have errors which is good maybe we can actually help figure out what's going wrong what's happening debugging or our queries here selects to the left and right of Union do not have the same number or result columns okay this is the next part of the test when you're using the Union select statement because the Select statement that happens originally the first the actual query that the server and the website does on its own that's going to be using a specific number of columns it might receive my age my name and my phone number and that's three columns so in my Union select I also have to have select one select to select 3 so it will still return something if it's the wrong number that we're supplying it's just gonna arrow out just like this so thankfully we can see the error so we know that that's happening but what we normally do is just go ahead and increment until we find which of these is gonna get us a result and this might take a little bit especially considering we know that this application already returned a lot of information to return an age and returned the title and returned to etcetera so let's try four that's gonna take nothing again and I'm fumbling around with my cursor I'm sorry let's go to six and it doesn't matter how long does takes dude you might if you know you've got an error and you know something may vary will return you can go up to 30 he'll like you're a determined attacker okay so now we've got a result now we've got five as our name username is one four six and seven we got a page return and we know that what we've been selecting is actually being displayed to us that means we have explicit sequel injection so now in one of those fields we can get some good stuff we can actually start to do our own select statements and try and leak out information I do this a lot with github John Hammond miscellaneous I have a sequel injection cheat sheet that might help leak out the entirety of a database if you don't know anything like if you don't know what the database name is if you don't know what a table name is if you don't know what column you're looking for this will help you figure it out if you can find one of those injection points and actually determine whether or not this returns for you so if we want to select group can cat schema name from information schema maybe we could get this to return something and let's say that five spot let's put that in parentheses and spit that in there copy and paste that for password as well and looks like that failed in this case okay you know what sometimes we give the devil's due cut our losses we know that we still have something in five can we select anything can we select hello right as a string let's see if we can do it yes that returns hello for us okay so we can we can still run our select statements that's not gonna that's not going to hold us back what can we get is users a real table like if you select something from and then a table if it doesn't exist let's say a table that doesn't exist that's fine that will say no such table a table that doesn't exist or it will just rate up err if we it won't return anything if you aren't seeing these errors another challenge what we can do then is try and determine does a table named users exist and that's normally what it's called right if it's a sensible program so we paste that in and that returns for us so we now know that users exist okay we can also probably determine some like like column names right we know we have user name age title flag we can try that let's select age and we don't need string quotes for that anymore because we're getting a real result back age was 65 just like we saw in Hulk Hogan okay so how about select flag n/a so that's the non-applicable that we saw earlier that doesn't help us because we could select flag from users where maybe username is equal to admin or something and maybe that would be what we're looking for let's try that no dice okay so let's try another route I went back and I because I still had my sequel injection cheat sheet in mind I know I have some fields that I can get with group concat and that's this group can cats index here that will take a column that is a lot of results of vertically right and it puts them all together so it makes them horizontal so it will use a comma at the delimiter by default I think you can specify something else but that group can cat will let you show all of the results all the rows that will return to you all in one in one result so that's very cool we can actually take advantage of that to say let's group concat every flag column like everything every flag row and we don't need to specify where user name is anymore because it's just going to give us everything so let's hit that copy/paste the throat and password just to be safe and blah-blah-blah-blah-blah cool we've got example flag and now we have sun just another sequel ciao cool so there's our flag when I first ran this I think my zoom in was off because I wasn't as zoomed in as I was and I'm doing this for real so it looked like it cut off the response and was like well that sucks I can't really see it all that well so what I had done is actually opened up developer tools with f12 and in the network I would reload the page get it to resend so in that post request once I've got it responded to me I can see the response and that way I could actually view it in a much better way and control it that way so there is our flag that was the exploit some cool sequel injection I really like I really like sequel injection explicit is very very fun especially because I feel like I've successfully weaponized that with the sequel injection cheat sheet and blind is fun too because it takes a little bit of fun troubleshooting and a good script so you could submit that flag 100 points and that is wrestler book in the sunshine CTF web the category sequel injection stuff hey I hope you guys enjoyed this video if you did like the video please you like comment subscribe I would love to see you on the discord server there is a link in description I'd love to see you on patreon I'd love to see on PayPal just be a part of the same thanks again guys minutes [Music] [Music] [Music] [Music]

Original Description

If you would like to support me, please like, comment & subscribe, and check me out on Patreon: https://patreon.com/johnhammond010 E-mail: johnhammond010@gmail.com PayPal: http://paypal.me/johnhammond010 GitHub: https://github.com/JohnHammond Site: http://www.johnhammond.org Twitter: https://twitter.com/_johnhammond
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from John Hammond · John Hammond · 0 of 60

← Previous Next →
1 Code Commentaries? PHP to JavaScript in Bash and PHP!
Code Commentaries? PHP to JavaScript in Bash and PHP!
John Hammond
2 Tutorials? MySQL connection with PHP and Bash!
Tutorials? MySQL connection with PHP and Bash!
John Hammond
3 Variable Naming in Python! Happy Birthday, Linux! Nokia N900!
Variable Naming in Python! Happy Birthday, Linux! Nokia N900!
John Hammond
4 JavaScript Splits The URL!
JavaScript Splits The URL!
John Hammond
5 HTML Tables in Python!
HTML Tables in Python!
John Hammond
6 HTML, Net Shares, GML!
HTML, Net Shares, GML!
John Hammond
7 Python 08 Programming Style and Comments
Python 08 Programming Style and Comments
John Hammond
8 Python 26 Object Oriented Programming
Python 26 Object Oriented Programming
John Hammond
9 75 Python Tutorials, Out Now!
75 Python Tutorials, Out Now!
John Hammond
10 Batch 14 Mathematical Expressions
Batch 14 Mathematical Expressions
John Hammond
11 Batch 85 Array Append
Batch 85 Array Append
John Hammond
12 Batch 86 Array Count
Batch 86 Array Count
John Hammond
13 Batch 87 Array Index
Batch 87 Array Index
John Hammond
14 Batch 88 Array Insert
Batch 88 Array Insert
John Hammond
15 Batch 89 Array Remove
Batch 89 Array Remove
John Hammond
16 Batch 90 Array Reverse
Batch 90 Array Reverse
John Hammond
17 Python [colorama] 00 Installing on Linux
Python [colorama] 00 Installing on Linux
John Hammond
18 Python [colorama] 09 Cursor Position
Python [colorama] 09 Cursor Position
John Hammond
19 Python [hashlib] 02 Algorithms
Python [hashlib] 02 Algorithms
John Hammond
20 Python 00 Installing IDLE on Linux
Python 00 Installing IDLE on Linux
John Hammond
21 Python [pygame] 11 Rectangular Collision Detection
Python [pygame] 11 Rectangular Collision Detection
John Hammond
22 Python [pygame] 12 Platforming Rectangular Collision Resolution
Python [pygame] 12 Platforming Rectangular Collision Resolution
John Hammond
23 Python [XML-RPC] 01 Research
Python [XML-RPC] 01 Research
John Hammond
24 Python [pyenchant] 03 Personal Word Lists
Python [pyenchant] 03 Personal Word Lists
John Hammond
25 FancyURLopener Authentication and User-Agent [urllib] 03
FancyURLopener Authentication and User-Agent [urllib] 03
John Hammond
26 Python 04: PEP8 Coding
Python 04: PEP8 Coding
John Hammond
27 Python Challenge! 17 COOKIES
Python Challenge! 17 COOKIES
John Hammond
28 Google CTF 2016: Ernst Echidna
Google CTF 2016: Ernst Echidna
John Hammond
29 Google CTF 2016: Spotted Quoll
Google CTF 2016: Spotted Quoll
John Hammond
30 Google CTF 2016: Can you Repo It?
Google CTF 2016: Can you Repo It?
John Hammond
31 Google CTF 2016: No Big Deal
Google CTF 2016: No Big Deal
John Hammond
32 Google CTF 2016: In Recorded Conversation
Google CTF 2016: In Recorded Conversation
John Hammond
33 Homemade CTF Challenge: 01 "Orchestra"
Homemade CTF Challenge: 01 "Orchestra"
John Hammond
34 Homemade CTF Challenge: 02 "Bae's Base"
Homemade CTF Challenge: 02 "Bae's Base"
John Hammond
35 Homemade CTF Challenge: 03 "Web Hunt"
Homemade CTF Challenge: 03 "Web Hunt"
John Hammond
36 Homemade CTF Challenge: 04 "UPX"
Homemade CTF Challenge: 04 "UPX"
John Hammond
37 Homemade CTF Challenge: 05 "The Assumption Song"
Homemade CTF Challenge: 05 "The Assumption Song"
John Hammond
38 Homemade CTF Challenge: 06 "A Brisk Stroll"
Homemade CTF Challenge: 06 "A Brisk Stroll"
John Hammond
39 Homemade CTF Challenge: 06 "I lost my password!"
Homemade CTF Challenge: 06 "I lost my password!"
John Hammond
40 web25 :: Mr. Robot : EKOPARTY CTF 2016
web25 :: Mr. Robot : EKOPARTY CTF 2016
John Hammond
41 web50 : RFC 7230 :: EKOPARTY CTF 2016
web50 : RFC 7230 :: EKOPARTY CTF 2016
John Hammond
42 misc50 : Hidden inside EKO :: EKOPARTY CTF 2016
misc50 : Hidden inside EKO :: EKOPARTY CTF 2016
John Hammond
43 Hack The Vote 2016 CTF: Sander's Fan Club [web100]
Hack The Vote 2016 CTF: Sander's Fan Club [web100]
John Hammond
44 Hack The Vote 2016 CTF Warpspeed [forensics150]
Hack The Vote 2016 CTF Warpspeed [forensics150]
John Hammond
45 Juniors CTF 2016 :: Black Suprematic Square
Juniors CTF 2016 :: Black Suprematic Square
John Hammond
46 Juniors CTF 2016 :: Six Strange Tales
Juniors CTF 2016 :: Six Strange Tales
John Hammond
47 Juniors CTF 2016 :: Lost Code
Juniors CTF 2016 :: Lost Code
John Hammond
48 Juniors CTF 2016 :: Here Goes!
Juniors CTF 2016 :: Here Goes!
John Hammond
49 Juniors CTF 2016 :: Southern Cross
Juniors CTF 2016 :: Southern Cross
John Hammond
50 Juniors CTF 2016 :: Clone Attack
Juniors CTF 2016 :: Clone Attack
John Hammond
51 Juniors CTF 2016 :: Dirty Repo
Juniors CTF 2016 :: Dirty Repo
John Hammond
52 Juniors CTF 2016 :: Hackers Blog
Juniors CTF 2016 :: Hackers Blog
John Hammond
53 Juniors CTF 2016 :: Voting!!!
Juniors CTF 2016 :: Voting!!!
John Hammond
54 Juniors CTF 2016 :: The Good, The Bad and The Junkman
Juniors CTF 2016 :: The Good, The Bad and The Junkman
John Hammond
55 Juniors CTF 2016 :: Stop Thief!
Juniors CTF 2016 :: Stop Thief!
John Hammond
56 Juniors CTF 2016 :: ROFL
Juniors CTF 2016 :: ROFL
John Hammond
57 Juniors CTF 2016 :: Restriced Area
Juniors CTF 2016 :: Restriced Area
John Hammond
58 Juniors CTF 2016 :: Oh SSH!
Juniors CTF 2016 :: Oh SSH!
John Hammond
59 HackCon CTF 2017 TRIVIA and BONUS Challenges
HackCon CTF 2017 TRIVIA and BONUS Challenges
John Hammond
60 HackCon CTF 2017 "Bacche" Challenges
HackCon CTF 2017 "Bacche" Challenges
John Hammond

This video teaches viewers how to exploit an explicit SQL injection vulnerability using Union Select statements and GROUP_CONCAT, and how to use developer tools to analyze network responses. The skills learned can be applied to real-world scenarios to identify and prevent SQL injection attacks.

Key Takeaways
  1. Try login with admin/admin
  2. Use single quote, double quote, comment, or hashtag to bypass terminating string
  3. Paste in 'admin - - 1=1' to gain access
  4. Retreat information from Hulk Hogan's profile
  5. Reproduce the login without using 'or 1=1'
  6. Hit copy/paste to retrieve flag
  7. Use developer tools to view response in network tab
  8. Reload page to resend post request
  9. View response in a better way
💡 The use of GROUP_CONCAT can be particularly effective in exploiting explicit SQL injection vulnerabilities, allowing attackers to combine multiple rows into one and retrieve sensitive data.

Related Reads

📰
Building Blue Watch: a tiny SIEM with a big attitude
Learn to build a tiny Security Information and Event Management (SIEM) system, a crucial tool for monitoring and analyzing security-related data.
Dev.to · Luna Meadows
📰
We launched Zalanx — security monitoring for lean SaaS teams
Learn how Zalanx provides security monitoring for lean SaaS teams and why it matters for their protection
Dev.to · Zalanx
📰
OSINT Framework Mimarisi: Dijital İzleri “Actionable Intelligence”a Dönüştürme Protokolleri
Learn how to convert digital footprints into actionable intelligence using OSINT framework architecture
Medium · Cybersecurity
📰
Trust After AI: Why the Physical World Needs a Verification Layer
Learn why AI necessitates a verification layer in the physical world to establish trust
Medium · Cybersecurity
Up next
OpenAI GPT 5 5 Cyber Just Got an Upgrade – Is it BETTER Than Mythos 5 ?
MaxonShire
Watch →