Skip to content

Instantly share code, notes, and snippets.

Adrian Serrano adriansr

Block or report user

Report or block adriansr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@adriansr
adriansr / random_cisco_asa.py
Created Apr 4, 2019
Random Cisco ASA logs generator
View random_cisco_asa.py
from datetime import datetime, date, time, timedelta
import random
class WeightedRand:
def __init__(self, weights):
self.v = []
self.n = sum(weights.values())
for (k, v) in weights.iteritems():
self.v += [k] * v
@adriansr
adriansr / iptables_random.py
Created Apr 4, 2019
Random log generator for iptables module
View iptables_random.py
import os
import random as rnd
import re
import sys
random_ips = set()
ips = {}
doc_ips = [[192, 0, 2], [198, 51, 100], [203, 0, 113]]
known_prefixes = set([ '.'.join([str(y) for y in x ]) for x in [
View auditd USER_AUTH USER_LOGIN
# local login failed
"type=USER_AUTH msg=audit(1553622768.697:628): pid=6261 uid=0 auid=1002 ses=40 msg='op=PAM:authentication acct=\"root\" exe=\"/bin/login\" hostname=? addr=? terminal=/dev/pts/1 res=failed'"
"type=USER_LOGIN msg=audit(1553622768.697:629): pid=6261 uid=0 auid=1002 ses=40 msg='op=login acct=\"root\" exe=\"/bin/login\" hostname=? addr=? terminal=/dev/pts/1 res=failed'"
# local login succeeded
"type=USER_AUTH msg=audit(1553622784.557:630): pid=6261 uid=0 auid=1002 ses=40 msg='op=PAM:authentication acct=\"adrian\" exe=\"/bin/login\" hostname=? addr=? terminal=/dev/pts/1 res=success'"
"type=USER_LOGIN msg=audit(1553622784.973:634): pid=6261 uid=0 auid=1002 ses=40 msg='op=login acct=\"adrian\" exe=\"/bin/login\" hostname=? addr=? terminal=/dev/pts/1 res=success'"
@adriansr
adriansr / compare-golden.py
Created Feb 4, 2019
Compare two -expected.json ES events
View compare-golden.py
# Usage:
# compare-golden-events.py <old.json> <new.json>
import json
import sys
def missing(keys, dct):
r = []
for key in keys:
View anonymize iptables logs
# Anonymize IPTABLES logs for documentation!
import os
import re
import sys
random_macs = set()
macs = {}
@adriansr
adriansr / remdog.py
Created Dec 10, 2018
Delete all Pull Request comments from HoundCI user
View remdog.py
import json
import requests
REPO='user/repo'
PULL= # PULL_REQUEST_ID (1234)
USER_TO_DELETE='houndci-bot'
TOKEN=YOUR_GITHUB_API_TOKEN
headers = { 'Authorization': 'token ' + TOKEN }
@adriansr
adriansr / syscall_stress.go
Last active Jul 11, 2018
Call a syscall in a loop, optionally limiting the number of calls per second
View syscall_stress.go
package main
import (
"sync/atomic"
"fmt"
"os"
"strconv"
"syscall"
"time"
)
@adriansr
adriansr / svg2icns.sh
Created Feb 19, 2018
Convert SVG file to macOS icon (icns) format
View svg2icns.sh
#!/bin/sh -x
set -e
SIZES="
16,16x16
32,16x16@2x
32,32x32
64,32x32@2x
128,128x128
@adriansr
adriansr / pkgcleanup.sh
Created Feb 6, 2018
Uninstall macOS pkg removing all files
View pkgcleanup.sh
#!/bin/bash
die() {
echo "error: $@" >&2
exit 1
}
test "$#" -gt 0 || die "Usage: $0 <package identifier>"
test "$(uname -s)" = "Darwin" || die "Must be run under macOS"
test $(id -u) -eq 0 || die "Must be root"
@adriansr
adriansr / main.go
Created Jan 11, 2018
GetExtendedTcpTable golang
View main.go
// +build windows
package main
import (
"encoding/binary"
"encoding/hex"
"fmt"
"syscall"
"time"
You can’t perform that action at this time.