Skip to content

Instantly share code, notes, and snippets.

@daehee
daehee / main.go
Created September 28, 2020 14:46
chromedp - get response headers
// https://stackoverflow.com/a/56602780
package main
import (
"context"
"io/ioutil"
"log"
"os"
"time"
@daehee
daehee / .gitignore
Created January 8, 2021 15:17
nim .gitignore
# ignore files with no extention:
*
!*/
!*.*
# normal ignores:
*.exe
nimcache
*.pdb
*.ilk
func PrintMemUsage() {
var m runtime.MemStats
runtime.ReadMemStats(&m)
// For info on each, see: https://golang.org/pkg/runtime/#MemStats
fmt.Printf("Alloc = %v MiB", bToMb(m.Alloc))
fmt.Printf("\tTotalAlloc = %v MiB", bToMb(m.TotalAlloc))
fmt.Printf("\tSys = %v MiB", bToMb(m.Sys))
fmt.Printf("\tNumGC = %v\n", m.NumGC)
}
@daehee
daehee / gist:45fbeb9df39552b6f561b48dd8cd0eab
Created December 30, 2020 20:02
Go: expand user path
if path == "~" {
// In case of "~", which won't be caught by the "else if"
path = dir
} else if strings.HasPrefix(path, "~/") {
// Use strings.HasPrefix so we don't match paths like
// "/something/~/something/"
path = filepath.Join(dir, path[2:])
}
func orDone(done, c <-chan interface{}) <-chan interface{} {
valStream := make(chan interface{})
go func() {
defer close(valStream)
for {
select {
case <-done:
return
case v, ok := <-c:
if ok == false {
@daehee
daehee / unfollow.js
Created October 21, 2020 18:02 — forked from verfasor/unfollow.js
LinkedIn Unfollow Script
function isHidden(el) {
if(el) return (el.offsetParent === null);
else return false;
}
TotalUnfollowed = 0;
var LoadingAnimation = document.getElementsByClassName("initial-load-animation")[0];
var CatchLoadingAnimation = setInterval(function(){
if(isHidden(LoadingAnimation) == true) {
@daehee
daehee / go-sqlite3_database_is_locked.go
Created September 14, 2020 18:30 — forked from mrnugget/go-sqlite3_database_is_locked.go
Program that tests the concurrency issues with go-sqlite3. This will create two tables: `products` and `users`. One goroutine will repeatedly read from the `products` table in N fresh goroutines. At the same time ONE goroutine writes to the other table.
package main
import (
"database/sql"
"fmt"
"log"
"math/rand"
"sync"
"time"
@daehee
daehee / converter.sh
Created February 20, 2020 19:19 — forked from xdavidhu/converter.sh
Converter.sh, a bash script to convert domain lists to resolved IP lists without duplicates
#!/bin/bash
# Converter.sh by @xdavidhu
# This is a script inspired by the Bug Hunter's Methodology 3 by @Jhaddix
# With this script, you can convert domain lists to resolved IP lists without duplicates.
# Usage: ./converter.sh [domain-list-file] [output-file]
echo -e "[+] Converter.sh by @xdavidhu\n"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "[!] Usage: ./converter.sh [domain-list-file] [output-file]"
exit 1
@daehee
daehee / domainstoips.sh
Created February 20, 2020 19:18
Convert list of domains to IPs using dig
#!/bin/sh
# call with domaintoips.sh <domain> <list of subdomains.txt>
ulimit -n 800000
while read -r domain; do dig +short $domain | grep -v '[[:alpha:]]' | sort -u >> $1-ipf.txt; done < $2
cat $1-ipf.txt | anew $1-ipz.txt
@daehee
daehee / cleanips.sh
Created February 20, 2020 19:17
strip out CDNs from list of IPs (cloudflare, akamai, incapsula, sucuri)
#!/bin/bash
# Call with domain name <e.g. tesla.com> as arg $1
scanned () {
cat $1 | sort -u | wc -l
}
## segregating cloudflare IP from non-cloudflare IP
iprange="173.245.48.0/20 103.21.244.0/22 103.22.200.0/22 103.31.4.0/22 141.101.64.0/18 108.162.192.0/18 190.93.240.0/20 188.114.96.0/20 197.234.240.0/22 198.41.128.0/17 162.158.0.0/15 104.16.0.0/12 172.64.0.0/13 131.0.72.0/22"
for ip in `cat $1-ipz.txt`; do