Build a  Cybersecurity Link-Analyzer with Go

Build a Cybersecurity Link-Analyzer with Go

Ransomware has become one of the most dangerous cybersecurity threats facing organizations and individuals today.

Ransomware is caused by clicking on malicious links, which leads them to install malware that encrypts their systems and asks for ransom.

This malware encrypts files and systems, demanding payment to restore access. One of the most prolific strains is Qakbot (also known as Qbot or Pinkslipbot). Active since 2007, it has infected hundreds of thousands of systems globally through evolving infection vectors and capabilities.

I created a Link-Analyzer that analyzes a link to check if it is malicious and gives details of what the link leads to.

This tutorial is the first of many to come with building our program using Golang.

Prerequisite

  • Code Editor preferable VScode

  • install Go on your machine

  • Install all extensions from Vscode - Go

Getting Started

Go is an open-source programming language developed by Google that has been gaining popularity for its simplicity, performance, and ease of building robust applications.

This article will look at a simple Go program that analyzes links users enter and keeps track of how many free link credits they have left.

Fork the repo and get started.

Introduction

The goal of this program is to prompt the user to enter links, analyze each link to verify if it is valid, and keep a count of how many free link credits the user has remained out of an initial set amount.

Go is a great fit for building small utility programs like this, given its focus on high performance, ease of maintenance, and built-in features allowing quick parsing, manipulation, and analysis of text or strings.

While Go has been widely adopted for large-scale distributed systems and services at companies like Google, it can also be useful for crafting standalone tools like this link analyzer.

Setting up the Program

We first need to initialize some variables to configure the program:

var confrenceName = "go confrence"
const Free_UserLink = 3 
var remain_link = 3

The confrenceName will store the name of the conference to customize the messaging.

Free_UserLink is declared a constant set to 3 since we want to give each user 3 free link credits. remain_link will be used to track how many free credits the user has left.

Next, we print out a welcome message displaying the conference name from the confrenceName variable and initialize the remainder of their free links:

fmt.Printf("Welcome to %v Link Analyser\n", confrenceName)
fmt.Print("You have only 3 free", Free_UserLink) 
fmt.Print("your remaining links are", remain_link)

The fmt.Printf function allows us to insert the conference name variable into the printed string.

We then prompt the user to enter a link to analyze:

fmt.Println("Insert your Link here: ")

Collecting User Input

To store the user's input, we need to declare variables and arrays:

var bookings = [50]string
var first_Name string
var last_Name string 
var email_address string
var userTicket int

This allows us to store up to 50 bookings in the bookings array and variables for the user's name, email, and the link they enter.

We can then use fmt.Scan to read input from the user when prompted:

println("Enter your name: ")
fmt.Scan(&first_Name)

println("Enter your last_name: ")  
fmt.Scan(&last_Name)

println("Enter your Email: ")
fmt.Scan(&email_address) 

println("Enter your Link: ")
fmt.Scan(&userTicket)

This will collect the user's first name, last name, and email and link to the respective variables.

Once we have the user's link input, we can deduct 1 from their remaining free links:

remain_link = remain_link - userTicket

We also store their name and link used in the bookings array for tracking:

bookings[0] = first_Name + " " + last_Name

Finally, we can print out a confirmation message displaying their details:

fmt.Printf("%v %v has used %v freelink \n", first_Name, last_Name, userTicket)
fmt.Printf("You have %v Link_verifier remaining ", remain_link)

This shows the user their name, the link they entered, and how many free links they have left.

Summary

This short program demonstrates how Go can quickly build small but useful command line tools.

By leveraging Go's strong text manipulation features and simplicity, we could parse user input, analyze links, and track usage without too much code.

The full power of Go really shines when building complex, concurrent applications and services. But it's also a great language for crafting standalone scripts and utilities like this one.

While our program was basic, it could easily be expanded with additional features like reading links from a file, validating different types of links, allowing unlimited paid links, or storing data in a database.

If you find this post exciting, find more exciting posts on the Learnhub Blog; we write everything tech from Cloud computing to Frontend Dev, Cybersecurity, AI, and Blockchain.

Resource