Introducing Code Search on AttackCapture: Uncover Exploit Code, Reverse Shells, C2 Configs, and More

Introducing Code Search on AttackCapture: Uncover Exploit Code, Reverse Shells, C2 Configs, and More

Published on

Published on

Published on

Oct 15, 2024

Oct 15, 2024

Oct 15, 2024

Introducing Code Search on AttackCapture: Uncover Exploit Code, Reverse Shells, C2 Configs, and More
Introducing Code Search on AttackCapture: Uncover Exploit Code, Reverse Shells, C2 Configs, and More
Introducing Code Search on AttackCapture: Uncover Exploit Code, Reverse Shells, C2 Configs, and More
TABLE OF CONTENTS

Overview 

Spotting malicious code across extensive collections of files can be daunting, especially as attackers constantly use new obfuscation libraries to hinder analysis. That's where Code Search, a powerful feature within our Attack Capture platform, comes into play. This tool allows security teams and researchers to efficiently scan through diverse file types to detect indicators of compromise (IoCs), such as exploit code, reverse shells, and C2 configurations.

In our recent post introducing Attack Capture, we discussed how the platform uncovers and categorizes attacker burner instances, indexing everything from recon tools and malware to remote exploits and exfiltration methods. Code Search enables threat hunters to locate and analyze specific attack patterns, such as unique Cobalt Strike configurations--all accessible for preview and download.  

Cobalt Strike Profiles

Cobalt Strike is a feature-rich post-exploitation tool often repurposed by cyber criminals and APT groups to manage command-and-control (C2) operations. Malleable C2 profiles allow attackers to customize network traffic--such as HTTP headers and URIs--to mimic legitimate services (Microsoft, Google, Amazon, etc.)  or other adversaries, making it an ideal tool for evading detection.

Malleable C2 profiles leverage a Data Transform Language that statements and data structures, aiding in their identification across files. In the following examples, we'll highlight specific Code Search queries designed to locate Malleable profiles across thousands of open directories, revealing patterns that adversaries use.

Profile: jquery-3.3.2

Code Search Query: set uri /jquery-3.3.2.min.js" AND "set OU Certificate Authority

Brief Description: This profile is designed to mimic requests for the popular JavaScript  jQuery library. Due to its ability to appear as benign traffic, this profile has seen repeated use by adversaries attempting to evade monitoring within targeted networks.

Figure 1: JQuery Malleable C2 Profile Results (Try it: Hunt)

Profile: Cobalt Strike 4.9

Code Search Query: header Server gsw" AND "set module_x86 netshell.dll

Brief Description: In late August, Michael Koczwara posted on using AttackCapture to uncover Cobalt Strike servers using unique or custom malleable profiles. He showcased a Malleable C2 profile for Cobalt Strike 4.9, which had not been publicly reported. Our queries are straightforward, using a keyword with a simple "AND" statement.

Figure 2: CS 4.9 Malleable Profiles (Try it: Hunt)
Figure 3: Snippet of one of the CS 4.9 profiles.

Profile: geacon_plus

Code Search Query: set uri /www/handle/doc" AND "set OU NN Fern

Brief Description: geacon_plus is a Golang-based variant of the Cobalt Strike beacon, designed for cross-platform use, including macOS, Linux, and Windows systems. This version uses unique TLS certificate fields, which can be leveraged to identify infrastructure during network scans.

Figure 4: Open directories hosting geacon_plus profiles (Try it: Hunt)

EagleSpy Malware

EagleSpy is a powerful Android spyware tool that covertly gathers data from infected devices, including contacts, messages, and location details. Using Telegram's Bot API, it relays this stolen information directly to the attacker's infrastructure.

Code Search Query: EagleSpy

Brief Description: The above query showcases the power of full-text search. With just one word, we can quickly identify multiple HTML files using the distinctive @EagleSpy identifier located within the code. You may recognize the IP address in Figure 5 from our previous research into a cybercriminal's exposed server.

Figure 5: Open directories hosting EagleSpy panels. (Try it: Hunt)
Figure 6: Snippet of EagleSpy identifier in phishing page targeting digital currency.

Covenant Grunt Implants

Covenant is an open-source, .NET-based C2 framework commonly used in red team operations for managing post-exploitation activities. Its primary implant, a "Grunt," executes commands on compromised systems, enabling tasks like lateral movement and credential theft. Covenant has been observed in numerous cyberattacks despite its intended use by penetration testers, where adversaries deploy Grunt agents to control victim networks​.

