GoToolSharing / htb-cli

Interact with Hackthebox using your terminal - Be faster and more competitive !
https://github.com/GoToolSharing/htb-cli
GNU General Public License v3.0
87 stars 6 forks source link

[BUG] VIP+ and Seasonal Machine not properly spawned #53

Closed DisplayGFX closed 1 year ago

DisplayGFX commented 1 year ago

Describe the bug The seasonal machine is not properly spawned. After running htb-cli start -m Drive (seasonal box at the time), the program spat out what appears to be an empty target string and incorrectly states that its been deployed to lab, when in reality its been deployed to seasonal/competitive.

Machine deployed to lab. Dedicated Instance spawned
Target: %!s(<nil>)

also, when spawning the machine, the IP of the seasonal machine is undefined

htb-cli info                         
? Do you want to check for active machine ? Yes
Name    |OS      |Retired   |Difficulty   |Stars   |IP          |Status        |Last Reset   |Release
Drive   |Linux   |No        |Hard         |4.8     |Undefined   |User & Root   |<nil>        |2023-10-14

It also seems to have side effects to the rest of the machines, as now spawning any machine is giving me this error

? The following machine was found : Visual Yes
No machine is running
Incorrect lab type.
Target: %!s(<nil>)

htb-cli start -m Travel
? The following machine was found : Travel Yes
No machine is running
Incorrect lab type.
Target: %!s(<nil>)

To Reproduce Steps to reproduce the behavior:

  1. Obtain name/id of current seasonal mac
  2. Run the command htb-cli start -m [current seasonal machine]
  3. try running other machines afterwards

Expected behavior The seasonal machine is recognized as such, and handled appropriately and not causing side effects.

QU35T-code commented 1 year ago

Thanks for the information. Can you rerun the command by adding the -v flag?

DisplayGFX commented 1 year ago

┌──(kali㉿kali)-[~/htb]
└─$ htb-cli start -m Drive -v
2023/10/19 01:40:14 HTTP request URL : https://www.hackthebox.com/api/v4/search/fetch?query=Drive
2023/10/19 01:40:14 HTTP request method : GET
2023/10/19 01:40:14 HTTP request body : {}
2023/10/19 01:40:14 Machine found : Drive
? The following machine was found : Drive Yes
2023/10/19 01:40:17 Machine ID: 570
2023/10/19 01:40:17 HTTP request URL : https://www.hackthebox.com/api/v4/machine/recommended/
2023/10/19 01:40:17 HTTP request method : GET
2023/10/19 01:40:17 HTTP request body : {}
2023/10/19 01:40:18 Machine Type: release
2023/10/19 01:40:18 HTTP request URL : https://www.hackthebox.com/api/v4/user/info
2023/10/19 01:40:18 HTTP request method : GET
2023/10/19 01:40:18 HTTP request body : {}
2023/10/19 01:40:19 User subscription: vip+
2023/10/19 01:40:19 HTTP request URL : https://www.hackthebox.com/api/v4/arena/start
2023/10/19 01:40:19 HTTP request method : POST
2023/10/19 01:40:19 HTTP request body : {{}}
2023/10/19 01:40:19 HTTP request URL : https://www.hackthebox.com/api/v4/machine/active
2023/10/19 01:40:19 HTTP request method : GET
2023/10/19 01:40:19 HTTP request body : {}
2023/10/19 01:40:20 Machine ID: 570
2023/10/19 01:40:20 HTTP request URL : https://www.hackthebox.com/api/v4/machine/profile/570
2023/10/19 01:40:20 HTTP request method : GET
2023/10/19 01:40:20 HTTP request body : {}
2023/10/19 01:40:20 map[academy_modules:[] active:1 authUserFirstRootTime:8H 34M 53S authUserFirstUserTime:2H 21M 46S authUserHasReviewed:false authUserHasSubmittedMatrix:false authUserInRootOwns:true authUserInUserOwns:true avatar:/storage/avatars/69894bcbc09fb85054b71bdc805f86bc.png can_access_walkthrough:false difficulty:58 difficultyText:Hard feedbackForChart:map[counterBitHard:244 counterBrainFuck:43 counterCake:29 counterEasy:72 counterExHard:28 counterHard:245 counterMedium:208 counterTooEasy:113 counterTooHard:100 counterVeryEasy:21] firstRootBloodTime:1H 35M 1S firstUserBloodTime:0H 38M 51S free:true has_changelog:false id:570 info_status:<nil> isCompleted:true isGuidedEnabled:false lab_server:<nil> last_reset_time:<nil> machine_mode:seasonal maker:map[avatar:/storage/avatars/c331a52ca1c8335e0cec97ce15455f14.png id:414823 isRespected:false name:Spectra199] maker2:<nil> name:Drive os:Linux ownRank:61 playInfo:map[active_player_count:<nil> expires_at:<nil> isActive:<nil> isSpawned:false isSpawning:true] points:40 recommended:0 release:2023-10-14T19:00:00.000000Z retired:0 rootBlood:map[blood_difference:1H 35M 1S created_at:2023-10-14 23:35:01 user:map[avatar:/storage/avatars/8c9faea377de064aa1c5333355e4ac14.png id:13569 name:xct]] rootBloodAvatar:/storage/avatars/8c9faea377de064aa1c5333355e4ac14.png root_owns_count:752 season_id:3 show_go_vip:false show_go_vip_server:false sp_flag:0 stars:4.8 start_mode:spawn static_points:40 userBlood:map[blood_difference:0H 38M 51S created_at:2023-10-14 22:38:51 user:map[avatar:/storage/avatars/8c9faea377de064aa1c5333355e4ac14.png id:13569 name:xct]] userBloodAvatar:/storage/avatars/8c9faea377de064aa1c5333355e4ac14.png user_can_review:false user_owns_count:947]
Machine deployed to lab. Dedicated Instance spawned
Target: %!s(<nil>)

┌──(kali㉿kali)-[~/htb]
└─$ htb-cli info -v
? Do you want to check for active machine ? Yes
2023/10/19 01:40:54 HTTP request URL : https://www.hackthebox.com/api/v4/machine/active
2023/10/19 01:40:54 HTTP request method : GET
2023/10/19 01:40:54 HTTP request body : {}
2023/10/19 01:40:55 Active machine found !
2023/10/19 01:40:55 Machine ID: 570
2023/10/19 01:40:55 HTTP request URL : https://www.hackthebox.com/api/v4/machine/profile/570
2023/10/19 01:40:55 HTTP request method : GET
2023/10/19 01:40:55 HTTP request body : {}
2023/10/19 01:40:55 map[academy_modules:[] active:1 authUserFirstRootTime:8H 34M 53S authUserFirstUserTime:2H 21M 46S authUserHasReviewed:false authUserHasSubmittedMatrix:false authUserInRootOwns:true authUserInUserOwns:true avatar:/storage/avatars/69894bcbc09fb85054b71bdc805f86bc.png can_access_walkthrough:false difficulty:58 difficultyText:Hard feedbackForChart:map[counterBitHard:244 counterBrainFuck:43 counterCake:29 counterEasy:72 counterExHard:28 counterHard:245 counterMedium:208 counterTooEasy:113 counterTooHard:100 counterVeryEasy:21] firstRootBloodTime:1H 35M 1S firstUserBloodTime:0H 38M 51S free:true has_changelog:false id:570 info_status:<nil> isCompleted:true isGuidedEnabled:false lab_server:<nil> last_reset_time:<nil> machine_mode:seasonal maker:map[avatar:/storage/avatars/c331a52ca1c8335e0cec97ce15455f14.png id:414823 isRespected:false name:Spectra199] maker2:<nil> name:Drive os:Linux ownRank:61 playInfo:map[active_player_count:<nil> expires_at:<nil> isActive:<nil> isSpawned:false isSpawning:true] points:40 recommended:0 release:2023-10-14T19:00:00.000000Z retired:0 rootBlood:map[blood_difference:1H 35M 1S created_at:2023-10-14 23:35:01 user:map[avatar:/storage/avatars/8c9faea377de064aa1c5333355e4ac14.png id:13569 name:xct]] rootBloodAvatar:/storage/avatars/8c9faea377de064aa1c5333355e4ac14.png root_owns_count:752 season_id:3 show_go_vip:false show_go_vip_server:false sp_flag:0 stars:4.8 start_mode:spawn static_points:40 userBlood:map[blood_difference:0H 38M 51S created_at:2023-10-14 22:38:51 user:map[avatar:/storage/avatars/8c9faea377de064aa1c5333355e4ac14.png id:13569 name:xct]] userBloodAvatar:/storage/avatars/8c9faea377de064aa1c5333355e4ac14.png user_can_review:false user_owns_count:947]
Name    |OS      |Retired   |Difficulty   |Stars   |IP          |Status        |Last Reset   |Release
Drive   |Linux   |No        |Hard         |4.8     |Undefined   |User & Root   |<nil>        |2023-10-14
2023/10/19 01:40:55 HTTP request URL : https://www.hackthebox.com/api/v4/user/info
2023/10/19 01:40:55 HTTP request method : GET
2023/10/19 01:40:55 HTTP request body : {}

2023/10/19 01:40:56 HTTP request URL : https://www.hackthebox.com/api/v4/search/fetch?query=DisplayGFX
2023/10/19 01:40:56 HTTP request method : GET
2023/10/19 01:40:56 HTTP request body : {}
2023/10/19 01:40:56 Username found : DisplayGFX
? The following username was found : DisplayGFX No
QU35T-code commented 1 year ago

