Skip to content

Commit

Permalink
Merge branch 'release/v1.3.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
qu35t-code committed Oct 20, 2023
2 parents 3d25e3c + 1717b9a commit 2acce62
Show file tree
Hide file tree
Showing 30 changed files with 911 additions and 456 deletions.
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] <title>"
labels: bug
assignees: QU35T-code

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.
60 changes: 1 addition & 59 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,62 +31,4 @@ jobs:
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: go build -v ./...

tests:
if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && !github.event.pull_request.draft)
needs: build
runs-on: ubuntu-latest
name: Update coverage badge
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- name: Setup go
uses: actions/setup-go@v2
with:
go-version: '1.19'

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run Test
run: |
go test -v ./... -covermode=set -coverprofile=coverage.out
go tool cover -func=coverage.out -o=coverage.out
env:
HTB_TOKEN: ${{ secrets.HTB_TOKEN }}
TEST: "true"

- name: Go Coverage Badge
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v12
id: verify-changed-files
with:
files: README.md

- name: Commit changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "chore: Updated coverage badge."
- name: Push changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.TOKEN_PUSH }}
branch: dev
run: go build -v ./...
176 changes: 155 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# htb-cli
![Coverage](https://img.shields.io/badge/Coverage-17.4%25-red)

![Workflows (main)](https://github.com/GoToolSharing/htb-cli/actions/workflows/go.yml/badge.svg?branch=main)
![Workflows (dev)](https://github.com/GoToolSharing/htb-cli/actions/workflows/go.yml/badge.svg?branch=dev)
Expand All @@ -17,51 +16,186 @@
<img alt="arm64" src="https://img.shields.io/badge/arm64%20(aarch64)-supported-success">
</div>

<div align="center">
<img src="./assets/logo.png" alt="Alt text" width="400">
</div></br>

## Installation

`go install github.com/GoToolSharing/htb-cli@latest`

## Configuration

You must add a Hackthebox **App token** in the **HTB_TOKEN** environment variable (zshrc maybe).
API Token can be find here : https://app.hackthebox.com/profile/settings => `Create App Token`
In order to use `htb-cli`, you need to generate a **HackTheBox application token**. This token can be generated via your account configuration page: https://app.hackthebox.com/profile/settings, then by clicking on `Create App Token`.

This API token must be set in the **HTB_TOKEN** environment variable. You can add it directly to your `bashrc / zshrc` to make it permanent.

```
export HTB_TOKEN=eyJ...
```

## Helper
## Commands

To exit a tview, press `CTRL + C`.

### Helper

```bash
❯ htb-cli help

This software, engineered using the Go programming language, serves to streamline and automate various tasks for the HackTheBox platform, enhancing user efficiency and productivity.

Usage:
htb-cli [command]

Available Commands:
help Help about any command
info Detailed information on challenges and machines
machines Displays active / retired machines and next machines to be released
reset Reset a machine
start Start a machine
status Displays the status of hackthebox servers
stop Stop the current machine
submit Submit credentials (machines / challenges / arena)

Flags:
-b, --batch Don't ask questions
-h, --help help for htb-cli
-p, --proxy string Configure a URL for an HTTP proxy
-v, --verbose Verbose mode
Use "htb-cli [command] --help" for more information about a command.
```
### info
The `info` command will retrieve information from the active machine (if any) and display it. If no argument is supplied, the logged-in user's information will be displayed.
You can combine machines / challenges and users.

```bash
Flags:
-c, --challenge strings Challenge name
-h, --help help for info
-m, --machine strings Machine name
-u, --username strings Username
Global Flags:
-b, --batch Allows all questions
-p, --proxy string Configure a URL for an HTTP proxy
-v, --verbose Verbose mode
```

```bash
❯ htb-cli info
? Do you want to check for active machine ? No
? The following username was found : QU35T3190 Yes
```

```bash
❯ htb-cli info -c test -m Sau -u Yakei
? Do you want to check for active machine? No
? The following machine was found : Sau Yes
Name |OS |Retired |Difficulty |Stars |IP |Status |Last Reset |Release
Sau |Linux |No |Easy |4.6 |Undefined |User & Root |1 month before |2023-07-08
? The following challenge was found : Leet Test Yes
Name |Category |Retired |Difficulty |Stars |Solves |Status |Release
Leet Test |Pwn |Yes |Easy |4.9 |256 |No flags |2020-11-18
? The following username was found : Yakei Yes
```

### machines

The `machines` command displays the list of active machines, the last 20 machines removed and the next machines planned.
The command requires no arguments.

```bash
❯ htb-cli machines
```

### start

The `start` command starts an instance for a machine. The machine name must be specified using the `-m` or `--machine` argument. Once started, its IP address is displayed.

```bash
Flags:
-h, --help help for start
-m, --machine string Machine name
Global Flags:
-b, --batch Allows all questions
-p, --proxy string Configure a URL for an HTTP proxy
-v, --verbose Verbose mode
```

```bash
❯ htb-cli start -m Visual
? The following machine was found : Visual Yes
Machine deployed to lab. Playing on a VIP server
Target: 10.10.11.234
```

### stop

The `stop` command is used to stop a machine instance. No arguments are required. The current machine will be stopped.

![Helper](/assets/helper.png)
```bash
❯ htb-cli stop
## Start
Machine terminated. VIP server available
```

![Start machine](/assets/start.png)
### reset

## Stop
The `reset` command is used to request the reset of an instance. No arguments are required. The reset request will be made for the current machine.

![Stop machine](/assets/stop.png)
```bash
❯ htb-cli reset
## Reset
No active machine found
```

![Reset machine](/assets/reset.png)
### status

## Submit
The `status` command displays the status of hackthebox servers.

### Submit machine flag
```bash
❯ htb-cli status
![Submit machine flag](/assets/submit_machine.png)
All Systems Operational
```

### Submit challenge flag
### submit

![Submit challenge flag](/assets/submit_challenge.png)
The `submit` command is used to submit a flag. Currently, the following submissions are supported :

## Info
* VIP machines
* VIP+ machines
* Machines Free
* Release Arena
* Challenges

![Info active machine](/assets/info_active.png)
If there is no `--machine` or `--challenge` flag, submission will be made on the current active machine. Otherwise, this can be specified with the `--machine` and `--challenge` flags.

![Info machines](/assets/info_machines.png)
```bash
❯ htb-cli submit -f flag4testing -d 3
No machine is running
```

```bash
❯ htb-cli submit -c test -f flag4testing -d 3
? The following challenge was found : Leet Test Yes
Incorrect flag
```

## Status
```bash
❯ htb-cli submit -m Sau -f flag4testing -d 3
![Status](/assets/status.png)
? The following machine was found : Sau Yes
Incorrect flag!
```
Binary file removed assets/helper.png
Binary file not shown.
Binary file removed assets/info_active.png
Binary file not shown.
Binary file removed assets/info_machines.png
Binary file not shown.
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/reset.png
Binary file not shown.
Binary file removed assets/start.png
Binary file not shown.
Binary file removed assets/status.png
Binary file not shown.
Binary file removed assets/stop.png
Binary file not shown.
Binary file removed assets/submit_challenge.png
Binary file not shown.
Binary file removed assets/submit_machine.png
Binary file not shown.
71 changes: 0 additions & 71 deletions cmd/active.go

This file was deleted.

12 changes: 0 additions & 12 deletions cmd/active_test.go

This file was deleted.

Loading

0 comments on commit 2acce62

Please sign in to comment.