<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="353176" data-post-id="353176">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="D4no0" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/D4no0/120/33624_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  D4no0
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="nix2intel" data-post="9" data-topic="68780">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nix2intel/48/37441_2.png" class="avatar"> nix2intel:</div>
<blockquote>
<p>I mention the NIF because I want folks to know what they are signing up for, as it is my understanding NIFS can bring down the beam correct?</p>
</blockquote>
</aside>
<p>Exactly, this is a necessary evil to reach native performance speeds or as in your case, borrow implementation of a library from another ecosystem. I think with dirty schedulers it’s much safer these days, but the general idea is that they should be used when other options are exhausted.</p>
<aside class="quote no-group" data-username="nix2intel" data-post="9" data-topic="68780">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nix2intel/48/37441_2.png" class="avatar"> nix2intel:</div>
<blockquote>
<p>I am very new to elixir and this was more about getting things done for work (we were using dnstwist at work written in python hosted on an api) twistrs was already written</p>
</blockquote>
</aside>
<p>Well, this is exactly what you should have posted in your description of the library, as you got people confused about why would you resort to a NIF for something that could be implemented in elixir.</p>
<aside class="quote no-group" data-username="nix2intel" data-post="9" data-topic="68780">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nix2intel/48/37441_2.png" class="avatar"> nix2intel:</div>
<blockquote>
<p>Having said that could you look at my task implementation on the elixir side and make suggestions for speed ups?</p>
</blockquote>
</aside>
<p>Looks fine for the first iteration, I would personally just focus on making it work correctly (for example so it’s not opening too many network connections and killing your server or network).</p>
<p>For a implementation that is more production-ready, take a look at <a href="https://forum.elixirforum.com/t/ssl-moon-ssl-monitoring-and-observability-of-open-networks/61317" rel="nofollow">SSL MOON</a>, that implementation uses oban for both rate-limiting on how many concurrent requests are done and for persistence when upgrades/restarts of the server happen.</p>
<p>BTW I’ve been looking for someone to use that project in production, if you find that could be something useful for your company, let me know, I might be able to give support and implement the missing features.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="353176" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/domaintwistex-domain-name-permutation-engine-in-elixir-using-rust-nifs/68780/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-353176" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="353176"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="353178" data-post-id="353178">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Lucassifoni" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Lucassifoni/120/39057_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Lucassifoni
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>A bit tangential, but way back I enjoyed this paper about domain permutations, not with typosquatting but bitsquatting : <a href="https://web.archive.org/web/20180713212603/http://media.blackhat.com/bh-us-11/Dinaburg/BH_US_11_Dinaburg_Bitsquatting_WP.pdf" class="inline-onebox" rel="noopener nofollow ugc">Wayback Machine</a></p>
<p>This is old (BlackHat 2011) and I am not sure whether hardware is now more resilient to those errors.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="353178" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/domaintwistex-domain-name-permutation-engine-in-elixir-using-rust-nifs/68780/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-353178" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="353178"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="353203" data-post-id="353203">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="nix2intel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nix2intel/120/37441_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  nix2intel
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Sslmoon looks amazing! Will be tearing through it to learn and ingest, thanks!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="353203" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/domaintwistex-domain-name-permutation-engine-in-elixir-using-rust-nifs/68780/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-353203" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="353203"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="353248" data-post-id="353248">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="filmor" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/filmor/120/6315_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  filmor
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<ul>
<li>The Rustler version you are using there is quite old and lacks (e.g.) forward compatibility in the build process</li>
<li>You have committed the binaries</li>
<li>You can simplify the NIF function quite a bit by using more of Rustler’s (and Rust’s) features:</li>
</ul>
<pre data-code-wrap="rust"><code class="lang-rust">use rustler::NifResult;
use std::collections::HashSet;
use twistrs::permutate::Domain;

