Skip to content

Instantly share code, notes, and snippets.

@pedroagabreu
pedroagabreu / dns2.py
Created October 22, 2013 16:16
Query nameservers nonrecursively. Script by Jeremy McGuinn, Cisco.
#!/usr/bin/python
# This script will query a name server nonrecursively
# RFC 1912 recommends that the $TTL value on the name server
# be set to 1 day or longer
# -*- coding: utf-8 -*-
import sys
import dns
from dns.exception import DNSException
from dns.rdataclass import *
@pedroagabreu
pedroagabreu / escleanup.sh
Created April 17, 2014 19:53
Elasticsearch cleanup, courtesy of http://thejmlcontinuum.blogspot.com.
#!/bin/bash
# delete one day
# curl -s -XDELETE 'http://127.0.0.1:9200/logstash-2014.02.28'
# delete from crontab
# DATETODELETE=`date +%Y.%m.%d -d '7 days ago'`
# curl -s -XDELETE http://127.0.0.1:9200/logstash-${DATETODELETE}
# delete by space
@pedroagabreu
pedroagabreu / gist:11008087
Last active August 29, 2015 14:00
Hide elasticsearch 1.1.0 behind Apache. Needs mod proxy and proxy_html, and 'elasticsearch: "https://whatever:443"' in Kibana's config.js.
# Set global proxy timeouts
<Proxy http://127.0.0.1:9200>
ProxySet connectiontimeout=5 timeout=90
</Proxy>
# Proxy for _aliases and .*/_search
<LocationMatch "^/(_status|_stats|_nodes|_aliases|.*/_aliases|_search|.*/_search|_mapping|.*/_mapping)$">
ProxyPassMatch http://127.0.0.1:9200/$1
ProxyPassReverse http://127.0.0.1:9200/$1
</LocationMatch>
@pedroagabreu
pedroagabreu / gist:fbcf8ed5eb03cf533c1f
Created May 5, 2014 17:30
Client certificate verification in Apache.
# verify client certificates using CA.pem
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/ServerCertAndKey.pem
SSLCACertificateFile /etc/apache2/ssl/CA.pem
SSLVerifyClient require
SSLVerifyDepth 1
# allow connections from certain CN only, except for that guy
SSLRequire ( %{SSL_CIPHER} !~ m/^(EXP|NULL)-/ and %{SSL_CLIENT_S_DN_CN} =~ m/^ROBOTS/ and %{SSL_CLIENT_S_DN_CN} !~ m/^ROBOTS - Bad Robot/ )
@pedroagabreu
pedroagabreu / gist:1908892061fcb2b2f3c6
Last active February 10, 2023 14:44
Salesforce web to lead via php-curl.
$sfurl = 'https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
$sffields = array(
'oid' => 'someoid',
'lead_source' => 'my website',
'last_name' => urlencode($_POST['name']),
'company' => urlencode($_POST['organization']),
'email' => urlencode($_POST['email']),
'phone' => urlencode($_POST['phone']),
);
foreach($sffields as $key=>$value) { $fieldstring .= $key.'='.$value.'&'; }
@pedroagabreu
pedroagabreu / gist:ae87dc081ff0588bbeff
Last active October 12, 2015 19:49
Apache 2.4 SSL configuration.
# Perfect Forward Secrecy ciphers
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
SSLHonorCipherOrder on
# Enabled protocols
SSLProtocol all -SSLv2 -SSLv3
# OCSP stapling
SSLUseStapling on
SSLStaplingResponderTimeout 5
@pedroagabreu
pedroagabreu / suricata
Last active August 29, 2015 14:05
Suricata 2.0.2+ log rotation.
/var/log/suricata/*.log /var/log/suricata/*.json
{
daily
rotate 3
missingok
nocompress
create
sharedscripts
postrotate
/bin/kill -HUP $(pidof suricata)
@pedroagabreu
pedroagabreu / oinkmaster
Last active August 29, 2015 14:05
Oinkmaster cron. Make sure "rule-reload: true" in suricata.yaml.
MAILTO="security@domain.tld"
55 5 * * * root ( /usr/sbin/oinkmaster -C /etc/oinkmaster.conf -o /etc/suricata/rules; sleep 5; kill -USR2 `pidof suricata` )
@pedroagabreu
pedroagabreu / suricata.conf
Created August 28, 2014 16:02
Suricata upstart configuration file.
description "Suricata Intrusion Detection System Daemon"
start on runlevel [2345]
stop on runlevel [!2345]
expect fork
exec suricata -D --pidfile /var/run/suricata.pid -c /etc/suricata/suricata.yaml -i eth1
@pedroagabreu
pedroagabreu / ratelimit.conf
Created August 28, 2014 16:06
Rate limit configuration example for rsyslog, goes in /etc/rsyslog.d.
$SystemLogRateLimitInterval 5
$SystemLogRateLimitBurst 2000