Skip to content

Instantly share code, notes, and snippets.

@merces
merces / readpe-bfd.c
Created Dec 13, 2017
read a file using libbfd
View readpe-bfd.c
#include <stdio.h>
#include <bfd.h>
struct bfd b;
int main(int argc, char* argv[]) {
struct bfd *b;
char *path = argv[1];
View primeiro-de-abril-foolbook.sh
#!/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 / stars.php
Created Jan 12, 2017
5 star rank in PHP
View stars.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;
@merces
merces / encrypt.c
Last active Aug 29, 2015
Looping and modifying without changing its pointer
View encrypt.c
void encrypt(char *dest, size_t size)
{
while (size--)
*dest++ ^= 0x69;
}
@merces
merces / steg-clavis.sh
Created Mar 6, 2015
A stenography challenge solution
View steg-clavis.sh
#!/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 (fernando@mentebinaria.com.br)
# just4fun! :)
@merces
merces / tls.c
Last active Nov 13, 2017
TLS callback implementation in C
View tls.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 / minibash.sh
Created Mar 6, 2015
A minimalist shell skeleton
View minibash.sh
#!/bin/bash
echo "bemvindo ao minibash
comandos disponiveis: listar sair"
while :; do
read -p '$ ' cmd
case $cmd in
listar)
ls ;;
@merces
merces / devprot.c
Created Nov 21, 2012
devprot - (un)set write protection flag in block devices
View devprot.c
/*
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.