Skip to content

Instantly share code, notes, and snippets.

@mbrownnycnyc
mbrownnycnyc / sendmail.vbs
Created March 27, 2013 12:23
quick vbscript to send email using smtp
main()
function IfYouGetCaught(strErr)
if len(strErr) > 1 then
strErrorLine = strErrorLine + strErr
strErrorLine = strErrorLine + vbnewline + vbnewline
end if
strErrorLine = strErrorLine + "usage: cscript sendmail.vbs /from:[from address] /to:[address1,address2] [/subject:[subject]] [/body:[message] [/attachment:path1,path 2]" & vbnewline & _
@mbrownnycnyc
mbrownnycnyc / xmlreader.cs
Created March 28, 2013 13:48
a c# function to read XML. I think I should be using XMLReader() instead, but this works fine.
public static Dictionary<string, string> ReadXML(string filename)
{
Dictionary<string, string> dcxml_config = new Dictionary<string, string>();
//thank you: http://www.mastercsharp.com/Article/69/working-with-xml-dom
FileStream docIn = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(docIn);
docIn.Close();
@mbrownnycnyc
mbrownnycnyc / xmlwriter.cs
Last active December 15, 2015 13:09
a c# function to write an XML; was written for generation of a config file for Microsoft Research's Management of Access Control in the Enterprise (MACE). I will be publishing the repo (a wrapper for the datacollector executable in the MACE suite) when it is sufficiently functional.
public static void WriteXML(string filename, Dictionary<string, string> commandoptions)
{
//if the file exists, then move it to DataCollector.exe.config.bak
if (File.Exists(filename))
{
File.Move(filename, filename + ".bak");
}
//write the XML document//
@mbrownnycnyc
mbrownnycnyc / fileuritounc_handler_installer.bat
Created May 7, 2013 20:28
Quick little batch script to parse the file URI when executed in explorer, because skype likes to change UNC paths to file URIs (and it has it's own handling). Relies on the win32 port of the gnucoreutils to be in the %path%.
echo "sed s/file:// %1 > %temp%\_holder" > c:\windows\fileurihandler.bat
echo "set /p holder= < %temp%\_holder" >> c:\windows\fileurihandler.bat
echo "echo %holder% | sed s@\/@\\@g > %temp%\_final" >> c:\windows\fileurihandler.bat
echo "set /p holder= < %temp%\_final" >> c:\windows\fileurihandler.bat
echo "del /q /f %temp%\_holder" >> c:\windows\fileurihandler.bat
echo "del /q /f %temp%\_final" >> c:\windows\fileurihandler.bat
echo "explorer %holder%" >> c:\windows\fileurihandler.bat
reg add HKCR\file\shell\open\command /ve /d "c:\windows\fileurihandler.bat %1"
@mbrownnycnyc
mbrownnycnyc / argus_working.sh
Last active December 17, 2015 06:58
a quick script that copies gzipped argus data files (produced with `rastream -S 127.0.0.1:561 -B 15s -M time 1h -w /var/opt/argus/%Y-%m-%d/argus_%T -f /usr/local/bin/rastream.sh` for instance [note the use of %Y-%m-%d]) to a working directory. This is to ease the targeting of queries.
#!/bin/bash
#arguswork script to copy and rename argus files to a working directory
#I've commented out the original script, which follows a different organizational structure.
# to limit times, I've opted to use the -t argument with any ra* clients instead of worrying about limiting time simply by argus data files read.
#mkdir -p ~/working/`basename $(pwd)`
#cp * ~/working/`basename $(pwd)`
#cd ~/working/`basename $(pwd)`
#gunzip *
export dateoffiles="$(basename $(pwd))_"
@mbrownnycnyc
mbrownnycnyc / argus.conf
Last active December 17, 2015 08:59
argus.conf for use with the argus flow probe
#
# Argus Software
# Copyright (c) 2000-2012 QoSient, LLC
# All rights reserved.
#
# Example argus.conf
#
# Argus will open this argus.conf if its installed as /etc/argus.conf.
# It will also search for this file as argus.conf in directories
# specified in $ARGUSPATH, or $ARGUSHOME, $ARGUSHOME/lib,
@mbrownnycnyc
mbrownnycnyc / rastream.sh
Created May 15, 2013 12:51
rastream.sh for use with rastream's `-f`. This is part of the original distribution unmodified.
#!/bin/sh
#
# Argus Client Software. Tools to read, analyze and manage Argus data.
# Copyright (C) 2000-2012 QoSient, LLC.
# All Rights Reserved
#
# Script called by rastream, to process files.
#
# Since this is being called from rastream(), it will have only a single
# parameter, filename,
@mbrownnycnyc
mbrownnycnyc / argusd
Last active December 17, 2015 09:09
argusd init rc severely edited
#! /bin/sh
### BEGIN INIT INFO
# Provides: argus-server
# Required-Start: $network
# Required-Stop:
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@mbrownnycnyc
mbrownnycnyc / rastreamd
Last active December 17, 2015 09:28
rastream init script
#! /bin/sh
### BEGIN INIT INFO
# Provides: rastream-client
# Required-Start: $network $argusd
# Required-Stop:
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@mbrownnycnyc
mbrownnycnyc / mbsa.bat
Last active December 17, 2015 10:18
super quick batch script to run microsoft baseline security analyzer against a given list of PCs
@echo off
echo > "%temp%/mbsalistfile.txt"
for %%G in (%*) do echo %%G >> "%temp%/mbsalistfile.txt"
"%programfiles%\Microsoft Baseline Security Analyzer 2\mbsacli.exe" /nvc /n "OS"+"SQL"+"IIS"+"PASSWORD" /wa /nd /listfile "%temp%/mbsalistfile.txt"
"%programfiles%\Microsoft Baseline Security Analyzer 2\mbsacli.exe" /l /rd "%userprofile%\securityscans"
pause
REM the mbsa files are xml and can be compared as such.