Friday, March 28, 2014

mtr via a php script

because i need people to run mtr and not shell in.
 <form action="index.php" method="get">  
 Address <input type=text name=address /> Counter <input type=text name=counter size=4 value=15> <input type=submit value=go />  
 </form>  
   
 see that count thing? that's seconds you have to wait.<br>  
   
 <?php  
   
 if (strlen($_GET[address]) > 0  
 && $_GET[address] != 'localhost'  
 && $_GET[address] != '127.0.0.1'  
 && $_GET[address] != '127.0.0.0/8'  
 && $_GET[counter] <= 50) {  
 $output = shell_exec('/usr/bin/mtr '.$_GET[address].' -r -c '.$_GET[counter]);  
 echo "<pre>$output</pre>";  
 }  
   
 ?>  

find all instances of creepy email addresses from a domain

don't ask.
grep -r '[^:]*@creepy.place' *
or howabout email addresses from any and every where?
grep -r '[^:]*@[^:]*' *

Tuesday, March 25, 2014

fun with lsd

so i fat-finger things from time to time. sometimes i type lsd as opposed to ls. to give myself a chuckle (and to figure out if i've actually configured a box), i put the following in /usr/local/bin:
#!/bin/bash
echo -e "did you say \e[5mlsd\e[0m?"     
alias ls='ls --color=auto'
fun.

explanation:
-e means hey respect those escape codes.
\e[5m is flashing text
\e[0m is please revert to normal

Friday, March 21, 2014

give me the keys!

create me a keytab for an http service.  okay.

your time is working right.  right.  okay.

* create:  servicename@my.domain.which.has.the.same.name.as.my.REALM
* went into servicename account properties and enabled Kerberos delegation.

* run following:
ktpass -princ HTTP/the-machine@REALM 
 -out c:\the.magic.happen\the-machine.keytab-out -mapuser servicetest 
 -MapOp set -pass sillypass

output:
Targeting domain controller: dc.my.domain.which.has.the.same.name.as.my.REALM
Using legacy password setting method

Successfully mapped HTTP/the-machine to servicename.
WARNING: pType and account type do not match. This might cause  problems.
Key created.

Output keytab to c:\the.magic.happen\the-machine.keytab-out:
Keytab version: 0x502
keysize 69 HTTP/the-machine@REALM ptype 0 (KRB5_NT_UNKNOWN) 
 vno 6 etype 0x17 (RC4-HMAC) keylength 16 (0x21837fd1736393d862a71c177e16fbb3)

* test spn:
setspn -L servicetest

output:
Registered ServicePrincipalNames for 
 CN=ServiceName,OU=Service Accounts,DC=REALM:    HTTP/the-machine

well then. that pType error was no fun. let's do it again.
ktpass -princ HTTP/the-machine@REALM /out c:\the.magic.happen\the-machine.keytab-out /crypto all /ptype KRB5_NT_PRINCIPAL /mapuser REALM\servicetest /MapOp set /pass sillypass
Targeting domain controller: dc.my.domain.which.has.the.same.name.as.my.REALM
Using legacy password setting method
Successfully mapped HTTP/the-machine to servicetest.
Key created.
Key created.
Key created.
Key created.
Key created.
Output keytab to c:\the.magic.happen\the-machine.keytab-out:
Keytab version: 0x502
keysize 74 HTTP/the-machine@REALMM ptype 1 (KRB5_NT_PRINCIPAL) vno 12 etype 0x1 (DES-CBC-CRC) keylength 8 (0x15e95efb798af485)
keysize 74 HTTP/the-machine@REALM ptype 1 (KRB5_NT_PRINCIPAL) vno 12 etype 0x3 (DES-CBC-MD5) keylength 8 (0x15e95efb798af485)
keysize 82 HTTP/the-machine@REALM 1 (KRB5_NT_PRINCIPAL) vno 12 etype 0x17 (RC4-HMAC) keylength 16 (0x21837fd1736393d862a71c177e16fbb3)
keysize 98 HTTP/the-machine@REALM ptype 1 (KRB5_NT_PRINCIPAL) vno 12 etype 0x12 (AES256-SHA1) keylength 32 (0xba3ab609c8e50b75ba09b28ef60794bd589100bc16b796ca1e3f5d4fde4ccea6)
keysize 82 HTTP/the-machine@REALM ptype 1 (KRB5_NT_PRINCIPAL) vno 12 etype 0x11 (AES128-SHA1) keylength 16 (0xcecabf70e2c94eb5712c1c07b8d6ef58)
and you can always add -kvno 0 to the end of the ktpass command (notice vno 12 that's because i created a keytab prior).

Monday, March 10, 2014

list outlook rules

i sure would like my outlook rules in a text document.

from here:
http://www.slipstick.com/outlook/rules/create-list-rules/

Sub ListRules()
 Dim colStores As Outlook.Stores
    Dim oFileSys As Object
    Dim oStore As Outlook.Store
    Dim oRoot As Outlook.Folder
    Dim oCondition As Outlook.RuleCondition
    Dim oCondfrom As Outlook.RuleCondition
    Dim oAction As Outlook.RuleAction
    Dim colRules As Object
    Dim oRule As Outlook.Rule
    Dim oInbox As Outlook.Folder
    Dim oMoveTarget As Outlook.Folder
    Dim sOutput As String
    Dim myVar As Variant

    'On Error Resume Next
    Set oFileSys = CreateObject("Scripting.FileSystemObject")

'Create a folder named Rules on your C drive or change the path to use an existing folder
    If oFileSys.FileExists("C:\Rules\OLfilterlist.txt") Then
        oFileSys.DeleteFile ("C:\Rules\OLfilterlist.txt")
    End If
    Open "C:\Rules\OLfilterlist.txt" For Output As #1

    Set colStores = Application.Session.Stores
    Set oStore = colStores(1)
        Set oRoot = oStore.GetRootFolder
        Set colRules = oStore.GetRules
        
For Each oRule In colRules
sOutput = (oRule.ExecutionOrder) & Chr(9) & "Rule Name:" & (oRule.Name) & vbCrLf


  For Each oCondition In oRule.Conditions
    If oCondition.Enabled = True Then
'From
 If oCondition.ConditionType = olConditionFrom Then
   sOutput = sOutput & Chr(9) & "From:" & (oRule.Conditions.From.Recipients(1)) & vbCrLf
 End If

'Words in the Subject
If oCondition.ConditionType = olConditionSubject Then

'use this format when the condition may contain multiple values
   sOutput = sOutput & Chr(9) & "Subject:"
      For Each myVar In oRule.Conditions.Subject.Text
        sOutput = sOutput & "'" & myVar & "' "
     Next
    sOutput = sOutput & vbCrLf
End If

If oCondition.ConditionType = olConditionBody Then
   sOutput = sOutput & Chr(9) & "Body:" & (oRule.Conditions.Body.Text) & vbCrLf
End If
               
If oCondition.ConditionType = olConditionMessageHeader Then
   sOutput = sOutput & Chr(9) & "Header:" & (oRule.Conditions.MessageHeader.Text) & vbCrLf
End If

If oCondition.ConditionType = olConditionBodyOrSubject Then
  sOutput = sOutput & Chr(9) & "Body Or Subject:"
     For Each myVar In oRule.Conditions.BodyOrSubject.Text
        sOutput = sOutput & "'" & myVar & "' "
     Next
     sOutput = sOutput & vbCrLf
End If

If oCondition.ConditionType = olConditionCategory Then
   sOutput = sOutput & Chr(9) & "Category:"
    For Each myVar In oRule.Conditions.Category.Categories
    sOutput = sOutput & "'" & myVar & "' "
    Next
  sOutput = sOutput & vbCrLf
End If

If oCondition.ConditionType = olConditionAccount Then
   sOutput = sOutput & Chr(9) & "Account:" & (oRule.Conditions.Account.Account) & vbCrLf
End If

If oCondition.ConditionType = olConditionAnyCategory Then
   sOutput = sOutput & Chr(9) & "AnyCategory:" & (oRule.Conditions.AnyCategory) & vbCrLf
End If

If oCondition.ConditionType = olConditionCc Then
   sOutput = sOutput & Chr(9) & "CC:" & (oRule.Conditions.CC.Enabled) & vbCrLf
End If


If oCondition.ConditionType = olConditionFlaggedForAction Then
   sOutput = sOutput & Chr(9) & "Flagged:" & (oRule.Enabled) & vbCrLf
End If


If oCondition.ConditionType = olConditionHasAttachment Then
   sOutput = sOutput & Chr(9) & "Attachment:" & (oRule.Conditions.HasAttachment.Enabled) & vbCrLf
End If


If oCondition.ConditionType = olConditionSenderAddress Then
   sOutput = sOutput & Chr(9) & "Sender:" & (oRule.Conditions.SenderAddress.Enabled) & vbCrLf
End If



End If
Next
            
            
 For Each oAction In oRule.Actions
  If oAction.Enabled = True Then
    If oAction.ActionType = olRuleActionMoveToFolder Then
     sOutput = sOutput & Chr(9) & "Move To:" & (oAction.Folder.FolderPath) & vbCrLf
    End If
    
    If oAction.ActionType = olRuleActionImportance Then
     sOutput = sOutput & Chr(9) & "Set Importance:" & (oAction.Enabled) & vbCrLf
    End If

    If oAction.ActionType = olRuleActionAssignToCategory Then
      sOutput = sOutput & Chr(9) & "Set Category:" & (oAction.Enabled) & vbCrLf
    End If
    
    If oAction.ActionType = olRuleActionRunScript Then
      sOutput = sOutput & Chr(9) & "Run Script:" & (oAction.Enabled) & vbCrLf
    End If
    
    If oAction.ActionType = olRuleActionDeletePermanently Then
      sOutput = sOutput & Chr(9) & "Delete Perm:" & (oAction.Enabled) & vbCrLf
    End If
        
    If oAction.ActionType = olRuleActionCopyToFolder Then
      sOutput = sOutput & Chr(9) & "Copy to:" & (oAction.Folder.FolderPath) & vbCrLf
    End If
    
    If oAction.ActionType = olRuleActionForward Then
      sOutput = sOutput & Chr(9) & "Forward:" & (oAction.Enabled) & vbCrLf
    End If
    


  End If
 Next
            Print #1, sOutput
         Next
    Close #1
End Sub
Sub ListRules1()

End Sub
how do we achieve this magic?
Copy and paste the VB code into Outlook's VB Editor. You'll also need to allow macros 
to run. If you aren't asked if you want to allow macros when you open the VB editor, 
you'll need to change the macro security in Options, Trust Center to 'Always ask' 
about macros. We do not recommend the lowest security setting to never ask about
 macros.

When you paste the code, the text colors should be the same as seen in the code 
above. Red lines mean there is an error in the code.

Press ALT+F11 to open Outlook’s VB editor
If asked, you need to enable Macros
Expand Project1 and Microsoft Office Outlook Objects
Double-click on ThisOutlookSession
Copy the code and paste it into the VB editor window (right pane)
Save the changes (Ctrl+S or click the Save icon)
Press F8 or the Run button to run the macro