Skip to content

Instantly share code, notes, and snippets.

@merces
merces / devprot.c
Created November 21, 2012 12:24
devprot - (un)set write protection flag in block devices
/*
devprot - (un)set write protection flag in block devices
Copyright (C) 2012 Fernando Mercês
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@merces
merces / minibash.sh
Created March 6, 2015 05:56
A minimalist shell skeleton
#!/bin/bash
echo "bemvindo ao minibash
comandos disponiveis: listar sair"
while :; do
read -p '$ ' cmd
case $cmd in
listar)
ls ;;
@merces
merces / tls.c
Last active February 27, 2024 04:44
TLS callback implementation in C
#include <stdio.h>
#include <windows.h>
void NTAPI tls_callback(void* DllHandle, DWORD Reason, void* Reserved)
{
if (Reason == DLL_PROCESS_ATTACH)
{
//MessageBox(0, L"Cheguei primeiro! ^^", L"Exemplo de TLS callback", MB_ICONEXCLAMATION);
HWND hnd;
ShellExecute(hnd, NULL, L"calc.exe", NULL, NULL, SW_SHOWNORMAL);
@merces
merces / steg-clavis.sh
Created March 6, 2015 06:00
A stenography challenge solution
#!/bin/bash
#
# Solução do desafio da Clavis, publicado em
# http://www.seginfo.com.br/challenge-3-blog-seginfo-esteganografia/
#
# Uso: ./steg-clavis.sh DesafioEsteg.jpg
#
# Fernando Mercês ([email protected])
# just4fun! :)
@merces
merces / encrypt.c
Last active August 29, 2015 14:22
Looping and modifying without changing its pointer
void encrypt(char *dest, size_t size)
{
while (size--)
*dest++ ^= 0x69;
}
@merces
merces / stars.php
Created January 12, 2017 01:53
5 star rank in PHP
<?php
// Reversing From Scratch - http://menteb.in/rfs
// In this example 3 people gave 4 starts while 15 people gave 5 starts, totalizing 18 votes.
$stars = array(0, 0, 0, 3, 15);
$total = array_sum($stars);
foreach ($stars as $s)
$res += $s / $total * ++$i;
#!/bin/bash
clear
while true; do
read -p 'C:\>' cmd
case $cmd in
ver)
echo -e "\nMS-DOS Version 6.22\n\n" ;;
@merces
merces / readpe-bfd.c
Created December 13, 2017 05:57
read a file using libbfd
#include <stdio.h>
#include <bfd.h>
struct bfd b;
int main(int argc, char* argv[]) {
struct bfd *b;
char *path = argv[1];

Keybase proof

I hereby claim:

To claim this, I am signing this object: