Skip to content

Command Injections ​

FieldValue
Module ID109
DifficultyMedium
TierTier II
CategoryOffensive
Estimated Time6 hours
Cubes Earned20
Experience Points600
Creators21y4d
Last Updated2022-12-13T00:00:00.000000Z
URLhttps://academy.hackthebox.com/app/module/109

Module Includes ​

  • 12 Sections
  • 9 Interactive Exercises
  • 1 Assessments
  • 20 Cubes

Module Description ​

Command injection vulnerabilities can be leveraged to compromise a hosting server and its entire network. This module will teach you how to identify and exploit command injection vulnerabilities and how to use various filter bypassing techniques to avoid security mitigations.

Module Summary ​

Command injections are among the most critical vulnerabilities in web applications, as they allow direct command execution on the hosting server, thus compromising the server and potentially the entire network. This is why it is vital to look for these types of vulnerabilities through pentesting and secure code review.

This module will teach the basics of identifying and exploiting OS command injections. It also covers techniques to bypass various filters and mitigations used to prevent the exploitation of command injections. This module covers methods for exploiting command injections on both Linux and Windows. This module will also teach how to patch command injection vulnerabilities with examples of secure code.

In addition to this, the module will teach you the following:

  • What are injections, and different types
  • Identifying code vulnerable to command injections
  • Different command injection operators we can use
  • When to use each injection operator, depending on the injection case
  • Creating a command injection payload
  • Bypassing front-end input validation and sanitization filters
  • Identifying back-end filters and security mitigations
  • Identifying which characters are blacklisted
  • Different techniques to bypass various blacklisted characters such as spaces, slashes, and semi-colons
  • Different techniques to bypass various blacklisted commands
  • Building unique obfuscation methods to bypass blacklisted commands
  • Using evasion tools to create advanced obfuscated payloads
  • How to turn vulnerable code to code that is secure against command injections

CREST CPSA/CRT-related Sections:

  • All sections

CREST CCT APP-related Sections:

  • All sections

CREST CCT INF-related Sections:

  • All sections

This module is broken into sections with accompanying hands-on exercises to practice each of the tactics and techniques we cover.

At the end of the module, you will face a skills assessment that reflects a real-world pentest with a real application vulnerable to command injection. This will teach you how to identify command injection vulnerabilities in different functionalities of web applications and how to bypass filters and WAFs to exploit web applications.

As you work through the module, you will see example commands and command output for the various topics introduced. It is worth reproducing as many of these examples as possible to reinforce further the concepts presented in each section. You can do this in the Pwnbox provided in the interactive sections or your virtual machine.

You can start and stop the module at any time and pick up where you left off. There is no time limit or "grading," but you must complete all of the exercises and the skills assessment to receive the maximum number of cubes and have this module marked as complete in any paths you have chosen.

The module is classified as "Medium" and assumes a working knowledge of the Linux command line and an understanding of information security fundamentals. This module assumes a basic understanding of web applications and web requests and will build on this understanding to teach how Command Injection vulnerabilities and attacks work.

In addition to the above, a firm grasp of the following modules can be considered prerequisites for successful completion of this module:

  • Intro to Web Applications
  • Web Requests

Sections ​

12 sections - 9 Interactive

#GroupTypeTitle
1IntroductiontheoryIntro to Command Injections
2ExploitationinteractiveDetection
3interactiveInjecting Commands
4interactiveOther Injection Operators
5Filter EvasioninteractiveIdentifying Filters
6interactiveBypassing Space Filters
7interactiveBypassing Other Blacklisted Characters
8interactiveBypassing Blacklisted Commands
9interactiveAdvanced Command Obfuscation
10theoryEvasion Tools
11PreventiontheoryCommand Injection Prevention
12Skills AssessmentinteractiveSkills Assessment

Conclusion ​

Congratulations on completing the Command Injections module.

Throughout this module, we learned different techniques for identifying and exploiting command injection vulnerabilities in web applications and applying various techniques to bypass filters and security mitigations.

If you are interested in learning about advanced command injections, like indirect command injection or blind command injection, you should check out the Whitebox Pentesting 101: Command Injection module, as it is designed to be the follow on to this module. If you are interested in learning about advanced obfuscation techniques and code auditing for command injection vulnerabilities, you may be interested in the Secure Coding 101: JavaScript module, as it covers this subject extensively.