Code Search Query: Grunt.GruntStager

Description: Each Grunt is generated through Covenant's web interface, where operators can customize the stager type and communication parameters. The above query looks for implants exposed on open directories prepped for delivery.

Figure 7: Exposed Covenant implants (Try it: Hunt)

Python & Bash Reverse Shells

Python and Bash reverse shells are tools commonly used in both malicious operations and legitimate security testing to gain remote access to target systems. They enable a malicious actor, or penetration tester, to bypass typical firewall rules by having the compromised machine initiate an outbound connection back to the control server.

Python reverse shells are valued for their flexibility and cross-platform capabilities, while Bash reverse shells are straightforward and frequently used on Unix systems. These shells are crucial for simulating real-world attacks, as they help assess vulnerabilities that an adversary on target could exploit.

Python Shells

Code Search Query: ("s=socket.socket" OR "import socket,subprocess,os")AND ("/bin/bash" OR "/bin/sh") AND "-i"

Description: This query is a bit more complicated than the previous ones as it uses both "AND" and "OR" operators to combine keywords, in addition to parenthesis. Our goal in this particular query is to filter for common elements found in reverse shells, specifically socket connections, and the use of Bash for interactive shells.

Figure 8: Python reverse Shells (Try it: Hunt)

Bash Shells

Code Search Query: sh -i" AND "/dev/tcp

Description: The Bash query identifies code that uses the shorthand "sh -i" for an interactive shell, combined with "/dev/tcp" to establish network connections. The "AND" operator helps pinpoint scripts that set up reverse shells over TCP, a common method for initiating connections to external servers.

Figure 9: Snippet of results for open directories hosting a Bash reverse shell (Try it: Hunt)

Exploit Code

Our final section explores the discovery of exploit code associated with known Common Vulnerabilities and Exposures (CVEs) within the open directories curated by AttackCapture. Finding this code provides defenders with a crucial perspective on how malicious actors might attempt to exploit vulnerabilities. This intelligence empowers security teams to anticipate attacker tactics and fortify network defenses, allowing for proactive preparation before a potential breach occurs.

CVE-2024-6387

Code Search Query: 7etsuo-regreSSHion.c

Description: Here, we are explicitly searching for the use of a C file named "7etsuo-regreSSHion.c," which contains code for the RegreSSHion exploit. This vulnerability affects SSH implementations, allowing attackers to potentially gain unauthorized access to systems. By targeting this file name, the query helps quickly locate instances where the RegreSSHion exploit may be present in open directories.

Figure 10: Searching for directories using a specific version of the regreSSHion exploit code (Try it: Hunt)

CVE-2024-29895

Code Search Query: /cacti/cmd_realtime.php

Description: The final query targets the cmd_realtime.php file in Cacti, which was vulnerable to command injection. This flaw affected Cacti versions on the 1.3.x DEV branch and allowed unauthenticated users to execute arbitrary commands on the server. In Figure 11 below, we see a few Python variations of the exploit and instances of the Nuclei scanner, likely used to check server exposure to the vulnerability.

Figure 11: Exploit code targeting a command injection vulnerability in Cacti (Try it: Hunt)

Conclusion

Code Search within AttackCapture gives defenders the ability to uncover a wide range of malicious code, from exploits and reverse shells to C2 configurations, just to name a few. This feature helps security teams gain insights into potential threats and proactively bolster defenses against evolving attack methods. As we continue to expand CodeSearch to include additional configurations like Havoc C2 (Coming Soon!), we invite your feedback on other file types or features that would enhance your threat-hunting capabilities.

TABLE OF CONTENTS

Overview 

Spotting malicious code across extensive collections of files can be daunting, especially as attackers constantly use new obfuscation libraries to hinder analysis. That's where Code Search, a powerful feature within our Attack Capture platform, comes into play. This tool allows security teams and researchers to efficiently scan through diverse file types to detect indicators of compromise (IoCs), such as exploit code, reverse shells, and C2 configurations.

In our recent post introducing Attack Capture, we discussed how the platform uncovers and categorizes attacker burner instances, indexing everything from recon tools and malware to remote exploits and exfiltration methods. Code Search enables threat hunters to locate and analyze specific attack patterns, such as unique Cobalt Strike configurations--all accessible for preview and download.  

Cobalt Strike Profiles

Cobalt Strike is a feature-rich post-exploitation tool often repurposed by cyber criminals and APT groups to manage command-and-control (C2) operations. Malleable C2 profiles allow attackers to customize network traffic--such as HTTP headers and URIs--to mimic legitimate services (Microsoft, Google, Amazon, etc.)  or other adversaries, making it an ideal tool for evading detection.