I see where the error is. I try to fix it during the day. Thanks for the feedback, that’s how we move forward!

QU35T-code commented 1 year ago

I think the problem may be related to the vip+ subscription. I'll test with a vip+ account.

❯ go run . start -m Drive   
? The following machine was found : Drive Yes
You have been assigned as an owner of this machine. Playing on a VIP server
Target: 10.10.11.235
QU35T-code commented 1 year ago

Can you run this commande with -v flag ?

htb-cli start -m Travel -v

Lerold commented 1 year ago
└─$ ./htb-cli start -m Travel -v
2023/10/19 13:22:40 HTTP request URL : https://www.hackthebox.com/api/v4/search/fetch?query=Travel
2023/10/19 13:22:40 HTTP request method : GET
2023/10/19 13:22:40 HTTP request body : {}
2023/10/19 13:22:40 Machine found : Travel
? The following machine was found : Travel Yes
2023/10/19 13:22:44 Machine ID: 252
2023/10/19 13:22:44 HTTP request URL : https://www.hackthebox.com/api/v4/machine/recommended/
2023/10/19 13:22:44 HTTP request method : GET
2023/10/19 13:22:44 HTTP request body : {}
2023/10/19 13:22:44 HTTP request URL : https://www.hackthebox.com/api/v4/machine/profile/252
2023/10/19 13:22:44 HTTP request method : GET
2023/10/19 13:22:44 HTTP request body : {}
2023/10/19 13:22:45 Machine Type: retired
2023/10/19 13:22:45 HTTP request URL : https://www.hackthebox.com/api/v4/user/info
2023/10/19 13:22:45 HTTP request method : GET
2023/10/19 13:22:45 HTTP request body : {}
2023/10/19 13:22:45 User subscription: vip+
2023/10/19 13:22:45 HTTP request URL : https://www.hackthebox.com/api/v4/machine/play/252
2023/10/19 13:22:45 HTTP request method : POST
2023/10/19 13:22:45 HTTP request body : {{}}
2023/10/19 13:22:45 HTTP request URL : https://www.hackthebox.com/api/v4/machine/active
2023/10/19 13:22:45 HTTP request method : GET
2023/10/19 13:22:45 HTTP request body : {}
No machine is running
Incorrect lab type.
Target: %!s(<nil>)
Lerold commented 1 year ago

On a side note, this just came up and I can't start machines via the GUI either.

image

QU35T-code commented 1 year ago

Thanks ! Can you start a new instance with the GUI and give me the endpoint when the machine starts ? (https://www.hackthebox.com/api/v4/..........spawn|start). This is a problem related to vip+, sorry.

Lerold commented 1 year ago

Thanks ! Can you start a new instance with the GUI and give me the endpoint when the machine starts ? (https://www.hackthebox.com/api/v4/..........spawn|start). This is a problem related to vip+, sorry.

I've managed to start it via GUI in the US, what command do you want me to run?

QU35T-code commented 1 year ago

It's ok, I think I've fixed it, I'm doing the last tests.

QU35T-code commented 1 year ago

I will wait HTB works again to release because their API does mystical things

DisplayGFX commented 1 year ago

Tested in Dev Seems to work, though stop still has trouble recognizing spawning machines. Much less of a problem though, thank you!

┌──(kali㉿kali)-[~/htb]
└─$ htb-cli start -m Drive
? The following machine was found : Drive Yes
Machine deployed to lab. Dedicated Instance spawned
Target: 10.129.72.61

┌──(kali㉿kali)-[~/htb]
└─$ htb-cli info          
? Do you want to check for active machine ? Yes
Name    |OS      |Retired   |Difficulty   |Stars   |IP          |Status        |Last Reset   |Release
Drive   |Linux   |No        |Hard         |4.8     |Undefined   |User & Root   |<nil>        |2023-10-14

? The following username was found : DisplayGFX No

┌──(kali㉿kali)-[~/htb]
└─$ htb-cli stop                                                                          
This machine is not active.

┌──(kali㉿kali)-[~/htb]
└─$ htb-cli stop
Machine terminated. VIP+ server available

┌──(kali㉿kali)-[~/htb]
└─$ htb-cli start -m Travel 
? The following machine was found : Travel Yes
Machine deployed to lab.
Target: 10.129.61.139
QU35T-code commented 1 year ago

Yep, a condition is missing on the stop and info command. I will add this morning

QU35T-code commented 1 year ago

@DisplayGFX This should be good for ip display via htb-cli info command. Can you confirm this ? For the bug related to htb-cli stop command, it's the api that doesn't return the info sometimes and I don't think I can fix it at the moment. (Dev branch)

QU35T-code commented 1 year ago

Merged : https://github.com/GoToolSharing/htb-cli/releases/tag/v1.3.1