Skip to content
KitploitKITPLOIT
도구블로그
제출
도구블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

··피드·문의·개인정보·© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
cs2modrewrite — Cobalt Strike 프로필을 modrewrite 스크립트로 변환합니다 | Kitploit
도구/GitHubGitHub/threatexpress/cs2modrewrite
Web Proxies & InterceptionIDS/IPS EvasionNetwork SecurityPenetration TestingCommand and ControlRed Teaming
GitHubthreatexpress/cs2modrewrite

cs2modrewrite

Cobalt Strike 프로필을 modrewrite 스크립트로 변환합니다

저장소 보기
60811653년 전Kitploit 검토 완료

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →
공유

Apache mod_rewrite 또는 Nginx를 위한 규칙 세트 자동 생성: 지능형 HTTP C2 리디렉션

Python application 이 프로젝트는 Cobalt Strike 프로파일을 기능적인 mod_rewrite .htaccess 또는 Nginx 구성 파일로 변환하여 HTTP 역방향 프록시 리디렉션을 Cobalt Strike 팀서버로 지원합니다. 역방향 프록시를 사용하면 프로파일링, 조사 및 일반적인 인터넷 배경 방사선으로부터 백엔드 C2 서버를 보호할 수 있습니다.

참고: 배포 전에 필요에 따라 출력을 테스트하고 조정해야 하지만, 이 스크립트들이 대부분의 작업을 처리할 것입니다.

기능

  • 이제 Python 3.0+ 필요
  • CS 4.0부터 Cobalt Strike 사용자 정의 URI 기능 지원
  • 유효한 C2 URI(HTTP GET, POST, Stager)와 지정된 User-Agent 문자열을 기반으로 하는 재작성 규칙
    • 결과: 기본적으로 지정된 UA 문자열이 있는 유효한 C2 엔드포인트에 대한 요청만 팀서버로 프록시됩니다.
  • 사용자 정의 Malleable C2 프로파일을 사용하여 해당 mod_rewrite 규칙이 포함된 .htaccess 파일을 빌드합니다.
  • 사용자 정의 Malleable C2 프로파일을 사용하여 해당 proxy_pass 규칙이 포함된 Nginx 구성 파일을 빌드합니다.
  • Cobalt Strike 팀서버로 HTTP 또는 HTTPS 프록시
  • 일치하지 않는 요청에 대해 합법적인 사이트로 HTTP 302 리디렉션

빠른 시작

빠른 테스트를 위해 havex.profile 예제가 포함되어 있습니다.

  1. 프로파일에 대해 스크립트 실행
  2. 출력을 리디렉터에 있는 .htaccess 또는 /etc/nginx/nginx.conf에 저장
  3. 필요에 따라 수정
  4. 웹 서버 다시 로드/재시작

원격 include 파일을 사용한 Apache mod_rewrite 사용 예시

root@kitploit:~
python3 cs2modrewrite.py -i havex.profile -c https://TEAMSERVER -r https://GOHERE -o /etc/apache2/redirect.rules

예제 Apache 구성

root@kitploit:~
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    RemoteIPHeader X-Forwarded-For

    ErrorLog /var/log/apache2/redirector_error.log
    CustomLog /var/log/apache2/redirector_access.log combined
    ErrorDocument 401 " "
    ErrorDocument 403 " "
    ErrorDocument 404 " "
    ErrorDocument 500 " "
    ErrorDocument 503 " "

    # Include redirect.rules
    Include /etc/apache2/redirect.rules
</VirtualHost>

다음과 같이 Apache Server Header, ServerTokens 및 로깅을 업데이트하는 것을 고려하세요.

root@kitploit:~
## Update Apached Server Header, ServerTokens, and logging
echo "Update Update Apached Server Header, ServerTokens, and logging"
sed -i -e 's/\(ServerTokens\s\+\)OS/\1Prod/g' /etc/apache2/conf-enabled/security.conf
sed -i -e 's/\(ServerSignature\s\+\)On/\1Off/g' /etc/apache2/conf-enabled/security.conf
echo "SecServerSignature Server" >> /etc/apache2/conf-enabled/security.conf
echo "LogLevel alert rewrite:trace2" >> /etc/apache2/conf-enabled/security.conf

