Setup a Pentest environment with Axiom

What is Axiom

Axiom is a dynamic infrastructure framework to efficiently work with multi-cloud enviornments, build and deploy repeatable infrastructure focussed on offensive and defensive security.

Tools for cloud-based testing environments. It’s easy to create/manage Instances, and it’s also a very cool and popular tool for parallel scanning.

클라우드 기반의 테스팅 환경을 위한 도구입니다. 쉽게 Instance를 생성/관리할 수 있고, 병렬 스캔을 지원하고 있어서 굉장히 멋지고 인기있는 도구이기도 하죠.

Set-up digitalocean’s API token

First, GET API Token from digitalocean. Privileges are required for both R/W.

우선 digitalocean에서 API Token을 받아줍니다. 권한은 R/W 모두 필요합니다.

https://cloud.digitalocean.com/account/api/tokens

Install Axiom using bash script

Install using a one-line script. @pry is the best 😎

다행히 쉬운 설치를 위해 @pry가 install script를 만들어둔 상태입니다. curl을 통해서 axiom을 설치해줍시다. 설치 과정에선 위에서 Generate 한 APK Key가 필요하며, 이를 기반으로 digitalocean에서

bash <(curl -s https://raw.githubusercontent.com/pry0cc/axiom/master/interact/axiom-configure)

When the installation is complete, add the API key.

설치가 완료되면 마지막에 API Key를 받습니다.

At the same time, an instance is created/run for installation on the digitalocean.

이를 통해서 digitalocean API를 사용하여 Instance를 관리할 수 있습니다. 완료와 동시에 digitalocean에선 Instance(Droplet)가 생성되며 Init scirpt가 동작합니다.

그리고 완료되면…

When finished, instance(droplet) ends and the image is saved in the snapshot.

구동중이던 Droplet 은 종료되고 설치한 이미지가 Snapshot에 저장됩니다.

Start new Instance

Now can boot up and use the image in the snapshot directly through the axiom-init command.

이제 스냅샷도 저장되었으니 테스팅 환경이 필요할 때 아래 명령으로 세팅해줍니다. 이미 스냅샷에 설치된 이미지가 있는 상태라 오래걸리진 않아요.

axiom-init

If the command appears to be not found, reload the rc file or reopen the terminal session. This is because the axiom related command goes into rc.

아 간혹 axiom 설치 후 바로 구동하면 명령어가 없다는 말이 나오는 경우가 있는데, 이 땐 터미털(bash/zsh 등)의 rc파일을 리로드해주면 됩니다. 귀찮으면 그냥 터미널 세션을 새로 열어도 되구요.

source ~/.zshrc

After axis-init, it automatically connects to ssh and allows you to use the configured environment immediately. If ssh connection is lost or re-connected after initialization, ssh access is possible with the axis-ssh command. I need an instance name to arguments

axiom-init 이후엔 자동으로 ssh로 연결되며 구성된 환경을 바로 사용할 수 있습니다. init 후 ssh connection을 잃거나 재 접속이 필요한 경우 axiom-ssh 명령으로 ssh 접근이 가능합니다. 인자값으론 구동중인 instance 이름이 필요하구요.

axiom-ssh pike28

axiom-@ command!!!

The environment itself is great, but the command set that has already been created is really cool. This allows you to skip the cumbersome process and control scanning in the cloud environment from the host.

axiom-ssh 접근 이후 구성된 도구를 쓰는것도 좋지만, Axiom의 매력은 host에 구성된 명령셋에 있습니다. axiom-scan axiom-boxes axiom-account axiom-fleet 등의 명령을 이용하여 클라우드에 구성된 서버를 쉽게 제어하고 테스팅하는데 사용할 수 있습니다.

For example. running cloud base httpx using the host domains in the files

간단하게 domains list를 기반으로 httpx를 이용하여 http/https 를 식별한다고 하면 axiom-scan -m httpx 로 쉽게 처리할 수 있습니다.

cat domains
localhost.hahwul.com
phoenix.hahwul.com
www.hahwul.com
axiom-scan domains -m httpx
Selecting module 'httpx'
Starting axiom-scan using instances: [ pike28 ]
Command: [ cat input | /home/op/go/bin/httpx -silent > output ] | Ext: [txt]
...
Files downloaded...
Mode set to txt.. Sorting unique.
Output successfully saved to 'output.txt'!

cat output.txt
http://phoenix.hahwul.com
https://www.hahwul.com

물론 httpx 자체가 명령이 굉장히 단순해서 host에서 사용하는것도 별 차이 없겠지만, 클라우드 서버로 대상의 리스트를 전달하고 클라우드 서버에서 테스팅 후 결과를 호스트로 가져오는 번거로운 과정이 이 명령어에 다 담긴거죠.

Scanning at scale with fleet

Fleet is a method of managing multiple instances.

fleet은 여러 인스턴스를 관리하는 방법입니다.

-i == instance -t == expiration time

axiom-fleet scanners -i=15 -t=5

15 instance , max time 5 hour

The generated instance can be identified as axiom-ls and multiple instances can be selected at once through characters such as *. Now, if you use multiple instances to scan nmap in parallel…

여러개 생성한 instance는 axiom-ls 로 확인할 수 있고, * 등의 문자를 통해 여러개의 인스턴스를 한번에 선택할 수 있습니다.

자 이게 여러 인스턴스를 이용해 nmap을 병렬 스캔해보면..

axiom-scan "scanners*" -p443 -iL=targets.txt -m nmapx -sV -C -PN

l2SpXyO9TOJCrCbo4

More? Cheatsheet

https://github.com/pry0cc/axiom/wiki/Cheatsheet

Remove instance

axiom-rm pike28
Deleting 'pike28'...
Warning: Are you sure you want to delete this Droplet? (y/N) ?  y

References