Skip to content

Instantly share code, notes, and snippets.

View sandromello's full-sized avatar

Sandro Mello sandromello

View GitHub Profile
# Pegar todas as contas do servidor:
zmprov -l gaa
# Nome de exibicao, nome da conta, Ultimo logon, senha hash
zmprov ga nnomedaconta@dominio displayName zimbraMailDeliveryAddress zimbraLastLogonTimestamp userPassword
# Forma demorada
for conta in $(zmprov -l gaa); do zmprov -l ga $conta displayName zimbraMailDeliveryAddress zimbraLastLogonTimestamp userPassword; zmprov gmi $conta; done
# Forma "rapida"
@sandromello
sandromello / lab-aws
Created April 24, 2015 19:33
Lab Aws
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters" : {
"BastionKeyName" : {
"Type" : "String",
"Description" : "The bastion server key."
},
"BastionSecurityCIDR" : {
"Type" : "String",
"Description" : "The CIDR block range for SSH."
@sandromello
sandromello / token.py
Last active August 29, 2015 14:19
Get User Zimbra Token
import requests
soapEnvelope = """<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header>\
<context xmlns="urn:zimbra"><nosession/></context></soap:Header><soap:Body><AuthRequest xmlns="urn:zimbraAccount">\
<account by="name">%s</account><password>%s</password></AuthRequest></soap:Body>\
</soap:Envelope>""" % ('usuario@dominio', 'senha')
headers = {
'Content-Type' : 'text/soap+xml'
}
zimbraUrl = 'https://host_ssl/service/soap'
@sandromello
sandromello / sysnotify.py
Created March 2, 2015 18:36
Telegram - sysnotify
#!/usr/bin/env python
import pika, logging, socket, yaml, marshal
from time import sleep
ACCEPTED_KEYS = ['message', 'sla_service', 'site', 'host', 'service']
def send_telegram(data, config):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', 2391))
if data['sla_service']:
@sandromello
sandromello / vericlock.py
Last active August 29, 2015 14:14
Request to vericlock API
import requests, json, sys, hmac, hashlib
auth_uri = 'https://api.vericlock.com/1.0/auth'
public_key = 'mypublickey'
privateKey = 'myprivatekey'
# Convert to binary??
#privateKey = ''.join(format(ord(n),'b') for n in privateKey)
@sandromello
sandromello / getInfo.php
Last active May 25, 2021 20:40
SOAP Requests Zimbra Example
function info_request_xml($token){
return <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<context xmlns="urn:zimbra">
<userAgent name="ZimbraConnectorForOutlook" version="8.0.6.1063" />
<nonotify />
<noqualify />
<authToken>$token</authToken>
@sandromello
sandromello / zimbra_prov_tools.py
Created September 23, 2014 13:46
Provisioning Zimbra
""" Provisioning functions Zimbra to Zimbra given ldap entries.
Requires: python-ldap
Author: Sandro Mello <sandromll@gmail.com>
"""
import ldap, sys
import xml.etree.ElementTree as ET
import datetime
LOCALCONFIG = 'localconfig.xml'
@sandromello
sandromello / ldap_zimbra.py
Last active October 26, 2015 16:13
Query ldap zimbra
""" Provisioning functions Zimbra to Zimbra given ldap entries.
Requires: python-ldap
Author: Sandro Mello <sandromll@gmail.com>
"""
import ldap, sys
import xml.etree.ElementTree as ET
import datetime
LOCALCONFIG = 'localconfig.xml'
@sandromello
sandromello / rr.sh
Created July 13, 2014 23:47
Round Robin iptables
#!/bin/bash
#FLUSH
iptables -F
iptables -t nat -F
iptables -F REGRAS_SNAT
iptables -X REGRAS_SNAT
echo 1 > /proc/sys/net/ipv4/ip_forward
@sandromello
sandromello / audit.md
Created June 2, 2014 21:36
Auditing messages in Zimbra

Configure audit

zmprov ma conta_auditada@domino.tld zimbraInterceptAddress conta_auditoria@domain.com

Remove audit

zmprov ma conta_auditada@domino.tld zimbraInterceptAddress ''