Skip to content

Instantly share code, notes, and snippets.

View mskf3000's full-sized avatar
💭
I may be slow to respond.

MSKF3000 mskf3000

💭
I may be slow to respond.
View GitHub Profile
@mskf3000
mskf3000 / ipinfo.sh
Last active June 6, 2022 02:53
ipinfo.sh
#!/usr/bin/env bash
__fmt() {
jq -r '.[] | [(.asn | [.asn, .name] | join(" ")), .country, .city, .ip] | join(" - ")'
}
__info() {
@mskf3000
mskf3000 / gist:e6445efaf02f28fb5e82a7285b3a7ba6
Created May 18, 2022 03:59 — forked from lordkhonsu/gist:7eca5cbf0440589946c7
bash sed anonymize ip adresses in file

This line will replace the last octet of ipv4 adresses in a given file with a zero:

sed -i '' -e 's/(([0-9]{1,3}.){3})[0-9]{1,3}/\10/g'

@mskf3000
mskf3000 / ipconv.py
Created April 30, 2022 23:10 — forked from staaldraad/ipconv.py
Quick script to generate different formats for a given IP address.
#!/usr/bin/env python
import sys
if len(sys.argv) < 2:
print "Enter IP address as first argument: python %s 127.0.0.1"%sys.argv[0]
sys.exit(1)
ip = sys.argv[1]
ips = ip.split('.')
iph = '0x{:02X}.0x{:02X}.0x{:02X}.0x{:02X}'.format(*map(int, ips))
@mskf3000
mskf3000 / awk_netstat.sh
Created April 30, 2022 23:06 — forked from qistoph/awk_netstat.sh
AWK to get details from /proc/net/tcp and /proc/net/udp when netstat and lsof are not available
# Based on gist https://gist.github.com/staaldraad/4c4c80800ce15b6bef1c1186eaa8da9f
# - added TCP states
awk 'BEGIN{states["01"]="TCP_ESTABLISHED"
states["02"]="TCP_SYN_SENT"
states["03"]="TCP_SYN_RECV"
states["04"]="TCP_FIN_WAIT1"
states["05"]="TCP_FIN_WAIT2"
states["06"]="TCP_TIME_WAIT"
states["07"]="TCP_CLOSE"
@mskf3000
mskf3000 / awk_netstat.sh
Created April 30, 2022 23:03 — forked from staaldraad/awk_netstat.sh
AWK to get details from /proc/net/tcp and /proc/net/udp when netstat and lsof are not available
# Gawk version
# Remote
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($3,index($3,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($3,i,2))}{print x":"strtonum("0x"substr($3,index($3,":")+1,4))}'
# Local
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($2,i,2))}{print x":"strtonum("0x"substr($2,index($2,":")+1,4))}'
# No Gawk
# Local
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){
@mskf3000
mskf3000 / DATA.txt
Last active February 22, 2022 23:39
|----------|------------------------------------------------------|------------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|----------------|
| AS132203 | Tencent Building, Kejizhongyi Avenue | 1.12.0.0/20 | TENCENTCLOUD | Tencent cloud computing (Beijing) Co., Ltd. | CN |
|----------|------------------------------------------------------|------------------|----------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|----------------|
| AS132203 | Tencent Building, Kejizhongyi Avenue | 1.12.34.0/23 | TENCENTCLOUD | Tence
@mskf3000
mskf3000 / pwsh-color-logcat.ps1
Created February 14, 2022 09:03 — forked from pulimento/pwsh-color-logcat.ps1
Function to colorize adb output, using PowerShell
# Change execution policy: Set-ExecutionPolicy -Scope Process Unrestricted
# Run this script, and then 'adb logcat | color-logcat'
Function global:color-logcat {
Process {
if ($_) {
$color = "White"
$fgcolor = "Black"
if($_ -match [regex]"\s[V]\s") {
@mskf3000
mskf3000 / s3-upload-aws4.sh
Created December 12, 2021 16:31 — forked from vszakats/s3-upload-aws4.sh
AWS S3 upload using signature v4
#!/bin/sh -u
# To the extent possible under law, Viktor Szakats
# has waived all copyright and related or neighboring rights to this
# script.
# CC0 - https://creativecommons.org/publicdomain/zero/1.0/
# Upload a file to Amazon AWS S3 using Signature Version 4
#
# docs:
@mskf3000
mskf3000 / .bash_profile
Created December 1, 2021 04:00 — forked from natelandau/.bash_profile
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management