Skip to content

Instantly share code, notes, and snippets.

View OzTamir's full-sized avatar

Oz Tamir OzTamir

View GitHub Profile
@OzTamir
OzTamir / gui.c
Last active August 29, 2015 14:00
Little GTK+ in C
#include <gtk/gtk.h>
void GtkTextviewAppend(GtkWidget *textview, gchar *text)
{
//Append a string to a textview
GtkTextBuffer *tbuffer;
GtkTextIter ei;
tbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
gtk_text_buffer_get_end_iter(tbuffer, &ei);
from scapy.all import *
import time
from SimpleHTTPServer import *
import thread
from os import system
import urllib2
routerIP = '10.0.2.2'
victimsIP = ['10.0.2.' + i for i in xrange(0, 255)]
myIP = '192.168.15.134'
@OzTamir
OzTamir / plist_quotes.py
Created April 17, 2014 13:33
Due to an amazing lack of good Quotes API out there, I wrote this little script to scrape some quotes into a plist file.
import urllib2 as urllib
import re
import random
import plistlib
catgories = {
'Age' : 'c[54]', \
'Art' : 'c[44]', \
'Beauty' : 'c[40]', \
'Emotion' : 'c[121]', \
@OzTamir
OzTamir / get_earth.py
Created April 17, 2014 11:40
Get some sweet images from reddit.com/r/EarthPorn (SFW)
import json
import urllib2 as urllib
import sys
def get_urls(limit=5):
'''Get the url and titles from /r/EarthPorn'''
# This is the api endpoint for hot submissions in /r/EarthPorn
api_url = 'http://www.reddit.com/r/EarthPorn/hot.json?limit=' + str(limit)
# Let's store this in urlopen
json_url = urllib.urlopen(api_url)
@OzTamir
OzTamir / spoiler.css
Created April 14, 2014 11:24
Blur Spoilers, for god's sake!
spoiler:hover {
text-shadow: none;
color: #000;
filter: none;
}
spoiler {
text-shadow: 0 0 8px #000;
color: rgba(255,255,255,0);
filter: DXImageTransform.Microsoft.Blur(pixelradius=2);
@OzTamir
OzTamir / get_image.py
Created April 13, 2014 15:42
Get an image from MJPEG stream
import urllib2 as urllib
def get_image(ip):
# The header represents the beginning of the image inside the stream
HEADER_MAGIC = "\xff\xd8"
# Get the stream and the initial data buffer
bytes = ''
stream = urllib.urlopen(ip)
# Start reading values
while True:
# Read the first 70 bytes to find the content length and the header magic
@OzTamir
OzTamir / heartHeal.sh
Last active August 29, 2015 13:58
Fix your Ubuntu's broken heart (Test for Heartbleed vulnerability and update OpenSSL if needed)
#!/bin/bash
# --- HeartHeal - Fix your broken heart (and SSL!) --- #
function update {
echo 'Your OpenSSL is unsafe!'
echo 'Running sudo apt-get update...'
sudo apt-get update
echo 'DONE.'
echo 'Running sudo apt-get dist-upgrade...'
sudo apt-get dist-upgrade
echo 'DONE.'
@OzTamir
OzTamir / fork.asm
Created March 26, 2014 11:37
Fork Process in x86 NASM. Each process will print a different message and then exit.
section .text
global _start
_start:
mov eax, 2 ; SYS_FORK Op Code
int 0x80
cmp eax, 0 ;If the return value is 0, we are in the child process
jz child
parent:
mov edx, len ;Move msg length to edx
@OzTamir
OzTamir / matrix.py
Last active August 29, 2015 13:57 — forked from metula/matrix.py
Represent a picture matrix - grayscale and colours!
#############################################################################
######### class Matrix with display() function for image visualization
#############################################################################
class Matrix:
"""
Represents a rectangular matrix with n rows and m columns.
"""
def __init__(self, n, m, val=0):
@OzTamir
OzTamir / see_queens.py
Last active August 29, 2015 13:57
Visualize the current game state in a valid N-Queens game board
def visual_board(N, game_state, only_row=False):
'''Format a board game per game_state. If only_row is True, the output will be only the specified row'''
board = [[] for i in range(N)]
empty = '-|'
for column, row in enumerate(game_state):
board[row] = str(row) + ' |' + empty * column + 'Q|' + (empty * (N - column))[:-1] + '|'
board[row] = board[row][:-2] + '\n'
if not isinstance(only_row, bool) and only_row == row:
return board[row]
return ' ' + ' '.join(str(i) for i in range(n)) + '\n' + ''.join(board)