Skip to content

Instantly share code, notes, and snippets.

View h4sh5's full-sized avatar

Haoxi Tan h4sh5

View GitHub Profile
#!/usr/bin/env python
import zlib, base64, re, xml.dom.minidom, struct, binascii
import sys
import urllib
d = sys.stdin.read()
urldecoded = urllib.unquote(d)
@h4sh5
h4sh5 / samlencode.py
Created February 27, 2020 23:16
encode XML to SAML
#!/usr/bin/env python
import zlib, base64
import sys
import urllib
d = sys.stdin.read()
b = base64.b64encode(zlib.compress(d.encode('utf-8'))[2:-4])
#!/usr/bin/env python
import ldap, ldap.asyncsearch
import sys
def process(item):
print item
if len(sys.argv) < 2:
print "usage: <DC IP> <domain name>"
@h4sh5
h4sh5 / pyconv.py
Created April 5, 2020 15:02
hex to string in python - also basic usage of getopt
#!/usr/bin/env python
import getopt
import sys
import binascii
def usage():
print("""%s [-oxd]
-x hex
-d decode
@h4sh5
h4sh5 / nsall
Created September 21, 2020 12:44
query all DNS records
#!/bin/bash
if (( $# != 1 )); then
echo "Usage: $0 <host> [ns server]"
exit 1
fi
HOST=$1
@h4sh5
h4sh5 / dumpshellcode.sh
Created March 30, 2021 08:17
objdump dump shellcode from a function of a binary file. Better used with gcc -static -fPIC to compile your C src
#!/bin/bash
# linux only! if on osx, use gpaste and gsed instead of paste and sed
if (( $# != 2 )); then
echo "Usage: $0 <file> <function>"
exit 1
fi
#set -x
@h4sh5
h4sh5 / gensong-avr.py
Created April 4, 2021 12:05
generate a song for AVR buzzer with frequency-duration equal length arrays
#!/usr/bin/env python3
# copyright Haoxi Tan 2019, reuse allowed with attribution
import sys
keys = {}
#TODO: REWORK FREQ. INTO 16-BIT BIGGER NUMBER
@h4sh5
h4sh5 / trim_spaces.rs
Created May 31, 2021 08:58
function for trim spaces. good example for string iteration, borrowing, bytes datatype etc.
fn main() {
let test1 = "We need more space.";
assert_eq!(trim_spaces(test1), "We need more space.");
let test2 = String::from(" There's space in front.");
assert_eq!(trim_spaces(&test2), "There's space in front.");
let test3 = String::from("There's space to the rear. ");
@h4sh5
h4sh5 / admsh.c
Created June 15, 2021 07:08
admin shell!
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main() {
setuid(0);
system("/bin/bash");
}
@h4sh5
h4sh5 / vtupload.sh
Created August 14, 2021 17:40
upload file to vt
apikey="xxx"
echo "$(tput setaf 7)Uploading $1 to VirusTotal$(tput sgr0)"
vt_hash=$(curl -X POST 'https://www.virustotal.com/vtapi/v2/file/scan' --form apikey=$apikey --form file=@"$(realpath $1)" | grep -o '"[0-9|a-f]{64}"' | head -1 | sed 's/"//g')
echo done: $(sha256sum $1)