There’s a Snake in My Boot Drive

Python is a high-level, object-oriented programming language with an easy-to-learn syntax that can benefit programmers of all skill levels. It is miles away from the complexities of managing computer memory, abstracting away these concepts, which are unnecessary anachronisms to the modern pragmatic programmer, and letting you get on with the important stuff.

The Python programming language is the top choice among cybersecurity professionals due to the vast number of powerful third-party libraries available. The ability to use these libraries to do the heavy lifting greatly reduces the time required to piece together scripts and develop applications. Python is also highly versatile: Security professionals can use it to write software for penetration testing, web development, applications or to simply throw a quick script together.

Sssscript Kiddies

It is well-known that the difference between being a script kiddie and a legitimate, card-carrying hacker is the ability to write your own code and tooling to perform better security assessments. Making the leap from blindly using shrink-wrapped code to creating and working with bespoke tooling can seem a bit daunting to newbie ethical hackers. Luckily, one area of security where Python has found a particularly strong (and slithery) grip is in the penetration testing industry.

Python has been used to create all kinds of well-known tools that would be instantly familiar to any hardened member of the security community. These include everything from simple scripts to full-blown exploit frameworks.

Let’s Get Modular

Due to Python’s widespread uptake, a penetration tester who has gained access to an endpoint will likely find Python installed, meaning that the programming language can be used to create code that manages networking. This is important if you are performing a penetration test because, upon gaining access to a target machine, you will be greeted with the grim reality that the hacking tools you know and love are nowhere to be found. This means that you occasionally need to make your own. Python has a particularly useful module called socket, which gives hackers all the tools they need to set up and execute basic network tasks.

Another very powerful module well worth your time and research is Scapy. This adds protocol analyzer (packet sniffer) capabilities to your Python code and can be used to read traffic, perform Address Resolution Protocol (ARP) cache poisoning, set up man-in-the-middle (MitM) attacks and more.

But Python tooling isn’t just used by white hats; black-hat fraudsters used the language in the 2016 ransomware CryPy, which used the power of Python to innovate on the ransomware genre. It would be very unsurprising to see more and more threats being perpetrated with Python in the near future. Like traditional software development, the cybercrime industry is driven by quick time to value and the ability to stay agile and ahead of competitors. Python is designed with fast, efficient development in mind.

Add Python Programming Language to Your Skillset

Not only is Python the preferred language for penetration testers, it is also a language of choice for service professionals when configuring and integrating security tooling. For example, many application frameworks use Python, as do the application programming interface (API) examples provided on the IBM Security Intelligence GitHub.

Many incident response platforms come with Python modules, which provide a framework for writing action processors and API integrations. IBM product professional services integration engineers frequently build reusable Python modules for common customer integrations such as ServiceNow, Splunk and JIRA.

When you put it all together, you have a fast, efficient language with wide uptake, many cybersecurity applications and all the modules you need to get started fast. It’s easy to see why this is becoming a must-have skill for operating in the security industry, and why the Python programming language is a part of some of the most cutting-edge tooling out there.

more from Application Security

Controlling the Source: Abusing Source Code Management Systems

For full details on this research, see the X-Force Red whitepaper “Controlling the Source: Abusing Source Code Management Systems”. This material is also being presented at Black Hat USA 2022. Source Code Management (SCM) systems play a vital role within organizations and have been an afterthought in terms of defenses compared to other critical enterprise systems such as Active Directory.…

Black Hat 2022 Sneak Peek: How to Build a Threat Hunting Program

You may recall my previous blog post about how our X-Force veteran threat hunter Neil Wyler (a.k.a “Grifter”) discovered nation-state attackers exfiltrating unencrypted, personally identifiable information (PII) from a company’s network, unbeknownst to the security team. The post highlighted why threat hunting should be a baseline activity in any environment. Before you can embark on a threat hunting exercise, however,…