Python Web Hacking: Remote Code Execution | Natas: OverTheWire (Level 10)
Key Takeaways
Demonstrates a remote code execution vulnerability in a Natas challenge
Full Transcript
what's up everybody John Hammond here back at the nattis war game from over thewire uh just finished up on level 10 now uh was looks to be pretty similar to level 9 uh I went ahead and ran the script um so we can check out the URL what's in the page right here and let's actually view it it says for security reasons we now filter on certain characters uh and let's has another fine words containing a needle and a Hy stack uh same functionality we had seen in the previous level but we can take a look at the s code and see what they're doing since they say they're filtering on certain characters so let's add that to our URL just do the get request on that and as usual this is pretty gross but we can run tidy HTML on it um we can run the HTML de entiti entities and this BR or HTML Break Tag it's kind of annoying we can control h to find replace those V and let's replace them with nothing I'm going to hit control alt and enter here so they all go away cool so we've got the PHP code denoted here um and we can search for a key that's um determined whether or not um we have actually submitted a request or posted to this web page and it's testing that determining whether or not this key exists if needle if that form input was provided and if it doesn't equal an empty string if if it were actually provided from this previous conditional it'll test if prg match um looks like braces of uh Square braces containing a semicolon pipe symbol Amper sand all inside the key um so preg match is um Regular expressions and it's testing is there a match for anything in this regular expression set you can tell it's regular Expressions by the forward slash beginning and ending and in regular Expressions the square brace means anything within this character set so anything like a semicolon pipe symbol or Amper sand in this case will return a match and it's testing on the key that's provided so whatever we actually input and otherwise it will return out it'll display input contains an illegal character otherwise it'll go ahead and run the command like it had in the previous level actually run GP um we can view this in the web page if we wanted to let me fire that up here steal the URL open up Firefox and we are in nattis 10 so let me just copy and paste this password here okay great so if we had anything with a semicolon at the end it'll say oh this input contains an Legal character so we can't use those but that's okay because in the last video for natus 9 um we didn't end up using any of those characters the exploit quote un quote or the technique we ended up using was posting to this page and doing some command injection to say I want to grip for anything with the period because of regular expressions in the file uh the like nattis password file in this case we want nattis 11 now because we're on level 10 we want to advance to the next level and then we use a uh pound symbol or a hashtag to comment out the rest of the line so it didn't actually check out dictionary. text it would just only uh run grep and process through the password file for the next level so since the hashtag or that pound symbol is not in this illegal character list it's not in this regular expression Set uh we can run this exact same thing and we should still be able to you know get the next password so let's run that post command um run that function and let's see what's returned to us go ahead and print the content out I just changed URL to make sure it's actually interacting with the page keep in mind you may have to do that if you forgot to but output here is the password for the next level right that okay we're done awesome because all we did was just that little technique um grap for anything the period here um specify the file that we want ET Rus web pass notus 11 and then comment out the rest because since there wasn't any sanitization or any filtering done to really um what's being input into that GP command or into that like system call that shell command um we were able to just inject just like that same as the last level pretty easy pretty simple really just reusing that same exploit and now we're ready to move on let's go to uh natus 11 create a script for that I'm going to have to replace it because I already had some stuff that I was just experimenting with and now we can check out what this level is this is going to be a pretty big one pretty long video for uh natus 11 um so that's why I wanted to offset with a pretty short video here for natus 10 because it's really the same attack as the nus level 9 UM thanks for watching guys hope you're enjoying these I hope you're enjoying this video um if you do please like the video comment tell me what you think uh what more videos you want to see if you're willing to subscribe and thanks for watching guys hope you're enjoying these see you later
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Code Commentaries? PHP to JavaScript in Bash and PHP!
John Hammond
Tutorials? MySQL connection with PHP and Bash!
John Hammond
Variable Naming in Python! Happy Birthday, Linux! Nokia N900!
John Hammond
JavaScript Splits The URL!
John Hammond
HTML Tables in Python!
John Hammond
HTML, Net Shares, GML!
John Hammond
Python 08 Programming Style and Comments
John Hammond
Python 26 Object Oriented Programming
John Hammond
75 Python Tutorials, Out Now!
John Hammond
Batch 14 Mathematical Expressions
John Hammond
Batch 85 Array Append
John Hammond
Batch 86 Array Count
John Hammond
Batch 87 Array Index
John Hammond
Batch 88 Array Insert
John Hammond
Batch 89 Array Remove
John Hammond
Batch 90 Array Reverse
John Hammond
Python [colorama] 00 Installing on Linux
John Hammond
Python [colorama] 09 Cursor Position
John Hammond
Python [hashlib] 02 Algorithms
John Hammond
Python 00 Installing IDLE on Linux
John Hammond
Python [pygame] 11 Rectangular Collision Detection
John Hammond
Python [pygame] 12 Platforming Rectangular Collision Resolution
John Hammond
Python [XML-RPC] 01 Research
John Hammond
Python [pyenchant] 03 Personal Word Lists
John Hammond
FancyURLopener Authentication and User-Agent [urllib] 03
John Hammond
Python 04: PEP8 Coding
John Hammond
Python Challenge! 17 COOKIES
John Hammond
Google CTF 2016: Ernst Echidna
John Hammond
Google CTF 2016: Spotted Quoll
John Hammond
Google CTF 2016: Can you Repo It?
John Hammond
Google CTF 2016: No Big Deal
John Hammond
Google CTF 2016: In Recorded Conversation
John Hammond
Homemade CTF Challenge: 01 "Orchestra"
John Hammond
Homemade CTF Challenge: 02 "Bae's Base"
John Hammond
Homemade CTF Challenge: 03 "Web Hunt"
John Hammond
Homemade CTF Challenge: 04 "UPX"
John Hammond
Homemade CTF Challenge: 05 "The Assumption Song"
John Hammond
Homemade CTF Challenge: 06 "A Brisk Stroll"
John Hammond
Homemade CTF Challenge: 06 "I lost my password!"
John Hammond
web25 :: Mr. Robot : EKOPARTY CTF 2016
John Hammond
web50 : RFC 7230 :: EKOPARTY CTF 2016
John Hammond
misc50 : Hidden inside EKO :: EKOPARTY CTF 2016
John Hammond
Hack The Vote 2016 CTF: Sander's Fan Club [web100]
John Hammond
Hack The Vote 2016 CTF Warpspeed [forensics150]
John Hammond
Juniors CTF 2016 :: Black Suprematic Square
John Hammond
Juniors CTF 2016 :: Six Strange Tales
John Hammond
Juniors CTF 2016 :: Lost Code
John Hammond
Juniors CTF 2016 :: Here Goes!
John Hammond
Juniors CTF 2016 :: Southern Cross
John Hammond
Juniors CTF 2016 :: Clone Attack
John Hammond
Juniors CTF 2016 :: Dirty Repo
John Hammond
Juniors CTF 2016 :: Hackers Blog
John Hammond
Juniors CTF 2016 :: Voting!!!
John Hammond
Juniors CTF 2016 :: The Good, The Bad and The Junkman
John Hammond
Juniors CTF 2016 :: Stop Thief!
John Hammond
Juniors CTF 2016 :: ROFL
John Hammond
Juniors CTF 2016 :: Restriced Area
John Hammond
Juniors CTF 2016 :: Oh SSH!
John Hammond
HackCon CTF 2017 TRIVIA and BONUS Challenges
John Hammond
HackCon CTF 2017 "Bacche" Challenges
John Hammond
Related AI Lessons
⚡
⚡
⚡
⚡
Aflac Japan Data Breach Exposes 4.38 Million Policyholder Records
Dev.to · BeyondMachines
Autonomous Cyberattacks Are Coming And Our Defenses Were Built for a Different Era
Dev.to · Arashad Dodhiya
Security Belongs on the Blueprint
Medium · Cybersecurity
# A 4-Line HTML File Stole the Admin’s Secret — Intigriti LeakyJar CTF Writeup
Medium · Cybersecurity
🎓
Tutor Explanation
DeepCamp AI