Skip to content

Instantly share code, notes, and snippets.

View leeramsay's full-sized avatar

Lee Ramsay leeramsay

  • Perth, West Australia
View GitHub Profile
@virtualstaticvoid
virtualstaticvoid / iptables_rules.sh
Created June 14, 2011 08:58
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
@ksafranski
ksafranski / expecting.md
Last active November 11, 2023 23:00
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@grugq
grugq / gist:7713916
Created November 30, 2013 00:43
The text from: http://dee.su/uploads/baal.html On Underground Communications
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Undercover communication
It should be obvious by now, that the only way to communicate
stealthily and securely is to avoid raising suspicion to the
level at which the authorities might consider it worthwhile
to put you under active surveillance (e.g., park a van with
TEMPEST equipment by your apartment).
@TemporaryJam
TemporaryJam / Howto convert a PFX to a seperate .key & .crt file
Last active April 4, 2024 10:52
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
GPO
Office 2010 SP1 Admin Templates:
Explanation: http://technet.microsoft.com/en-us/library/cc178992.aspx
Download: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=18968
# How to create custom .adm or .admx files to add search providers to the toolbar search box in IE7
http://support.microsoft.com/kb/918238
# Allowing Standard Users to Install Network Printers on Windows 7 without Prompting for Administrative Credentials
@bryanzak
bryanzak / MunkiSyncer.sh
Last active May 25, 2016 01:16
Munki Syncer - LaunchDaemon and script to auto sync a local munki_repo from a master on an smb server elsewhere within your organization once a day at a specified time. The server mount point could be automounted etc, but this script demonstrates mounting it dynamically if needed
#!/bin/bash
SERVER_MOUNT_PT="/Volumes/Munki"
SERVER_URL="//SERVICEACCOUNTNAME:SERVICEACCOUNTPASS@mastermunkiserver.yourorg.org/Munki"
we_mounted="false"
MUNKI_MASTER="/Volumes/Munki/Master Repository/munki_repo/"
MUNKI_LOCAL="/Users/Shared/munki_repo"
# important, trailing slash must be on source and must not be on destination
MountServer()
@mesimeris
mesimeris / grok-patterns
Last active April 16, 2021 22:10
LOGSTASH: syslog listener filtering with grok patterns and applying useful tags
# NOTE: These patterns take into account the additional log-line information passed to the logstash listener from rsyslog. YMMV.
DHCPD ((%{SYSLOGTIMESTAMP:timestamp})\s*(%{HOSTNAME:hostname})\s*dhcpd\S+\s*(%{WORD:dhcp_action})?.*[for|on] (%{IPV4:dhcp_client_ip})?.*[from|to] (%{COMMONMAC:dhcp_client_mac})?.*via (%{USERNAME:interface}))
IPTABLES ((%{SYSLOGTIMESTAMP:nf_timestamp})\s*(%{HOSTNAME:nf_host})\s*kernel\S+\s*(%{WORD:nf_action})?.*IN=(%{USERNAME:nf_in_interface})?.*OUT=(%{USERNAME:nf_out_interface})?.*MAC=(%{COMMONMAC:nf_dst_mac}):(%{COMMONMAC:nf_src_mac})?.*SRC=(%{IPV4:nf_src_ip}).*DST=(%{IPV4:nf_dst_ip}).*PROTO=(%{WORD:nf_protocol}).?*SPT=(%{INT:nf_src_port}?.*DPT=%{INT:nf_dst_port}?.*))
DNS ((%{MONTHDAY:day})-(%{MONTH:month})-(%{YEAR:year}) (%{TIME:timestamp}) client (%{IPV4:dns_client_ip})#(%{NONNEGINT:dns_uuid})?.*query: (%{HOSTNAME:dns_dest}) (%{WORD:dns_type}) (%{WORD:dns_record})?.*(%{IPV4:dns_server}))
PGSQL ((%{SYSLOGTIMESTAMP:pgsql_timestamp}) (%{HOSTNAME:pgsql_hostname})?.*SAST >(%{WORD:pgs
@gregneagle
gregneagle / update_complex_pref_v1.py
Created January 26, 2015 20:06
Python scripts for MacTech MacEnterprise column "Managing Complex Preferences"
import CoreFoundation
from Foundation import NSDate
# read Safari's current ManagedPlugInPolicies
policy = CoreFoundation.CFPreferencesCopyAppValue(
'ManagedPlugInPolicies', 'com.apple.Safari')
if not 'com.oracle.java.JavaAppletPlugin' in policy:
# create an empty dict
policy['com.oracle.java.JavaAppletPlugin'] = {}
@maciakl
maciakl / profile-cleanup.cmd
Last active February 12, 2024 19:48
A script to delete user data for those occasions where you just want to nuke all user data without reimaging machine.
@echo off
REM use this file to run the powershell script bypassing the policy restrictions
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1'"
pause
@james2doyle
james2doyle / curl-smtp-email.sh
Last active September 15, 2023 17:21
Send SMTP email using cURL
curl --connect-timeout 15 -v --insecure "smtp://smtp.example.com:25" -u "username:password"
\ --mail-from "sender@example.com" --mail-rcpt "destination@example.com"
\ -T email-contents.txt --ssl