Binary Vault: Sharing Data Packages Securely using Github

Posted by : on

Category : powershell   scripts   network   download   sharing   bmw


Table of Contents

Overview

Overview of the Binary Vault Data Sharing System

Baretail

table

Baretail is a free real-time log file monitoring tool from Bare Metal Software Pty Ltd. It’s like Linux tail, but on WIndows with GUI, I find it usefull, use it during development, and thought there was no point in removing this feature for prod. Comes as a stand-alone executable that you get from this link. View the license here. The exe is not signed, and I can understand if you have hesitation in downloading and running an unsigned binary, but I’ve done an analysis of it and it’s clean.

The version I downloaded and checked is 3.50a / 2006-11-02.

It has the following checksums:

To view logs using baretail, follow these steps:

  1. Download, install Baretail.exe
  2. Configure the program
  3. Use the button

Install Baretail

Get it here. View the license here. It has the following checksums:

Here’s s small powershell function to install it

function Install-Baretail {
    [CmdletBinding(SupportsShouldProcess = $true)]
    param(
        [Parameter(Position = 0, Mandatory = $false, HelpMessage = "Destination directory, defaults to program files/baretail")]
        [string]$DestinationPath = $(if ($env:ProgramFiles_x86) { Join-Path $env:ProgramFiles_x86 'baretail' } else { 'C:\Program Files (x86)\baretail' }),
        [Parameter(Mandatory = $False)]
        [switch]$Force
    )
    try {
        # Validate and create directory if needed
        if (-not (Test-Path $DestinationPath)) {
            Write-Host "Destination directory does not exist. Creating: $DestinationPath" -ForegroundColor Yellow
            $null = New-Item -ItemType Directory -Path $DestinationPath -Force
        } elseif (-not (Get-Item $DestinationPath).PSIsContainer) {
            throw "DestinationPath is not a directory: $DestinationPath"
        }

        $DestinationBaretailExe = Join-Path $DestinationPath "baretail.exe"

        # Check if the exe exists
        if (Test-Path $DestinationBaretailExe) {
            if ($Force) {
                Write-Warning "baretail.exe already exists at destination and will be overwritten due to -Force."
            } else {
                throw "baretail.exe already exists at $DestinationBaretailExe. Use -Force to overwrite."
            }
        }

        $ExpectedMd5Hash = 'F3E7A015C1D541528085D3F9581AB41F'
        $ExpectedSha256Hash = '160D6A3BDC9D64677643376F82E559EB4112289E6B6D722B5B3B32699D18BCA9'
        $ExpectedSize = 225280
        $DownloadUri = "https://www.baremetalsoft.com/baretail/download.php?p=m"
        $headers_struct = @{
            "authority" = "www.baremetalsoft.com"
            "method" = "GET"
            "path" = "/baretail/download.php?p=m"
            "scheme" = "https"
            "accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"
            "accept-encoding" = "gzip, deflate, br, zstd"
            "priority" = "u=0, i"
            "referer" = "https://www.baremetalsoft.com/baretail/"
        }

        $tmpFile = [System.IO.Path]::GetTempFileName()
        try {

            if ($PSVersionTable.PSVersion.Major -lt 6) {
                # PowerShell 5.1 workaround
                $wc = New-Object System.Net.WebClient
                $wc.Headers.Add("User-Agent", "Mozilla/5.0")
                $wc.DownloadFile($DownloadUri, $tmpFile)
                Start-Sleep 2
                [pscustomobject]$Res = [pscustomobject]@{}
                if ((Test-Path "$tmpFile") -and ((Get-Item "$tmpFile").Length -eq $ExpectedSize)) {
                    $Res | Add-Member -MemberType NoteProperty -Name 'StatusCode' -Value 200
                    $Res | Add-Member -MemberType NoteProperty -Name 'StatusDescription' -Value "OK"
                    $Res | Add-Member -MemberType NoteProperty -Name 'RawContentLength' -Value $ExpectedSize
                } else {
                    $Res | Add-Member -MemberType NoteProperty -Name 'StatusCode' -Value 1
                    $Res | Add-Member -MemberType NoteProperty -Name 'StatusDescription' -Value "FAILED"
                }

            } else {
                $Res = Invoke-WebRequest -Uri $DownloadUri -Headers $headers_struct -OutFile $tmpFile -ErrorAction Stop -Passthru
            }

            if ($Res.StatusCode -eq 200) {
                Write-Host "Download Success. Status $($Res.StatusCode)" -ForegroundColor DarkGreen

                # Validate file
                $Md5 = (Get-FileHash -Path $tmpFile -Algorithm MD5).Hash.ToUpper()
                $Sha256 = (Get-FileHash -Path $tmpFile -Algorithm SHA256).Hash.ToUpper()
                $Size = (Get-Item $tmpFile).Length

                $TestSize = ($Size -eq $ExpectedSize)
                $TestMd5Hash = ($Md5 -eq $ExpectedMd5Hash)
                $TestShaHash = ($Sha256 -eq $ExpectedSha256Hash)

                Write-Host ("  {0,-16} => {1}" -f "Checking Size", ($(if ($TestSize) { "✔ OK" } else { "❌ ERROR ($Size vs $ExpectedSize)" })))
                Write-Host ("  {0,-16} => {1}" -f "MD5 checksum", ($(if ($TestMd5Hash) { "✔ OK" } else { "❌ ERROR ($Md5)" })))
                Write-Host ("  {0,-16} => {1}" -f "SHA256 checksum", ($(if ($TestShaHash) { "✔ OK" } else { "❌ ERROR ($Sha256)" })))

                if ($TestSize -and $TestMd5Hash -and $TestShaHash) {
                    Move-Item -Force $tmpFile $DestinationBaretailExe
                    Write-Host "baretail.exe installed successfully to $DestinationBaretailExe" -ForegroundColor Green
                } else {
                    throw "Validation failed: Hash or size mismatch. Downloaded file will NOT be installed."
                }
            } else {
                throw "Download Failure. Status $($Res.StatusCode) $($Res.StatusDescription)."
            }
        } finally {
            if (Test-Path $tmpFile) { Remove-Item $tmpFile -ErrorAction SilentlyContinue }
        }
    } catch {
        Write-Host "ERROR: $_" -ForegroundColor Red
        throw
    }
}

Configure Baretail

In settings, in the log tab, et the baretail.exe path



About Guillaume Plante
Guillaume Plante

A developper with a passion for technology, music, astronomy and art. Coding range: hardware/drivers, security, ai,. c/c++, powershell

Email : guillaumeplante.qc@gmail.com

Website : https://arsscriptum.ddns.net

Useful Links