// 1. Rustler has builtin support for maps with atom keys
// -------------------------------------------------------
#[derive(rustler::NifMap)]
struct Result {
    fqdn: String,
    tld: String,
    kind: String,
}

// 2. You can return anything that is convertible to a Term, you don't need to do inline encoding (and thus don't need `env`, together with `NifMap`)
// ------------------------------------------
#[rustler::nif]
fn generate_permutations(domain_str: String) -&gt; NifResult&lt;Vec&lt;Result&gt;&gt; {
    let domain = match Domain::new(&amp;domain_str) {
        Ok(d) =&gt; d,
        Err(_) =&gt; return Ok(Default::default()),
    };

    // 3. No need to convert the HashSet into a Vec if you just want to
    //    iterate over it again
    // -----------------------------------------
    let perms = match domain.all() {
        Ok(p) =&gt; p.collect::&lt;HashSet&lt;_&gt;&gt;(),
        Err(_) =&gt; return Ok(Default::default()),
    };

    let results = perms
        .iter()
        .map(|p| Result {
            fqdn: p.domain.fqdn.clone(),
            tld: p.domain.tld.clone(),
            kind: format!("{:?}", p.kind),
        })
        .collect();

    Ok(results)
}

rustler::init!("Elixir.DomainTwistex");
</code></pre>
<p>It would be even shorter if you didn’t use <code>NifResult</code> (which is unnecessary as you don’t report any errors back).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="353248" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/domaintwistex-domain-name-permutation-engine-in-elixir-using-rust-nifs/68780/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-353248" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="353248"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="353256" data-post-id="353256">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="nix2intel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nix2intel/120/37441_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  nix2intel
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Holy cow thank you! I’ve never written rust code before and thus terrible at it.  ill be sure to make these changes!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="353256" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/domaintwistex-domain-name-permutation-engine-in-elixir-using-rust-nifs/68780/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-353256" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="353256"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="353259" data-post-id="353259">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="nix2intel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nix2intel/120/37441_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  nix2intel
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>For anyone interested i made some recent changes, and will be implementing what <a class="mention" href="/u/filmor" rel="nofollow">@filmor</a> just suggested in the coming days, but as an example, I ran this tool against <a href="http://forum.elixirforum.com" rel="nofollow">forum.elixirforum.com</a> 's domain and it found this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  %{
    nameservers: ["ns2.ownidentity.com", "ns1.ownidentity.com"],
    kind: "Tld",
    fqdn: "elixirforum.it",
    ip_addresses: ["217.70.146.10"],
    mx_records: [%{priority: 10, server: "gmail-smtp-in.l.google.com"}],
    resolvable: true,
    server_response: %{
      server: "Microsoft-IIS/10.0",
      headers: %{
        "Accept-Ranges" =&gt; "bytes",
        "Connection" =&gt; "close",
        "Content-Length" =&gt; "444",
        "Content-Type" =&gt; "text/html",
        "Date" =&gt; "Sat, 18 Jan 2025 00:14:52 GMT",
        "ETag" =&gt; "\"0c4edd728bd71:0\"",
        "Last-Modified" =&gt; "Thu, 25 Feb 2021 03:46:48 GMT",
        "Server" =&gt; "Microsoft-IIS/10.0",
        "X-Powered-By" =&gt; "ASP.NET"
      },
      status_code: "200"
    },
    txt_records: [],
    tld: "it"
  },
</code></pre>
<p>is it malicious? probably not, but it is something I would potential check mail logs on for elixirforum, the domain is hosting an unconfigured plesk server that may be on a windows machine (always skeptical as I sometimes spoof headers as well) that is configured to use gmail as it’s mail servers. In our environment we’d likely add rules to either block the domain outright to avoid potential business email compromise accounts, or make rules in our organizational email for it. We would also monitor for changes to things like this.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="353259" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/domaintwistex-domain-name-permutation-engine-in-elixir-using-rust-nifs/68780/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-353259" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="353259"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>