Skip to content

Instantly share code, notes, and snippets.

View icedraco's full-sized avatar
🐲
Rawr

Artex icedraco

🐲
Rawr
View GitHub Profile
@icedraco
icedraco / self-modify.py
Created July 22, 2015 17:07
Self-modifying python script. Might not work on Windows!
# the quick brown fox jumps over the lazy dog
import md5, sys
def main(argv):
me = argv[0]
# Get the first line from this file, remove # and strip extra characters
data = open(me, 'r').readlines()
first_line = data[0][1:].strip()
@icedraco
icedraco / modulo-test.c
Last active August 29, 2015 14:25
Different approaches to implementing support for modulo of negative numbers in C (comparison test)
#include <stdio.h>
#define STOP_MAX 20
// Lazy method: If negative, add "base" until no longer negative.
int lazy_mod(int n, int base) {
while (n < 0) {
n += base;
}
#include <stdio.h>
int main(void) {
char buffer[1024];
char buffer2[2048];
fgets(buffer, 1023, stdin);
sprintf(buffer2, "echo $((%s))", buffer);
system(buffer2); // TADA! :D
return 0;
@icedraco
icedraco / bytecode.c
Created June 25, 2015 21:54
Running x86 bytecode (assembly) in C
#include <string.h>
#include <sys/mman.h>
int main(void) {
char rawr[] = "Rawr!\n";
char bytecode[] = {
0x60, // pusha
0xb8, 0x04, 0x00, 0x00, 0x00, // mov eax, 4
0xbb, 0x01, 0x00, 0x00, 0x00, // mov ebx, 1
0xb9, /* for rawr */ 0,0,0,0, // mov ecx, 0
@icedraco
icedraco / trafficgen.py
Created June 5, 2015 17:05
Simple TCP traffic generator script
# TCP Traffic Generator
import socket
import time
DEFAULT_PAYLOAD = 100 ;# MiB
DEFAULT_BYTERATE = 100 ;# MiB/sec
DEFAULT_TARGET = ("10.0.0.2", 31337)
SEC_FRACTION = 0.01
@icedraco
icedraco / EncryptedEntryProcessor.cs
Created June 2, 2015 15:28
TripleDES/base64 line-based encryption/decryption class
using System;
using System.Security.Cryptography;
using System.Text;
namespace my_proxy.Lists
{
public class EncryptedEntryProcessor : IEntryProcessor
{
private readonly ICryptoTransform _encryptor;
private readonly ICryptoTransform _decryptor;
@icedraco
icedraco / packet-capture.py
Created March 5, 2015 15:27
Packet capture reference via Python
# Packet capturing on Linux (requires root!)
# May need to enable promiscuous mode with:
# ifconfig eth1 up
# ifconfig eth1 promisc
from socket import *
s = socket(PF_PACKET, SOCK_RAW, htons(0x0800))
s.setsockopt(IPPROTO_IP, IP_HDRINCL, 1)
while True:
print s.recvfrom(65565)
@icedraco
icedraco / phpfurc.php
Created February 23, 2015 03:02
PHP-driven Furcadia Bot (skeleton)
<?php
/*** Configuration Phase ***/
$addr = 'furc';
$port = 6500;
$name = 'CPU';
$pass = 'password';
$col = '" 367**888 "!';
$desc = '//Central Processing Unit//';
@icedraco
icedraco / download-oosd.sh
Created January 29, 2015 21:35
Automatic downloader for OOSD lecture files at BGU
#!/bin/bash
# OOSD132 Lecture Downloader
#
# Author: IceDragon <[email protected]>
# Contact: http://www.icerealm.org/contact
#
# Exit Codes:
# 0 - No new changes
# 1 - Downloaded new files (or at least tried to)
#
@icedraco
icedraco / csbgu-extract.sh
Created January 29, 2015 21:34
URL extractor for documents in a CS BGU course page
BASE_URL='http://www.cs.bgu.ac.il'
MATERIAL="$BASE_URL/~oosd132/Practical_Sessions"
MATERIAL_DIR="$HOME/bgu/oosd"
CMD_DOWNLOAD_DATA="wget -o /dev/null -O - $MATERIAL"
EXIT_CODE=0
###--# BODY #--################################################################
function getFilePaths {