Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2014-6271 PoC — GNU Bash 远程代码执行漏洞

Source
Associated Vulnerability
Title:GNU Bash 远程代码执行漏洞 (CVE-2014-6271)
Description:GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution, aka "ShellShock." NOTE: the original fix for this issue was incorrect; CVE-2014-7169 has been assigned to cover the vulnerability that is still present after the incorrect fix.
Readme
## CVE-2014-6271
- CVE-2014-6271은 "Shellshock"라고 알려진 심각한 취약점으로, 2014년에 발견되어 공개된 취약점이다. 이 취약점은 Bash 쉘에서 발견되어 거의 모든 Unix 및 Linux 시스템에 영향을 미치며, 인터넷 상에서 가장 널리 이해되는 취약점 중 하나이다.

## 보안 위협
- Shellshock 취약점은 Bash 쉘에서 환경 변수를 통해 임의의 코드 실행을 허용하는 취약점으로, 공격자는 특정 환경 변수 값을 조작함으로써 시스템에 악의적인 코드를 삽입할 수 있었습니다. 이는 시스템을 제어하거나 사용자 정보를 탈취하는 등의 악용이 가능했다.

## 실습 환경
- pwnable.kr shellshock 문제를 활용하여 실습 해볼것이다.
- ssh shellshock@pwnable.kr -p2222
- pw: guest
## 공격 방법
- shellshock 취약점은 bash shell 에서 환경변수 설정을 함수와 유사한 문법으로 설정 햇을 때 bash shell에서 이를 불러 올때 함수로 인식하는 취약점을 이용한 것이다.
- 악의적으로 환경변수 값을 함수 문법과 유사하게 설정한 후 그뒤에 ';'을 넣고 커맨드를 삽입하면 bash가 실행 될때 뒤에 커맨드가 실행 된다.
- 환경 변수 설정 해보기
> ![0](https://github.com/hanmin0512/CVE-2014-6271_pwnable/assets/37041208/ba52652e-c9de-4228-8f24-c3c328255d57)

- 함수 설정해보기 (export -f 다른 세션(subprocess)에서도 함수 사용할수 있게 해주는 옵션)
> ![1](https://github.com/hanmin0512/CVE-2014-6271_pwnable/assets/37041208/040df9a2-37c5-47f4-9242-09c2a0c3db58)

- 환경 변수 설정 공격 해보기
> ![2](https://github.com/hanmin0512/CVE-2014-6271_pwnable/assets/37041208/29bef225-e85f-4f15-afde-2c83da9b6498)
- 환경 변수의 값을 함수문법으로하여 bash가 함수로 인식하게 한후 뒤에 커맨드를 삽입하여 flag를 읽으려 시도 하였지만 권한이 없어 실행 하지 못했다.

- shellshock.c의 코드를 보면 유효한 그룹 아이디로 상승 시켜준 후 bash를 실행 시킨다.
> ![3](https://github.com/hanmin0512/CVE-2014-6271_pwnable/assets/37041208/d30d0941-18ff-464d-816d-3fe61b5d1246)

- bash가 subprocess로 실행 될 때 export한 attack 환경변수를 초기화 하는데 그 과정에서 함수로 인식하고 그 뒤 커맨드가 실행된다.
- shellshock을 실행시키면 그룹 아이디가 권한 상승 되기 때문에  flag를 읽을 수 있는 권한이 생기고, 프로그램에서 bash를 실행시키기 때문에 그 과정에서 삽입한 커맨드 /bin/cat flag가 실행 된다.
> ![4](https://github.com/hanmin0512/CVE-2014-6271_pwnable/assets/37041208/c466a405-9cc1-4f8a-81b0-4af777dd6e3b)



File Snapshot

[4.0K] /data/pocs/bf0dc91409e927f55bbbc5bb4e288a99d9a67d1f ├── [2.7K] README.md └── [ 187] shellshock.c 0 directories, 2 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →