Skip to content

Instantly share code, notes, and snippets.

int catvars(char *buf1, char *buf2, unsigned int len1,
unsigned int len2){
char mybuf[256];
if((len1 + len2) > 256){ /* [3] */
return -1;
}
memcpy(mybuf, buf1, len1); /* [4] */
memcpy(mybuf + len1, buf2, len2);
@awsong
awsong / gist:d0fc069f88638c75c033
Created January 22, 2015 08:43
Buffer Overflow
#include <stdio.h>
#include <string.h>
int main(void)
{
char buff[15];
int pass = 0;
printf("\n Enter the password : \n");
gets(buff);
@awsong
awsong / cm12_aws
Last active August 29, 2015 14:10
Script to build CyanogenMod on AWS
#!/bin/sh
apt-get install bwm-ng curl byobu screen zsh vim-nox bison build-essential curl flex git gnupg gperf libesd0-dev libncurses5-dev libsdl1.2-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev ccache
curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo
apt-get install -y mdadm
mdadm -C /dev/md0 --level=raid0 --raid-devices=2 /dev/xvdb /dev/xvdc
repo init -u https://github.com/CyanogenMod/android -b cm-12.0
repo sync -j40
@awsong
awsong / test.html
Created April 6, 2012 07:32
spoof code
<script language="javascript" src="jquery-1.4.2.js"></script>
<SCRIPT LANGUAGE=JAVASCRIPT>
if (top.location != self.location) {
top.location=self.location;
}
</SCRIPT>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@awsong
awsong / combine.sh
Created October 27, 2011 14:03
Combine scanned TIFF to a single PDF
#!/bin/bash
for X in "$@"
do
convert "$X" -compress jpeg -quality 50 "${X%%tiff}pdf"
done
echo "${@/tiff/pdf}"
pdftk "${@/tiff/pdf}" cat output out1.pdf
pdfopt out1.pdf finish.pdf
rm -rf out1.pdf
@awsong
awsong / websocket_client.erl
Created July 22, 2011 09:31
Erlang WebSocket message masking test code snippet
-module(websocket_client).
-compile(export_all).
-on_load(init/0).
init() ->
ok = erlang:load_nif("./nif_mask", 3).
nif_mask(_,_,_) ->
exit(nif_library_not_loaded).
mask(Key,Data,Accu) ->
case Data of
@awsong
awsong / nif_mask.c
Created July 22, 2011 09:26
Erlang NIF function for WebSocket message masking
#include "erl_nif.h"
void mask(unsigned char *key, unsigned char *data, unsigned long len)
{
unsigned int *p = (unsigned int *)data;
unsigned int *k = (unsigned int *)key;
for(int i=4; i<len; i+=4)
{
*(p+(i-4)/4) ^= *k;
}