diff --git a/pkgs/by-name/ht/htb-toolkit/disable-shell-prompt-change.patch b/pkgs/by-name/ht/htb-toolkit/disable-shell-prompt-change.patch index 07e8468ccbcf..d841a3b2eb79 100644 --- a/pkgs/by-name/ht/htb-toolkit/disable-shell-prompt-change.patch +++ b/pkgs/by-name/ht/htb-toolkit/disable-shell-prompt-change.patch @@ -1,5 +1,5 @@ ---- a/src/main.rs 2024-01-17 23:44:21.346253718 +0100 -+++ b/src/main.rs 2024-01-17 23:48:54.536921610 +0100 +--- a/src/main.rs 2025-08-25 13:02:46.484172665 +0200 ++++ b/src/main.rs 2025-08-25 13:04:40.721403934 +0200 @@ -15,7 +15,6 @@ use crate::utils::*; use crate::vpn::*; @@ -8,13 +8,13 @@ use std::process::Command; #[tokio::main] -@@ -44,16 +43,6 @@ - eprintln!("Error creating folder: {}", err); +@@ -47,16 +46,6 @@ + eprintln!("Error creating folder: {err}"); } } - - // Create HTB config file if not existing -- let htb_config = format!("{}/.htb.conf", home); +- let htb_config = format!("{home}/.htb.conf"); - - let file = Path::new(&htb_config); - if !file.exists() { @@ -25,7 +25,7 @@ // Initialize Xorg in WSL for secret-tool popup window if is_wsl() && is_display_zero() { -@@ -104,13 +93,6 @@ +@@ -107,13 +96,6 @@ let _ = play_machine(&args[2]).await; } } @@ -39,9 +39,17 @@ "-r" => { reset_machine().await; } ---- a/src/manage.rs 2024-01-17 22:50:22.450368210 +0100 -+++ b/src/manage.rs 2024-01-17 23:49:21.143071918 +0100 -@@ -77,19 +77,14 @@ +--- a/src/manage.rs 2025-08-25 13:03:00.835291752 +0200 ++++ b/src/manage.rs 2025-08-25 13:18:21.770141852 +0200 +@@ -12,7 +12,6 @@ + use std::fs; + use std::io::{self,Write}; + use std::path::PathBuf; +-use regex::Regex; + use tokio::spawn; + + pub async fn get_active_machine_info() { +@@ -78,19 +77,14 @@ if machine_info.ip.is_empty() { //Starting Point case because SP IP address is assigned only after spawn of the machine machine_info.ip = active_machine.ip; } @@ -61,7 +69,7 @@ let appkey = get_appkey(); let active_machine = ActiveMachine::get_active(&appkey).await; -@@ -126,31 +121,9 @@ +@@ -130,31 +124,9 @@ // Await the result of the blocking task blocking_task.await.expect("Blocking task failed"); @@ -74,7 +82,7 @@ -pub fn prompt_setting(option: &str) { - let home = env::var("HOME").unwrap_or_default(); -- let htb_config = format!("{}/.htb.conf", home); +- let htb_config = format!("{home}/.htb.conf"); - - let content = fs::read_to_string(&htb_config) - .expect("Failed to read HTB config file"); @@ -82,19 +90,19 @@ - let re = Regex::new(r"prompt_change=\w+") - .expect("Failed to create regular expression"); - -- let new_content = re.replace(&content, format!("prompt_change={}", option)); +- let new_content = re.replace(&content, format!("prompt_change={option}")); - - fs::write(&htb_config, new_content.to_string()) - .expect("Failed to write updated content to HTB config file"); - -- println!("Prompt setting updated to: {}", option); +- println!("Prompt setting updated to: {option}"); -} - - pub async fn update_machines() -> io::Result<()> { + fn find_menu_children_mut<'a>(value: &'a mut Value, name: &str) -> Option<&'a mut Vec> { + let obj = value.as_object_mut()?; - println!("Retrieving updated data from Hack The Box... Gimme some time hackerzzz..."); ---- a/src/play.rs 2024-01-17 22:50:25.709380651 +0100 -+++ b/src/play.rs 2024-01-17 23:39:08.715395211 +0100 +--- a/src/play.rs 2025-08-25 13:03:09.912367073 +0200 ++++ b/src/play.rs 2025-08-25 13:06:49.170236608 +0200 @@ -4,7 +4,6 @@ use crate::types::*; use crate::utils::*; @@ -112,7 +120,7 @@ let mut machine_info = PlayingMachine::get_machine(machine_name, &appkey).await; -@@ -103,7 +100,7 @@ +@@ -107,7 +104,7 @@ machine_info.ip = get_ip(&appkey_clone).await; // For Starting Point machines and VIP and VIP+ VPNs, if I call the play API two times on the same machine, the old IP address associated to the machine can still live for some seconds providing a wrong IP related to the new same machine. For this reason, it is better to compute always the IP address (no problems for free VPNs because they associate always the same IP address to the same machine) @@ -121,8 +129,8 @@ let _ = print_banner(); -@@ -115,10 +112,6 @@ - println!("{}Hey! You have already found the Root Flag! Keep it up!{}", BGREEN, RESET); +@@ -119,10 +116,6 @@ + println!("{BGREEN}Hey! You have already found the Root Flag! Keep it up!{RESET}"); } - if htbconfig.promptchange { //If the prompt is set to change during the playing... @@ -132,8 +140,8 @@ // Writing /etc/hosts let _ = add_hosts(&machine_info); ---- a/src/types.rs 2024-01-17 23:40:14.341769452 +0100 -+++ b/src/types.rs 2024-01-17 23:43:14.159871196 +0100 +--- a/src/types.rs 2025-08-25 13:03:30.716513609 +0200 ++++ b/src/types.rs 2025-08-25 13:07:49.414296572 +0200 @@ -2,7 +2,6 @@ use crate::colors::*; use crate::utils::get_interface_ip; @@ -142,7 +150,7 @@ use std::process; use std::thread::sleep; -@@ -485,37 +484,4 @@ +@@ -475,37 +474,4 @@ ip: userip, } } @@ -181,9 +189,9 @@ - } } \ No newline at end of file ---- a/src/utils.rs 2024-01-17 23:29:49.215407440 +0100 -+++ b/src/utils.rs 2024-01-17 23:46:20.681009209 +0100 -@@ -5,7 +5,6 @@ +--- a/src/utils.rs 2025-08-25 13:03:34.500525470 +0200 ++++ b/src/utils.rs 2025-08-25 13:09:31.055654489 +0200 +@@ -7,7 +7,6 @@ use crate::types::*; use crate::vpn::*; use pnet::datalink; @@ -191,9 +199,9 @@ use reqwest::Client; use std::fs; use std::net::IpAddr; -@@ -13,96 +12,6 @@ - use tokio::io::{AsyncWriteExt, BufWriter}; - use tokio::sync::mpsc; +@@ -25,96 +24,6 @@ + } + } -pub fn change_shell(machine_info: &mut PlayingMachine, user_info: &mut PlayingUser) { - let result = std::env::var("SHELL").unwrap_or_default(); @@ -287,8 +295,8 @@ - pub fn display_target_info(machine_info: &PlayingMachine, user_info: &PlayingUser) { println!(); - println!("{}Our secret agent gathered some information about the target:{}", BYELLOW, RESET); -@@ -184,7 +93,7 @@ + println!("{BYELLOW}Our secret agent gathered some information about the target:{RESET}"); +@@ -196,7 +105,7 @@ println!("Play Hack The Box machines directly on your system."); println!(); std::thread::sleep(std::time::Duration::from_secs(2)); //Showing the description for some secs before showing the help message @@ -297,7 +305,7 @@ println!(); println!("Options:"); println!("-a Print information about the current active machine."); -@@ -193,7 +102,6 @@ +@@ -205,7 +114,6 @@ println!("-k Set, reset or delete the Hack The Box App Key."); println!("-m Specify the machine name to play."); println!("-l List free, retired or starting point machines."); diff --git a/pkgs/by-name/ht/htb-toolkit/package.nix b/pkgs/by-name/ht/htb-toolkit/package.nix index bd068d877a63..77c32d43bd71 100644 --- a/pkgs/by-name/ht/htb-toolkit/package.nix +++ b/pkgs/by-name/ht/htb-toolkit/package.nix @@ -2,6 +2,7 @@ lib, rustPlatform, fetchFromGitHub, + unstableGitUpdater, pkg-config, openssl, stdenv, @@ -15,14 +16,14 @@ rustPlatform.buildRustPackage { pname = "htb-toolkit"; - version = "0-unstable-2025-03-15"; + version = "0-unstable-2025-08-12"; src = fetchFromGitHub { owner = "D3vil0p3r"; repo = "htb-toolkit"; # https://github.com/D3vil0p3r/htb-toolkit/issues/3 - rev = "dd193c2974cd5fd1bbc6f7f616ebd597e28539ec"; - hash = "sha256-NTZv0BPyIB32CNXbINYTy4n8tNVJ3pRLr1QDhI/tg2Y="; + rev = "60996a88fbd5e8aeab78005e754ef37d95ffdba4"; + hash = "sha256-u+IigAs/W0lzp9kCW43TkjHTIrPCkGdmva6tesQq/Pk="; }; cargoHash = "sha256-ReEe8pyW66GXIPwAy6IKsFEAUjxHmzw5mj21i/h4quQ="; @@ -44,8 +45,6 @@ rustPlatform.buildRustPackage { ]; postPatch = '' - substituteInPlace src/manage.rs \ - --replace-fail /usr/share/icons/htb-toolkit/ $out/share/icons/htb-toolkit/ substituteInPlace src/utils.rs \ --replace-fail "\"base64\"" "\"${coreutils}/bin/base64\"" \ --replace-fail "\"gunzip\"" "\"${gzip}/bin/gunzip\"" @@ -56,6 +55,8 @@ rustPlatform.buildRustPackage { --replace-fail "arg(\"killall\")" "arg(\"${killall}/bin/killall\")" ''; + passthru.updateScript = unstableGitUpdater { }; + meta = with lib; { description = "Play Hack The Box directly on your system"; mainProgram = "htb-toolkit";