Skip to content

Instantly share code, notes, and snippets.

View Silva97's full-sized avatar

Luiz Felipe Silva Silva97

View GitHub Profile
@Silva97
Silva97 / pa-demo.py
Created September 17, 2024 02:43
|a[n] - a[m]| / |n - m| = r
#!/usr/bin/env python3
import sys
def main():
"""
Demonstração de que dado uma P.A. com razão constante, existe uma proporção
entre a diferença entre os índices de 2 termos quaisquer e a diferença de
seus valores.
@Silva97
Silva97 / dalias.sh
Last active September 17, 2024 03:11
Create alias commands to run inside a Docker environment.
#!/bin/bash
# Script migrated to repository: https://github.com/freedev-org/dalias
CONFIG_DIR=~/.dalias
CONFIG_FILE="$CONFIG_DIR/config"
ALIAS_DIR="$CONFIG_DIR/bin"
DOCKER_CMD='docker run -it --rm -v $(pwd):/host -w /host'
BGDOCKER_CMD='docker run -id --rm -v $(pwd):/host -w /host'
DEFAULT_VALUE="bitnami/minideb:latest bash"
@Silva97
Silva97 / countlines.c
Last active July 30, 2024 00:01
Just a exercise to count lines on text files using SSE
// gcc countlines.c -O2 -o countlines
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <emmintrin.h>
#define BLOCK_SIZE 4096 * 2
@Silva97
Silva97 / chorts.sh
Created July 15, 2024 02:19
Just a script to shortcuts (poorly tested)
#!/bin/bash
if ! which yad >/dev/null; then
echo "The 'yad' is required to run this script. Try:" >&2
echo " sudo apt install yad" >&2
exit 1
fi
CONFIG_FILE=~/.chorts
LOG_FILE=~/.chorts.log
@Silva97
Silva97 / pipe.py
Created March 28, 2023 13:59
Class to create a wrapper to pipe function calls.
import inspect
class Pipe:
"""
Create a wrapper to pipe function calls with the given value.
The functions could be: value's method, builtin or any
function in the current module.
Examples:
@Silva97
Silva97 / sigreturn-frame.py
Created March 15, 2023 21:36
Class to make sigreturn frame to exploit SROP
# By Luiz Felipe Silva (https://github.com/Silva97)
## References ##
# sys_rt_sigreturn: https://elixir.bootlin.com/linux/latest/source/arch/x86/um/signal.c#L560
# sigframe: https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/sigframe.h
# ucontext: https://elixir.bootlin.com/linux/latest/source/include/uapi/asm-generic/ucontext.h
# sigcontext: https://elixir.bootlin.com/linux/latest/source/arch/x86/include/uapi/asm/sigcontext.h#L324
import struct
@Silva97
Silva97 / target-example.c
Created November 2, 2021 11:28
Conditional function by target O.S. or architecture
#include <stdio.h>
#include "target.h"
OS_LINUX(char *os, void)
{
return "Linux";
}
OS_WINDOWS(char *os, void)
{
@Silva97
Silva97 / error_handling.c
Created October 21, 2021 20:40
PoC macros to do error handling in C
#include <stdio.h>
#include <string.h>
#define CATCH(name) \
if (0) \
_catch_##name:
#define FAIL(name) goto _catch_##name
#define FAIL_IF(expr, name) \
@Silva97
Silva97 / lexer-example.c
Last active June 23, 2022 12:56
Example of lexical analysis in C language.
/**
* Example by Luiz Felipe (Silva97)
*
* It's just an example. Don't consider it a final code and DON'T write
* all your code on a unique module, please.
*
* Tip: Use a struct to manipulate translate units instead of use only a
* FILE pointer ;)
*/
@Silva97
Silva97 / demo.c
Created August 19, 2021 16:35
C macro for print struct's fields
#include <stdio.h>
#include "printstruct.h"
typedef struct
{
int a;
char *b;
char c;
long int d;
long long int e;