Malleable C2 profiles leverage a Data Transform Language that statements and data structures, aiding in their identification across files. In the following examples, we'll highlight specific Code Search queries designed to locate Malleable profiles across thousands of open directories, revealing patterns that adversaries use.

Profile: jquery-3.3.2

Code Search Query: set uri /jquery-3.3.2.min.js" AND "set OU Certificate Authority

Brief Description: This profile is designed to mimic requests for the popular JavaScript  jQuery library. Due to its ability to appear as benign traffic, this profile has seen repeated use by adversaries attempting to evade monitoring within targeted networks.

Figure 1: JQuery Malleable C2 Profile Results (Try it: Hunt)

Profile: Cobalt Strike 4.9

Code Search Query: header Server gsw" AND "set module_x86 netshell.dll

Brief Description: In late August, Michael Koczwara posted on using AttackCapture to uncover Cobalt Strike servers using unique or custom malleable profiles. He showcased a Malleable C2 profile for Cobalt Strike 4.9, which had not been publicly reported. Our queries are straightforward, using a keyword with a simple "AND" statement.

Figure 2: CS 4.9 Malleable Profiles (Try it: Hunt)
Figure 3: Snippet of one of the CS 4.9 profiles.

Profile: geacon_plus

Code Search Query: set uri /www/handle/doc" AND "set OU NN Fern

Brief Description: geacon_plus is a Golang-based variant of the Cobalt Strike beacon, designed for cross-platform use, including macOS, Linux, and Windows systems. This version uses unique TLS certificate fields, which can be leveraged to identify infrastructure during network scans.

Figure 4: Open directories hosting geacon_plus profiles (Try it: Hunt)

EagleSpy Malware

EagleSpy is a powerful Android spyware tool that covertly gathers data from infected devices, including contacts, messages, and location details. Using Telegram's Bot API, it relays this stolen information directly to the attacker's infrastructure.

Code Search Query: EagleSpy

Brief Description: The above query showcases the power of full-text search. With just one word, we can quickly identify multiple HTML files using the distinctive @EagleSpy identifier located within the code. You may recognize the IP address in Figure 5 from our previous research into a cybercriminal's exposed server.

Figure 5: Open directories hosting EagleSpy panels. (Try it: Hunt)
Figure 6: Snippet of EagleSpy identifier in phishing page targeting digital currency.

Covenant Grunt Implants

Covenant is an open-source, .NET-based C2 framework commonly used in red team operations for managing post-exploitation activities. Its primary implant, a "Grunt," executes commands on compromised systems, enabling tasks like lateral movement and credential theft. Covenant has been observed in numerous cyberattacks despite its intended use by penetration testers, where adversaries deploy Grunt agents to control victim networks​.

Code Search Query: Grunt.GruntStager

Description: Each Grunt is generated through Covenant's web interface, where operators can customize the stager type and communication parameters. The above query looks for implants exposed on open directories prepped for delivery.

Figure 7: Exposed Covenant implants (Try it: Hunt)

Python & Bash Reverse Shells

Python and Bash reverse shells are tools commonly used in both malicious operations and legitimate security testing to gain remote access to target systems. They enable a malicious actor, or penetration tester, to bypass typical firewall rules by having the compromised machine initiate an outbound connection back to the control server.

Python reverse shells are valued for their flexibility and cross-platform capabilities, while Bash reverse shells are straightforward and frequently used on Unix systems. These shells are crucial for simulating real-world attacks, as they help assess vulnerabilities that an adversary on target could exploit.

Python Shells

Code Search Query: ("s=socket.socket" OR "import socket,subprocess,os")AND ("/bin/bash" OR "/bin/sh") AND "-i"

Description: This query is a bit more complicated than the previous ones as it uses both "AND" and "OR" operators to combine keywords, in addition to parenthesis. Our goal in this particular query is to filter for common elements found in reverse shells, specifically socket connections, and the use of Bash for interactive shells.

Figure 8: Python reverse Shells (Try it: Hunt)

Bash Shells

Code Search Query: sh -i" AND "/dev/tcp

Description: The Bash query identifies code that uses the shorthand "sh -i" for an interactive shell, combined with "/dev/tcp" to establish network connections. The "AND" operator helps pinpoint scripts that set up reverse shells over TCP, a common method for initiating connections to external servers.

