Skip to content

Instantly share code, notes, and snippets.

View aristidesneto's full-sized avatar

Aristides Neto aristidesneto

View GitHub Profile
Link da resposta: https://pt.stackoverflow.com/questions/223725/login-com-php-session-%C3%A9-seguro
Resumo:
O cliente possui extensões, plugins, softwares maliciosos instalados que podem obter os cookies diretamente. Uma outra situação cliente acessou um página do seu site que estava com um código malicioso injetado ou ele mesmo injetou um código no console para tal.
A conexão está sendo monitorada/interceptada por um terceiro ou a conexão foi apontada para um servidor fora do seu controle.
O servidor está gerando sessões previsíveis, o valor do PHPSESSID é gerado de maneira insegura permitindo que alguém consiga saber o próximo valor ou é pouco aleatório. Um outro ponto é se alguém conseguir acessos aos arquivos no /tmp/.
@aristidesneto
aristidesneto / test.php
Created March 15, 2019 12:46 — forked from claudiosanches/test.php
Regex for test credit card brand
<?php
// Test cards
$cards = array(
'378282246310005', // American Express
'371449635398431', // American Express
'5078601870000127985', // Aura
'5078601800003247449', // Aura
'30569309025904', // Diners Club
'38520000023237', // Diners Club
#!/bin/bash
# Reinicia o MySQL caso de encerramento inesperado
MYSQL=$(lsof -i :3306 | grep mysql | wc -l);
if [ "$UPMYSQL" -le 0 ];
then
/etc/init.d/mysql restart
fi
## Crie uma entrada no cron para executar esse script a cada 5 minutos por exemplo ##
@aristidesneto
aristidesneto / slackpost
Created April 22, 2019 20:24 — forked from dopiaza/slackpost
Post a message to a Slack channel
#!/bin/bash
# Usage: slackpost <token> <channel> <message>
# Enter the name of your slack host here - the thing that appears in your URL:
# https://slackhost.slack.com/
slackhost=PUT_YOUR_HOST_HERE
token=$1
@aristidesneto
aristidesneto / my.cnf
Last active April 23, 2019 21:02
Tunning Mysql
## Não utilize em seus servidores antes de saber o que cada comando faz
## Dica retirada de https://www.vivaolinux.com.br/etc/mycnf/
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
-- Query estatísticas
SET @nome_do_schema = 'db_name';
Select
(select schema_name from information_schema.schemata where schema_name=@nome_do_schema) as "Nome do Banco de dados",
(SELECT Round( Sum( data_length + index_length ) / 1024 / 1024, 3 )
FROM information_schema.tables
WHERE table_schema=@nome_do_schema
GROUP BY table_schema) as "Tamanho do Banco de dados em Mega Bytes",
(select count(*) from information_schema.tables where table_schema=@nome_do_schema and table_type='base table') as "Quant. Tabelas",
@aristidesneto
aristidesneto / slack.sh
Created May 24, 2019 15:31 — forked from andkirby/slack.sh
Shell/Bash script for sending slack messages.
#!/usr/bin/env bash
####################################################################################
# Slack Bash console script for sending messages.
####################################################################################
# Installation
# $ curl -s https://gist.githubusercontent.com/andkirby/67a774513215d7ba06384186dd441d9e/raw --output /usr/bin/slack
# $ chmod +x /usr/bin/slack
####################################################################################
# USAGE
# Send message to slack channel/user
@aristidesneto
aristidesneto / nginx-tuning.md
Created May 25, 2019 02:33 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@aristidesneto
aristidesneto / grafana.json
Created May 29, 2019 15:20
Dashboard para Grafana - Monitorando recursos do servidor
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",