## Update Apached remoteip.conf
echo "Update Apached remoteip.conf"
echo "RemoteIPHeader X-Forwarded-For" >> /etc/apache2/conf-enabled/remoteip.conf

## Restart apache server
echo "Restart apache server"
systemctl restart apache2

.htaccess 파일을 사용한 Apache mod_rewrite 사용 예시

root@kitploit:~
python3 cs2modrewrite.py -i havex.profile -c https://TEAMSERVER -r https://GOHERE -o /var/www/html/.htaccess

Apache Rewrite 설정 및 팁

Rewrite 및 Proxy 활성화

root@kitploit:~
apt-get install apache2
a2enmod rewrite headers proxy proxy_http ssl cache
a2dismod -f deflate
service apache2 reload

참고: https://bluescreenofjeff.com/2016-06-28-cobalt-strike-http-c2-redirectors-with-apache-mod_rewrite/ "e0x70i님이 아래 댓글에서 지적했듯이, Cobalt Strike Malleable C2 프로파일에 gzip에 대한 Accept-Encoding 헤더가 포함되어 있으면 Apache 설치 시 기본적으로 해당 트래픽을 압축하여 Beacon이 응답하지 않거나 오작동할 수 있습니다. 이를 해결하려면 mod_deflate를 비활성화하고(a2dismod deflate 사용) 재작성 규칙에 No Encode ([NE]) 플래그를 추가하세요. (감사합니다, e0x70i!)"

SSL 지원 활성화

다음 항목이 사이트 구성(예: /etc/apache2/available-sites/*.conf)에 있는지 확인하세요.

root@kitploit:~
# Enable SSL
SSLEngine On
# Enable SSL Proxy
SSLProxyEngine On
# Trust Self-Signed Certificates generated by CobaltStrike
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off

.HTACCESS

.htaccess 파일에서 mod_rewrite를 사용하려면(사이트 구성 파일 대신) AllowOverride None을 AllowOverride All로 변경하여 .htaccess 파일 사용을 활성화해야 합니다. 모든 웹사이트에 대해 /etc/apache2/apache.conf를 편집하세요.

root@kitploit:~
<Directory /var/www/>
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

마지막으로, 확실하게 Apache를 한 번 더 재시작하세요.

service apache2 restart

문제 해결

리디렉션 규칙 동작 문제를 해결해야 하는 경우, 다음 줄을 추가하여 사이트 구성 파일에서 자세한 오류 추적을 활성화하세요.

LogLevel alert rewrite:trace5

다음으로 Apache를 다시 로드하고 /var/log/access.log와 /var/log/error.log를 모니터링하여 어떤 규칙이 일치하는지 확인하세요.


Nginx 사용 예시

Nginx 설치

root@kitploit:~
apt-get install nginx nginx-extras

참고: 사용자 정의 서버 헤더를 위해 nginx-extras가 필요합니다. 이 패키지를 설치할 수 없으면 결과 구성 파일에서 서버 헤더 줄을 주석 처리하세요.

리디렉션 규칙 생성

cs2nginx.py의 출력을 /etc/nginx/nginx.conf에 저장하고 필요에 따라 수정하세요(SSL 매개변수).

python3 ./cs2nginx.py -i havex.profile -c https://127.0.0.1 -r https://www.google.com -H mydomain.local >/etc/nginx/nginx.conf

마지막으로, 서버 구성 파일을 수정한 후 nginx를 재시작하세요.

service nginx restart

마지막 생각

리디렉션이 구성되고 작동하면 C2 서버가 리디렉터와 신뢰할 수 있는 IP(VPN, 사무실 범위 등)에서만 인그레스를 허용하도록 확인하세요.

GeoIP 제한(mod_maxmind) 및 불량 사용자 에이전트와 IP 범위의 블랙리스트를 사용하여 추가 리디렉터 보호를 고려하세요. 아이디어를 주신 @curi0usJack님께 감사드립니다.

참고 자료

  • Joe Vest와 Andrew Chiles - cs2modrewrite.py 블로그 포스트

  • @bluescreenofjeff - Apache mod_rewrite를 사용한 Cobalt Strike HTTP C2 리디렉터

  • Adam Brown - Nginx를 사용한 탄력적인 레드팀 HTTPS 리디렉션

  • Apache - Apache mod_rewrite 문서

도구 다운로드