Skip to content

Instantly share code, notes, and snippets.

@s1037989
s1037989 / repo-si.pl
Last active November 12, 2025 10:46
repository software inventory generator
#!/usr/bin/env perl
use Mojo::Base -strict, -signatures;
use Mojo::File qw(path);
use Mojo::Collection qw(c);
use Mojo::ByteStream qw(b);
use Mojo::Util qw(getopt trim decamelize);
use constant DEFAULT_THRESHOLD => 0.60;
# ---- CLI -------------------------------------------------------------
@s1037989
s1037989 / nessus-si.ps1
Last active November 12, 2025 10:46
windows software inventory generator
<#
.SYNOPSIS
Collect extensive Windows host inventory & security-relevant configuration.
.DESCRIPTION
Produces JSON + HTML report containing:
- system / OS info
- installed apps (registry, winget/choco/Get-Package)
- installed updates/hotfixes
- services, processes, listening ports
- firewall rules
@s1037989
s1037989 / gist:233aac66589be102bb3351ce7a4987f0
Created November 6, 2025 01:11
bash random number generator
# Source - https://stackoverflow.com/questions/1194882/how-to-generate-random-number-in-bash
# Posted by s1037989
# Retrieved 2025-11-05, License - CC BY-SA 4.0
rand() {
perl -E '$ARGV[0]||=""; $ARGV[0]=int($ARGV[0])||length($ARGV[0]); say join "", int(rand(9)+1)*($ARGV[0]?1:0), map { int(rand(10)) } (0..($ARGV[0]||0)-2)' $1
}
@s1037989
s1037989 / save.py
Created November 5, 2025 22:00
mitmdump -s save.py
# save.py
# mitmdump -s save.py
"""
mitmproxy addon: save each response body to a separate file and print only
metadata + response headers (no bodies).
Filename format:
<ct_main_sanitized>__<url_escaped>__<timestamp>.response
Example printed output block:
@s1037989
s1037989 / gist:44eb6e1c87e77e7904f0ffac9c9da709
Created June 27, 2025 12:08
tc netem - Network Emulator is an enhancement of the Linux traffic control facilities that allow to add delay, packet loss, duplication and more other characteristics to packets out‐ going from a selected network interface.
// tc - traffic control
// netem - network emulator
// Start a web server that takes time to do something and respond with the Server-Timing HTTP header
$ perl -Mojo -E 'a("/" => sub ($c) { $c->timing->begin("routed"); $c->render_later; Mojo::IOLoop->timer(2 => sub { $c->timing->server_timing("routed", "Routed", $c->timing->elapsed("routed")); $c->render(text => "", status => 204); }) })->start' daemon
Web application available at http://127.0.0.1:3000
// Delete artificial 50ms roundtrip delay
$ sudo tc qdisc delete dev lo root netem delay 25ms
@s1037989
s1037989 / gist:ac450aafd6e2090bf56309d239712937
Created May 28, 2025 00:48
Create big RPM from added RPMs and unpacked tarballs
Capture state after a fresh install
# rpm -qa --qf "%{name} == %{version}\n" > /root/1.rpm-qa.txt ; rpm -qal > /root/1.rpm-qal.txt ; find / \( -path /proc -prune -o -path /sys -o -path /dev -o -path /boot -o -path /run -o -path /tmp \) -prune -o ! -type d > /root/1.files.txt ; find / \( -path /proc -prune -o -path /sys -o -path /dev -o -path /boot -o -path /run -o -path /tmp \) -prune -o -type d > /root/1.dirs.txt
# wc -l 1.*
5104 1.dirs.txt
30962 1.files.txt
52912 1.rpm-qal.txt
404 1.rpm-qa.txt
Add rpms and unpack tarballs
# yum update -q -y && yum upgrade -q -y ; yum install -q -y firefox postgresql grafana wget rpm-build rpmdevtools; wget -q https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.15.tar.xz -O /tmp/linux-6.15.tar.xz && tar xf /tmp/linux-6.15.tar.xz -C /opt
With the sample Open Metrics SLOC scrape, how to represent that in a Grafana table with these headers?
Baseline, Release, Total Baseline SLOC Ada, Total Release SLOC C++, Added SLOC Ada, Added SLOC C++, Modified SLOC Ada, Modified SLOC C++, Deleted SLOC Ada, Deleted SLOC C++
ChatGPT said:
To represent the OpenMetrics SLOC data in a Grafana table with your specified headers, follow this plan:
🪄 Grafana Table Setup Plan
📋 Desired Headers:
| Baseline | Release | Total Baseline SLOC Ada | Total Baseline SLOC C++ | Added SLOC Ada | Added SLOC C++ | Modified SLOC Ada | Modified SLOC C++ | Deleted SLOC Ada | Deleted SLOC C++ |
🧮 Step 1: Use Prometheus as a Data Source
JFrog Artifactory doesn't have a Perl repository type, which would regenerate a new set of Perl modules index files on every artifact change in the repository. Create a Jfrog Artifactory plugin that will regenerate the Perl index files every type a file is added, removed or modified in order to allow Artifactory to become a "DarkPAN", or offline CPAN.
ChatGPT said:
To enable JFrog Artifactory to act as a DarkPAN (a private/offline CPAN mirror), you can write a user plugin that listens to events like artifact deployment, deletion, or modification, and then regenerates the required Perl index files (such as 02packages.details.txt.gz, etc.).
🛠 Plugin Strategy
We'll create a User Plugin in Groovy that:
Hooks into the afterCreate, afterDelete, and afterMove events.

Install Perlbrew

$ PERLBREW_ROOT=/data/perlbrew perlbrew init
$ . /data/perlbrew/etc/bashrc
$ perlbrew self-install && perlbrew install-cpanm
$ perlbrew install-multiple -j 10 -n perl-5.40.0 perl-5.32.1 perl-5.26.3

Setup CPAN::Mini::Inject

#!/usr/bin/env perl
use strict;
use warnings;
use File::Find;
use File::Spec;
use File::Basename;
use File::Path qw(make_path);
use MIME::Base64;
my $srcdir = shift or die "Usage: $0 /path/to/dir\n";