Figure 9: Snippet of results for open directories hosting a Bash reverse shell (Try it: Hunt)

Exploit Code

Our final section explores the discovery of exploit code associated with known Common Vulnerabilities and Exposures (CVEs) within the open directories curated by AttackCapture. Finding this code provides defenders with a crucial perspective on how malicious actors might attempt to exploit vulnerabilities. This intelligence empowers security teams to anticipate attacker tactics and fortify network defenses, allowing for proactive preparation before a potential breach occurs.

CVE-2024-6387

Code Search Query: 7etsuo-regreSSHion.c

Description: Here, we are explicitly searching for the use of a C file named "7etsuo-regreSSHion.c," which contains code for the RegreSSHion exploit. This vulnerability affects SSH implementations, allowing attackers to potentially gain unauthorized access to systems. By targeting this file name, the query helps quickly locate instances where the RegreSSHion exploit may be present in open directories.

Figure 10: Searching for directories using a specific version of the regreSSHion exploit code (Try it: Hunt)

CVE-2024-29895

Code Search Query: /cacti/cmd_realtime.php

Description: The final query targets the cmd_realtime.php file in Cacti, which was vulnerable to command injection. This flaw affected Cacti versions on the 1.3.x DEV branch and allowed unauthenticated users to execute arbitrary commands on the server. In Figure 11 below, we see a few Python variations of the exploit and instances of the Nuclei scanner, likely used to check server exposure to the vulnerability.

Figure 11: Exploit code targeting a command injection vulnerability in Cacti (Try it: Hunt)

Conclusion

Code Search within AttackCapture gives defenders the ability to uncover a wide range of malicious code, from exploits and reverse shells to C2 configurations, just to name a few. This feature helps security teams gain insights into potential threats and proactively bolster defenses against evolving attack methods. As we continue to expand CodeSearch to include additional configurations like Havoc C2 (Coming Soon!), we invite your feedback on other file types or features that would enhance your threat-hunting capabilities.

Related Posts:

Introducing Code Search on AttackCapture: Uncover Exploit Code, Reverse Shells, C2 Configs, and More
Oct 15, 2024

Read how CodeSearch helps security professionals to identify exploit code, reverse shells, and C2 configs across open directories, enhancing threat detection.

Introducing Code Search on AttackCapture: Uncover Exploit Code, Reverse Shells, C2 Configs, and More
Oct 15, 2024

Read how CodeSearch helps security professionals to identify exploit code, reverse shells, and C2 configs across open directories, enhancing threat detection.

Unmasking Adversary Infrastructure: How Certificates and Redirects Exposed Earth Baxia and PlugX Activity
Oct 10, 2024

Learn how basic tracking techniques using unusual certificates and redirects helped uncover Earth Baxia and a hidden cyber threat, providing practical insights for network defense.

Unmasking Adversary Infrastructure: How Certificates and Redirects Exposed Earth Baxia and PlugX Activity
Oct 10, 2024

Learn how basic tracking techniques using unusual certificates and redirects helped uncover Earth Baxia and a hidden cyber threat, providing practical insights for network defense.

Inside a Cybercriminal’s Server: DDoS Tools, Spyware APKs, and Phishing Templates
Oct 8, 2024

Explore our in-depth analysis of a cybercriminal’s server, revealing DDoS tools, SpyNote spyware, phishing sites, and ransomware tactics.

Inside a Cybercriminal’s Server: DDoS Tools, Spyware APKs, and Phishing Templates
Oct 8, 2024

Explore our in-depth analysis of a cybercriminal’s server, revealing DDoS tools, SpyNote spyware, phishing sites, and ransomware tactics.

Announcing Hunt SQL
Oct 3, 2024

We’re excited to release Hunt SQL and to provide the power and flexibility of SQL to researchers, analysts and threat hunters alike. 

Announcing Hunt SQL
Oct 3, 2024

We’re excited to release Hunt SQL and to provide the power and flexibility of SQL to researchers, analysts and threat hunters alike. 

Introducing Code Search on AttackCapture: Uncover Exploit Code, Reverse Shells, C2 Configs, and More
Oct 15, 2024

Read how CodeSearch helps security professionals to identify exploit code, reverse shells, and C2 configs across open directories, enhancing threat detection.

Unmasking Adversary Infrastructure: How Certificates and Redirects Exposed Earth Baxia and PlugX Activity
Oct 10, 2024

Learn how basic tracking techniques using unusual certificates and redirects helped uncover Earth Baxia and a hidden cyber threat, providing practical insights for network defense.