Skip to content

Instantly share code, notes, and snippets.

View proger's full-sized avatar
🎯
Focusing

Volodymyr Kyrylov proger

🎯
Focusing
View GitHub Profile
# prtdiag
System Configuration: LENOVO 3626GG4
BIOS Configuration: LENOVO 6QET61WW (1.31 ) 10/26/2010
==== Processor Sockets ====================================
Version Location Tag
-------------------------------- --------------------------
Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz None
@proger
proger / pytrace.py
Created December 19, 2011 18:33
adhoc dtrace in python
#!/usr/bin/env python
"""
dtrace -n return'{ustack()}'
for python
"""
from byteplay import *
def seekret(code):
@proger
proger / gist:1547880
Created January 1, 2012 17:40
walking MAC impl structures in uts
> ::walkers ! grep mod_hash
mod_hash_entries - walk the mod_hash_entries cache
modchain - walk list of entries in a given mod_hash_entry
modent - walk list of entries in a given mod_hash
modhash - walk list of mod_hash structures
> ::dcmds ! grep mod_hash
modent - display information about a mod_hash_entry
modhash - display information about one or all mod_hash structures
> ::modhash ! grep mac_impl
ffffff01c7581a40 43 8 1 4 mac_impl_hash
@proger
proger / dbgrep.sh
Created January 17, 2012 14:31
do not try this on your database
#!/bin/bash
db=$1
pat=$2
for table in $(psql -Atc '\dt' -d $db | awk -F\| '{print $2}'); do
psql -Atc "select * from $table" -d $db | grep $pat | sed "s/^/$table:/"
done
% cat t.c
int f3(void) { return 1; }
int f2(void) { return f3(); }
int f1(void) { return f2(); }
int
main(int argc, char **argv)
{
while (1)
f1();
@proger
proger / gist:1755645
Created February 6, 2012 22:48
execsnoop.real.d
#!/usr/sbin/dtrace -Cs
#pragma D option quiet
fbt::__mac_execve:entry, fbt::posix_spawn:entry
{
self->want_malloc = 1;
}
/*
* First _MALLOC call inside execve/posix_spawn allocates memory
@proger
proger / gist:1818524
Created February 13, 2012 17:40
acceptsnoop.d
#!/usr/bin/env dtrace -s
/* tested on linux */
typedef struct sockaddr_in {
short sin_family;
unsigned short sin_port;
unsigned char a0;
unsigned char a1;
unsigned char a2;
@proger
proger / gist:1842717
Created February 16, 2012 06:42
udpsnoop.d
#!/usr/bin/env dtrace -s
typedef struct sockaddr_in {
short sin_family;
unsigned short sin_port;
unsigned char a0;
unsigned char a1;
unsigned char a2;
unsigned char a3;
} sockaddr_in_t;
@proger
proger / gist:1869664
Created February 20, 2012 15:25
linuxvfs.d
#!/usr/local/bin/dtrace -s
//#define d_name(dent) ((uintptr_t) ((struct dentry *)dent)->d_name.name))
fbt::vfs_create:entry,
fbt::vfs_unlink:entry
{
printf("%s[%d]: %s", execname, pid, copyinstr((uintptr_t) ((struct dentry *)arg1)->d_name.name));
}
@proger
proger / gist:1877247
Created February 21, 2012 16:26
oneway git->svn sync
#!/bin/bash
SVN_HOST="https://svn/path/to/repo"
git checkout master
git pull --rebase
git config --local svn-remote.svn.url "${SVN_HOST}"
git config --local svn-remote.svn.fetch ":refs/remotes/git-svn"
git config --local svn.rmdir true