Skip to content

Instantly share code, notes, and snippets.

@clly
clly / Get-LastPassword.ps1
Created April 5, 2012 14:18
Powershell: Account and Password Info
Function Get-LastPassword($username) {
$a = Get-Module activedirectory
if($a) {
Import-Module activedirectory -force
}
$props = "PasswordExpired", "PasswordLastSet", "LockedOut", "lockoutTime", "LastLogonDate"
$u = get-aduser -Filter {samaccountname -eq $username} -properties $props
write-host "`nPassword Expired: " $u.PasswordExpired
write-host "Account Locked: " $u.LockedOut
if($u.LockedOut) {
@clly
clly / CryptRot13.java
Created April 5, 2012 14:47
Java: Rot13
import java.util.*;
public class CryptRot13 {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
String value = "";
String rotValue = "";
CryptRot13 crypt = new CryptRot13();
@clly
clly / Make-Config.ps1
Created April 11, 2012 19:03
Make XML configuration file for powershell based on properties of the .NET object entered
Function Make-Config($obj) {
$gm = $obj|Get-Member -MemberType Property
$config = "<?xml version='1.0'?>
<config>
<include>
</include>
<exclude>
"
foreach($prop in $gm) {
$config += "`t`t<add property='" + $prop.name + "' />`n"
@clly
clly / Check-Auth.ps1
Created April 12, 2012 20:16
Check domain user authentication
$cred = Get-Credential #Read credentials
$username = $cred.username
$password = $cred.GetNetworkCredential().password
$server = "" + ":389"
# Get current domain using logged-on user's credentials
$CurrentDomain = "LDAP://$server" + ([ADSI]"").distinguishedName
$domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$UserName,$Password)
if ($domain.name -eq $null)
{
@clly
clly / Reset-Password.ps1
Created April 12, 2012 20:37
Reset user password
Function ResetPassword() {
$a = Get-Module activedirectory
if($a) {
Import-Module activedirectory -force
}
$server = ""
$ProgressPreference = "SilentlyContinue"
import-module activedirectory
$ProgressPreference = "Continue"
$username = Read-Host "What is your username: "
@clly
clly / class.py
Created May 8, 2012 02:07
Template for python class
class className:
def __init__(self):
pass
def method1(self):
pass
def method2(self):
pass
@clly
clly / setDHCP.vbs
Created May 29, 2012 22:00
Set Windows DNS and IP addressing to use DHCP
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each obj in colNicConfigs
obj.SetDNSServerSearchOrder(null)
if not obj.DHCPEnabled Then
obj.EnableDHCP
@clly
clly / getRepo.sh
Created July 9, 2012 02:15
Get git repository without the .git directory in specified folder
#!/bin/sh
#######
# Change for actual use
#######
USER="example"
FINAL_LOCATION = "/tmp"
PREFIX = "junk/"
#######
@clly
clly / compile.py
Created September 21, 2012 21:30
compile python scripts
import py_compile, sys
py_compile.compile(sys.argv[1])
@clly
clly / setuid.c
Created October 8, 2012 17:33
Drop into root shell
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
setuid( 0 );
system( "/path/to/script.sh" );