• Re: Converted my Go program to Rust

    From vallor@21:1/5 to rek2@hispagatos.org.invalid on Sun Aug 4 10:59:02 2024
    XPost: alt.comp.lang.rust

    On Fri, 2 Aug 2024 01:33:36 -0000 (UTC), rek2 hispagatos <rek2@hispagatos.org.invalid> wrote in
    <v8hd1g$1fk30$1@matrix.hispagatos.org>:

    On 2024-08-01, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Thu, 1 Aug 2024 22:14:53 -0000 (UTC), rek2 hispagatos wrote:

    Last year I made a small Go program to automatize some of the first
    steps I do when participating on HackTheBox, I decided to migrate it
    to rust, this is the result, free software GPLv3

    https://git.sr.ht/~rek2/rek2htb-rust

    I assume you are munging the hosts file just so your web client will
    pass the right “Host:” header line. There should be easier (i.e. less
    intrusive) ways of doing that: for example, in wget you can add the
    option “--header="Host: «hostname»"”, and there should be something
    similar in whatever HTTP client you are using.

    Actually I found a couple bugs that I fixed related to ffuf one of them
    was missing flag to add the Host header -H "Host: FFUZ.{}.htb" as it was before it was just passing the site -s other issue was the output,
    also I have fixed it.

    Thanks, I will had read your msg and found out as well even if I had not noticed it before, so thank you for the reply, good to know someone is reading.

    Happy Hacking ReK2

    Hello,

    I don't know Rust, so your program is a bit of an introduction.

    With that in mind, I wonder if this wouldn't be a little bit
    better:

    - -%<- cut here - -
    --- main.rs~ 2024-08-04 03:44:07.000000000 -0700
    +++ main.rs 2024-08-04 03:45:19.824804343 -0700
    @@ -106,7 +106,7 @@
    }

    // If the entry does not exist, append it to the file using SUPERUSER_CMD - let update_hosts_command = format!("echo {} {}.htb | tee -a /etc/hosts", ip_address, box_name);
    + let update_hosts_command = format!("echo {} | tee -a /etc/hosts", entry);
    let mut command = Command::new(SUPERUSER_CMD);
    command
    .arg("sh")
    - -%<- cut here - -

    Would that work? If so, it would let you change the entry format
    in "entry" in only one place, if you decide to do so.

    (Also, was intrigued by how "let" seems to work, if I understand it correctly. Will have to take a look at Rust!)

    Finally, I've long been disappointed that git doesn't preserve
    timestamps on files. Does anyone know of any discussion about
    why that is, and perhaps changing git to have that capability?

    [ sorry about not honoring your fu2, my server doesn't seem to
    have alt.comp.lang.r
  • From rek2 hispagatos@21:1/5 to vallor on Sun Aug 4 15:24:14 2024
    XPost: alt.comp.lang.rust

    On 2024-08-04, vallor <vallor@cultnix.org> wrote:

    I don't know Rust, so your program is a bit of an introduction.

    I also started not far away a go, I come from C and GO.

    With that in mind, I wonder if this wouldn't be a little bit
    better:

    Not a problem is why I link it to this newsgroup ;)

    - -%<- cut here - -
    --- main.rs~ 2024-08-04 03:44:07.000000000 -0700
    +++ main.rs 2024-08-04 03:45:19.824804343 -0700
    @@ -106,7 +106,7 @@
    }

    // If the entry does not exist, append it to the file using SUPERUSER_CMD
    - let update_hosts_command = format!("echo {} {}.htb | tee -a /etc/hosts", ip_address, box_name);
    + let update_hosts_command = format!("echo {} | tee -a /etc/hosts", entry);
    let mut command = Command::new(SUPERUSER_CMD);
    command
    .arg("sh")
    - -%<- cut here - -

    Would that work? If so, it would let you change the entry format
    in "entry" in only one place, if you decide to do so.

    This indeed will save some lines of code, but from my security best
    habits in coding I always try to limit the amount of stdin that can be
    added, so if I split variables I have a better way to handle each value
    and avoid the user input to do things it was not supposed to.

    (Also, was intrigued by how "let" seems to work, if I understand it correctly.
    Will have to take a look at Rust!)

    Yeah takes time to get used to the new wording and such but is nice when
    you pick it up.

    Finally, I've long been disappointed that git doesn't preserve
    timestamps on files. Does anyone know of any discussion about
    why that is, and perhaps changing git to have that capability?

    [ sorry about not honoring your fu2, my server doesn't seem to
    have alt.comp.lang.rust. ]

    No problem you can always ask your news server admin to add it.
    and I think it did came in to alt.comp.lang.rust I am reading it there.

    Cheers
    Happy Hacking
    ReK2


    --
    - {gemini,https}://{,rek2.}hispagatos.org - mastodon: @rek2@hispagatos.space
    - [https|gemini]://2600.Madrid - https://hispagatos.space/@rek2
    - https://keyoxide.org/A31C7CE19D9C58084EA42BA26C0B0D11E9303EC5

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to vallor on Sun Aug 4 22:40:22 2024
    XPost: alt.comp.lang.rust

    On Sun, 4 Aug 2024 10:59:02 -0000 (UTC), vallor wrote:

    Finally, I've long been disappointed that git doesn't preserve
    timestamps on files.

    Note that Git does distinguish between the commit timestamp and the author timestamp.

    <https://git-scm.com/docs/git-commit-tree>

    Also note the “--date” option in git-commit <https://git-scm.com/docs/git-commit>.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rek2 hispagatos@21:1/5 to All on Thu Aug 1 22:14:53 2024
    XPost: alt.comp.lang.rusth, alt.2600.madrid, alt.2600

    Last year I made a small Go program to automatize some of the first
    steps I do when participating on HackTheBox, I decided to migrate it to
    rust, this is the result, free software GPLv3

    https://git.sr.ht/~rek2/rek2htb-rust

    Parches welcome, I keep adding more stuff every day.

    Happy Hacking
    ReK2

    --
    - {gemini,https}://{,rek2.}hispagatos.org - mastodon: @rek2@hispagatos.space
    - [https|gemini]://2600.Madrid - https://hispagatos.space/@rek2
    - https://keyoxide.org/A31C7CE19D9C58084EA42BA26C0B0D11E9303EC5

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lawrence D'Oliveiro@21:1/5 to All on Thu Aug 1 23:08:07 2024
    XPost: alt.comp.lang.rust

    On Thu, 1 Aug 2024 22:14:53 -0000 (UTC), rek2 hispagatos wrote:

    Last year I made a small Go program to automatize some of the first
    steps I do when participating on HackTheBox, I decided to migrate it to
    rust, this is the result, free software GPLv3

    https://git.sr.ht/~rek2/rek2htb-rust

    I assume you are munging the hosts file just so your web client will pass
    the right “Host:” header line. There should be easier (i.e. less
    intrusive) ways of doing that: for example, in wget you can add the option “--header="Host: «hostname»"”, and there should be something similar in whatever HTTP client you are using.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From rek2 hispagatos@21:1/5 to Lawrence D'Oliveiro on Fri Aug 2 01:33:36 2024
    XPost: alt.comp.lang.rust

    On 2024-08-01, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
    On Thu, 1 Aug 2024 22:14:53 -0000 (UTC), rek2 hispagatos wrote:

    Last year I made a small Go program to automatize some of the first
    steps I do when participating on HackTheBox, I decided to migrate it to
    rust, this is the result, free software GPLv3

    https://git.sr.ht/~rek2/rek2htb-rust

    I assume you are munging the hosts file just so your web client will pass
    the right “Host:” header line. There should be easier (i.e. less intrusive) ways of doing that: for example, in wget you can add the option “--header="Host: «hostname»"”, and there should be something similar in whatever HTTP client you are using.

    Actually I found a couple bugs that I fixed related to ffuf one of them
    was missing flag to add the Host header -H "Host: FFUZ.{}.htb" as it was
    before it was just passing the site -s other issue was the output,
    also I have fixed it.

    Thanks, I will had read your msg and found out as well even if I had not noticed it before, so thank you for the reply, good to know someone is
    reading.

    Happy Hacking
    ReK2

    --
    - {gemini,https}://{,rek2.}hispagatos.org - mastodon: @rek2@hispagatos.space
    - [https|gemini]://2600.Madrid - https://hispagatos.space/@rek2
    - https://keyoxide.org/A31C7CE19D9C58084EA42BA26C0B0D11E9303EC5

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)