Skip to content

Instantly share code, notes, and snippets.

@mikehearn
mikehearn / Scripts
Last active December 4, 2023 11:45
systemd unit monitoring setup
----------------------------------------------------
#!/usr/bin/env bash
# place in a file called email-unit-status.sh on the PATH
# requires you to have set /etc/admin-email to contain the address to receive the messages
# requires install of ansi2html
#
set -e
@luckylittle
luckylittle / Mock Exam 1.md
Last active November 11, 2024 18:20
Prometheus Certified Associate (PCA)

Mock Exam

1

Q1. The metric node_cpu_temp_celcius reports the current temperature of a nodes CPU in celsius. What query will return the average temperature across all CPUs on a per node basis? The query should return {instance=“node1”} 23.5 //average temp across all CPUs on node1 {instance=“node2”} 33.5 //average temp across all CPUs on node2.

node_cpu_temp_celsius{instance="node1", cpu="0"} 28
node_cpu_temp_celsius{instance="node1", cpu="1"} 19
node_cpu_temp_celsius{instance="node2", cpu="0"} 36
node_cpu_temp_celsius{instance="node2", cpu="1"} 31
@testanull
testanull / PoC_CVE-2021-28482.py
Created May 2, 2021 11:10
PoC of CVE-2021-28482
import requests
import time
import sys
from base64 import b64encode
from requests_ntlm2 import HttpNtlmAuth
from urllib3.exceptions import InsecureRequestWarning
from urllib import quote_plus
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
@sindresorhus
sindresorhus / esm-package.md
Last active November 17, 2024 22:07
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
// sensor via https://wiki.postmarketos.org/wiki/PINE64_PinePhone_(pine64-pinephone)#Sensors
const x_path = "/sys/bus/iio/devices/iio:device3/in_accel_x_raw"
const y_path = "/sys/bus/iio/devices/iio:device3/in_accel_y_raw"
const z_path = "/sys/bus/iio/devices/iio:device3/in_accel_z_raw"
var fs = require("fs");
var express = require('express');
var app = express();
// could be WSS but fast enough on LAN as-is
@vsec7
vsec7 / BurpSuiteSSLPassTrough.json
Created June 25, 2020 11:43
Filter out the noise
{
"proxy":{
"ssl_pass_through":{
"automatically_add_entries_on_client_ssl_negotiation_failure":false,
"rules":[
{
"enabled":true,
"host":".*\\.google\\.com",
"protocol":"any"
},
@yoyosan
yoyosan / cleancrap.md
Last active November 15, 2024 12:41
How to clean kdetmpdevfsi or .ICEd-unix suspicious files/folders or processes

Problem

I've recently been hacked on my VPS(using Centos 7.6 and CWP up to date) and the following files/folders were created:

  • /tmp/.ICEd-unix
  • /var/tmp/.ICEd-unix
  • /tmp/kdevtmpfsi
  • /var/tmp/kinsing

The following processes were running and using 100% CPU and Memory:

@claudioc
claudioc / drop_shadow.sh
Created May 29, 2020 17:05
Script which finds the newest screenshot image and adds a shadow to it
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
echo "Needs the filename as the first argument"
exit -1
fi
type /usr/local/bin/convert >/dev/null 2>&1 || { echo >&2 "The convert command must be available."; exit 1; }
input_filename="${1}"
@Tumar
Tumar / gist:cd1ef5ecd88086d49d04d9a4205f4763
Last active September 10, 2024 13:19
Install alertmanager
# Create user
useradd --no-create-home --shell /bin/false alertmanager
# Download and unpack
wget https://github.com/prometheus/alertmanager/releases/download/v0.20.0/alertmanager-0.20.0.linux-amd64.tar.gz
tar -xvf alertmanager-0.20.0.linux-amd64.tar.gz
mv alertmanager-0.20.0.linux-amd64/alertmanager /usr/local/bin/
mv alertmanager-0.20.0.linux-amd64/amtool /usr/local/bin/
chown alertmanager:alertmanager /usr/local/bin/alertmanager
@ruanbekker
ruanbekker / promtail_docker_logs.md
Last active November 17, 2024 10:23
Docker Container Logging using Promtail