Skip to content

Instantly share code, notes, and snippets.

@MESYETI
Last active December 6, 2025 22:34
Show Gist options
  • Select an option

  • Save MESYETI/eda2b50033d5406ab2bb64bf0d9047b6 to your computer and use it in GitHub Desktop.

Select an option

Save MESYETI/eda2b50033d5406ab2bb64bf0d9047b6 to your computer and use it in GitHub Desktop.
Rust detector
module rustdetector.app;
import std.file;
import std.path;
import std.stdio;
import std.algorithm;
string[] rustyThingsSource = [
"svtu0svtud",
"joefy/dsbuft/jp"
];
string[] rustyThings = [];
bool IsRusty(string path) {
auto contents = cast(ubyte[]) std.file.read(path);
if (contents.length < 4) {
return false;
}
if (cast(string) contents[0 .. 4] != "\x7fELF") {
return false;
}
foreach (ref thing ; rustyThings) {
if (contents.canFind(cast(ubyte[]) thing)) {
return true;
}
}
return false;
}
void main(string[] args) {
foreach (ref thing ; rustyThingsSource) {
rustyThings ~= string.init;
foreach (ref ch ; thing) {
rustyThings[$ - 1] ~= ch - 1;
}
}
string path = args.length == 1? getcwd() : args[1];
if (isFile(path)) {
if (IsRusty(path)) {
writeln(path);
}
return;
}
foreach (DirEntry file ; dirEntries(path, SpanMode.depth)) {
if (!file.isFile()) continue;
if (IsRusty(file.name)) {
writeln(file.name);
}
}
}
@Pdzly
Copy link

Pdzly commented Dec 6, 2025

Ahh yes the rust finder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment