From 6f72d3ed31c82033321de7db0cd0647c321ecfb3 Mon Sep 17 00:00:00 2001 From: Etienne Stalmans Date: Thu, 11 May 2017 13:58:58 +0100 Subject: [PATCH] Add OS detection for logging. Windows < 10 doesn't support ANSI escape codes --- README.md | 5 ++++- utils/logging.go | 34 ++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4bb417a..aee088f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ Ruler is a tool that allows you to interact with Exchange servers remotely, through either the MAPI/HTTP or RPC/HTTP protocol. The main aim is abuse the client-side Outlook features and gain a shell remotely. -The full low-down on how Ruler was implemented and some background regarding MAPI can be found in our blog posts: [Ruler release], [Pass the Hash with Ruler], [Outlook forms and shells]. +The full low-down on how Ruler was implemented and some background regarding MAPI can be found in our blog posts: +* [Ruler release] +* [Pass the Hash with Ruler] +* [Outlook forms and shells]. For a demo of it in action: [Ruler on YouTube] diff --git a/utils/logging.go b/utils/logging.go index 9cbe751..7f483a9 100644 --- a/utils/logging.go +++ b/utils/logging.go @@ -3,6 +3,7 @@ package utils import ( "io" "log" + "runtime" ) var ( @@ -22,15 +23,28 @@ func Init( infoHandle io.Writer, warningHandle io.Writer, errorHandle io.Writer) { + if runtime.GOOS == "windows" { + Trace = log.New(traceHandle, "[*] ", 0) + Info = log.New(infoHandle, "[+] ", 0) + Clear = log.New(infoHandle, " ", 0) + Debug = log.New(warningHandle, " ", 0) + Fail = log.New(infoHandle, "[x] ", 0) + Question = log.New(infoHandle, "[?] ", 0) + Warning = log.New(warningHandle, + "[WARNING] ", 0) + Error = log.New(errorHandle, + "ERROR: ", log.Ldate|log.Ltime) - Trace = log.New(traceHandle, "\033[33m[*] \033[0m", 0) - Info = log.New(infoHandle, "\033[32m[+] \033[0m", 0) - Clear = log.New(infoHandle, " ", 0) - Debug = log.New(warningHandle, " ", 0) - Fail = log.New(infoHandle, "\033[91m[x] \033[0m", 0) - Question = log.New(infoHandle, "\033[91m[?] \033[0m", 0) - Warning = log.New(warningHandle, - "\033[91m[WARNING] \033[0m", 0) - Error = log.New(errorHandle, - "\033[31mERROR\033[0m: ", log.Ldate|log.Ltime) + } else { + Trace = log.New(traceHandle, "\033[33m[*] \033[0m", 0) + Info = log.New(infoHandle, "\033[32m[+] \033[0m", 0) + Clear = log.New(infoHandle, " ", 0) + Debug = log.New(warningHandle, " ", 0) + Fail = log.New(infoHandle, "\033[91m[x] \033[0m", 0) + Question = log.New(infoHandle, "\033[91m[?] \033[0m", 0) + Warning = log.New(warningHandle, + "\033[91m[WARNING] \033[0m", 0) + Error = log.New(errorHandle, + "\033[31mERROR\033[0m: ", log.Ldate|log.Ltime) + } }