Skip to content

Instantly share code, notes, and snippets.

View cataphract's full-sized avatar

Gustavo Lopes cataphract

View GitHub Profile
@Grab('io.undertow:undertow-core:2.2.25.Final')
@Grab('io.undertow:undertow-servlet:2.2.25.Final')
@Grab('com.squareup.okhttp3:okhttp:4.9.1')
import io.undertow.Undertow
import io.undertow.channels.DetachableStreamSinkChannel
import io.undertow.server.HttpServerExchange
import io.undertow.servlet.Servlets
import io.undertow.servlet.api.DeploymentInfo
import io.undertow.servlet.api.ServletContainer
function _h {
local postprompt=$1
local prompt
if [[ $# -eq 1 || $2 == '-' ]]; then
prompt=$(cat)
else
prompt="$2"
fi
prompt=$(echo "$prompt"$'\n'"$postprompt" | jq -sR '@text')
@cataphract
cataphract / cmdline
Last active March 27, 2023 14:37
C++ with no standard lib
g++ -v -std=c++11 -fno-exceptions -fno-rtti -nostdlib \
/usr/lib/x86_64-linux-gnu/{Scrt1.o,crti.o} \
/usr/lib/gcc/x86_64-linux-gnu/11/crtbeginS.o \
example.cpp -o example \
-lgcc \
-Wl,--push-state -Wl,--as-needed -lgcc_s -Wl,--pop-state \
-lc -lgcc \
-Wl,--push-state -Wl,--as-needed -lgcc_s -Wl,--pop-state \
/usr/lib/gcc/x86_64-linux-gnu/11/crtendS.o \
/usr/lib/x86_64-linux-gnu/crtn.o
struct link_map {
char _other[8];
char *l_name;
};
uprobe:/usr/lib/x86_64-linux-gnu/libc.so.6:dlopen {
printf("opening %s\n", str(reg("di")));
}
uprobe:/usr/lib/x86_64-linux-gnu/libc.so.6:dlclose {
$lm = (struct link_map*)reg("di");
printf("closing %s\n", str($lm->l_name));
struct link_map {
char _other[8];
char *l_name;
char _other2[776];
unsigned l_direct_opencount;
};
uprobe:/usr/lib/x86_64-linux-gnu/libc.so.6:dlopen {
@enter[tid] = arg0;
}
uretprobe:/usr/lib/x86_64-linux-gnu/libc.so.6:dlopen {
import groovy.transform.CompileStatic
import java.lang.invoke.*
import static groovyjarjarasm.asm.Opcodes.H_INVOKESTATIC
class Logger {
private final String name
Logger(Class cls) {
name = cls.name
#include <iostream>
#include <type_traits>
struct type_to_convert {
type_to_convert(int i) : i(i) {};
type_to_convert(const type_to_convert&) = delete;
type_to_convert(type_to_convert&&) = delete;
int i;
};
@cataphract
cataphract / Dockerfile
Last active December 6, 2019 14:56
PHP bug #78919
FROM php:7.2.25
ADD config.m4 php_rinit_error.h rinit_error.c /opt/rinit_error/
RUN cd /opt/rinit_error && phpize && ./configure && make -j install && make clean
ADD index.php /var/www/html
CMD ["php", "-S", "0.0.0.0:8080", "-d", "memory_limit=2m", \
"-d", "extension=rinit_error.so", "index.php"]
require 'json'
data = ARGF.read
json = JSON.load data
json = json['results']['data']
json = json.select { |x| x[6] == 'v' }
json = json.map { |x| [x[5], JSON.load(x[7])] }
puts JSON.dump(json)
package io.sqreen.powerwaf.test;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;
import org.junit.runners.model.TestClass;
import java.lang.reflect.UndeclaredThrowableException;