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 / mysql_replication.md
Created November 8, 2023 13:41
Setting Up MySQL Replication

Setting Up MySQL Replication

Overview

We’ll configure one MySQL instance as the source database and another as its replica. Replication allows data synchronization between these separate databases.

Step 1: Configure the source

  1. Obviously install MySQL on 2 servers.
@cmbaughman
cmbaughman / compromisejs-name.js
Last active January 29, 2023 23:07
Using Compromise.js to get name formats right.
const nlp = require("compromise");
const nameParser = require("name-parser");
// Function to determine the name format
function determineNameFormat(name) {
// Patterns to match different name formats
const firstLast = nlp(name).match("#Honorific #FirstName #LastName").out("array");
const lastFirst = nlp(name).match("#LastName, #FirstName #Honorific").out("array");
const middleName = nlp(name).match("#FirstName #MiddleName #LastName").out("array");
const middleInitial = nlp(name).match("#FirstName #MiddleInitial #LastName").out("array");
@cmbaughman
cmbaughman / README.md
Created January 29, 2023 02:31
The JavaScript feature, Generators

Here is an example of using JavaScript generators to handle multiple HTTP requests in a sequential manner:

const fetch = require("node-fetch");

function* fetchUsers() {
  const user1 = yield fetch("https://jsonplaceholder.typicode.com/users/1");
 const user2 = yield fetch("https://jsonplaceholder.typicode.com/users/2");
@cmbaughman
cmbaughman / RokuFun.md
Created June 8, 2022 23:49
Fun with Roku

Fun stuff with Roku

Enumerate Roku devices

sudo nmap -sV -O -n 192.168.X.X/24

Identify the device and other stuff using netcat on the SSDP multicast address, port 1900.

@cmbaughman
cmbaughman / linux_ad.sh
Created September 10, 2020 13:00
Ubuntu Active Directory
#!/bin/bash
sudo apt install sssd heimdal-clients msktutil
sudo mv /etc/krb5.conf /etc/krb5.conf.default
COMP=$HOSTNAME
read -p 'What is the domain name? (example: URLFINANCIAL without the .local) ' DOMAIN
LCASEDOMAIN=`echo "$DOMAIN" | tr '[:upper:]' '[:lower:]'`
@cmbaughman
cmbaughman / DockerFile
Created August 7, 2020 16:05 — forked from zhunhung/DockerFile
Selenium Linux DockerFile
FROM ubuntu:latest
RUN apt-get update \
&& apt-get install -y python3-pip python3-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip
# INSTALL DEPENDENCIES
RUN apt-get install -y curl unzip openjdk-8-jre-headless xvfb libxi6 libgconf-2-4
@cmbaughman
cmbaughman / clean-empty-dir.sh
Created August 5, 2020 18:15
Clean up empty directories relative to the current directory
#!/bin/bash
find . -type d -empty -exec rm -i -R {} \;
@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 / 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"
@JeremyMorgan
JeremyMorgan / getbadguys.sh
Created February 8, 2020 04:35
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"