Skip to content

Instantly share code, notes, and snippets.

@aachyee
aachyee / bash
Created September 24, 2020 07:35 — forked from harasou/bash
シェルスクリプトで IPアドレス計算 ref: http://qiita.com/harasou@github/items/5c14c335388f70e178f5
$ ip2decimal 192.168.0.1
3232235521
$ decimal2ip 3232235521
192.168.0.1
$
$ ip2decimal 255.255.255.0
4294967040
$ cidr2decimal 24
4294967040
@aachyee
aachyee / annonthatshit.sh
Created September 24, 2020 07:39 — forked from CMDann/annonthatshit.sh
Onion Pi IPTables
#!/bin/bash
# By Frank Danielson @ Bold Apps
IPS=(`ifconfig | grep "inet addr:" | awk -F: '{ print $2 }' | awk '{ print $1 }'`)
MASKS=(`ifconfig | grep "Mask:" | awk -F: '{ print $4 }'`)
BITS=()
i=0
mask2cidr() {
@aachyee
aachyee / convert_between_cidr_and_netmask.sh
Created September 24, 2020 07:40 — forked from rsperl/convert_between_cidr_and_netmask.sh
convert between cidr and netmask
#!/bin/bash
# src: https://stackoverflow.com/questions/20762575/explanation-of-convertor-of-cidr-to-netmask-in-linux-shell-netmask2cdir-and-cdir
mask2cidr ()
{
# Assumes there's no "255." after a non-255 byte in the mask
local x=${1##*255.}
set -- 0^^^128^192^224^240^248^252^254^ $(( (${#1} - ${#x})*2 )) ${x%%.*}
x=${1%%$3*}
@aachyee
aachyee / ip.sh
Created September 24, 2020 07:56 — forked from ginokent/ip.sh
#!/bin/bash
_err() {
printf "$(date +'%Y-%m-%dT%H:%M:%S%z') [ERROR] $@" >&2
}
_usage() {
_err "Usage: $(basename $0) {$(sed "s/ () /|/g; s/ ()$//g;" <<< $(declare -f | egrep "^[[:alpha:]][[:graph:]]+[[:space:]]\(\)"))} \$IPADDR/\$PREFIX\n"
}
#!/bin/bash
ip2dec () {
local a b c d ip=$@
IFS=. read -r a b c d <<< "$ip"
printf '%d\n' "$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))"
}
die () {
echo $1
@aachyee
aachyee / inet.sh
Created September 24, 2020 08:00 — forked from ernix/inet.sh
#/bin/sh
set -eu
ip2dec () {
local ip="$1"
if test -z "$ip"; then
printf "Argument required" 1>&2
return 1
fi
#!/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() {
@aachyee
aachyee / knock
Created September 24, 2020 09:29 — forked from lumenpink/knock
Knock 2015.1 - Projeto elaborado na Estácio de Sá Santa Catarina - https://docs.google.com/presentation/d/1G-kDirpN6SyehQw8KUaFqMJARwLrHhw80Y9wdXNNkXQ/edit?usp=sharing
#!/bin/bash
. /usr/local/knock/library
#Lista de portas na ordem da sequencia
ports=(34 1032 43231 456)
#Porta a Ser desbloqueada
safePort=29
#Comando tshark (wireshark para console)
#customizado para exibir apenas
#ip de origem e porta de destino
tshark -n -l -f "tcp and dst 177.70.2.30 and tcp[tcpflags] & (tcp-syn) != 0 and tcp[tcpflags] & (tcp-ack) = 0" -E separator=":" -Tfields -e ip.src -e tcp.dstport |
@aachyee
aachyee / estadisticas.sh
Created September 24, 2020 09:34 — forked from felmoltor/estadisticas.sh
Kippo statistic extraction script
#!/bin/bash
TOPIP=15
TOPUP=30
TOPU=30
TOPP=30
TOPLU=15
TOPLP=15
GEOLITEDB="/home/<username>/maxmind/GeoIPCountryWhois.db" # Use the sqlite3 db created with http://pastebin.com/9WxCy5ks
@aachyee
aachyee / analyze.new.logs.sh
Created September 24, 2020 09:37 — forked from felmoltor/analyze.new.logs.sh
OVH Apache Access log periodic download
#!/bin/bash
# Author: Felipe Molina (@felmoltor)
# Date: 05/03/2015
# Summary:
# This script analyzes the Apache logs previously downloaded with "download.ovh.logs.sh"
# It compares the requests done yesterday with the whitelist of files of the website contained in "whitelist.files.list"
# If one of the requests is not pressent in this whitelist, the script stores it as suspicious along with the server response
# of the request and finally a summary is sent to your email.