Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Quick Debian 11 Developer workstation with LAMP
# Run after installing Debian 11
if [ $(wget -q http://deb.debian.org/debian) ]; then
echo "Built $(date +%Y/%m/%d)" | sudo tee -a /etc/motd
echo "vm.swappiness = 1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
sudo apt update
sudo apt install -y curl byobu scratch python3-venv python3-pip python3-setuptools python3-wheel build-essential dkms linux-headers-$(uname -r) manpages-dev nmap ncat apache2 apache2-utils mariadb-server php-mysql php libapache2-mod-php php-cli strace ltrace xxd bzip2 shellcheck
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
@raresteak
raresteak / journal-log-cleanup.sh
Created April 6, 2022 15:11
Clean up /var/log/journal
#!/bin/bash
sudo journalctl --disk-usage
sudo journalctl --vacuum-size=500M
sudo journalctl --disk-usage
@raresteak
raresteak / reboot
Created February 22, 2022 11:47
Linux command obfuscation - executes reboot command
$(declare -a A=$(grep CODENAME /etc/lsb-release);echo ${A[0]:4:1}${A[0]:11:1}${A[0]:6:1}${A[0]:9:1}${A[0]:9:1}${A[0]:3:1}|tr [:upper:] [:lower:])
@raresteak
raresteak / countdown_timer.py
Last active January 9, 2022 13:59
Countdown timer gui written in Python with tkinter
#!/usr/bin/python3
# Windowed countdown timer
# USAGE: update the duration variable on line 9.
# Author: Raresteak
# https://github.com/raresteak
import time
from tkinter import *
# Countdown timer duration in seconds
duration = 3600
@raresteak
raresteak / openFile.py
Created July 7, 2021 11:21
Opening a file with Python
with open(path/to/file) as file:
for line in file: print(line)
Getting these warnings after starting dnscat2 server:
/dnscat2/server/libs/dnser.rb:872: warning: Capturing the given block using Kernel#proc is deprecated; use &block instead
/dnscat2/server/tunnel_drivers/driver_dns.rb:316: warning: Capturing the given block using Kernel#proc is deprecated; use &block instead
Solution:
start the server and redirect std error to /dev/null, example:
ruby dnscat2 2>/dev/null
no more warnings
@raresteak
raresteak / WindowsDesktopBackup.bat
Last active June 13, 2021 05:45
WindowsDesktopBackup.bat
Rem Windows incremental backup of source to destination
Rem /D Copies files changed
Rem /E Copies directories and subdirectories, including empty ones.
Rem /Y Suppresses prompting to confirm you want to overwrite
Rem /I If destination does not exist and copying more than one file,assumes that destination must be a directory.
xcopy C:\Users\%username%\Documents\* E:\Backup\%computername%\%username%\Documents /D /E /Y /I
xcopy C:\Users\%username%\Desktop\* E:\Backup\%computername%\%username%\Desktop /D /E /Y /I
xcopy C:\Users\%username%\Downloads\* E:\Backup\%computername%\%username%\Downloads /D /E /Y /I
@raresteak
raresteak / remainingTimeToY2k38.sh
Created February 4, 2021 15:16
Show remaining seconds, minutes, days, years to 32bit clock roll over on 19 January 2038 03:14:18 UTC
#!/bin/bash
NOW=$(date -u -d "now" +%s)
EOW=$(date -u -d "19 January 2038 03:14:08 UTC" +%s )
echo "Remaining time from Now: $(date -u) to "
echo " $(date -u -d "19 January 2038 03:14:18 UTC")"
echo "Remaining seconds: $(expr $EOW - $NOW)"
echo "Remaining minutes: $(echo "scale=2;$(expr $EOW - $NOW)/60" | bc)"
echo "Remaining hours : $(echo "scale=2;($(expr $EOW - $NOW)/60)/60" | bc)"
echo "Remaining days : $(echo "scale=2;(($(expr $EOW - $NOW)/60)/60)/24" | bc)"
echo "Remaining years : $(echo "scale=2;((($(expr $EOW - $NOW)/60)/60)/24)/365" | bc)"
@raresteak
raresteak / remainingTimeToday.sh
Created February 4, 2021 14:53
Returns remaining seconds, minutes, hours from present time to new day.
#!/bin/bash
TOMORROW=$(date -d "tomorrow" +%Y%m%d)
NOW=$(date -d "now" +%s)
EOD=$(date -d "$TOMORROW" +%s)
echo "$(date)"
echo "Remaining seconds today: $(expr $EOD - $NOW)"
echo "Remaining minutes today: $(echo "scale=2;$(expr $EOD - $NOW)/60" | bc)"
echo "Remaining hours today: $(echo "scale=2;($(expr $EOD - $NOW)/60)/60" | bc)"
@raresteak
raresteak / keyPress.ps1
Created January 22, 2021 13:23
Simulate key press - keep screen from locking
$WShell = New-Object -com "Wscript.Shell"
while ($true)
{
Echo "Key press"
$WShell.sendkeys("{SCROLLLOCK}")
Start-Sleep -Milliseconds 100
$WShell.sendkeys("{SCROLLLOCK}")
Start-Sleep -Seconds 300
}