Skip to content

Instantly share code, notes, and snippets.

@huyphan
huyphan / gist:9888959
Created March 31, 2014 09:51
Weird behavior of Elasticsearch 1.0.1
# Delete the index if exists
$ curl -XDELETE "http://localhost:9200/sample"
{"acknowledged":true}
# Create "sample" index, with standard analyzer using comma character for tokenizing
$ curl -XPUT "http://localhost:9200/sample" -d '
{
"settings" : {
"index" : {
"analysis" : {
@huyphan
huyphan / buildlog
Created April 28, 2014 05:36
Error when building NAKL
Build target NAKL
ProcessInfoPlistFile /Users/nmstech/Library/Developer/Xcode/DerivedData/NAKL-dpardqrwpmjiuhgivowjjbhyjpab/Build/Products/Debug/NAKL.app/Contents/Info.plist NAKL/NAKL-Info.plist
cd "/Users/nmstech/Desktop/XUAN CUONG/huyphan-NAKL-e2c5b08"
builtin-infoPlistUtility /Users/nmstech/Desktop/XUAN\ CUONG/huyphan-NAKL-e2c5b08/NAKL/NAKL-Info.plist -genpkginfo /Users/nmstech/Library/Developer/Xcode/DerivedData/NAKL-dpardqrwpmjiuhgivowjjbhyjpab/Build/Products/Debug/NAKL.app/Contents/PkgInfo -expandbuildsettings -platform macosx -o /Users/nmstech/Library/Developer/Xcode/DerivedData/NAKL-dpardqrwpmjiuhgivowjjbhyjpab/Build/Products/Debug/NAKL.app/Contents/Info.plist
ProcessPCH /Users/nmstech/Library/Developer/Xcode/DerivedData/NAKL-dpardqrwpmjiuhgivowjjbhyjpab/Build/Intermediates/PrecompiledHeaders/NAKL-Prefix-eqokzgkoqclrkxaingnrhyfxcfrx/NAKL-Prefix.pch.pch NAKL/NAKL-Prefix.pch normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd "/Users/nmstech/Desktop/XUAN CUONG/huyphan-
@huyphan
huyphan / gist:4abb4f8edd6ce1cac528
Created June 10, 2014 08:33
Spark 1.0 + Hadoop 2.0 + Elasticsearch
$ ADD_JARS=../elasticsearch-hadoop-2.1.0.BUILD-SNAPSHOT/dist/elasticsearch-hadoop-2.1.0.BUILD-SNAPSHOT.jar bin/spark-shell
### COMMAND ###
val tweet = Map("user" -> "kimchy", "post_date" -> "2009-11-15T14:12:12", "message" -> "trying out Elastic Search")
val tweets = sc.makeRDD(Seq(tweet))
import org.apache.hadoop.io.{MapWritable, Text, NullWritable}
def toWritable(in: Map[String, String]) = {
val m = new MapWritable
for ((k, v) <- in)
@huyphan
huyphan / gist:9609bd1ead8b5c64a6ae
Created August 22, 2014 05:04
Reviewboard + Nginx + UWSGI
# NGINX CONFIGURATION
upstream reviewboard_uwsgi {
server localhost:8005;
}
server {
....
@huyphan
huyphan / gist:6361962
Created August 28, 2013 03:50
A modified version of this script https://pika.readthedocs.org/en/latest/examples/asynchronous_publisher_example.html to test how pika deals with closed socket
# -*- coding: utf-8 -*-
import logging
import pika
import json
import time
LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s')
LOGGER = logging.getLogger(__name__)
@huyphan
huyphan / 0_reuse_code.js
Created December 30, 2015 03:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Keybase proof

I hereby claim:

  • I am huyphan on github.
  • I am hphan (https://keybase.io/hphan) on keybase.
  • I have a public key whose fingerprint is 0311 B2AA FF4F E772 470D 09DA 2E4D 544B 7047 A53C

To claim this, I am signing this object:

@huyphan
huyphan / defcon-2014-quals-100lines-bruteforce.cpp
Last active July 21, 2016 04:46
defcon-2014-quals-100lines-bruteforce
#include <iostream>
#include <cstdint>
using namespace std;
typedef uint8_t CHAR;
typedef uint16_t WORD;
typedef uint32_t DWORD;
typedef int8_t BYTE;
#include <iostream>
#include <cstdint>
using namespace std;
typedef uint8_t CHAR;
typedef uint16_t WORD;
typedef uint32_t DWORD;
typedef int8_t BYTE;
@huyphan
huyphan / README.md
Last active March 20, 2017 21:49
Organizing exploit development and debugging process with Tmux

Idea

  • Having a single script to automatically run the binary, attach gdb, re-set breakpoints every time you restart your debugging session.
  • The main idea is to run your debugging processes on different Tmux panes and let the controller script (also running on another tmux pane) send keystrokes to automate activities on those panes.

Prerequisites

  • tmux
  • If you run your tmux session as non-root user, the system configuration /proc/sys/kernel/yama/ptrace_scope should be set to 0 (i.e. running echo 0 > /proc/sys/kernel/yama/ptrace_scope as root) to allow attaching gdb to an existing process as non-root user.

Usage