Skip to content

Instantly share code, notes, and snippets.

View le4ker's full-sized avatar

Panos Sakkos le4ker

View GitHub Profile
@le4ker
le4ker / change_page_protection
Last active May 28, 2017 22:07
Change the page protection in Linux kernel
static void disable_page_protection(void)
{
unsigned long cr0 = read_cr0();
if(cr0 & (1 << 16))
{
cr0 &= ~ (1 << 16);
write_cr0(cr0);
}
}
@le4ker
le4ker / gist:2148224
Created March 21, 2012 15:13
SET/GET debug registers MACROS
//REGISTER must be between "0" and "7" for the dr0-dr7 accordingly
#define SET_DEBUG_REGISTER(REGISTER, VALUE) __asm__ __volatile__ ("mov %0,%%dr" REGISTER "\n" :: "r" (VALUE));
#define GET_DEBUG_REGISTER(REGISTER, VALUE) __asm__ __volatile__ ("mov %%dr" REGISTER ",%0\n" : "=r" (VALUE));
@le4ker
le4ker / exe_from_mm
Last active May 28, 2017 22:07
Get absolute executable process path in Linux kernel
#include <linux/err.h>
char *exe_from_mm(const struct mm_struct *mm, char *buffer, int length)
{
char *p = NULL;
struct vm_area_struct *vma;
if(mm == NULL)
{
return NULL;
@le4ker
le4ker / length-extension-attack.rb
Last active May 21, 2017 20:40
A demonstration of length extention attack
# # #
# /17/sha-256.rb
# (c) 2010 Jan Lelis <mail@janlelis.de>. MIT License.
# See: http://ruby.janlelis.de/17-sha-256
#
# May 2017, Modified by Panos Sakkos to demonstrate Length Extension Attack
# - Refactored so the initialization vector and message length can be injected.
# - Added example of length extension attack
# # #
@le4ker
le4ker / padding-oracle-attack.rb
Last active September 17, 2023 09:56
A demonstration of Padding Oracle Attack
# # # # # # # # # # # # # # # # # # # # # # # # #
# Demonstration of Padding Oracle Attack #
# Author: Panos Sakkos <panos.sakkos@gmail.com> #
# Date: May 2017 #
# License: MIT #
# # # # # # # # # # # # # # # # # # # # # # # # #
require 'openssl'
class PaddingOracle
# # # # # # # # # # # # # # # # # # # # # # # # # #
# Demonstration of CBC Bit Flipping Attack #
# Author: Panos Sakkos <panos.sakkos@gmail.com> #
# Date: October 2017 #
# License: MIT #
# # # # # # # # # # # # # # # # # # # # # # # # # #
require 'openssl'
class UnauthenticatedEncryption
@le4ker
le4ker / embed-blocktopus-sign-in.html
Last active September 6, 2019 00:16
Blocktopus embed iframe for signing-in to third-party service
<html>
<body>
<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
if (event.data.event_id == 'blocktopus_height') {
iframe = document.getElementById("blocktopus_iframe");
iframe.height = event.data.value + "px";
@le4ker
le4ker / parent.html
Created September 16, 2019 20:42
Embed Blocktopus to a Token Sale landing page
<html>
<body>
<script>
// The following Javascript resizes the iframe's height when Blocktopus' embeded page's height changes
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
if (event.data.event_id == 'blocktopus_height') {
iframe = document.getElementById("blocktopus_iframe");
iframe.height = event.data.value + "px";