Skip to content

Instantly share code, notes, and snippets.

View tarpanpathak's full-sized avatar

Tarpan Pathak tarpanpathak

  • Los Angeles, CA
View GitHub Profile
@staaldraad
staaldraad / awk_netstat.sh
Last active March 6, 2024 06:10
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){
@kamermans
kamermans / install_jq.sh
Created January 22, 2015 17:21
Install jq (JSON Command Line processor)
#!/bin/bash -e
# This scripts installs jq: http://stedolan.github.io/jq/
JQ=/usr/bin/jq
curl https://stedolan.github.io/jq/download/linux64/jq > $JQ && chmod +x $JQ
ls -la $JQ
@staaldraad
staaldraad / uid_awk.sh
Created December 12, 2017 14:06
Get the uid, gid and user groups without touching /etc/passwd or running the `id` command
awk -F: 'END {print "uid:"u" gid:"g" groups:"gg}{if($1=="Uid"){split($2,a," ");u=a[1]}if($1=="Gid"){split($2,a," ");g=a[1]}if($1=="Groups"){gg=$2}}' /proc/self/status
@magnetikonline
magnetikonline / example.ps1
Last active February 13, 2021 01:09
PowerShell push message to Slack incoming webhook.
Set-StrictMode -Version Latest
$payload = @{
"channel" = "#my-channel"
"icon_emoji" = ":bomb:"
"text" = "This is my message. Hello there!"
"username" = "Mr. Robot"
}
Invoke-WebRequest `