rust, macos Peter Girnus rust, macos Peter Girnus

Rust MacOS - How To Install Using Homebrew

Installing Rust on MacOS, including M1, is easy using Homebrew. In this tutorial, I will show you how to install Rust from a Mac terminal without an installer by using the Homebrew package manager to download rustup and execute the rustup-init script, which we can run in order to install and configure the entire Rust toolchain and its dependencies.

Read More
rust, windows Peter Girnus rust, windows Peter Girnus

Install Rust on Windows: From the Terminal

Easily Install Rust on Windows 10 or Windows 11. I will show you how to install Rust without an installer using the Windows Package Manager (winget) to install Rust with rustup, the Rust toolchain, and the necessary dependencies such as Visual Studio build tools and Desktop development with C++ tool set. Once installed, we will compile a rust program to demonstrate a successful installation!

Read More
rust Peter Girnus rust Peter Girnus

Rust Reqwest Crate - GET JSON Object

The reqwest HTTP client library can be utilized to make HTTP requests and receive responses from a server. Once a response is received, it can be converted into a JSON object for further processing using HashMap or the serde_json::Value object, depending if the JSON struct is known ahead of time or not. This allows you to access the data within the response object, regardless of its structure.

Read More
rust, rust-fs, windows Peter Girnus rust, rust-fs, windows Peter Girnus

Rust Metadata Extensions (std::os::windows::fs::MetadataExt) Trait for the Windows OS

The Rust std::os::windows::fs::MetadataExt trait provides operating system extensions for the Microsoft Windows platform. These Metadata extensions for Windows allow programmers to view metadata such as its permissions, size, modification times, and other information about a file. The MetadataExt trait is a part of the Windows-specific extensions to primitives in the std::fs module. Data exposed by this trait include those of the Windows BY_HANDLE_FILE_INFORMATION structure.

Read More
rust, rust-fs, linux Peter Girnus rust, rust-fs, linux Peter Girnus

Rust Metadata Extensions (std::os::linux::fs::MetadataExt) Trait for the Linux OS

In Rust the std::os::linux::fs::MetadataExt trait provides os-specific extensions for the Linux platform. These extensions allow programmers to view metadata about a file such as its permissions, size, modification times, and other information about a file. The MetadataExt trait is a part of the Linux-specific extensions to primitives in the std::fs module.

Read More
rust, rust-fs Peter Girnus rust, rust-fs Peter Girnus

Rust Standard Library (std::fs): Getting File Metadata With Code Examples

In Rust, the standard library (std::fs) provides the Metadata structure, which gives programmers Metadata about a file, such as its permissions, size, times, file type, block information, etc. In addition, the Metadata structure contains a plethora of implementations for platform-specific behavior and fields that include functions for Linux, Unix, MacOS, and Windows. In this blog post, I will highlight Rust examples of the various functions and implementations provided by the Rust standard library.

Read More
rust, rust-fs Peter Girnus rust, rust-fs Peter Girnus

Rust std::fs Programming - Filetype Struct, Learning Through Rust Code

The Rust FileType struct is a structure within the Rust standard library (std::fs) and is part of the filesystem manipulation operations (fs) module. The FileType structure represents a type of file and provides accessors for each file type. This is accomplished through the return of the Metadata::file_type method. In this post, we will explore the FileType struct with examples using Rust code, providing valuable examples based on the Rust lang documentation.

Read More
cybersecurity, rust Peter Girnus cybersecurity, rust Peter Girnus

Rust vs. C/C++: Ensuring Memory Safety & Security

C/C++ is popular for system development due to its hardware control. However, manual memory management in these languages can be unsafe and lead to memory corruption and other security vulnerabilities. Rust is a modern programming language with guaranteed memory safety. This post compares Rust and C/C++ regarding memory safety and security and provides Rust programming examples.

Read More
rust, rust-fs Peter Girnus rust, rust-fs Peter Girnus

Rust std::fs: Creating, Writing, & Reading Files In Rust

Today, I want to explore the Rust std::fs library and its file creation, writing, and reading functions. This post can be helpful to Rust newcomers or those seeking a refresher on this topic. In this guide, we will explore the impressive capabilities of the File object, including how to create files in Rust using this object and how to read them using various techniques.

Read More
rust, rust-fs Peter Girnus rust, rust-fs Peter Girnus

Rust std::fs: Parsing Directories & File Entries with DirEntry

The Rust programming language provides a robust and efficient way to interact with the file system, making it a popular choice for systems programming and file manipulation tasks. In this mini how-to guide, we will explore the powerful capabilities of the DirEntry struct, which is part of the Rust standard library's std::fs module. DirEntry enables developers to navigate and extract valuable information from directory entries effortlessly, making it an essential tool for file-related operations.

Read More
rust, rust-fs Peter Girnus rust, rust-fs Peter Girnus

Rust std::fs: Creating Directories with DirBuilder

This lightning how-to focuses on creating directories in Rust using the the DirBuilder impl which is is part of the Rust standard library (source code).

The DirBuilder impl is part of the the DirBuilder Struct contained in the std::fs module (filesystem manipulation operations) which allows us to use Rust to manipulate the filesystem.

This lightning how-to will first define a simple problem and then work out the solution. Let’s define our problem first.

Read More
rust, threat-hunting, malware Peter Girnus rust, threat-hunting, malware Peter Girnus

Scanning Files With Regular Expressions (RegEx) In Rust

This article shows you how to easily scan the contents of files using Regular Expressions (RegEx) using the Rust language. Rust implements a regular expression engine similar to many other regex engines such as Perl Compatible Regular Expressions (PCRE) and ECMAScript but lacks features such as look-arounds and backreferences. You can visit the source code of the regex crate by visiting the Rust implementation of regular expressions on GitHub.

Read More
how-to, rust, malware, threat-hunting Peter Girnus how-to, rust, malware, threat-hunting Peter Girnus

How To Compile YARA Rules & Scan With Files Rust

In this how-to I will show you how to easily compile yara rules and scan files using Rust. While VirusTotal does not have an official Rust implementation there is an experimental project hosted on GitHub. In this how-to we will use he yara-rust crate which provides the bindings around yara inspired by the popular yara-python library maintained by VirusTotal. Using this step-by-step guide we will install the yara-rust crate, compile a yara rule file as well as a yara rule string, and finally we will scan a file using yara-rust.

Read More
how-to, rust, programming Peter Girnus how-to, rust, programming Peter Girnus

How To Make HTTP/HTTPS Web Requests in Rust

In this blog post I will show you how to make web requests in Rust using the Reqwest and Hyper crates. Using web requests forms the basis of interacting with many different services such as API’s, AI services, web-servers, microservices, and other connected devices such as IoT devices. Since many of the core features of modern interconnected devices rely on web requests this makes it critical for programmers to understand, implement, and troubleshoot it’s functionality in an increasingly connected world.

Read More