Skip to content

Instantly share code, notes, and snippets.

View yellowbyte's full-sized avatar

Yu-Jye Tung yellowbyte

View GitHub Profile
@aspyct
aspyct / signal.c
Last active February 19, 2024 11:24
Unix signal handling example in C, SIGINT, SIGALRM, SIGHUP...
/**
* More info?
* a.dotreppe@aspyct.org
* http://aspyct.org
*
* Hope it helps :)
*/
#include <stdio.h>
#include <stdlib.h>

Screencapture and animated gifs

I say "animated gif" but in reality I think it's irresponsible to be serving "real" GIF files to people now. You should be serving gfy's, gifv's, webm, mp4s, whatever. They're a fraction of the filesize making it easier for you to deliver high fidelity, full color animation very quickly, especially on bad mobile connections. (But I suppose if you're just doing this for small audiences (like bug reporting), then LICEcap is a good solution).

Capturing (Easy)

  1. Launch quicktime player
  2. do Screen recording

screen shot 2014-10-22 at 11 16 23 am

@menzenski
menzenski / helloworld.asm
Created February 4, 2015 15:24
Hello World in Assembly language (x86-64 Unix-like operating systems, NASM syntax)
; MacOS X: /usr/local/bin/nasm -f macho64 *.s && ld -macosx_version_min 10.7 *.o
; Solaris/FreeBSD/DragonFly: nasm -f elf64 -D UNIX *.s && ld *.o
; NetBSD: nasm -f elf64 -D UNIX -D NetBSD *.s && ld *.o
; OpenBSD: nasm -f elf64 -D UNIX -D OpenBSD *.s && ld -static *.o
; OpenIndiana: nasm -f elf64 -D UNIX *.s && ld -m elf_x86_64 *.o
; Linux: nasm -f elf64 *.s && ld *.o
%ifdef NetBSD
section .note.netbsd.ident
dd 7,4,1
@magnetikonline
magnetikonline / README.md
Last active June 22, 2024 13:35
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set, value is returned.

Combine with a : no-op to discard/ignore return value.
${variable="value"}
: ${variable="value"}
@withzombies
withzombies / install-api.py
Created September 21, 2016 04:21
Install the Binary Ninja Python API
#!/usr/bin/env python
import os
import sys
import os.path
import site
try:
import binaryninja
print "Binary Ninja API Installed"
@ivg
ivg / cyclomatic.py
Created September 27, 2017 12:20
Computes cyclomatic complexity of all functions in a binary
import bap
import networkx as nx
def build_cfg(sub):
G = nx.DiGraph()
entry = sub.blks[0].id.number
G.add_node(entry)
for blk in sub.blks:
for jmp in blk.jmps:
if jmp.constr == 'Goto' and jmp.target.constr == 'Direct':
@sdasgup3
sdasgup3 / max_stack_height.cpp
Created May 24, 2018 00:46
Implements a function pass to approximate the max stack height of each McSema lifted function.
//===-- max_stack_height.cpp - Static analysis for stack height approximation --------------------------------------==//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This implements a function pass to approximate the max stack height of each function.
@sdasgup3
sdasgup3 / allProofs.z3
Last active August 26, 2020 06:37
My Z3 proof snippets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;popcnt expl ;;;;;;;;;;;;;;;;;;;;;;;;;;;
(declare-const V (_ BitVec 64))
(declare-const I1 (_ BitVec 64))
(declare-const I2 (_ BitVec 64))
(assert
(not
(=

I've been working on optimizing the YARA compiler to generate better bytecode for loops. The goal is to skip as much of loops as possible by not iterating further once the loop condition is met. Here's the rule I'm using. Completely contrived and excessive, but it's to show the performance improvement:

wxs@wxs-mbp yara % cat rules/test.yara
rule a {
  condition:
    for any i in (0..100000000): (i == 1)
}
wxs@wxs-mbp yara %
@sdasgup3
sdasgup3 / alltutoroals.md
Last active December 23, 2022 07:53
Few things I am inerested in!