Raku 1

After a long break (again) I come back to write about Raku.

I spent quite some time on Ruby before moving to Perl, why ? Because Perl is more likely to be installed on a device I get access to, and why not Python ? Because Perl has better backward compatibility, I wont need to worry about whether its Python2 or Python3 and which subversion etc.

I heard about Raku before but didn’t really want to give it a try, it is neither as ubiquitous as Perl neither as famous as Python. But last week, I allowed myself to take a look and see how different the language is from Perl and if its worth it for me to spend time learning it and oh well it didn’t disappoint.

Janet

After a long time (almost a year!) I am writing again. It took me some time to get fully installed in Hong Kong (I moved from Belgium to Hong Kong on July 18).

I enjoyed 3 months of “holiday” there while looking for a job and now I am fully installed !

Anyway, this (very short) post is about a nice language I discovered few months ago named Janet (yes like in The Good Place).

Perl One Liner

Today I had to add a list of users to a service (knowbe4). I could have done it manually but I decided to use Perl to do it which (I think) made me gain a lot of time.

Instead of checking the current subscribed users, see which one to delete and which one to add manually (would have taken a lot of time since there are a lot of users already and even more users to add).

Basic Backup Powershell

Here is a basic backup script that I made from the powershell exam the second grade had today.

<#
    .SYNOPSIS
    Backup file from folder matching extension

    .DESCRIPTION
    Backup all the files from a 'WinPath' that match the given 'FileExtension'.
    The 'Backup' directory is created by default.
    You can also 'SearchBackup' in the 'Backup' directory with a regex.

    .PARAMETER WinPath
    Path to the directory to search in

    .PARAMETER FileExtension
    Extension of files to backup

    .PARAMETER Backup
    Create Backup directory (true by default)

    .PARAMETER SearchBackup
    Search pattern in backed-up files (false by default)
#>

param(
    [Parameter(mandatory=$true)]
    [string]$WinPath,

    [Parameter(mandatory=$true)]
    [string]$FileExtension,
    
    [bool]$Backup = $true,
    [string]$SearchBackup
)

# check if the directory exists
if (!(Test-Path -Path $WinPath -PathType Container)) {
    Write-Host "'$WinPath' does not exist or is not a directory"
    exit 1
}

# if SearchBackup then show files matching and quit
if ($SearchBackup -ne '') {
    if (!(Test-Path -Path "$WinPath" -PathType Container)) {
        Write-Host "'$WinPath' does not exist or is not a directory"
        exit 2
    }
    Get-ChildItem -Path "$WinPath/Backup" -File | ForEach-Object {
        if ($_.Name -match $FileExtension) {
            Write-Host "$_"
        }
    }
    exit
}

# create the Backup directory
if ($Backup) {
    $null = New-Item -Path "$WinPath/Backup" -ItemType Directory -Force
}

# add all files matching the extension to the Backup directory
$count = 0
Get-ChildItem -Path $WinPath Recurse -File | ForEach-Object {
    if ($_.Extension -eq $FileExtension -and $_.DirectoryName -cnotmatch "Backup") {
        Move-Item -Path $_ -Destination "$WinPath/Backup"
        $count += 1
    }
}
Write-Host "$count file(s) backed-up"

I think it is mostly self explanatory^^

CTF Mr Robot 1

Simple writeup about the CTF Mr Robot 1. (Root-Me version)

Based on the show, Mr. Robot. This VM has three keys hidden in different locations. Your goal is to find all three. Each key is progressively difficult to find. The VM isn’t too difficult. There isn’t any advanced exploitation or reverse engineering. The level is considered beginner-intermediate.

First flag

  • Go to url/robots.txt
    • fsocity.dic (wordlist for later)
    • key-1-of-3.txt (first flag)
  • Go to url/key-1-of-3.txt

Yeah! You got the first one. You’re on the right way! Go on!

Music Fetch Tool

Presenting my two scripts to manage my music collection.

I used to run cmus in my terminal as music player, but after a while it started to get really slow when I got lot of musics.
So I decided to try something else, that’s how I found
ncmpcpp.
It is a music player that is a client of the MPD (Music Player Daemon) server.

I have a very basic system to handle my music which is a simple script that allows me to:

CliProtect Deployment

Today, the deployment of CliProtect was completed successfully. However, during the testing phase, we found an issue with the rdpclip.exe process. If this process was already running before my injector was executed, it caused a conflict.

I did not see that during the testing phase since between every attempt I was logged out not simply disconnected (which keeps processes running). But on that server the users aren’t directly logged out, there is a delay between the disconnection and the log out action.

My Homelab

Simply presenting my homelab and the services running on it.

My homelab setup is really simple:

  • Zimaboard 832
  • 512gb SSD
  • Debian 11

For the services I run them inside containers for simplicity and security. To manage my containers I use portainer community edition which itself runs in a container.

The interface looks like this:

portainer dashboard

portainer dashboard

portainer containers

portainer containers

On the screenshot we can see the services I run:

Discovered Jekyll

A Ruby library allowing to easily create static website (like this one).

Today I discovered Jekyll with this comment on Reddit.

To install and run jekyll simply do:

➜ gem install bundler jekyll

➜ jekyll new my_blog

➜ cd my_blog

➜ bundle exec jekyll serve

# => Now browse to http://localhost:4000 

To add posts you can simply add a new mardown file:

➜ cd _posts
➜ touch > 2023-04-25-my-super-title.md
  • the filename format is YEAR-MONTH-DAY-title.EXT

Example of post (this one actually):

Discovered Thor

A Ruby library allowing to easily create command line tool.

Today I discovered Thor with this comment on Reddit.

It is super easy to install, just run: gem install thor

Then to use it, simple command line tool:

#!/bin/ruby

require 'thor'

class SayHello < Thor
    desc "greet [NAME]", "greet using [NAME]"
    def greet(name)
        puts "Hi #{name} !"
    end

    # without this it shows an ugly warning on error
    def self.exit_on_failure?
      true
    end
end

SayHello.start ARGV

If you run the script with no argument you will get: