Latest / CyberCode Academy / Course 3 - Mastering Nuclei for Bug Bounty | Episode 4: Headers, Body, Raw Requests, and Response Matching
Transcript
- 0:00Speaker 1: You know, most of the time when we were online,
- 0:02Speaker 1: our browser just handles everything right. It sends requests, gets responses.
- 0:06Speaker 1: It's all very neat and tidy.
- 0:07Speaker 2: Yeah, it does all the heavy lifting behind the scenes
- 0:09Speaker 2: politeness protocol almost exactly.
- 0:12Speaker 1: But when you get into things like cybersecurity or building
- 0:16Speaker 1: complex applications, sometimes you need to well through politeness out
- 0:21Speaker 1: the window. You need direct.
- 0:22Speaker 2: Control absolutely relying on the standard browser stuff is it's
- 0:27Speaker 2: often not precise enough. Today, we're really going to dig
- 0:30Speaker 2: into how you can build exactly the network requests you
- 0:33Speaker 2: need using automation tools or bucking granular control.
- 0:37Speaker 1: Okay, so the mission today is to break down what
- 0:39Speaker 1: three main things, how to craft the request content headers
- 0:42Speaker 1: and body.
- 0:43Speaker 2: Right, and how to get like total control over the
- 0:45Speaker 2: request format itself, even if it's a bit weird.
- 0:48Speaker 1: Uh huh. And finally, how do you actually checked if
- 0:51Speaker 1: your specific custom built request even worked? How do you
- 0:54Speaker 1: know you got the response you want.
- 0:56Speaker 2: Exactly defining those success conditions?
- 0:58Speaker 1: Okay, great, let's unpack this. Do we start? How about
- 1:01Speaker 1: those little bits of metadata they go with every request?
- 1:04Speaker 2: The headers good place to start. Headers are basically like
- 1:08Speaker 2: instructions and ID for your request. They're usually key value pairs.
- 1:13Speaker 1: You know, key simple enough, but you're saying changing these
- 1:16Speaker 1: is where the power lies.
- 1:18Speaker 2: Oh absolutely, yeah. It's crucial for testing how systems react
- 1:21Speaker 2: to let's say unexpected or specific conditions.
- 1:24Speaker 1: Right Like, you could change the user agent string make
- 1:27Speaker 1: it look like you're coming from a different browser device.
- 1:30Speaker 2: Yep, that's a common one. Or you can get more
- 1:31Speaker 2: technical like setting cash control to no transform.
- 1:34Speaker 1: No transform or what does that do?
- 1:37Speaker 2: It tells the server and anything in between like proxies, Hey,
- 1:40Speaker 2: don't mess with this response, give it to me exactly
- 1:42Speaker 2: as is super important if you're trying to make sure
- 1:45Speaker 2: you're not getting old cached data, especially when testing vulnerabilities.
- 1:49Speaker 1: Okay, I see, But then there are these more specialized ones.
- 1:52Speaker 1: I saw an example about injecting something called x forwarded
- 1:55Speaker 1: host with a value like htify dot in ah.
- 1:58Speaker 2: Yes, really interesting. See. Lots of web apps sit behind
- 2:02Speaker 2: things like load balancers or reverse proxies, and they often
- 2:06Speaker 2: trust headers like exported host to know what the original
- 2:10Speaker 2: domain name the user asked for was.
- 2:12Speaker 1: So if you can change that header, you might.
- 2:14Speaker 2: Be able to fool the back end server into thinking
- 2:16Speaker 2: it's serving content for a completely different site, maybe bypass
- 2:19Speaker 2: some security rules, access internal stuff. It's all about exploiting
- 2:23Speaker 2: that trust in the header.
- 2:24Speaker 1: Wow. Okay, so it's not just data. You're messing with
- 2:27Speaker 1: the server's sense of identity. And you can just make
- 2:30Speaker 1: up headers too, like test heeader dot Hello World.
- 2:33Speaker 2: Totally. These tools give you that freedom. If you need
- 2:36Speaker 2: a custom header for some specific test, you just define it.
- 2:40Speaker 2: Complete control over the metadata.
- 2:41Speaker 1: Okay, so that's a metadata sorted. What about the actual
- 2:44Speaker 1: stuff we're sending the request body?
- 2:48Speaker 2: Right? The body that's where your actual data goes, could
- 2:50Speaker 2: be anything really search terms, log in details, file uploads,
- 2:53Speaker 2: jason data for an API.
- 2:55Speaker 1: And structurally, is it similar to headers often?
- 2:58Speaker 2: Yeah? Yeah, inside the body section of your template you
- 3:01Speaker 2: might use that same key value idea, Like a simple
- 3:03Speaker 2: search query could just be search Apple in the body.
- 3:06Speaker 1: Seems straightforward, But I guess controlling this precisely is where
- 3:09Speaker 1: a lot of classic web vulnerabilities come in. SQL injection,
- 3:13Speaker 1: cross sit scripting exactly. That.
- 3:15Speaker 2: Being able to send very specific, maybe even malformed data
- 3:20Speaker 2: in the body is fundamental for testing input validation. Are
- 3:24Speaker 2: they handling weird characters correctly? What about really long inputs?
- 3:29Speaker 1: Makes sense? And there was another detail about cookies keeping
- 3:33Speaker 1: sessions alive.
- 3:34Speaker 2: Ah, yeah, that's important. Good automation tools let you specify
- 3:39Speaker 2: that you want to reuse cookies from previous requests. So
- 3:43Speaker 2: your template isn't just firing off isolated, anonymous requests.
- 3:46Speaker 1: It's acting like a logged in user maintaining.
- 3:48Speaker 2: A session precisely, which means you can test functionality that's
- 3:51Speaker 2: only available after log in, or interactions that happen over
- 3:55Speaker 2: multiple steps. That's often where the more critical vulnerabilities hide.
- 3:58Speaker 1: That really is a game to it moves beyond simple
- 4:01Speaker 1: pings to simulating actual user journeys.
- 4:04Speaker 2: It does, but sometimes yea, even with all this control
- 4:07Speaker 2: over headers and the body in separate blocks, it's still
- 4:10Speaker 2: not quite enough. The structure itself can be limiting. Okay,
- 4:13Speaker 2: so what's next, Well, that brings us to using raw
- 4:16Speaker 2: requests raw requests.
- 4:17Speaker 1: What's the difference compared to defining headers and bodies separately.
- 4:21Speaker 2: Think about when you use a network sniffer tool or
- 4:23Speaker 2: look in your browser's developer console. You see the exact
- 4:27Speaker 2: text of the HTTP request right line by lene.
- 4:30Speaker 1: The method, the path, the headers, then the body.
- 4:33Speaker 2: That's a raw request. And these automation tools let you
- 4:36Speaker 2: define your request using that exact format. You just paste
- 4:40Speaker 2: or type the whole thing in from get path HGTP
- 4:43Speaker 2: one point one all the way down. You bypass the
- 4:46Speaker 2: structured header body blocks entirely.
- 4:48Speaker 1: I get it. So total control over every single character,
- 4:51Speaker 1: every line break.
- 4:52Speaker 2: Exactly if you need to use an uncommon HTTP method
- 4:55Speaker 2: like patch, or maybe the order of headers matters for
- 4:58Speaker 2: some weird edge case, the raw format gives you that
- 5:00Speaker 2: absolute text level control.
- 5:02Speaker 1: Can you give an example?
- 5:03Speaker 2: Sure, you could have a raw block that looks like,
- 5:05Speaker 2: uh post post HGTP one point one, exem, what's that
- 5:08Speaker 2: application XWWW, do form, actors, Y CSS search.
- 5:12Speaker 1: Apple all in one block method hosts standard header's custom
- 5:16Speaker 1: header body that the tool just sends that text directly.
- 5:19Speaker 2: Okay, that's flexible. But then there's another level, something called
- 5:23Speaker 2: unsafe raw requests That sounds potentially risky.
- 5:29Speaker 1: Yeah, risky in a good way if you're testing security.
- 5:33Speaker 1: This is where things get really really interesting. You enable
- 5:36Speaker 1: it with a simple flag like unsafe true.
- 5:40Speaker 2: And what does unsafe actually let you do? That regular
- 5:42Speaker 2: raw doesn't.
- 5:43Speaker 1: Okay, So standard tools, browsers, network libraries, they generally try
- 5:49Speaker 1: to follow the rules of HTTP. They make sure requests
- 5:52Speaker 1: are well formed. Unsafe mode tells the tool forget the rules,
- 5:56Speaker 1: send exactly what I type, even if it's technically broken broken?
- 5:58Speaker 2: Why would you want to send a broken request? Wouldn't
- 6:00Speaker 2: server just reject it?
- 6:02Speaker 1: Sometimes rejection is the goal, or rather seeing how it
- 6:04Speaker 1: rejects it. But more often you're trying to send something
- 6:06Speaker 1: subtly malformed to confuse the server, or maybe a proxy
- 6:10Speaker 1: server sitting in.
- 6:10Speaker 2: Front of it confuse it. How you mentioned things like
- 6:13Speaker 2: CRF injection HTTP request smuggling. Those sound pretty advanced.
- 6:18Speaker 1: They are. Take request smuggling. The whole idea there is
- 6:21Speaker 1: to craft a request that one server, like a front
- 6:23Speaker 1: end proxy, interprets differently than another server the back end application.
- 6:28Speaker 1: You create ambiguity about where one request ends and the
- 6:31Speaker 1: next begins. How often by playing with content length and
- 6:34Speaker 1: transfer encoding headers in ways that vitolate the HTTP spec,
- 6:38Speaker 1: or by injecting extra CRF sequences. That's carriage return line
- 6:42Speaker 1: feed the characters that normally separate lines in HTTP AH.
- 6:45Speaker 2: So CRF injection lets you add those line breaks where
- 6:48Speaker 2: they shouldn't fit exactly.
- 6:49Speaker 1: A normal HTTP client wouldn't let you do that within
- 6:52Speaker 1: header values or things like that but unsafe, true says,
- 6:56Speaker 1: go ahead, break the rules. You send this deliberately flawed request.
- 7:00Speaker 2: Not necessarily looking for a nice two hundred OK response.
- 7:03Speaker 1: Often no, you might be looking for a four hundred
- 7:06Speaker 1: bad request, or maybe the server leads an internal error message,
- 7:09Speaker 1: or maybe your smuggled second request gets processed unexpectedly. The
- 7:13Speaker 1: weird response is your proof that the server was vulnerable
- 7:16Speaker 1: to that kind of malformed input.
- 7:18Speaker 2: Okay, that makes sense. You're proving a vulnerability by causing
- 7:22Speaker 2: an unexpected, often erroneous behavior. So once you've sent your
- 7:27Speaker 2: incredibly specific, even deliberately broken request, how do you actually
- 7:33Speaker 2: confirm success? That brings us to the verification part? Right,
- 7:37Speaker 2: Response matches spot on.
- 7:39Speaker 1: You've done all this work crafting the perfect input. Now
- 7:42Speaker 1: you need to tell the tool exactly what a successful
- 7:45Speaker 1: response looks like for this specific test. That's what response
- 7:48Speaker 1: matchers do.
- 7:49Speaker 2: So they're like a set of rules.
- 7:51Speaker 1: Pretty much a rules engine for the response. You define
- 7:53Speaker 1: conditions that must be met in the server's reply, and
- 7:56Speaker 1: you can usually link them together, typically with and agologic,
- 7:59Speaker 1: meaning all your specified conditions have to pass for the
- 8:02Speaker 1: test to be marked successful.
- 8:03Speaker 2: What's the most basic condition?
- 8:05Speaker 1: Almost always the HTTP status code matching two hundred ok
- 8:08Speaker 1: is the classic sign of success for many tests.
- 8:11Speaker 2: But not always. As you said with the unsafe requests,
- 8:14Speaker 2: success might be a four hundred or four h three.
- 8:16Speaker 1: Sometimes absolutely If your testing, say whether you can trigger
- 8:19Speaker 1: a specific error condition that indicates a flaw, then matching
- 8:23Speaker 1: that specific error code, maybe like a five hundred internal
- 8:26Speaker 1: server error, is your success condition for that test.
- 8:30Speaker 2: Right. What about looking inside the response checking the actual content.
- 8:35Speaker 2: Let's start with the body.
- 8:36Speaker 1: Yeah, Matching content in the response body is super common.
- 8:40Speaker 1: You might be looking for a specific piece of text
- 8:42Speaker 1: that confirms an action worked, or maybe an error message disappeared,
- 8:46Speaker 1: or perhaps data you submitted is now reflected on the page.
- 8:49Speaker 2: So maybe you send a request to some test page
- 8:54Speaker 2: like test endpoint dot php.
- 8:56Speaker 1: Right, maybe you sent search banana in the request body, and.
- 8:59Speaker 2: Then you set up a match that says success status
- 9:01Speaker 2: code is two hundred a D and the word banana
- 9:04Speaker 2: appears in the response.
- 9:05Speaker 1: Body exactly that That combination makes it pretty unambiguous that
- 9:09Speaker 1: your input was processed and reflect it correctly.
- 9:11Speaker 2: Okay, that handles visible content, But sometimes the important clues
- 9:15Speaker 2: aren't in the main body, right, They might be hidden
- 9:17Speaker 2: away in the response headers. Definitely.
- 9:19Speaker 1: Sometimes servers leak sensitive information, version numbers, internal state details,
- 9:25Speaker 1: or custom flags in the response headers, not in the
- 9:28Speaker 1: htm a body itself.
- 9:29Speaker 2: So how do you check there?
- 9:30Speaker 1: It's usually quite straightforward. In the match or definition. Instead
- 9:33Speaker 1: of telling it to look for your word or pattern
- 9:35Speaker 1: in the body, you specify header.
- 9:38Speaker 2: Ah. Okay, So you could have a rule like find
- 9:40Speaker 2: the word secret flag, but only look within the response.
- 9:44Speaker 1: Headers precisely, or even better, you might look for a
- 9:47Speaker 1: specific header name existing or a specific header having a
- 9:50Speaker 1: specific value.
- 9:52Speaker 2: Like in one of the examples, success was defined as
- 9:55Speaker 2: finding the word apple, but specifically inside a header named
- 9:59Speaker 2: new header.
- 9:59Speaker 1: Yep, that's a perfect example. So the rule would be
- 10:02Speaker 1: status code is two hundred type and the word apple
- 10:05Speaker 1: exists and d its location is the header section, potentially
- 10:08Speaker 1: even pinpointing the new header.
- 10:10Speaker 2: Wow, that level of precision is impressive. You're really nailing
- 10:13Speaker 2: down exactly what constitutes success for very specific scenarios.
- 10:17Speaker 1: That's the goal. It moves you beyond just generic stanning
- 10:20Speaker 1: to highly targeted, a hypothesis driven testing.
- 10:23Speaker 2: Okay, so let's try and pull this all together for
- 10:24Speaker 2: everyone listening. We've basically covered three core pillars for taking
- 10:29Speaker 2: real control over network traffic, especially for testing. First, crafting
- 10:35Speaker 2: those precise inputs, customizing headers to manipulate how the server
- 10:39Speaker 2: sees you and what rules it applies.
- 10:42Speaker 1: And crafting the body payload for targeted data submission or
- 10:45Speaker 1: injection attempts right.
- 10:46Speaker 2: Second, achieving that absolute structural control with raw requests letting
- 10:51Speaker 2: you define every byte.
- 10:52Speaker 1: And especially using the unsafe mode to deliberately break protocol
- 10:55Speaker 1: rules for advanced vulnerability testing like smuggling or injection.
- 10:59Speaker 2: And third, setting crystal clear verification rules with response matchers
- 11:04Speaker 2: checking status codes yes, but also looking for specific content
- 11:07Speaker 2: in either.
- 11:07Speaker 1: The response body or hidden away in the response setters,
- 11:10Speaker 1: and combining these conditions logically.
- 11:12Speaker 2: So what's the big takeaway here? Why is mastering these
- 11:15Speaker 2: building blocks so important?
- 11:16Speaker 1: Well, look, understanding this stuff, how to build requests, how
- 11:21Speaker 1: to break them, and how to verify the outcome it
- 11:24Speaker 1: lets you move way beyond just clicking buttons and standard tools.
- 11:27Speaker 1: You can start to model really complex targeted interactions.
- 11:30Speaker 2: Which is key for finding those harder to.
- 11:32Speaker 1: Reach bugs exactly for advanced bug hunting security analysis, but
- 11:38Speaker 1: also honestly for writing better, more defensive code yourself. If
- 11:42Speaker 1: you understand how these precise attacks work, you can build
- 11:44Speaker 1: applications that are much more resilient to them. Knowledge is power,
- 11:48Speaker 1: but applied knowledge is where the value is.
- 11:50Speaker 2: That's a great point. Build better by knowing how things break. Okay,
- 11:54Speaker 2: let's wrap up with a little exercise for you the
- 11:56Speaker 2: listener to think about. Imagine you need to find a
- 11:58Speaker 2: vulnerability where the goal is to confuse a server about
- 12:01Speaker 2: where a request actually came from. Maybe you want to
- 12:04Speaker 2: bypass a geographic restriction or trick it into thinking the
- 12:08Speaker 2: request originated internally. Which specific part of the custom request
- 12:13Speaker 2: based on what we discussed today, would you absolutely need
- 12:15Speaker 2: to modify or inject and maybe think about why a
- 12:19Speaker 2: server might even trust the value you provide in that
- 12:21Speaker 2: part of the request. What assumption is being exploited?
- 12:25Speaker 1: Good one think about how trust works in HTTP headers?
- 12:28Speaker 1: Where does the server get its information about the original client?
- 12:31Speaker 2: Definitely something to mull over. Thanks for that deep dive.
- 12:34Speaker 2: That was fascinating my pleasure.
- 12:35Speaker 1: It's fundamental stuff, but incredibly powerful once you grasp it.