Skip to content

Commit 1b4409f

Browse files
authored
Update phoenix_command.rb
Style fix: replace "ractionport == nil ?" with "ractionport.nil?" Is it OK? Did not find time to install and run rubocop ...
1 parent 4ea9214 commit 1b4409f

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

modules/auxiliary/admin/scada/phoenix_command.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def get_state1(data)
138138
end
139139
state
140140
end
141-
142141
def get_state2(data)
143142
if data[16..17] == '04'
144143
state = 'STOP'
@@ -150,7 +149,6 @@ def get_state2(data)
150149
end
151150
state
152151
end
153-
154152
def get_cpu(rhost, rport, devicetype)
155153
connect(true, 'RHOST' => rhost, 'RPORT' => rport)
156154
state = 'unknown'
@@ -160,8 +158,7 @@ def get_cpu(rhost, rport, devicetype)
160158
send_recv_once("\x01\x00\x02\x00\x00\x00\x1c\x00\x03\x00\x03\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x07\x00\x05\x00\x06\x00\x08\x00\x10\x00\x02\x00\x11\x00\x0e\x00\x0f\x00\r\x00\x16@\x16\x00")
161159
## Query packet
162160
data = send_recv_once("\x01\x00\x02\x00\x00\x00\x08\x00\x03\x00\x03\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x40\x0b\x40")
163-
state = get_state1(data)
164-
elsif devicetype == '39x'
161+
state = get_state1(data) elsif devicetype == '39x'
165162
init_phase2
166163
data = send_recv_once("\xcc\x01\x00\x0f@\x07\x00\x00\xea\xfa")
167164
state = get_state2(data)
@@ -171,8 +168,7 @@ def get_cpu(rhost, rport, devicetype)
171168
state
172169
end
173170

174-
def set_cpu(rhost, rport, action, state, devicetype)
175-
connect(true, 'RHOST' => rhost, 'RPORT' => rport)
171+
def set_cpu(rhost, rport, action, state, devicetype) connect(true, 'RHOST' => rhost, 'RPORT' => rport)
176172
if devicetype == '15x'
177173
init_phase1 ## Several packets (21)
178174
send_recv_once("\x01\x00\x02\x00\x00\x00\x1c\x00\x03\x00\x03\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x07\x00\x05\x00\x06\x00\x08\x00\x10\x00\x02\x00\x11\x00\x0e\x00\x0f\x00\r\x00\x16@\x16\x00")
@@ -182,8 +178,7 @@ def set_cpu(rhost, rport, action, state, devicetype)
182178
else
183179
print_status('--> Sending STOP now')
184180
send_recv_once("\x01\x00\x02\x00\x00\x00\x00\x00\x01\x00\x07\x00\x00\x00\x00\x00")
185-
end
186-
elsif devicetype == '39x'
181+
end elsif devicetype == '39x'
187182
init_phase2 ## Several packets (6)
188183
if action == 'START' || (action == 'REV' && state == 'STOP')
189184
print_status('--> Sending COLD start now')
@@ -211,11 +206,11 @@ def run
211206
if device.start_with?('ILC 15', 'ILC 17')
212207
devicetype = '15x'
213208
print_status('--> Detected 15x/17x series, getting current CPU state:')
214-
ractionport == nil ? (rport = 41100) : (rport = ractionport)
209+
ractionport.nil? (rport = 41100) : (rport = ractionport)
215210
elsif device.start_with?('ILC 39')
216211
devicetype = '39x'
217212
print_status('--> Detected 39x series, getting current CPU state:')
218-
ractionport == nil ? (rport = 20547) : (rport = ractionport)
213+
ractionport.nil? (rport = 20547) : (rport = ractionport)
219214
else
220215
print_error('Only ILC and (some) RFC devices are supported.')
221216
return

0 commit comments

Comments
 (0)