Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #149: Dew on the telephone lines.


comp / comp.lang.misc / Re: Converted my Go program to Rust

SubjectAuthor
* Converted my Go program to Rustrek2 hispagatos
`* Re: Converted my Go program to RustLawrence D'Oliveiro
 `* Re: Converted my Go program to Rustrek2 hispagatos
  `* Re: Converted my Go program to Rustvallor
   +- Re: Converted my Go program to Rustrek2 hispagatos
   `- Re: Converted my Go program to RustLawrence D'Oliveiro

1
Subject: Converted my Go program to Rust
From: rek2 hispagatos
Newsgroups: alt.comp.lang.rusth, alt.2600.madrid, alt.2600, comp.lang.misc
Followup: alt.comp.lang.rust
Organization: Hispagatos
Date: Thu, 1 Aug 2024 22:14 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.hispagatos.org!.POSTED!not-for-mail
From: rek2@hispagatos.org.invalid (rek2 hispagatos)
Newsgroups: alt.comp.lang.rusth,alt.2600.madrid,alt.2600,comp.lang.misc
Subject: Converted my Go program to Rust
Followup-To: alt.comp.lang.rust
Date: Thu, 1 Aug 2024 22:14:53 -0000 (UTC)
Organization: Hispagatos
Message-ID: <v8h1ct$1fe39$1@matrix.hispagatos.org>
Reply-To: ReK2 <rek2@hispagatos.org>
Injection-Date: Thu, 1 Aug 2024 22:14:53 -0000 (UTC)
Injection-Info: matrix.hispagatos.org;
logging-data="1554537"; mail-complaints-to="abuse@hispagatos.org"
User-Agent: slrn/pre1.0.4-9 (Linux)
View all headers

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

Subject: Re: Converted my Go program to Rust
From: Lawrence D'Oliv
Newsgroups: comp.lang.misc, alt.comp.lang.rust
Organization: A noiseless patient Spider
Date: Thu, 1 Aug 2024 23:08 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.misc,alt.comp.lang.rust
Subject: Re: Converted my Go program to Rust
Date: Thu, 1 Aug 2024 23:08:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <v8h4gn$2e5g0$3@dont-email.me>
References: <v8h1ct$1fe39$1@matrix.hispagatos.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 02 Aug 2024 01:08:08 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="480e27b3b4cc073acc0e6062d3b4dc69";
logging-data="2561536"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187XPiZ160tPH5p+cbWTO5E"
User-Agent: Pan/0.159 (Vovchansk; )
Cancel-Lock: sha1:76F5j2919/NRTPs9mWU0hmKwkj4=
View all headers

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.

Subject: Re: Converted my Go program to Rust
From: rek2 hispagatos
Newsgroups: comp.lang.misc, alt.comp.lang.rust
Followup: alt.comp.lang.rust
Organization: Hispagatos
Date: Fri, 2 Aug 2024 01:33 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.hispagatos.org!.POSTED!not-for-mail
From: rek2@hispagatos.org.invalid (rek2 hispagatos)
Newsgroups: comp.lang.misc,alt.comp.lang.rust
Subject: Re: Converted my Go program to Rust
Followup-To: alt.comp.lang.rust
Date: Fri, 2 Aug 2024 01:33:36 -0000 (UTC)
Organization: Hispagatos
Message-ID: <v8hd1g$1fk30$1@matrix.hispagatos.org>
References: <v8h1ct$1fe39$1@matrix.hispagatos.org>
<v8h4gn$2e5g0$3@dont-email.me>
Reply-To: ReK2 <rek2@hispagatos.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 2 Aug 2024 01:33:36 -0000 (UTC)
Injection-Info: matrix.hispagatos.org;
logging-data="1560672"; mail-complaints-to="abuse@hispagatos.org"
User-Agent: slrn/pre1.0.4-9 (Linux)
View all headers

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

Subject: Re: Converted my Go program to Rust
From: vallor
Newsgroups: comp.lang.misc, alt.comp.lang.rust
Organization: A noiseless patient Spider
Date: Sun, 4 Aug 2024 10:59 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vallor@cultnix.org (vallor)
Newsgroups: comp.lang.misc,alt.comp.lang.rust
Subject: Re: Converted my Go program to Rust
Date: Sun, 4 Aug 2024 10:59:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <v8nmtm$3neof$1@dont-email.me>
References: <v8h1ct$1fe39$1@matrix.hispagatos.org>
<v8h4gn$2e5g0$3@dont-email.me> <v8hd1g$1fk30$1@matrix.hispagatos.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 04 Aug 2024 12:59:03 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="313bcd881188dc1d599373ae554c1687";
logging-data="3914511"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hjwYw95MrhSQySTSWct97"
User-Agent: Pan/0.159 (Vovchansk; 26ff567; Linux-6.11.0-rc1)
Cancel-Lock: sha1:fI/swCsK5QKCj52R2h6uHtDo/q4=
X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n
XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ
View all headers

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.rust. ]

--
-v

Subject: Re: Converted my Go program to Rust
From: rek2 hispagatos
Newsgroups: comp.lang.misc, alt.comp.lang.rust
Organization: Hispagatos
Date: Sun, 4 Aug 2024 15:24 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.hispagatos.org!.POSTED!not-for-mail
From: rek2@hispagatos.org.invalid (rek2 hispagatos)
Newsgroups: comp.lang.misc,alt.comp.lang.rust
Subject: Re: Converted my Go program to Rust
Date: Sun, 4 Aug 2024 15:24:14 -0000 (UTC)
Organization: Hispagatos
Message-ID: <v8o6eu$1k6ob$2@matrix.hispagatos.org>
References: <v8h1ct$1fe39$1@matrix.hispagatos.org>
<v8h4gn$2e5g0$3@dont-email.me> <v8hd1g$1fk30$1@matrix.hispagatos.org>
<v8nmtm$3neof$1@dont-email.me>
Reply-To: ReK2 <rek2@hispagatos.org>
Injection-Date: Sun, 4 Aug 2024 15:24:14 -0000 (UTC)
Injection-Info: matrix.hispagatos.org;
logging-data="1710859"; mail-complaints-to="abuse@hispagatos.org"
User-Agent: slrn/pre1.0.4-9 (Linux)
View all headers

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

Subject: Re: Converted my Go program to Rust
From: Lawrence D'Oliv
Newsgroups: comp.lang.misc, alt.comp.lang.rust
Organization: A noiseless patient Spider
Date: Sun, 4 Aug 2024 22:40 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.misc,alt.comp.lang.rust
Subject: Re: Converted my Go program to Rust
Date: Sun, 4 Aug 2024 22:40:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <v8p00l$8t63$9@dont-email.me>
References: <v8h1ct$1fe39$1@matrix.hispagatos.org>
<v8h4gn$2e5g0$3@dont-email.me> <v8hd1g$1fk30$1@matrix.hispagatos.org>
<v8nmtm$3neof$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 05 Aug 2024 00:40:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9703e35b9105f1543e11e482bcc52d23";
logging-data="292035"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4XFC/pPrd1hyGPO6UpIcV"
User-Agent: Pan/0.159 (Vovchansk; )
Cancel-Lock: sha1:QJI9QCSlYyRKpvC3NrvXPCZl66Q=
View all headers

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>.

1

rocksolid light 0.9.8
clearnet tor