Skip to content

Instantly share code, notes, and snippets.

View santa4nt's full-sized avatar
💭
😬

Santoso santa4nt

💭
😬
  • Los Angeles, CA
View GitHub Profile
@santa4nt
santa4nt / ioctl.py
Last active May 28, 2023 11:31
A Python-ctypes script to dispatch IOCTL in Windows
#!C:\Python27\python.exe
# The MIT License (MIT)
#
# Copyright © 2014-2016 Santoso Wijaya <santoso.wijaya@gmail.com>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sub-license, and/or sell copies of the Software,
@santa4nt
santa4nt / sudoers
Created January 8, 2014 17:56
Using truecrypt without prompting for user's sudoer password at each mount
# add with `sudo visudo`:
username ALL=(root) NOPASSWD:/usr/bin/truecrypt
# obviously change 'username'
@santa4nt
santa4nt / genrandints.py
Last active December 16, 2015 08:48
Combine the last three gists: generate random ints, sort them by chunking, and verify sorted final output.
#!/usr/bin/env python
import os
import sys
import array
import struct
NUMRANDS = 10 ** 6 # the number of random integers we want to generate (one million)
BUFSIZE = 1000 # the number of integers we buffer internally before flushing to output
@santa4nt
santa4nt / vrfsrtints.py
Created April 17, 2013 22:18
Verify that a binary input containing 4-byte (signed) integers are sorted ascending.
#!/usr/bin/env python
import sys
import array
BUFSIZE = 4096 # read 1000 * 4-byte (32-bit) numbers at a time
input = sys.stdin
@santa4nt
santa4nt / sortints.py
Last active December 16, 2015 08:39
Sort a large number of (signed) 4-byte integers in machine format, chunks at a time.
#!/usr/bin/env python
import os
import sys
import array
import heapq
import struct
import tempfile
@santa4nt
santa4nt / genrandints.py
Last active December 16, 2015 08:19
Generate one million random, signed 32-bit integers.
#!/usr/bin/env python
import os
import sys
import array
import struct
NUMRANDS = 10 ** 6 # the number of random integers we want to generate (one million)
BUFSIZE = 1000 # the number of integers we buffer internally before flushing to output
@santa4nt
santa4nt / dnsfuzz.py
Last active October 3, 2017 12:48
Implement a DNS server/forwarder using Twisted that intercepts responses and fuzz them before relaying them back to the original requesting client.
# http://notmysock.org/blog/hacks/a-twisted-dns-story.html
# https://gist.github.com/johnboxall/1147973
# twistd -y dnsfuzz.py
import sys
import socket
from twisted.python import log
from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
import random
def sort(arr):
random.shuffle(arr)
_sort(arr, 0, len(arr) - 1)
def _sort(arr, lo, hi):
if hi <= lo: return
lt = lo
gt = hi
@santa4nt
santa4nt / .profile
Created March 15, 2013 22:49
A .profile file
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
@santa4nt
santa4nt / arp_scapy.py
Created February 28, 2013 19:23
Some quick-n-dirty sample code and functions to manipulate ARP packets (for network filter testing).
from scapy.all import *
# change this to your test machine's MAC address
SELF_MAC = '00:0c:29:67:22:c2'
BCAST_MAC = 'ff:ff:ff:ff:ff:ff'
# this will send a PROBE ARP request packet to the supplied IP address argument