-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstb_getcodes.rb
More file actions
259 lines (182 loc) · 7.36 KB
/
stb_getcodes.rb
File metadata and controls
259 lines (182 loc) · 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# This file is part of VAG202.
#
# VAG202 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# VAG202 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with VAG202. If not, see <http://www.gnu.org/licenses/>.
# STB CLONEA
require 'socket' # Sockets are in standard library
require "vhash.rb"
$control_code = "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
#$control_code = ARGV.shift
$control_code = $control_code.split(" ")
puts "default control code is " + $control_code.join(" ")
def construct_fios_stb_packet_stb_first()
# i am stb packet
#0000 56 02 02 01 00 04 00 00 00 00 00 00 00 00 00 00 V...............
#0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
#0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
#0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
#0040 00 00 00 00 00 72 .....r
first_packet = %w{56 02 02 01 00 04 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 72}
return first_packet
end
def construct_fios_stb_packet_stb_second()
# i am stb number whatever w/ damn fuckin code
#0000 12 00 01 02 01 00 05 53 54 42 31 00 04 00 01 01 .......STB1.....
#0010 05 00 04 39 37 13 4d 06 00 04 00 00 00 14 07 00 ...97.M.........
#0020 20 48 9f 19 9f 93 73 ad 73 9a 0e 1b 9c 20 ba 39 H....s.s.... .9
#0030 eb 94 0e 01 5f 00 00 00 00 00 00 00 00 00 00 00 ...._...........
#0040 00 0b 00 04 01 0c 00 02 c0 00 0d 00 04 c0 00 00 ................
#0050 00 0e 00 04 c0 00 00 00 0f 00 06 c0 00 00 00 00 ................
#0060 06 10 00 04 c0 00 00 00 11 00 04 00 00 64 00 00 .............d..
#0070 00 00
# changed
second_packet = %w{12 00 01 02 01 00 05 53 54 42 30 00 04 00 01 01
05 00 04 39 37 13 4d 06 00 04 00 00 00 14 07 00
20} + $control_code + %w{00 00 00 00 00 00 00 00 00 00 00
00 0b 00 04 01 0c 00 02 c0 00 0d 00 04 c0 00 00
00 0e 00 04 c0 00 00 00 0f 00 06 c0 00 00 00 00
06 10 00 04 c0 00 00 00 11 00 04 00 00 64 00 00
00 00}
puts
return second_packet
end
def construct_fios_remote_packet_yay()
#newtime()
yay_payload = %w{56 02 02 01 00 19 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00
00 00 00 00 00 00}
return yay_payload
end
def construct_fios_remote_packet_codeforme(whattocode)
#0000 56 02 02 01 00 1b 00 39 3e 09 7f 00 00 00 00 00 V......9>.......
#0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
#0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
#0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
#0040 00 00 00 00 00 32 04 00 01 01 05 00 01 00 06 00 .....2..........
#0050 04 00 00 00 00 07 00 20 00 00 00 00 00 00 00 00 ....... ........
#0060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
#30070 00 00 00 00 00 00 00 00
#newtime()
codeme_payload = %w{56 02 02 01 00 1b 00} + whattocode + %w{00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 32 04 00 01 01 05 00 01 00 06 00
04 00 00 00 00 07 00 20 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00}
return codeme_payload
end
puts [construct_fios_stb_packet_stb_second().join ''].pack('H*')
hostname = '192.168.1.2'
port = 4532
sock = TCPSocket.open(hostname, port)
puts "Expecting init packet / printing response"
data = sock.recvfrom( 2220 )[0].chomp
if data
puts data.unpack("H*")
time_code_to_encode = [data[7].to_s(16), data[8].to_s(16), data[9].to_s(16),data[10].to_s(16)]
for x in time_code_to_encode
if x.length < 2
time_code_to_encode[time_code_to_encode.index(x)] = "0" + x.to_s
end
end
time_code_to_encode = time_code_to_encode[0] + time_code_to_encode[1] + time_code_to_encode[2] + time_code_to_encode[3]
time_code_to_encode = time_code_to_encode.upcase
puts "time code to encode is: #{time_code_to_encode}"
v = Vhash.find_by_input(time_code_to_encode)
v.show
$control_code = v.hash_as_array
end
puts "sending stb first packet"
sock.write [construct_fios_stb_packet_stb_first().join ''].pack('H*')
# puts "Expecting init packet / printing response"
# data = sock.recvfrom( 2220 )[0].chomp
# if data
# puts data.unpack("H*")
# end
puts "sending stb second packet"
sock.write [construct_fios_stb_packet_stb_second().join ''].pack('H*')
puts [construct_fios_stb_packet_stb_second().join ''].pack('H*')
now_in_gps = Time.now.to_i - 315964819
puts "now is #{now_in_gps}"
now_in_hex = dec2hex(now_in_gps)
puts "now is in hex #{now_in_hex}"
puts "Entering loop state"
while true
puts "Looped"
1000.times do
puts "sending code for me packet"
input = [now_in_hex[0..1], now_in_hex[2..3], now_in_hex[4..5], now_in_hex[6..7] ]
sock.write [construct_fios_remote_packet_codeforme(input).join ''].pack('H*')
puts "Expecting / printing response"
data = sock.recvfrom( 2220 )[0].chomp
if data.unpack("H*").to_s.length == 240
puts "good"
puts data.unpack("H*")
control_word = [data[29].to_s(16), data[30].to_s(16), data[31].to_s(16), data[32].to_s(16), data[33].to_s(16), data[34].to_s(16), data[35].to_s(16), data[36].to_s(16), data[37].to_s(16), data[38].to_s(16),
data[39].to_s(16), data[40].to_s(16), data[41].to_s(16), data[42].to_s(16), data[43].to_s(16), data[44].to_s(16), data[45].to_s(16), data[46].to_s(16), data[47].to_s(16), data[48].to_s(16) ]
for x in control_word
if x.length < 2
control_word[control_word.index(x)] = "0" + x.to_s
end
end
code = control_word.join("")
puts input
test = Vhash2.find_by_input(now_in_hex.to_s)
if test == nil
newcode = Vhash2.new
newcode.input = now_in_hex.to_s
newcode.output = code
newcode.save
else
puts "fuck I had that one already"
end
puts "code is: #{code}"
now_in_gps = now_in_gps + 1
now_in_hex = dec2hex(now_in_gps)
puts "now is in hex #{now_in_hex}"
# change what to code to next thing
else
puts data.unpack("H*")
puts "============"
puts data.unpack("H*").to_s.length
puts "============"
puts "blah redo"
end
#sleep 0.1
end
puts "got thru 1000 times"
puts "Expecting / printing response"
data = sock.recvfrom( 2220 )[0].chomp
if data
puts data.unpack("H*")
end
puts "sending yay packet"
sock.write [construct_fios_remote_packet_yay().join ''].pack('H*')
sleep 1
# puts "sending encode for me packet"
# sock.write [construct_fios_stb_packet_encodeforme().join ''].pack('H*')
# puts "Expecting / printing the code we want"
# data = sock.recvfrom( 2220 )[0].chomp
# if data
# puts data.unpack("H*")
# end
end
#s.close