This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/chnroute.txt | |
| netcalc(){ | |
| local IFS='.' ip i | |
| local -a oct msk | |
| read -ra oct <<<"$1" | |
| read -ra msk <<<"$2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # $1 is a decimal number between 0-255 | |
| dec2bin () { | |
| [ -z "$1" ] && return | |
| D2B=({0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}) | |
| echo ${D2B[$1]} | |
| } | |
| # $1 is ip address (dotted quad) | |
| # $2 is netmask (dotted quad) | |
| calc_network () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ip2decimal(ip) { | |
| ip = ip.split("."); | |
| var e, w = 16777216, x = 65536, y = 256, a = eval(ip[0]), b = eval(ip[1]), c = eval(ip[2]), d = eval(ip[3]); | |
| e = a * w + b * x + c * y + d; | |
| return e; | |
| } | |
| function decimal2ip(ip) { | |
| var w = 16777216, x = 65536, y = 256, e = eval(ip), a = e / w, z = e - (a - e % w / w) * w, b = z / x, q = z - (b - z % x / x) * x, c = q / y, d = q - (c - q % y / y) * y; | |
| return parseInt(a) + "." + parseInt(b) + "." + parseInt(c) + "." + parseInt(d); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Return netmask for a given network and CIDR. | |
| cidr_to_netmask() { | |
| value=$(( 0xffffffff ^ ((1 << (32 - $1)) - 1) )) | |
| echo "$(( (value >> 24) & 0xff )).$(( (value >> 16) & 0xff )).$(( (value >> 8) & 0xff )).$(( value & 0xff ))" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ############################ | |
| ## Methods | |
| ############################ | |
| prefix_to_bit_netmask() { | |
| prefix=$1; | |
| shift=$(( 32 - prefix )); | |
| bitmask="" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/nodejs | |
| function showHelp(){ | |
| console.log('Usage: ipnum [ip] ...'); | |
| } | |
| function convert(ip){ | |
| if(typeof ip !== 'string') return false; | |
| if(!/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(ip)) return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Calculates network and broadcast based on supplied ip address and netmask | |
| # Usage: broadcast_calc.sh 192.168.0.1 255.255.255.0 | |
| # Usage: broadcast_calc.sh 192.168.0.1/24 | |
| tonum() { | |
| if [[ $1 =~ ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+) ]]; then |