Skip to content

Instantly share code, notes, and snippets.

@truekonrads
truekonrads / typhoeus_proxy.rb
Created June 15, 2012 09:22
Invoke Typhoeus with proxy and authentication
require 'typhoeus'
e=Typhoeus::Easy.new
e.url="http://konrads.smelkovs.com/ip/"
e.proxy = :server => "1.2.3.4:80"
e.proxy_auth=:username => "user", :password => 'password'
e.perform
@truekonrads
truekonrads / countsites.ps1
Created July 3, 2012 11:43
Counts the number of sites in each AD site link
$dEntry = New-Object DirectoryServices.DirectoryEntry("LDAP://xyz.com/cn=sites,cn=configuration,dc=xyz,dc=com","user1","Pass1");
$searcher=New-Object DirectoryServices.DirectorySearcher($dEntry);
$searcher.Filter="(objectClass=siteLink)";
$searcher.PropertiesToLoad.Add("siteList");
$searcher.PropertiesToLoad.Add("cost");
$searcher.PropertiesToLoad.Add("replInterval");
$searcher.PropertiesToLoad.Add("cn");
$searcher.FindAll() |%{
$count=$_.Properties.sitelist.Count;
$p=@{"cn"=[string]$_.Properties.cn; "sites"=$count;};
@truekonrads
truekonrads / getsid.py
Created July 5, 2012 13:23
Get objectSID from AD/LDAP and convert it to traditional string SID
searchFilter="(&(objectClass=group)(distinguishedName=%s))" % (groupName)
res=self.search(searchFilter,["objectSid"])
rawsid=res[0]['objectSid']
objectSid=win32security.ConvertSidToStringSid(pywintypes.SID(rawsid))
primaryGroupID=objectSid.split("-")[-1]
logging.log(logging.DEBUG,"objectSid: %s, RID: %s" % (objectSid,primaryGroupID))
@truekonrads
truekonrads / rdpjoker.c
Created July 25, 2012 00:19
Code to run commands under another user's rdp session
// rdpjoker.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#define SERVER "XXX.compute-1.amazonaws.com"
#define CMD "cmd.exe /C dir \\tsclient\\c >output.txt"
int main(int argc, char **argv){
HANDLE server;
PWTS_SESSION_INFOA ppSessionInfo=NULL;
@truekonrads
truekonrads / bing.py
Created November 14, 2012 21:53
Bare bones Bing API
proxy_handler = ProxyHandler()
opener = build_opener(proxy_handler)
MAX_REQS=50
ENDPOINT="https://api.datamarket.azure.com/Bing/Search/Web?"
KEY='XAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
class Bing(object):
def __init__(self,key):
self.key=key
def query(self,query,maxreq=MAX_REQS,skip=0):
url=ENDPOINT+urlencode({
@truekonrads
truekonrads / outlookstats.rb
Last active December 17, 2015 20:39
Retrieve messages from an outlook folder specified by path and save to a CSV while doing some basic word count calculatins.
#
# Copyright Konrads Smelkovs <[email protected]>, KPMG LLP
# 2013 All rights reserved
require 'win32ole'
require 'csv'
require 'date'
require 'trollop'
#$outlook = WIN32OLE.new('Outlook.Application')
$VERBOSE=false
def getFolderByName(path)
@truekonrads
truekonrads / flow_fuzz.py
Last active December 20, 2015 18:19
simple netflowv9 fuzzer
from sulley import *
from requests import ipfix
sess = sessions.session(session_filename='audits/ipfix.session',proto="udp",log_level=1,sleep_time=0.1)
target = sessions.target('1.2.3.4',2055)
target.netmon = pedrpc.client('127.0.0.1',26001)
sess.add_target(target)
# sess.connect(s_get("flowheader"))
@truekonrads
truekonrads / getips.pl
Created August 9, 2013 12:16
Read files and stdin and output all IP addresses
#!/usr/bin/perl -wn
@a=split /[^\d.]/;
foreach (@a){
print "$1\n" if m!^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$!;
}
@truekonrads
truekonrads / aix2john.pl
Last active December 24, 2015 15:39
aix2john
#!/usr/bin/perl -w
#/
# This software is Copyright (c) 2013 Konrads Smelkovs <[email protected]>,
# and it is hereby released to the general public under the following terms:
# Redistribution and use in source and binary forms, with or without
# modification, are permitted.
#
# This script converts AIX /etc/security/passw
# cat /etc/security/passwd
# root:
@truekonrads
truekonrads / dsts.txt
Last active December 25, 2015 18:39
fake a syn scan
6.7.8.9
2.2.2.2