Latest / CyberCode Academy / Course 8 - Penetration Testing OSINT Gathering with Recon-ng | Episode 2: Modules, Data Flow, Naming Structure, API Keys
Transcript
- 0:00Speaker 1: Welcome back to the deep dive. Today. We're going to
- 0:02Speaker 1: break down the whole idea of digital reconnaissance, right. I mean,
- 0:06Speaker 1: that's the systematic process of gathering intelligence on different infrastructure targets.
- 0:11Speaker 1: But we're not talking about just basic searches. We're diving
- 0:15Speaker 1: into the core structure the operational commands of a really
- 0:20Speaker 1: expert level tool for organized digital detective work.
- 0:24Speaker 2: That's the mission exactly. I mean, for anyone in cybersecurity
- 0:27Speaker 2: or even competitive intelligence, efficiency is everything.
- 0:30Speaker 1: It's the difference between success and just getting buried.
- 0:33Speaker 2: In data completely. When you're dealing with thousands of data points,
- 0:36Speaker 2: you need a system, right, You need to know how
- 0:38Speaker 2: the information flows. So our goal is to really understand
- 0:40Speaker 2: the system's blueprint, how data comes in, how it gets processed,
- 0:44Speaker 2: and you know why it's built this way.
- 0:47Speaker 1: Okay, so if efficiency is the goal, let's start with
- 0:50Speaker 1: the simplest thing. You're looking at a brand new module
- 0:51Speaker 1: in this system. How do you even know where to begin? Like?
- 0:54Speaker 1: What does it do? What data does it need?
- 0:57Speaker 2: It's a great question, and the first step is always
- 0:59Speaker 2: always it's self documentation.
- 1:02Speaker 1: Self documentation.
- 1:03Speaker 2: Yeah, once a module is loaded, you just run the
- 1:06Speaker 2: fundamental show info command. You can think of it like, well,
- 1:09Speaker 2: like the module's business card.
- 1:10Speaker 1: Okay.
- 1:11Speaker 2: It instantly tells you its purpose, what inputs it needs,
- 1:13Speaker 2: so which table it's pulling data from, and this is
- 1:16Speaker 2: key where its output is going to be written.
- 1:19Speaker 1: Let's make that concrete. You mentioned an example, the who
- 1:22Speaker 1: is PC harvester? What is that trying to do? And
- 1:26Speaker 1: I guess what does that name tell us?
- 1:28Speaker 2: Okay, so that module is a perfect example of how
- 1:30Speaker 2: the whole system is organized. Who is you know, the
- 1:33Speaker 2: standard Internet domain look up and PC just stands for
- 1:37Speaker 2: point of contact. So this module's job is literally to
- 1:41Speaker 2: harvest that official contact information. It uses the AI run
- 1:45Speaker 2: who's RWA.
- 1:46Speaker 1: AIRN being the American registry for Internet night exactly.
- 1:49Speaker 2: It uses their service to search all the official databases
- 1:53Speaker 2: for you know, owner details tied to your target domains.
- 1:56Speaker 1: So you're using an official channel to find the legal owner.
- 1:59Speaker 1: And once you find that info, where does it go?
- 2:01Speaker 2: This is the important part. Any results that come back, names, emails, addresses,
- 2:07Speaker 2: they are automatically written to the framework's internal contacts database table,
- 2:12Speaker 2: and this is where you see the logic of the system.
- 2:14Speaker 2: The name of the data it gathers contacts matches the
- 2:16Speaker 2: name of the data base table. It feeds that consistency
- 2:20Speaker 2: is everything.
- 2:21Speaker 1: I'm with you, so show infoe tells is the job.
- 2:24Speaker 1: The name gives us a big hint about the tables
- 2:26Speaker 1: and the input. It usually comes from the domains table.
- 2:29Speaker 2: To start, right, it does that table holds your initial
- 2:33Speaker 2: targets your starting point. But and this is powerful, you're
- 2:37Speaker 2: not stuck with that. You can substitute that input. You
- 2:41Speaker 2: could point the module to a local file you have saved,
- 2:43Speaker 2: or if you want to be really surgical about it,
- 2:46Speaker 2: you can use standard SQL syntax right in the run
- 2:48Speaker 2: command to select just a specific subset of values from
- 2:52Speaker 2: your database.
- 2:52Speaker 1: Wow, that surgical control is huge. It means I don't
- 2:55Speaker 1: have to scan all, say a thousand domains every single time.
- 2:59Speaker 1: I can just pull the ones I need for this
- 3:00Speaker 1: specific task precisely.
- 3:02Speaker 2: And that leads us right into this idea of a
- 3:06Speaker 2: data chain reaction. You're never really running these things in isolation.
- 3:10Speaker 2: The output of one step becomes the essential input for
- 3:13Speaker 2: the next one.
- 3:13Speaker 1: So if the contact details are the who we now
- 3:16Speaker 1: need to wear, so how do we pivot from people
- 3:20Speaker 1: to scanning the actual infrastructure for files?
- 3:23Speaker 2: We pivot from the contacts table to the host table.
- 3:27Speaker 2: Let's take a look at the interesting files module. Okay,
- 3:30Speaker 2: its whole purpose is to search a website for developer
- 3:32Speaker 2: file paths, you know, things like sitemap, dot xml, canfig files,
- 3:36Speaker 2: maybe your references to an admin console. It's pretty clever.
- 3:38Speaker 2: It even uses Google dorks to find hints in paid URLs.
- 3:42Speaker 1: It sounds incredibly useful. But there's a problem, isn't there.
- 3:45Speaker 1: It won't run if you've only populated the domain table.
- 3:48Speaker 2: That is the catch. It requires the host table to
- 3:50Speaker 2: be populated. If the domains table is like the front door,
- 3:53Speaker 2: you know it holds BBC dot com, then the host
- 3:55Speaker 2: table is the guest list for the party.
- 3:57Speaker 1: Inside the subdomains like admin dot BBC dot com or
- 4:01Speaker 1: dev dot BBC.
- 4:02Speaker 2: Dot com exactly. And if that host table is empty,
- 4:05Speaker 2: the interesting files module is basically blind. It has nowhere
- 4:09Speaker 2: to look.
- 4:09Speaker 1: So we need an extra step in between. We have
- 4:12Speaker 1: to populate that host's list first. What's a quick way
- 4:15Speaker 1: to do that?
- 4:16Speaker 2: You'd use another recon module, something like the Google Site
- 4:19Speaker 2: web module. It show info tells you it only needs
- 4:22Speaker 2: an entry in that basic domains table. You run it
- 4:25Speaker 2: and it just crawls the main domain for all the
- 4:27Speaker 2: subdomains that can find.
- 4:29Speaker 1: And this is where things can get a little interactive
- 4:31Speaker 1: because the system we're hitting might realize what we're doing.
- 4:34Speaker 2: That's very true. Because you're acting like a really fast,
- 4:37Speaker 2: sophisticated bot. You might get hit with Captccha.
- 4:41Speaker 1: Challenge, so you have to prove you're not a robot.
- 4:43Speaker 2: Yeah, it's a little humbling, right, this powerful system, and
- 4:47Speaker 2: you still have to type in some squiggly letters, but
- 4:49Speaker 2: the framework is built for that. It'll pause, let you
- 4:52Speaker 2: enter the text, and then it just continues right where
- 4:54Speaker 2: it left off.
- 4:55Speaker 1: So once that scan is done, we run show hosts
- 4:58Speaker 1: and boom, there's our list subdomains. Now the host stable
- 5:02Speaker 1: is full and we can finally run interesting files. What
- 5:05Speaker 1: happens to the files it actually finds.
- 5:08Speaker 2: So the file names themselves get printed right to your console.
- 5:11Speaker 2: But the system is smarter than that. It actually saves
- 5:14Speaker 2: the files themselves.
- 5:15Speaker 1: Oh, it downloads them.
- 5:16Speaker 2: It downloads and stores them right on your local system
- 5:18Speaker 2: in a directory that's usually named after your current workspace.
- 5:21Speaker 2: And that's critical because your real job then is to
- 5:24Speaker 2: actually analyze the contents of those files for potential vulnerabilities.
- 5:29Speaker 1: Okay, here's where it gets really interesting for me, this
- 5:32Speaker 1: ability to slice and dice data with SQL. When these
- 5:37Speaker 1: tables get huge, why would I use the framework's native
- 5:41Speaker 1: query command instead of just, you know, exporting the data
- 5:44Speaker 1: and using my own database tools.
- 5:45Speaker 2: That's a great question, and it all comes back to efficiency.
- 5:49Speaker 2: Raw data exports can be just overwhelming. The framework gives
- 5:54Speaker 2: you the query command so you can use standard SQL
- 5:57Speaker 2: syntax inside the environment. It stops you from having to
- 5:59Speaker 2: constantly switch contexts.
- 6:01Speaker 1: Did you give us a practical example of that.
- 6:03Speaker 2: Sure? Imagine your context table is just massive, thousands of
- 6:07Speaker 2: email addresses from all over. You can use the query
- 6:10Speaker 2: command to say, select everything from that table where the
- 6:13Speaker 2: email column includes a specific word like Bootstrap for instance.
- 6:17Speaker 2: And just like that, and just like that, you've cut
- 6:20Speaker 2: a huge data set down to only the records that
- 6:23Speaker 2: matter for the next step of your assessment.
- 6:25Speaker 1: That is significant. Okay, let's switch gears a bit. What
- 6:28Speaker 1: about configuring modules that don't need a database input? Some
- 6:32Speaker 1: of them need custom values.
- 6:33Speaker 2: Right absolutely. A good one is the bing LinkedIn cash module.
- 6:37Speaker 2: It queries the bing API to find LinkedIn pages related
- 6:40Speaker 2: to a company. Okay, it needs two custom values that
- 6:44Speaker 2: aren't in a database, a limit to control how many
- 6:47Speaker 2: pages it pulls, and subdomains to narrow the search down
- 6:50Speaker 2: to say, specific departments for countries.
- 6:53Speaker 1: And we adjust those with the set command.
- 6:54Speaker 2: Correct, you'd use set limit one hundred or set subdomains
- 6:57Speaker 2: followed by a comma separated list, and if you make
- 7:00Speaker 2: a mistake unset as your friend, it just deletes the
- 7:02Speaker 2: variables value. This is how you find tune an investigation.
- 7:06Speaker 1: Let's circle back to that architectural insight you mentioned earlier,
- 7:09Speaker 1: because I think it's probably the most strategic thing to
- 7:11Speaker 1: take away from this. The way the modules themselves are organized.
- 7:15Speaker 2: Right, So the biggest category is reconnaissance, and that's subdivided
- 7:18Speaker 2: into these logical groups companies, contacts, domains, hosts, and so on.
- 7:23Speaker 1: And the core idea is the.
- 7:25Speaker 2: Core idea is that the group name almost always matches
- 7:28Speaker 2: the name of a database table.
- 7:30Speaker 1: It's an internal map for how the system works.
- 7:32Speaker 2: It's exactly that a module inside a group is designed
- 7:36Speaker 2: to do one of two things. Either processed data that's
- 7:39Speaker 2: already in that specific table, or go out and gather
- 7:43Speaker 2: new information for that table.
- 7:45Speaker 1: So, for example, domains, hosts modules.
- 7:47Speaker 2: Those are all about crawling infrastructure to find active host names,
- 7:51Speaker 2: and they all write that information directly to the host's
- 7:54Speaker 2: table and.
- 7:54Speaker 1: The way around a module under the contacts group, like
- 7:58Speaker 1: one that checks against have I been pound?
- 8:00Speaker 2: That kind of module takes the email addresses that are
- 8:02Speaker 2: already in your contact table and processes them to see
- 8:05Speaker 2: if they've shown up in any known data breaches. Once
- 8:09Speaker 2: you get that structure, all the guesswork is gone. You
- 8:12Speaker 2: know exactly how to build your plan.
- 8:14Speaker 1: It really is a blueprint, okay. So to make that
- 8:16Speaker 1: plan easier to execute, we have TUK automation. Some of
- 8:19Speaker 1: the best scans need external authentication, like API keys. How
- 8:25Speaker 1: do we get that key registered in the system.
- 8:27Speaker 2: It's pretty straightforward. You use the command keys ad, then
- 8:31Speaker 2: the name of the API, and then the key itself.
- 8:33Speaker 2: And if you're not sure of the exact API name,
- 8:36Speaker 2: just type show keys. It'll list them all and confirm
- 8:39Speaker 2: which ones you've already added.
- 8:40Speaker 1: Okay, so once the key is in the module can
- 8:43Speaker 1: use those external services.
- 8:44Speaker 2: Correct, It's authenticated and ready to go.
- 8:46Speaker 1: Now, since security assessments are something you should run over
- 8:49Speaker 1: and over, doing it all by hand is just not realistic, so.
- 8:53Speaker 2: Scripting automation is absolutely essential. Yeah, you can record an
- 8:57Speaker 2: entire session using the record start command and just give
- 9:00Speaker 2: it a file.
- 9:00Speaker 1: Location, and then everything you do is saved.
- 9:03Speaker 2: Everything setting the workspace, adding domains, running all your modules,
- 9:07Speaker 2: it all gets saved in order as simple text commands
- 9:10Speaker 2: in that script file.
- 9:11Speaker 1: So down the road, I don't even have to open
- 9:12Speaker 1: up a live session, I can just run the script.
- 9:15Speaker 2: That's the beauty of it. You run the script from
- 9:17Speaker 2: outside the framework using thy Hassar flag, point it to
- 9:20Speaker 2: your file, and the system just executes all those commands automatically.
- 9:24Speaker 2: You can repeat a full assessment instantly.
- 9:26Speaker 1: And one last thing, we need a record, an audit
- 9:29Speaker 1: trail of not just what we typed, but all the
- 9:32Speaker 1: data that came back.
- 9:34Speaker 2: For that, you use the spool command. Spool start records
- 9:37Speaker 2: everything that happens in a session, the commands, the output,
- 9:40Speaker 2: the data that's returned. It creates a perfect verifiable record
- 9:44Speaker 2: for compliance or just for your own notes later on.
- 9:46Speaker 1: Okay, So to wrap this all up, the key takeaways
- 9:48Speaker 1: are using show info for instant documentation, the power of
- 9:53Speaker 1: filtering with the sql query command, that crucial chain reaction
- 9:56Speaker 1: between the domains and host tables, and of course that
- 10:00Speaker 1: and the logic in the module naming that just simplifies everything.
- 10:03Speaker 2: You've got it. And just to leave you with a
- 10:04Speaker 2: quick thought exercise based on that naming convention, go for it.
- 10:08Speaker 2: Imagine you're starting an assessment and all you have is
- 10:10Speaker 2: the name of a company what three specific module categories
- 10:14Speaker 2: you know, companies, hosts, domains, et cetera. Would you run
- 10:18Speaker 2: in sequence to end up with a solid list of
- 10:20Speaker 2: IP addresses that company controls? Really think about how the
- 10:24Speaker 2: output of one table has to become the input for
- 10:26Speaker 2: the next.
- 10:27Speaker 1: A great challenge to really make sure you understand that
- 10:29Speaker 1: data flow and understanding these structured processes is just fundamental
- 10:33Speaker 1: whether your focus is on vulnerability testing or even competitive intelligence.
- 10:38Speaker 1: Thanks for joining us for this deep dive.