Skip to content

Instantly share code, notes, and snippets.

@aubique
aubique / c4wol.ps1
Last active September 29, 2020 09:20
WakeOnLan script for PowerShell
function Main
{
# File containing a MAC device list
$filename = './c4_lan/c4_lan_list.txt'
# The variables above may vary according to your input
$ip = Get-IPAddress
$broadcast = Get-BroadcastAddress $ip
Send-WOL-FromFile $filename $broadcast -Verbose
@StephenGenusa
StephenGenusa / gist:90f0ecc094eb630975a97732489d4ba4
Created August 27, 2020 20:55
Build wget2 with all features on clean Ubuntu 20.04 installation
sudo apt-get -y install doxygen pandoc flex lzip lcov git gcc cmake libpcre3-dev zlib1g-dev libssl-dev libnghttp2-dev autoconf-archive nettle-dev libtool python-is-python3 autopoint texinfo nettle-dev nettle-dev nettle-bin libunistring-dev gettext make libbz2-dev lzma brotli libbrotli-dev libzstd-dev zstd lzip liblz-dev libpcre2-dev libmicrohttpd-dev libgpgme-dev liblzma-dev libgnutls28-dev libgcrypt20-dev git-merge-changelog
cd ~/Downloads
mkdir wget-dev
cd wget-dev
git clone https://gitlab.com/rockdaboot/libhsts
cd libhsts
autoreconf -fi
./configure
make
#!/bin/sh
# Copyright (C) 2016 The Linux Containers Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@TimaGribanov
TimaGribanov / decimal2ip.sh
Created October 24, 2019 13:16
Converting IPs
#!/bin/bash
#Converting decimal to binary
##Source: https://stackoverflow.com/questions/55239476/awk-convert-decimal-to-binary
gawk '
function d2b(d, b) {
while(d) {
b=d%2b
d=int(d/2)
}
#!/bin/bash
# cf. https://www.skyarch.net/blog/?p=7423
ip2dec() {
local IFS=.
local C=($1)
printf "%s\n" $(( (${C[0]} << 24) | (${C[1]} << 16) | (${C[2]} << 8) | ${C[3]} ))
}
mask2dec() {
@deardooley
deardooley / cidr2ip
Last active November 1, 2024 05:54
cidr to ip range or list. This script prints the ip ranges for a cidr by default. Full ip lists can be obtained with the -a or --all flags.
#!/usr/bin/env bash
# Print usage
function usage {
echo -n "$(basename $0) CIDR...
$(basename $0) [OPTION] CIDR...
This script prints the ip range or full list of ip addresses for one or more CIDR.
Options:
@toonetown
toonetown / shimo-sshuttle
Last active September 24, 2020 10:10
Connects to sshuttle tunnel using Shimo
#!/bin/bash
# Function to convert cidr to a mask
cidr2mask () {
# Number of args to shift, 255..255, first non-255 byte, zeroes
set -- $(( 5 - (${1} / 8) )) 255 255 255 255 $(( (255 << (8 - (${1} % 8))) & 255 )) 0 0 0
[ ${1} -gt 1 ] && shift ${1} || shift
echo ${1-0}.${2-0}.${3-0}.${4-0}
}
// 2018.12.03 Atienza, Chris
// Given a slash specified network (ie: 10.1.1.1/24) returns the low and hi IPs in the defined range
// does not exclude any special reserved addresses
function _cidrToRange(cidr) {
var range = [2];
cidr = cidr.split('/');
var cidr_1 = parseInt(cidr[1])
range[0] = long2ip((ip2long(cidr[0])) & ((-1 << (32 - cidr_1))));
start = ip2long(range[0])
#!/bin/bash
############################
## Methods
############################
prefix_to_bit_netmask() {
prefix=$1;
shift=$(( 32 - prefix ));
bitmask=""
#
# Library with various ip manipulation functions
#
# convert ip ranges to CIDR notation
# str range2cidr(ip2dec("192.168.0.15"), ip2dec("192.168.5.115"))
#
# Credit to Chubler_XL for this brilliant function. (see his post below for non GNU awk)
#
function range2cidr(ipStart, ipEnd, bits, mask, newip) {