Skip to content

Instantly share code, notes, and snippets.

@dumpmycode
dumpmycode / misc
Last active September 22, 2016 05:47
Misc
# Miscellaneous snippets
# Author: op
### BASH * remove spaces in binary string, then convert it to hex, and add 0x format for every 2 hex chars.
### output sent to xxd for hex to ascii conversion
echo "obase=16; ibase=2; `./.trash/bin | sed 's/ //g'` " | bc | sed 's/../0x\0/g' | xxd -r
### GDB * Only disassemble MAIN section of binary using gdb
gdb -batch -ex 'set disassembly-flavor intel' -ex 'file /home/leviathan2/printfile' -ex 'disassemble main'
; Continuation from cdkey2 asm practice, this time we look at simple function call
; and try to interpret what this asm code does.
; esi = cdkey
mov ebp, 13AC9741h ; ebp = 0x13AC9741
mov ebx, 0Bh ; ebx = 11
top:
movsx eax, byte ptr [ebx+esi] ; eax = cdkey[ebx]
push eax ; arg for function call
@dumpmycode
dumpmycode / cdkey2
Last active June 6, 2016 02:43
CDkey2 - skulllsecurity.org
;Continuation from previous cdkey asm, this time I try to understand the next variation in asm code.
lea edi, [esi + 0xb] ; edi = address of cdkey[0 + 11], address of 12th digit
mov ecx, 0xc2 ; ecx = 194
top:
mov eax, ecx ; eax = 194 or 0xc2
mov ebx, 0xc ; ebx = 12
cdq ; Convert eax from Double word to Quadruple word. so eax becomes edx:eax
; this also zero out any value previously in edx.
@dumpmycode
dumpmycode / cdkey1
Last active June 6, 2016 02:43
CDKey.asm - skullsecurity.org
segment .data
cdkey db "1111111111111"
segment .text
global _start
_start:
mov ecx, cdkey
mov eax, 3 ; eax = 3
mov esi, ecx ; esi = ecx, ecx = 13 digit starcraft cd key entered
@dumpmycode
dumpmycode / disassembler.py
Created April 3, 2016 12:14
Shellcode disassembler
#! /usr/bin/env python
# shellcode disassembler using capstone engine
# source = http://hacktracking.blogspot.com.au/2015/05/execute-shellcode-in-python.html
from sys import argv, exit
from capstone import *
if len(argv[:]) < 3:
print("\nUsage: {} [ARCH] [MODE] ['shellcode']\n".format(argv[0]))
exit(0)
@dumpmycode
dumpmycode / pingsweep.py
Created April 3, 2016 01:17
OSCP 1.4.3 Exercise
#! /usr/bin/env python
# author: op.
'''
create short ping sweep script of your local subnet using a higher level
programming language such as Python, Ruby or Perl.
'''
from multiprocessing import Pool
import subprocess as sub
@dumpmycode
dumpmycode / copyspecial.py
Created March 30, 2016 00:55
Google Python Class - copyspecial.py
#!/usr/bin/python
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
'''
Used argparse instead of using sys.argv and also opted for
@dumpmycode
dumpmycode / names.py
Last active March 29, 2016 08:06
Google Python Class - babynames.py
#!/usr/bin/python
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
import sys
import re
@dumpmycode
dumpmycode / logpuzzle.py
Last active March 26, 2016 06:09
Google Python Class - logpuzzle.py
#!/usr/bin/python
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
import os
import re
@dumpmycode
dumpmycode / mimic.py
Last active March 24, 2016 13:58
Google Python Class - mimic.py
#!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/
"""Mimic pyquick exercise -- optional extra exercise.
Google's Python Class