Skip to content

Instantly share code, notes, and snippets.

View Silva97's full-sized avatar
🤔
Thinking, of course.

Luiz Felipe Silva Silva97

🤔
Thinking, of course.
View GitHub Profile
@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
#define _GNU_SOURCE
#include <dlfcn.h>
typedef int (*puts_t)(const char *);
int puts(const char *string)
{
puts_t original_puts = dlsym(RTLD_NEXT, "puts");
original_puts("-- Hookado --");
#include <stdio.h>
#include <stdlib.h>
int getint(int *number);
int main()
{
int n;
fputs("Digite um inteiro cara: ", stdout);
/*********************
* Resolução do problema: https://leetcode.com/problems/reverse-integer/
*********************/
int aux_rev(int x, long long int rev)
{
if(rev > INT_MAX || rev < INT_MIN) return 0;
if(!x) return rev;
return aux_rev(x/10, rev*10 + x%10);
#include <stdio.h>
enum {
RECT_T = '-', // Aresta do topo
RECT_TR = '+', // Vértice do canto superior direito
RECT_R = '|', // Aresta da direita
RECT_BR = '+', // Vértice do canto inferior direito
RECT_B = '-', // Aresta da parte inferior
RECT_BL = '+', // Vértice do canto inferior esquerdo
RECT_L = '|', // Aresta da esquerda
/********************
* Exemplo de replace em C.
* Por Luiz Felipe.
* https://github.com/Silva97
********************/
#include <stdio.h>
#include <string.h>
int replace(char *text, char *word, char *new);
@Silva97
Silva97 / lscanf.c
Last active November 3, 2022 13:35
Maneira segura de pegar o input do usuário
/********************
* Developed by Luiz Felipe.
*
* GitHub: https://github.com/Silva97
* Facebook: https://www.facebook.com/B4.0E.B0.48.CD.10.B0.69.CD.10.C3
********************/
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
/********************
* Exemplo desenvolvido por Luiz Felipe
* Link do vídeo: https://youtu.be/wUrk9AK6ItY
********************/
#include <stdio.h>
char keyboard[BUFSIZ];
void getinput(char *buff, int size);
@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 ;)
*/