Rust Project: CLI Port Sniffer Tool

in #technology8 years ago (edited)

When considering what types of projects to do for the Rust Project tutorial series after I finished the Intro to Rust series, one of the first ideas that came to my mind was a CLI tool. After going through many different Linux tools, I settled on building a port sniffer because it is a multi-threaded project and it allowed me to build the entire tool without using a single 3rd party dependency or library. Admittedly, had I used at least one third party library, the tool would have been much cleaner but that is simply because the library in question does a lot of the heavy lifting for us. From an educational standpoint, it made more sense to build this particular tool without relying on a DSL or a non-standard library.

Our CLI port sniffer is a minimal viable product but it can easily be extended to include tons of other features should you feel the need to add them. We use a vector of strings to collect our arguments and then create a struct to hold the data of these arguments. We then use a method for the struct to check the arguments so that we are getting the correct patterns from the user. After instantiating our struct's data using the method, we then create a scalable amount of threads based on the user input to preform the task. Given that Rust uses OS Threads and not Green threads, your assigned threads will depend on the power of your computer and the operating system that you are using.

Each operating system has a maximum number of threads it assigns to a single process and a faster computer will be able to use more then a slower one.

The tool then iterates through all of the potential ports that could be open on the called IP and returns any ports that return a connection. This type of tool can be useful to gain information on what ports could potentially be open on your system or router without your knowledge and also could potentially be used for malicious means (though you would would need the know how and many more tools to do so.). This was a fun little project to make and it was deceptively difficult at times to write in a live coded session as a result of the multiple constrants that I put on myself.

I hope you guys enjoy this video and I hope it also helps you better understand the language of Rust. There are many more projects to come

Full Github Source Code is here

If you enjoy the video, feel free to follow me on Steemit or on YouTube to get updates on the channel as well as more content.

If you like what I do, tips and upvotes are welcome:
ETH: 0xE448a8DDA5886C49d35B191B2F20630c103024c8
LTC: LXsKxF5JhmMtKgqfcUFdvcXVwiaSqxN9cP

Also, feel free to check out my channel for videos on Go, Elixir and Elm

Sort:  

The @OriginalWorks bot has determined this post by @tensor to be original material and upvoted it!

ezgif.com-resize.gif

To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!

Qurator
Your Quality Content Curator
This post has been upvoted and given the stamp of authenticity by @qurator. To join the quality content creators and receive daily upvotes click here for more info.

Qurator's exclusive support bot is now live. For more info click HERE or send some SBD and your link to @qustodian to get even more support.

you're making steemit a great community with your content tensor! keep it up!

Thank you that means a lot to me. I try to make the content as engaging as possible. I've got another video coming out tonight and then it the amount of content will probably start to slow down as I start to look at larger projects.

Coin Marketplace

STEEM 0.13
TRX 0.33
JST 0.034
BTC 110156.04
ETH 4276.74
USDT 1.00
SBD 0.83