Skip to content

Instantly share code, notes, and snippets.

@raresteak
raresteak / update_time_from_web.sh
Last active August 11, 2019 16:52
Time sync over http
#!/bin/bash
# Sync time from HTTP response. update_time_from_web.sh
# Fix system time from retrieved webpage off of Internet.
# I need to do it this way because the system only has outbound http/s access
# to a couple websites and no outbound access to a time server.
# Use any highly available reference website.
SITE="http://www.openntpd.org/"
HTTP_PROXY=http://webproxy:port
HTTPS_PROXY=http://webproxy:port
nmap -Pn -sS -sV -sC -p- -oA IP-out IP
@raresteak
raresteak / Work_around_to_problems_decrypting_TLS_traffic_in_Wireshark.txt
Created August 24, 2019 14:27
Work around to problems decrypting TLS traffic in Wireshark
If you're having a problem decoding TLS traffic in Wireshark due to TLS 1.3 perfect forward secrecy then lower your browser's max TLS version.
In Linux configure ssl key logging
1. Open terminal,
export SSLKEYLOGFILE=/tmp/sslkeylog.log
2. Launch firefix from the same terminal.
firefox &
or
firefox-esr
@raresteak
raresteak / gen_random_time.sh
Created November 15, 2019 14:55
A short Bash script to generate a random time in 24 hour format.
#!/bin/bash
# Generate a random time in 24H format
# Requires Bash because using builtin Random function
# Author: raresteak
HOUR=$(echo $(($RANDOM % 124)) )
while [ $HOUR -lt "100" ]; do
HOUR=$(echo $(($RANDOM % 124)) )
done
RHOUR=$(echo $HOUR | sed 's/^1//g')
@raresteak
raresteak / udp_listener.sh
Created November 15, 2019 21:38
Persistent UDP listener
#!/bin/bash
# Create a persistent self restarting udp listener to recover from client disconnects
# Usage:
# nohup /path/to/udp_listener.sh &
PORT=60000
RESTART=600
while : ; do
/bin/netcat -u -l ${PORT} >> /path/to/output/file &
@raresteak
raresteak / generate_random_time.ps1
Created December 13, 2019 11:38
Generate a random time using Powershell
<#
.SYNOPSIS
Create a random time in 24 hour format
.OUTPUTS
Outputs time to standard out.
.NOTES
Version: .1
Author: raresteak
@raresteak
raresteak / gist:69d9057cbcc0c848aa685843bbdfdf45
Created February 6, 2020 18:58
Tail a file and perform some action when keyword is found
tail --retry -s 2 -f /var/log/apache2/access.log | grep --line-buffered 404 | while read ; do echo "404 keyword found, $(doSomeCommand)" ; done
@raresteak
raresteak / gist:219578890310acaf7cc472589461c1a4
Last active February 6, 2020 20:36
Wiping out your bash session history
export HISTSIZE=0
export HISTFILE=/dev/null
@raresteak
raresteak / wipeFreeSpace.sh
Last active January 22, 2021 20:40
Linux: Wiping free space
# requires shred
dd if=/dev/urandom of=junk bs=1M; shred -v -u -n 1 junk
@raresteak
raresteak / html_picture_embed.sh
Last active March 5, 2020 14:43
Create self contained html files with embedded images
#!/bin/bash
# Create self contained html files with embedded images
# Usage
# ./html_picture_embed.sh picture.png > html_file.html
# Example https://pastebin.com/K3dDXjfA
PIC=$1
echo -n '<html><img src="data:image/png;base64,'
base64 $PIC | tr -d '\n'
echo '"></html>'