The Power of Learning Code for Automation and Cybersecurity

Introduction

Imagine this: You sit at a computer with a nice piping hot cup of coffee (or tea, you pick) and look up at the screen. There you see the latest and greatest tool released on GitHub with hundreds of lines of code and think to yourself, “What will this code do when it’s executed in a client’s environment?” Well, to answer those questions, you must first understand what the underlying code does and what programming language it is written in.

In understanding a programming language, someone might be able to gather what the script is doing in the environment before execution. If someone was to accidentally execute a program in an environment without prior knowledge of a programming language, that person might be executing malicious software (malware) or ransomware.

Understanding code helps to automate otherwise time-consuming, menial tasks. Tim Ferriss, a noteworthy American entrepreneur, coined the phrase:

“Never automate something that can be eliminated, and never delegate something that can be automated or streamlined. Otherwise, you waste someone else’s time instead of your own, which now wastes your hard-earned cash. How’s that for incentive to be effective and efficient?”

With this phrase in mind, what simple tasks can you automate by learning how to code?

What Can You Automate with Code?

You don’t need to be a seasoned coder to start automating tasks. Here are some simple, yet impactful tasks you can automate:

  • Pull specific live traffic from any website if an application programming interface (API) is associated with it.
  • Automate sending personalized emails to multiple recipients.
  • Clean your computer of large and unnecessary files.
  • Throw a party with your HUE lights at the end of the workday to celebrate!
  • Obtain internal server logs and email them to the IT team.
  • Pull a specific tweet or post from Twitter or Facebook of your favorite celebrity.
  • Use an automated service like Zapier or IFTTT (If This Then That).
  • Create a bot that automatically sends GitHub links to an online repository (more on that in the future).

Learning how to automate processes is not only a time-saver but can also make your professional life more organized and efficient. This goes beyond just personal tasks. As cybersecurity professionals, we look to code for many practical use cases.

Automating Security Tasks

Learning code isn’t just about automating household chores. It plays a critical role in the cybersecurity space, helping us automate essential tasks like:

  • Updating operating systems to the latest version.
  • Finding information on organizations using open-source intelligence (OSINT) techniques.
  • Building infrastructure setups through automated scripts.
  • Previewing web pages of IP (Internet Protocol) addresses that were given to us during an engagement.

Understanding the Code You Use

Learning to code not only helps us automate tasks, but it also helps us understand what we are doing when using various tools. For example, when performing penetration testing, many of us clone tools from repositories like GitHub. Without understanding the underlying code, we could potentially run malicious or flawed scripts in a production environment, causing irreparable damage.

In hacker lingo, we call people who execute code without fully understanding it Script Kiddies. According to TechTarget:

“Script Kiddies aren’t interested in learning and understanding the exploits they use, instead using what is easy to find and available.”

Many people in our industry go through the motions of cloning a repository and executing the software without understanding the full consequences. To be a true ethical hacker, we must know what the underlying code does, how it will affect the environment where it’s being executed, and ensure it doesn’t cause unintended harm. Here are a few steps you can take to make sure the tools you use are safe:

How to Safely Execute Code in a Client’s Environment

  1. Test the current tools in a local environment: Always run tools on a local network, preferably an air-gapped (isolated) virtual environment. This ensures you are testing in a controlled setting.

  2. Use sandboxed environments: If you don’t have an air-gapped environment, use online or sandboxed environments like Hybrid-Analysis, which can help you analyze malware safely.

  3. Ask the vendor: Before performing a penetration test, always confirm with the client which tools you will be using and the potential impact on their production environment. This can prevent any accidental breaches or disruptions.

  4. Explain to the client: Ensure the client understands what the tool does, how it works, and the potential consequences before running it in a live environment.

  5. Review credentials used by the tool: Check if the tool requires elevated privileges like domain administrator credentials. If so, ensure that the minimum permissions required for the test are applied, reducing the risk of over-permissioned access.

Conclusion

Learning code is not just a skill for software developers; it’s a game changer for cybersecurity professionals. Automation allows us to streamline repetitive tasks, making us more efficient and effective. But more importantly, understanding code lets us safely navigate the digital world, ensuring the tools we use don’t cause harm to our clients.

Next time you find yourself saying, “I need to do this, but I really just don’t want to,” ask yourself, “Can this task be automated?” If it involves technology, it almost certainly can be. Start by learning a programming language, and you’ll be amazed at how much time you can save. You can begin by taking free online courses, with YouTube being a great starting point for beginners.

Don’t wait. Automate!