Skip to content

Instantly share code, notes, and snippets.

View sitano's full-sized avatar

Ivan Prisyazhnyy sitano

View GitHub Profile
@sitano
sitano / settings.lua
Created November 14, 2023 14:23 — forked from lalitmee/settings.lua
nvim settings
local fn = vim.fn
local api = vim.api
local executable = function(e)
return fn.executable(e) > 0
end
local opts_info = vim.api.nvim_get_all_options_info()
local opt = setmetatable(
{}, {
/*
* Copyright (c) 2020 Andrew G Morgan <morgan@kernel.org>
*
* This program exploit demonstrates why libcap alone in a
* multithreaded C/C++ program is inherently vulnerable to privilege
* escalation.
*
* The code also serves as a demonstration of how linking with libpsx
* can eliminate this vulnerability by maintaining a process wide
* common security state.
@sitano
sitano / setuidgid_with_caps.c
Created September 18, 2023 09:35
setuidgid playground but keeping caps
// $ clang -lcap -Wall -O2 ./setuidgid.c
#include <getopt.h>
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
#include <stdlib.h>
#include <stdbool.h>
#include <errno.h>
@sitano
sitano / test_sqlite3_int_vs_stmt.cc
Created January 16, 2023 16:30
test_sqlite3_int_vs_stmt.cc
#define _MULTI_THREADED
#include <sqlite3.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
#include <cstring>
#define SQLOK(line) do { \
@sitano
sitano / sample.c
Created January 3, 2023 15:15
define gdb symbol
https://stackoverflow.com/questions/7272558/can-we-define-a-new-data-type-in-a-gdb-session
// sample.c
#include "sample.h"
struct sample foo;
gcc -g -c sample.c
(gdb) add-symbol-file sample.o 0
add symbol table from file "sample.o" at
@sitano
sitano / test_sqlite5.cc
Created December 6, 2022 16:08
checking on the heap allocation greedy-ness
#define _MULTI_THREADED
#include <sqlite3.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
int print_row_cb(void *NotUsed, int argc, char **argv, char **azColName) {
NotUsed = 0;
@sitano
sitano / test_sqlite3_int.cc
Created December 2, 2022 15:32
test sqlite3 interrupt
#define _MULTI_THREADED
#include <sqlite3.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
int callback(void *, int, char **, char **);
void check(const char *str, int err);
void *threadfunc(void *parm);
@sitano
sitano / ruby_fork_pgkill_test.rb
Last active April 29, 2022 13:21
ruby_fork_pgkill_test.rb
$stdin.sync = true;
$stdout.sync = true;
$a = true
def handle(id, sig)
puts id.to_s + " got " + sig.to_s + " at " + Process.pid.to_s
$a = false
end
@sitano
sitano / gist:b12f4710eb3445aa993ed7782b88a3b5
Last active February 25, 2022 09:10
X1 Carbon Linux suspend fixes
$ cat /etc/systemd/logind.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
@sitano
sitano / fork_reaper.c
Created November 18, 2021 14:46
test reaping caps
#include <stdio.h>
#include <unistd.h>
#include <sys/prctl.h>
int main() {
printf("origin: pid=%d, ppid=%d, pgid=%d\n", getpid(), getppid(), getpgid(getpid()));
printf("prctl %d\n", prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0));
pid_t pid = fork();