Skip to content

Instantly share code, notes, and snippets.

View rafaelfoster's full-sized avatar

Rafael Foster rafaelfoster

View GitHub Profile
@rafaelfoster
rafaelfoster / webrevproxy-ssl.conf
Last active February 15, 2022 20:58
Apache Reverse Proxy + SSL Client Authentication
# The first two lines are also important
# Some tests with *:443 never work for me. Needed to test more times
NameVirtualHost server.example.com:443
<VirtualHost server.example.com:443>
ServerName server.example.com
# SSL Params
# Activate the client certificate
SSLEngine On
SSLCertificateFile /etc/httpd/cert/ca.crt
@rafaelfoster
rafaelfoster / phpAntiSQLInjection.php
Last active December 27, 2015 15:19 — forked from danilowm/gist:1997988
Function in PHP that receives the parameters (normaly passed by a $_POST or a $_GET and treat the informations removing some SQL commands, preventing the SQL Injection
<?php
/*
* Anti Injection
* Verifica e Trata as informações
* Autor: Danilo Iannone - danilowm@gmail.com
*/
function anti_injection( $obj ) {
$obj = preg_replace("/(from|alter table|select|insert|delete|update|where|drop table|show tables|#|\*|--)/i", "",strtolower($obj));
$obj = trim($obj);
@rafaelfoster
rafaelfoster / detect_session.vbs
Created November 29, 2013 14:45
VBS Detect session (if RDP or Local console)
Set WshShell = CreateObject("WScript.Shell")
strSessionName = wshShell.ExpandEnvironmentStrings( "%SESSIONNAME%" )
if ( inStr(LCase(strSessionName),"rdp") <> 0 ) Then
' Do something
End If
@rafaelfoster
rafaelfoster / HandlingShortcuts.vbs
Last active December 29, 2015 17:58
VBS for files and folder manipulation functions
' Replace a Shortcut with regex search
On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
Set objRegEx = CreateObject("VBScript.RegExp")
Set objFSO = CreateObject("Scripting.FileSystemObject")
NumberFiles = 0
Const ForReading = 1
Const ForWriting = 2
Const ForAppend = 8
# Command extracts public key to domain.cer.
openssl pkcs12 -in domain.pfx -clcerts -nokeys -out domain.cer
# Command extracts private key to domain.key.
openssl pkcs12 -in domain.pfx -nocerts -nodes -out domain.key
<VirtualHost example.com:443>
...
SSLEngine on
SSLCertificateFile /path/to/domain.cer
@rafaelfoster
rafaelfoster / scan_scsi_disks.sh
Last active January 2, 2016 19:39
Scan for new disks on Host
# This command scan new hard disk drives on Linux Systems.
# this is useful when the host is on a Virtual Environment and you add new hard disks to it
ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done
@rafaelfoster
rafaelfoster / Mysql_Change_TableEngine.sh
Last active January 2, 2016 20:29
Mysql Braimstorm
DATABASE="DATABASE"
USER="username"
PASSWD="password"
mysql -u $USER -p$PASSWD $DATABASE -e "show tables" |while read dbtable
do
mysql $DATABASE -e "ALTER TABLE $DATABASE.$dbtable ENGINE=InnoDB"
echo "Convertendo tabela: $dbtable"
done
@rafaelfoster
rafaelfoster / selinux_audit2allow.sh
Created January 13, 2014 14:16
SELinux - Audit2allow
# instalar pacotes para liberação de regras no SELinux
yum install policycoreutils-python
# Verificar se houve bloqueios no SELinux
aureport --avc
# Criar arquivos de regras
cat /var/log/audit/audit.log |grep "filtro" |audit2allow -M "nome_do_modulo"
# Instalar modulo
@rafaelfoster
rafaelfoster / gitlab_api.sh
Last active January 3, 2016 11:29
Gitlab API - Some commands
# Gitlab API reference: http://api.gitlab.org/
# To use Gitlab API you must specify the Private Token.
# You can get it on Profile -> Account -> Private Token.
# Some operations require that the Tokens belongs to an Admin
# Get a list of All projects
curl --header "PRIVATE-TOKEN: [private token]" "http[s]://[servername_or_ip]/api/v3/projects/$id"
# Simple mass deletion of Gitlab projects
import-module ServerManager
Remove-WindowsFeature WinRM-IIS-Ext
Add-WindowsFeature WinRM-IIS-Ext