Latest / CyberSecurity Summary / Cybersecurity Ops with bash: Attack, Defend, and Analyze from the Command Line
Transcript
- 0:00Speaker 1: Welcome back to the deep dive. We're your shortcut to
- 0:03Speaker 1: getting well, incredibly well informed without feeling totally overwhelmed.
- 0:08Speaker 2: Yeah, there's a lot out there.
- 0:09Speaker 1: There really is. So today we're diving into something powerful,
- 0:13Speaker 1: maybe a bit underestimated, a kind of secret weapon that's
- 0:16Speaker 1: actually been part of computing for decades. Foundational really exactly,
- 0:21Speaker 1: but it's becoming super critical now in cybersecurity. Okay, let's
- 0:25Speaker 1: unpack this. We are talking about cybersecurity operations, but maybe
- 0:30Speaker 1: not with the fancy, expensive tools you might think of. First,
- 0:32Speaker 1: we're talking about the command line.
- 0:34Speaker 2: Ah, yes, good old command line, specifically the Bash Shehell.
- 0:39Speaker 1: Our guide for this is a really practical book, Cybersecurity
- 0:42Speaker 1: Ops with Bash, Attack, Defend and Analyze from the command
- 0:46Speaker 1: Line by Paul Truncone and Carl Alvin. Great resource, totally,
- 0:50Speaker 1: and our mission today is to give you a shortcut
- 0:52Speaker 1: a way to see how Bash isn't just you know,
- 0:54Speaker 1: for developers coding away or cised men's managing servers. It's
- 0:58Speaker 1: this incredibly flexible multi tool anyone interested in computer security,
- 1:02Speaker 1: whether you're on the offense probing systems or on defense
- 1:05Speaker 1: building walls, attack or defend. Yeah, and the cool thing
- 1:08Speaker 1: is the techniques work, whether you're on Linux, mac Os,
- 1:12Speaker 1: even Windows these days.
- 1:13Speaker 2: And what's truly fascinating here, I think is just how
- 1:16Speaker 2: fundamental the command line is. I mean, most of us, right,
- 1:19Speaker 2: we spend our time clicking around in graphical interfaces. Guisappoint
- 1:24Speaker 2: click and they're great, super easy to use, no doubt,
- 1:27Speaker 2: but that ease it often costs you something speed, maybe flexibility,
- 1:32Speaker 2: and you definitely get distanced from what the system is
- 1:35Speaker 2: actually doing.
- 1:36Speaker 1: Underneath, like a layer of abstraction exactly.
- 1:38Speaker 2: GUIs are like that nice dashboard in your car. Looks good,
- 1:41Speaker 2: tells you the basics, but the command line that's like
- 1:44Speaker 2: lifting the hood. You're right there with the engine.
- 1:46Speaker 1: Okay. I like that analogy, and this.
- 1:48Speaker 2: Deep dive hopefully will kind of reconnect you to that
- 1:51Speaker 2: raw power, show you that Bash is this direct, super
- 1:55Speaker 2: efficient way to tap into everything your operating system can do.
- 1:58Speaker 1: Getting under the hood. I like, yeah, So, okay, why
- 2:01Speaker 1: Bash specifically for cybersecurity? It still feels a bit basic.
- 2:07Speaker 2: Well, it's basic in the best sense, you know, it's foundational.
- 2:11Speaker 2: It's universal. Bash started in the Unix and Linux world obviously,
- 2:15Speaker 2: but it's just everywhere now. It's standard on macOS, and
- 2:18Speaker 2: you can get it really easily on Windows is get
- 2:20Speaker 2: Bash seguine or the Window subsystem for Linux WSL WSL. Yeah,
- 2:26Speaker 2: which means the stuff we talk about today. These aren't
- 2:29Speaker 2: niche skills. They are incredibly transferable. You learn the stuff once,
- 2:33Speaker 2: you can probably use it almost any way you might
- 2:35Speaker 2: need to secure a system or figure out what.
- 2:37Speaker 1: Happened on one. Okay, So it's like the ultimate cross
- 2:40Speaker 1: platform utility belt for security folks pretty much. But to
- 2:43Speaker 1: really use that belt effectively, especially for tricky security tasks,
- 2:47Speaker 1: we probably need to nail down some and core ideas first.
- 2:50Speaker 1: What are the essential bits of Bash that make it
- 2:53Speaker 1: so good for this?
- 2:54Speaker 2: Yeah, definitely if we connect this to the bigger picture,
- 2:58Speaker 2: the real power often comes from how Bash handles data,
- 3:02Speaker 2: how it moves information around data streams exactly. Every program
- 3:06Speaker 2: fundamentally has like three channels, one for input coming in stin,
- 3:10Speaker 2: one for normal output going out strout, and one for
- 3:13Speaker 2: error messages.
- 3:14Speaker 1: Sure, okay, in out and oops.
- 3:16Speaker 2: Yeah basically. But the magic and where Bash really shines
- 3:20Speaker 2: for security work is redirection and piping.
- 3:23Speaker 1: Right.
- 3:23Speaker 2: This is what lets you chain simple commands together to
- 3:26Speaker 2: build surprisingly powerful custom tools like right on the spot.
- 3:30Speaker 1: So redirection is sending stuff places.
- 3:32Speaker 2: Yep. You can send the normal output of a command
- 3:35Speaker 2: straight into a file maybe command results dot out, or
- 3:38Speaker 2: if you want to add to a file that's already there,
- 3:40Speaker 2: you use up and it tended exactly and you can
- 3:43Speaker 2: send just the error messages somewhere else. Maybe two aero
- 3:46Speaker 2: loog dot txt, or combine both normal output and errors
- 3:50Speaker 2: into one file with evan in handy, or just make
- 3:53Speaker 2: output disappear entirely if you don't need it, send it
- 3:55Speaker 2: to dubnel, kind of like a black hole for data. Okay,
- 3:58Speaker 2: And one more really full one is t That command
- 4:01Speaker 2: lets you see the output on your screen while it's
- 4:03Speaker 2: also saving it to a file. Great for monitoring something
- 4:06Speaker 2: live but also keeping a record.
- 4:08Speaker 1: Right, see it and save it makes sense. And piping
- 4:11Speaker 1: that's the connector right the symbol. That's the one.
- 4:14Speaker 2: Piping takes the standard output from the command on the
- 4:16Speaker 2: left and feeds it directly as the standard input to
- 4:19Speaker 2: the command on the.
- 4:20Speaker 1: Right, connecting the tools precisely.
- 4:22Speaker 2: This is how you build those complex workflows from simple
- 4:26Speaker 2: building blocks. It's like creating an assembly line for your
- 4:29Speaker 2: data right there in the terminal okay, And one more thing.
- 4:33Speaker 2: If you have a command that might take a while,
- 4:35Speaker 2: like maybe pinging a machine constantly to see if it's up,
- 4:39Speaker 2: you can run it in the background using the ampersand
- 4:41Speaker 2: so like ping one two point one sixty eight point
- 4:44Speaker 2: one point one and ping results do log. It just
- 4:48Speaker 2: runs quietly, logs its output and gives you your prompt
- 4:51Speaker 2: back immediately.
- 4:52Speaker 1: Oh that's useful.
- 4:53Speaker 2: Yeah, And you can check on those background tasks with
- 4:55Speaker 2: the jobs command and bring one back to the foreground
- 4:58Speaker 2: with FG if you need to interact with it.
- 5:00Speaker 1: Got it.
- 5:00Speaker 2: And beyond just moving data, remember Bash is a full
- 5:03Speaker 2: on programming language too. You've got variables, you can read input,
- 5:06Speaker 2: you have if statements, wild loops, functions, you can automate
- 5:09Speaker 2: almost anything.
- 5:10Speaker 1: That flexibility is huge. Okay, but here's something you mentioned
- 5:14Speaker 1: in the book that seems to trip people up a lot. Honestly,
- 5:17Speaker 1: it confused me at first too.
- 5:18Speaker 2: Ah, let me guess shell patterns versus regular expressions.
- 5:23Speaker 1: Bingo. It gets really interesting here. What's the fundamental difference
- 5:29Speaker 1: and why is getting them mixed up such a potential
- 5:32Speaker 1: problem in security?
- 5:33Speaker 2: It's a great question, and yeah, it is critical for
- 5:36Speaker 2: doing things accurately. So shell patterns think for match anything,
- 5:40Speaker 2: for match any single character for a range like a
- 5:43Speaker 2: ZA right the file globbing stuff exactly. They're primarily designed
- 5:46Speaker 2: for matching filenames in the filesystem. When you type ls
- 5:50Speaker 2: dot log, you're telling the shell itself to find all
- 5:52Speaker 2: filenames ending in dot log.
- 5:54Speaker 1: Okay, so it's about the names of files, correct.
- 5:56Speaker 2: Now. Regular expressions or rejects are different beasts, which more
- 6:00Speaker 2: powerful patterns designed for matching text content stuff inside files
- 6:04Speaker 2: or within a stream of data.
- 6:05Speaker 1: Like searching inside a log file.
- 6:07Speaker 2: Precisely. Rejects has a much richer, sometimes more complex set
- 6:11Speaker 2: of special characters and rules. And you use rejects with
- 6:14Speaker 2: tools that process text like rep or AUC or said.
- 6:18Speaker 1: So, different tools, different patterns, yeah.
- 6:20Speaker 2: And confusing them. That can lead to you missing crucial
- 6:23Speaker 2: evidence because you used a file name pattern to search
- 6:26Speaker 2: file content, or maybe doing something unintended because your pattern
- 6:29Speaker 2: match files you didn't expect.
- 6:30Speaker 1: Can you give a quick example, sure.
- 6:32Speaker 2: Find varlogdash name dot gz uses a show pattern dot
- 6:36Speaker 2: gz to find filenames ending in GZ.
- 6:39Speaker 1: Simple okay, But.
- 6:40Speaker 2: Grep error zerosh nine plus farlow gap dot log uses
- 6:44Speaker 2: a regular expression error zero zero nine plus to find
- 6:48Speaker 2: lines inside the app dot log file that contain the
- 6:50Speaker 2: word error followed by one or more digits.
- 6:53Speaker 1: Ah, Okay, one looks at the label, the other looks
- 6:56Speaker 1: inside the box.
- 6:57Speaker 2: That's a great way to put it. Understanding that difference
- 6:59Speaker 2: is vital for precise investigation.
- 7:01Speaker 1: Definitely. Okay. Let's shift gears into our first deep dive
- 7:04Speaker 1: area defensive security operations with Bash. Using Bash as the
- 7:09Speaker 1: investigator's toolkit, how do we usually frame defensive thinking?
- 7:12Speaker 2: Well, A really helpful framework is the five principles of
- 7:15Speaker 2: cybersecurity Confidentiality, integrity, availability, non repudiation, and authentication, often called
- 7:21Speaker 2: CIANA for short CIA. Briefly, confidentiality is about keeping secrets
- 7:27Speaker 2: secret only authorized access. Integrity means making sure data hasn't
- 7:33Speaker 2: been messed with it's trustworthy. Availability is ensuring systems and
- 7:37Speaker 2: data are there when you need them right. Non Repudiation
- 7:40Speaker 2: is about proof linking in action to a specific user
- 7:42Speaker 2: so they can't deny it. And authentication is simply proving
- 7:46Speaker 2: you are who you say you are.
- 7:48Speaker 1: Okay, the core security goals.
- 7:49Speaker 2: Exactly, So the important question for us becomes, how does Bash,
- 7:53Speaker 2: this command line tool actually help us maintain these principles,
- 7:57Speaker 2: or maybe more importantly, how does it help us investigate
- 8:00Speaker 2: when we suspect one of them has been violated?
- 8:02Speaker 1: That makes sense. It grounds what we're doing. So if
- 8:04Speaker 1: we're thinking about actually doing defense or investigating an incident,
- 8:07Speaker 1: say checking data integrity or figuring out the confidentiality impact
- 8:11Speaker 1: of a breach, Bash becomes our hands on toolkit. Where
- 8:14Speaker 1: do we start maybe data collection and analysis.
- 8:17Speaker 2: Absolutely, when something happens you need to gather evidence quickly
- 8:20Speaker 2: and thoroughly. Bash gives you these direct tools. You've got
- 8:23Speaker 2: simple things like cut to pull out specific columns of
- 8:26Speaker 2: data file to quickly tell you what kind of file
- 8:29Speaker 2: you're looking at, header tail to peak at the starter
- 8:31Speaker 2: end of logs. The basics, the powerful, basic, And what's
- 8:35Speaker 2: really neat is this isn't just a Linux Mac thing.
- 8:37Speaker 2: If you're using git Bash on a Windows machine, you
- 8:41Speaker 2: can call native Windows command line tools directly, things like
- 8:44Speaker 2: reg to query the Windows registry oh wow, or web
- 8:47Speaker 2: toodle to work with Windows event logs. You can investigate
- 8:51Speaker 2: Windows systems using the same Bash skills. That cross platform
- 8:54Speaker 2: ability is a huge win for analysts.
- 8:56Speaker 1: So you're not constantly switching mental gears between operating systems.
- 9:00Speaker 1: What about grabbing log files, say for later analysis.
- 9:03Speaker 2: Super efficient. On Linux, you can package up all the
- 9:06Speaker 2: logs in varlog into one compressed file, like sealing an
- 9:09Speaker 2: evidence bag, with a command like tarh ccf O scs
- 9:13Speaker 2: ez name logs, dot tr dot gz varlog easy.
- 9:16Speaker 1: Nice.
- 9:17Speaker 2: On Windows, you can script webtoodle to export all the
- 9:19Speaker 2: different event logs. And here's a really powerful technique for
- 9:22Speaker 2: remote systems, dotsh.
- 9:24Speaker 1: It cure shell.
- 9:25Speaker 2: Yeah, you don't even need to log into the remote machine.
- 9:28Speaker 2: Sometimes you can run a command remotely like swash user
- 9:31Speaker 2: at remote server command and get the output back on
- 9:34Speaker 2: your local machine, or even run a local script on
- 9:37Speaker 2: the remote machine like swash user at remote server, Bash,
- 9:40Speaker 2: dash s dot mylocalscript, dot sh The script itself never
- 9:45Speaker 2: has to be copied over there. It's efficient and sometimes stealthier.
- 9:49Speaker 1: Okay, that's very cool for quick data grabs. So once
- 9:52Speaker 1: you have the data, maybe logs or files from a system,
- 9:55Speaker 1: it can be a lot of data. How do you
- 9:57Speaker 1: start searching through it effectively? With Bash?
- 10:00Speaker 2: Yeah, finding the needle in the haystack. Bash's fine command
- 10:03Speaker 2: is your go to for searching based on filenames and
- 10:06Speaker 2: other file attributes.
- 10:07Speaker 1: Like finding suspicious file.
- 10:08Speaker 2: Names exactly find dash name password. Could search the whole
- 10:12Speaker 2: system for files with password in the name, use in
- 10:14Speaker 2: name for case insensitive, or find hitting files which often
- 10:18Speaker 2: start with a dot on Linux or Mac fine home
- 10:20Speaker 2: name maagine. Remember that dot is a shell pattern matching
- 10:23Speaker 2: file names starting with a dot.
- 10:24Speaker 1: Got it filenames? What about searching inside the files for
- 10:28Speaker 1: keywords or indicators.
- 10:30Speaker 2: That's where GRIP comes in. Grap ir some directory suspicious pattern.
- 10:35Speaker 2: The I makes it case insensitive, R makes it recursive
- 10:39Speaker 2: through directories, and E specifies the pattern, which would typically
- 10:42Speaker 2: be a regular expression here that you're looking for within
- 10:45Speaker 2: the files.
- 10:45Speaker 1: Okay, find for names grap for content makes sense. What
- 10:49Speaker 1: about checking if files have been tampered with that integrity piece?
- 10:53Speaker 2: Ah? Yes, Message digests or hashes tools like chess on
- 10:58Speaker 2: some or md fivesome creator a unique digital fingerprint for
- 11:01Speaker 2: a file. I could check some sort of but much
- 11:04Speaker 2: more cryptographically strong. The key property is that changing even
- 11:07Speaker 2: one single bit in the file will produce a completely
- 11:10Speaker 2: different hash value.
- 11:11Speaker 1: Wow.
- 11:11Speaker 2: Okay, So if you calculate the hash of a critical
- 11:13Speaker 2: system file and compare it to a known good value,
- 11:16Speaker 2: you can tell instantly if it's been modified. It's a
- 11:18Speaker 2: fundamental integrity check. You can script Bash to check hashes
- 11:21Speaker 2: of many files very quickly.
- 11:23Speaker 1: Powerful stuff. Okay, moving on to data processing and analysis.
- 11:26Speaker 1: You've collected logs, maybe found some interesting files. How does
- 11:30Speaker 1: Bash help make sense of, say a massive web server log.
- 11:33Speaker 2: This is where combining tools with pipes really shines. Think
- 11:36Speaker 2: about an Apache Access dot log, huge file, lots of lines. Right,
- 11:40Speaker 2: you can use cut to extract just the IP address
- 11:43Speaker 2: a the first field, then pipe that into sort, then
- 11:46Speaker 2: pipe that into unique miss to count occurrences, and finally
- 11:49Speaker 2: pipe that into sort. Dice on to see which ips
- 11:51Speaker 2: made the most requests. Four simple commands chained together give
- 11:55Speaker 2: you a top talkers list.
- 11:56Speaker 1: It's pretty neat turning raw logs into a summary exact.
- 12:00Speaker 2: Or you could use ak, which is brilliant for field
- 12:03Speaker 2: based processing. Maybe you want to find which ips are
- 12:05Speaker 2: getting lots of four O four not found errors, AC
- 12:08Speaker 2: nine dollars easials four O four print one dollar. Access
- 12:11Speaker 2: dot log could print the IP address field one from
- 12:15Speaker 2: lines where the status code field nine is four oh four.
- 12:18Speaker 2: Pipe that through your sertunic chain again.
- 12:20Speaker 1: Help spot reconnaissance scanning.
- 12:21Speaker 2: Maybe could be or maybe you want to see who's
- 12:24Speaker 2: transferring the most data, use cut or ok to get
- 12:26Speaker 2: the IP address and the number of bytes transferred. Then
- 12:29Speaker 2: use another script maybe like the summer chistish example from
- 12:32Speaker 2: the book, to total the bytes per IP. Sort that
- 12:35Speaker 2: and a huge spike for one IP that might warrant
- 12:37Speaker 2: investigation for data exultration.
- 12:39Speaker 1: Right, checking the confidentiality wasn't breached precisely, and you can
- 12:43Speaker 1: even visualize this stuff simply in the terminal.
- 12:46Speaker 2: The book has examples like histogram dot ash that can
- 12:48Speaker 2: take counts or totals and draw basic bar charts right there.
- 12:52Speaker 2: Quick visual checks.
- 12:53Speaker 1: Very cool. Okay. One more defensive area real time log monitoring,
- 12:59Speaker 1: watching things as they happen.
- 13:00Speaker 2: Yeah, super important for catching things early. The classic command
- 13:03Speaker 2: here is tail dash F PATHTOLG file follow the file right.
- 13:08Speaker 2: It just sits there and prints new lines as they
- 13:10Speaker 2: get added to the end of the file. But the
- 13:12Speaker 2: real power comes when you pipe that live stream.
- 13:15Speaker 1: Ah pipe tail dash f output.
- 13:17Speaker 2: Yes, pipe it into rep or egrep using the line
- 13:20Speaker 2: buffered options, so it processes each line immediately, and you
- 13:23Speaker 2: can filter that live stream for keywords or patterns so
- 13:25Speaker 2: you can.
- 13:26Speaker 1: Watch for specific errors or maybe log in attempts exactly.
- 13:29Speaker 2: You could even build a simple lightweight intrusion detection system
- 13:33Speaker 2: and IDs have a file say ioc dot txt with
- 13:37Speaker 2: known bad patterns indicators of compromise like attempts to access
- 13:40Speaker 2: sensitive files et cetera, paswd, or run commands pinch. Then
- 13:45Speaker 2: you tail dash f your weblog and pipe it into
- 13:47Speaker 2: egrep lineh buffer dash fioc dot txt. It will only
- 13:53Speaker 2: show you the lines that match your bad patterns, alerting
- 13:55Speaker 2: you in real time.
- 13:56Speaker 1: Wow. Okay, a homegrown IDs with just tail.
- 13:59Speaker 2: And rep pretty much, and you can do similar things
- 14:01Speaker 2: on Windows. The book has a windtail dot sh script
- 14:04Speaker 2: that uses web toodle in a loop to simulate tail
- 14:06Speaker 2: dash f for Windows event logs.
- 14:08Speaker 1: Bringing that real time view to Windows logs too.
- 14:10Speaker 2: And you can take it further. There are scripts like
- 14:12Speaker 2: webdash dot sh that use terminal control commands to create
- 14:15Speaker 2: simple dashboards. They repeatedly run several commands, maybe monitoring different
- 14:19Speaker 2: logs or system stats, and repaint the screen, giving you
- 14:22Speaker 2: multiple live views in one terminal window.
- 14:24Speaker 1: Okay, so Bash is definitely a powerhouse for defense and investigation.
- 14:28Speaker 1: Let's flip the coin now penetration testing with Bash. Thinking
- 14:31Speaker 1: like an adversary. How does Bash fit into the attacker's toolkit?
- 14:34Speaker 1: Is there a structure they follow?
- 14:35Speaker 2: Often yes, especially for more organized attackers. It's rarely just
- 14:39Speaker 2: random hacking. A useful model to understand the phases is
- 14:43Speaker 2: Mandiance attack life cycle. It lays out typical steps.
- 14:46Speaker 1: Okay, where are they?
- 14:47Speaker 2: There are about eight phases in that model. Reconnaissance first,
- 14:51Speaker 2: then initial exploitation, establish foothold, escalate, privileges internal reconnaissance, move
- 14:57Speaker 2: laterally inside the network, maintain presence, and and finally complete
- 15:01Speaker 2: the mission whatever.
- 15:02Speaker 1: That might be. Recon exploit foothold, escalate, internal recon lateral movement,
- 15:05Speaker 1: maintain complete. Got it?
- 15:08Speaker 2: Understanding that flow helps you see where tools including bashcripts
- 15:11Speaker 2: might be used. It gives context to offensive actions. Bash
- 15:15Speaker 2: makes an attacker very agile within this cycle.
- 15:18Speaker 1: That framework definitely helps visualize it. Given how quick and
- 15:22Speaker 1: low profile Bash can be, where does it really shine
- 15:24Speaker 1: in this attack cycle? Let's start at the beginning. Reconnaissance.
- 15:27Speaker 2: Reconnaissance is all about gathering intel in the target. Bash
- 15:30Speaker 2: is great here. You can use kerl for example, to
- 15:33Speaker 2: download web pages, maybe follow redirects to l save the output.
- 15:36Speaker 2: Basically crawl website looking for information or vulnerabilities.
- 15:40Speaker 1: This is from the command line.
- 15:41Speaker 2: Yeah, and another classic technique is banner grabbing. Lots of
- 15:44Speaker 2: network services like web servers, HGTP file servers, FTP mail
- 15:49Speaker 2: servers SMTP. They announce themselves with a banner when you.
- 15:53Speaker 1: Connect, like a welcome message kind of.
- 15:55Speaker 2: And that banner often reveals the software name and version,
- 15:59Speaker 2: maybe even the operating system gold dust for an attacker
- 16:02Speaker 2: looking for known exploits.
- 16:04Speaker 1: And you can automate grabbing these banners with Bash absolutely.
- 16:07Speaker 2: But here's where Bash gets really sneaky and powerful, something
- 16:10Speaker 2: that surprises people. You don't always need a dedicated tool
- 16:13Speaker 2: like telnet or nmap to connect to a port and
- 16:16Speaker 2: see that banner. No, Bash itself has this built in capability.
- 16:20Speaker 2: Using a special filepath deftcfos nameport.
- 16:23Speaker 1: Wait, Bash can make TCP connections directly effectively.
- 16:26Speaker 2: Yes, it's a fetcher of the show. So an attacker
- 16:28Speaker 2: on a system where maybe tools like telnet are removed
- 16:31Speaker 2: or blocked, they can still perform network reconnaissance using just
- 16:34Speaker 2: built in Bash commands. The book shows an SMTP connect
- 16:38Speaker 2: dotsh script that uses exec three DVTCP one twenty five
- 16:42Speaker 2: dollars to open a connection to an SMTP server on
- 16:44Speaker 2: port twenty five and read its banner. No external tools needed.
- 16:48Speaker 1: WHOA Okay, that is sneaky, minimal.
- 16:50Speaker 2: Footprint exactly, pure command line resourcefulness.
- 16:54Speaker 1: Okay. So after recun the model had like establishing a foothold,
- 16:59Speaker 1: getting persistence.
- 17:00Speaker 2: Right right Once you're in, you want a way to
- 17:02Speaker 2: stay in or get back in easily. NC or netcat
- 17:06Speaker 2: is often called the Swiss Army knife for networking. You
- 17:09Speaker 2: can use it to create simple listeners, nclap port or
- 17:13Speaker 2: make outbound connections.
- 17:14Speaker 1: For simple data transfer or shells.
- 17:16Speaker 2: Yes, and one very common technique for footholds is a
- 17:19Speaker 2: reverse shell, especially using.
- 17:21Speaker 1: SSH versus SSH. How does that work?
- 17:24Speaker 2: Instead of the attacker connecting into the target, which might
- 17:27Speaker 2: be blocked by a firewall, the compromised target machine initiates
- 17:30Speaker 2: an outbound SSH connection to the attacker's machine using the
- 17:33Speaker 2: natch R option SSR one two three four five dot
- 17:36Speaker 2: local host part two to two attacker at attacker. This
- 17:38Speaker 2: punches a hole out through the firewall. The attacker then
- 17:41Speaker 2: connects to port one two three four five on their
- 17:43Speaker 2: own machine, and SSH tunnels that connection back to the
- 17:45Speaker 2: SSH server on the compromise targetqwever bypasses inbound rules very common.
- 17:50Speaker 2: You can also create simpler, though less secure back doors
- 17:54Speaker 2: just with Bash redirection and that devtsap trick again, something
- 17:58Speaker 2: like exec binbash zero one one in two, two in
- 18:00Speaker 2: one combined with connecting input output to a network socket
- 18:04Speaker 2: instant remote shell Wow. Big warning though that kind of
- 18:07Speaker 2: simple Bash backdoor. It's usually plain text unencrypted. Anyone stuffing
- 18:12Speaker 2: the network can see everything risky, very so attackers might
- 18:16Speaker 2: develop more sophisticated custom tools, maybe like the local rat
- 18:19Speaker 2: dot show listener and remote rat dot ish client examples
- 18:22Speaker 2: which use Bash scripting to provide more robust command execution
- 18:25Speaker 2: and even file transfer capabilities over their backdoor channel.
- 18:28Speaker 1: Makes sense now. If attackers are using these tools, they
- 18:31Speaker 1: probably don't want defenders easily figuring them out if they
- 18:34Speaker 1: get caught. That brings us to script obfuscation.
- 18:37Speaker 2: Exactly, if your penetration testing script or your back door
- 18:40Speaker 2: gets found, you don't want the blue team immediately understanding
- 18:43Speaker 2: exactly how it works and what it did. Obfuscation makes
- 18:46Speaker 2: reverse engineering harder.
- 18:48Speaker 1: How do you obfuscate a Bash script?
- 18:50Speaker 2: Several ways? Syntax obfuscation is the simplest. Just make the
- 18:54Speaker 2: code hard to read. Put the whole script on one
- 18:56Speaker 2: giant line, separated by semicolons. Use really meaningless variable and
- 19:01Speaker 2: function names like afrioco.
- 19:03Speaker 1: Or funky one annoying to read. That's the point.
- 19:06Speaker 2: Then there's logic offuscation. This is where you add tons
- 19:09Speaker 2: of useless code, pointless variables, functions calling other functions that
- 19:13Speaker 2: do nothing important, complex loops that calculate something trivial. Makes
- 19:17Speaker 2: a simple script look incredibly.
- 19:19Speaker 1: Complicated, like hiding a needle in a bigger messier astac.
- 19:21Speaker 2: Pretty much, but the most effective method is usually encryption. Okay,
- 19:25Speaker 2: The basic idea is you have your real script plaintext.
- 19:28Speaker 2: You encrypt it using a key producing ciphertext. You can
- 19:32Speaker 2: use standard tools like ohensolars two thousand, CBC sll inrelscript
- 19:36Speaker 2: dot sa outencrypted dot dot dot a password. Then you
- 19:40Speaker 2: create a small rapper script. This wrapper contains the encrypted
- 19:43Speaker 2: data and the password or prompts for it. When run,
- 19:46Speaker 2: the rapper decrypts the real script into memory importantly, often
- 19:49Speaker 2: without writing the decrypted version to disc, and then executes
- 19:52Speaker 2: it using something like Bash open.
- 19:53Speaker 1: Soli executes from memory much harder to recover the original script,
- 19:58Speaker 1: much harder.
- 19:59Speaker 2: Bash, which can even be used to demonstrate simple xor
- 20:02Speaker 2: stream ciphers like the stream cipher dot sh example, using
- 20:05Speaker 2: the random variable and a seed for educational purposes, showing
- 20:09Speaker 2: the principles involved fascinating.
- 20:11Speaker 1: Okay, one more offensive technique fuzzing. What is that exactly?
- 20:16Speaker 2: Fuzzing is basically throwing junk at a program to see
- 20:20Speaker 2: if it breaks. It's an automated way to find vulnerabilities,
- 20:24Speaker 2: particularly thing like buffer overflows.
- 20:26Speaker 1: Buffer overflows where the program tries to stuff too much
- 20:29Speaker 1: data into a small.
- 20:30Speaker 2: Space exactly classic C programming vulnerability With functions like strikeat
- 20:34Speaker 2: they copy data from one place to another, but don't
- 20:37Speaker 2: always check if the destination has enough room. If you
- 20:39Speaker 2: send way too much data, it spills over overwriting adjacent memory,
- 20:43Speaker 2: potentially crashing the program, or worse, allowing an attacker to
- 20:46Speaker 2: inject malicious code. So a fuzzer, often just a simple script,
- 20:50Speaker 2: systematically sends slightly different, often invalid or overly long inputs
- 20:54Speaker 2: to the target program. The book has an example fuzzer
- 20:57Speaker 2: dot is sha targeting a vulnerable C program fuzzme dot ex.
- 21:02Speaker 2: The script just keeps sending longer and longer strings as
- 21:04Speaker 2: command line arguments until fuzz me dot ex crashes. That
- 21:08Speaker 2: crash point tells you roughly how much data causes the overflow.
- 21:12Speaker 1: Automated vulnerability discovery yep.
- 21:14Speaker 2: Bash is great for scripting that kind of repetitive testing.
- 21:17Speaker 1: So we've seen Bash used for defense and offense. How
- 21:20Speaker 1: do these two sides connect?
- 21:22Speaker 2: Well? If we connect, this all back to the bigger picture.
- 21:25Speaker 2: Understanding these attack methods is directly useful for defense. Knowing
- 21:28Speaker 2: your enemy precisely. If you know how an attacker might
- 21:31Speaker 2: use DEVTCP for banner grabbing or set up a reverse
- 21:35Speaker 2: SSH tunnel, you know what kind of network traffic or
- 21:37Speaker 2: process behavior to look for on your systems, you can
- 21:40Speaker 2: figure firewalls better, maybe monitor for suspicious outbound connections. Knowing
- 21:45Speaker 2: how a Bash backdoor works helps you spot those weird
- 21:48Speaker 2: Bash processes talking over the network. Understanding fuzzing helps you
- 21:52Speaker 2: appreciate why validating INP and properly in your own applications
- 21:55Speaker 2: is so critical. Defense and offense really inform each other.
- 22:00Speaker 2: Using Bash for offense gives you insight into how to
- 22:02Speaker 2: use Bash for defense and vice versa.
- 22:05Speaker 1: So what does this all really mean for you? The
- 22:07Speaker 1: listener trying to learn this stuff? This deep dive? I
- 22:10Speaker 1: think really Hammers home that Bash isn't just some utility
- 22:14Speaker 1: for moving files around, not at all. It's this incredibly powerful,
- 22:18Speaker 1: versatile language right at the heart of cybersecurity. Doesn't matter
- 22:22Speaker 1: if you're Red Team or Blue Team. It's a foundational
- 22:25Speaker 1: skill that just amplifies everything else.
- 22:27Speaker 2: You do, which raises the important question, how can you
- 22:30Speaker 2: actually practice these skills? Make them real?
- 22:32Speaker 1: Good question? Reading is one thing doing as another exactly, And.
- 22:36Speaker 2: The book actually has some really good practical workshop props
- 22:39Speaker 2: to get you hands on. They're great starting points.
- 22:41Speaker 1: Oh yeah, like what well?
- 22:43Speaker 2: For example, you could try modifying one of the data
- 22:45Speaker 2: collection scripts like get local dot shsh to automatically upload
- 22:49Speaker 2: its findings to a secure server using CPP automate your
- 22:53Speaker 2: evidence collection.
- 22:54Speaker 1: Okay, practical.
- 22:54Speaker 2: Or take the hash search dot s script, the one
- 22:57Speaker 2: that finds files by their hash. Modify it so it
- 23:00Speaker 2: stops searching as soon as it finds the first match.
- 23:02Speaker 2: Make it more efficient, or maybe simplify the output paths
- 23:06Speaker 2: it displays, tidying it up. Or for Windows, enhance the
- 23:10Speaker 2: windlogs dot sh sh script to show a progress bar
- 23:13Speaker 2: while it's working using tiput make it more user friendly.
- 23:16Speaker 1: Nice little touches.
- 23:17Speaker 2: On the offensive side. You could expand the fuzzer dot
- 23:20Speaker 2: sh syncrypt to fuzz more than one command line argument
- 23:23Speaker 2: at a time, make it a bit more thorough, or
- 23:25Speaker 2: modify the banner grabber dot sh script instead of just
- 23:28Speaker 2: one target, make it read a whole list of IPS
- 23:31Speaker 2: from a file and output the results neatly into an
- 23:34Speaker 2: htmel table for reporting. That sounds useful, and definitely try
- 23:37Speaker 2: encrypting a simple script yourself using open sale or even
- 23:40Speaker 2: the xor method and then write the rapper script to
- 23:43Speaker 2: decrypt and run. It really helps understand that obfuscation technique.
- 23:47Speaker 1: Get your hands dirty with encryption exactly.
- 23:49Speaker 2: This kind of exercises really bridge that gap from just
- 23:52Speaker 2: reading about it to actually doing it.
- 23:54Speaker 1: Absolutely so, mastering the command line using Bash like this.
- 23:59Speaker 1: It's not about throwing away your fancy graphical security tools, noah,
- 24:03Speaker 1: not at all. It's about augmenting them, adding this fundamental
- 24:06Speaker 1: layer of control and insight that maybe you didn't realize
- 24:09Speaker 1: you had access to.
- 24:10Speaker 2: Well said, I mean, the command line is your direct
- 24:13Speaker 2: pipe to the OS. Right. All that power refined over
- 24:16Speaker 2: decades in a world where we're increasingly using these slightly
- 24:21Speaker 2: opaque GUIs understanding and being able to wield this direct power.
- 24:27Speaker 2: That's not just another skill. It really is a critical
- 24:29Speaker 2: advantage whether you're protecting systems or probing them, Which maybe
- 24:33Speaker 2: leads to a final thought, what other lost arts, maybe
- 24:36Speaker 2: in computing or even your own field, holds similar kinds
- 24:39Speaker 2: of untapped power just waiting to be rediscovered.
- 24:43Speaker 1: That's a great question to chew on something powerful hidden
- 24:47Speaker 1: in plain sight. Well that's all the time we have
- 24:49Speaker 1: for this deep dialk into cybersecurity ops with Bash. We
- 24:52Speaker 1: hope you found it useful.
- 24:53Speaker 2: Yeah, hope it sparks some ideas.
- 24:56Speaker 1: Thanks for joining us, and we'll catch you on the
- 24:57Speaker 1: next deep dive.