Security

BeEF

BeEF 사용법 정리

BeEF


1. 설치

시놀로지 나스에 설치하기 위해 docker 를 이용했다.


docker image pull

Copy
docker pull beefproject/beef

아래 명령어로 컨테이너를 생성하자.
Copy
docker run -p 3000:3000 -p 6789:6789 -p 61985:61985 -p 61986:61986 --name beef beefproject/beef

사용자명과 비밀번호를 수정하라고 메세지가 출력된다.


아래 명령어로 컨테이너 내부의 config.yaml 파일을 호스트로 복사하자.
Copy
docker cp d72f2b6f1b8b:/beef/config.yaml /volume1/private/DockerTest/


사용자명과 비밀번호를 수정하자.
Copy
nano config.yaml

수정한 config.yaml 파일을 컨테이너 내부로 복사하자.
Copy
docker cp /volume1/private/DockerTest/config.yaml d72f2b6f1b8b:/beef/
docker restart beef

웹사이트에서 접속해보자.
http://IP_ADDRESS:3000/ui/authentication

http://IP_ADDRESS:3000/hook.js 을 target 으로 보내자.

2. SSL 적용

ssl 을 적용해 보자.

DSM 에서 제어판 > 보안 > 기본 인증서를 선택하고 > 내보내기 누르자.

컨테이너에서 /beef/cert 를 만들고 wget 을 이용해서 내보내기 했던 ECC-cert.pem 와 ECC-privkey.pem 을 받아오자.

기존 파일을 바꾸자.

bash-5.1$ mv ./cert/ECC-cert.pem beef_cert.pem bash-5.1$ mv ./cert/ECC-privkey.pem beef_key.pem

beef 에서 https 접속을 하기 위해 beef 컨테이너로 들어가서 config.yaml 수정하려고 하면 권한이 없다.

아래 명령어로 컨테이너 root 로 로그인 할수 있다.

Copy
docker exec -u 0 -it beef bash


아래와 같이 enable true 로 수정하자

config.yaml
Copy
https:
            enable: true
            # Enabled this config setting if you're external facing uri is using https
            public_enabled: true
            # In production environments, be sure to use a valid certificate signed for the value
            # used in beef.http.public (the domain name of the server where you run BeEF)
            key: "beef_key.pem"
            cert: "beef_cert.pem"

이제 SSL 연결이 된다.

3. 컨테이너 네트워크 설정

그런데 BeEF 서버에서 target ip 가 모두 172.17.0.1 로 표시된다.
docker 가 자신만의 네임스페이스를 갖기 때문이다.


이를 해결하기 위해 아래 명령어로 컨테이너를 새로 만들자.
Copy
docker run --network host --name BeEF beefproject/beef

이제 컨테이너에서 호스트 네트워크를 공유하게 된다.

따라서 포트 맵핑이 필요가 없다.
도커는 호스트와 격리되도록 설계 되었기 때문에 좋은 방법은 아니다.

기존 컨테이너는 삭제하자.

Copy
docker rm beef

Reference