Skip to content

Instantly share code, notes, and snippets.

@196Ikuchil
Created October 26, 2019 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 196Ikuchil/5171617c3e45c75e46109389324e37f7 to your computer and use it in GitHub Desktop.
Save 196Ikuchil/5171617c3e45c75e46109389324e37f7 to your computer and use it in GitHub Desktop.
pico2019 javascriptkiddle2
result = []
File.open("q2.txt","r") do |f|
bytes = f.readline.split(" ")
LEN = 16
# key = "6059204266803763"
key ="0"*32
if key.length !=32
p "長さが違うよ"
return
end
for i in 0...LEN do
shifter = key[i*2,2]
for j in 0...bytes.length/LEN do
result[j*LEN+i] = bytes[(((j + shifter.to_i)*LEN%bytes.length)+i)]
end
end
end
# 表示してみる
for i in 0...result.length / 16 do
for j in 0...16 do
printf("%4s",result[i*16 + j]&.to_i&.to_s(16) + ", ")
end
p "\n"
end
png_header = "89 50 4e 47 d a 1a a 0 0 0 d 49 48 44 52".split(" ")
a = []
for l in 0...16 do
li =[]
for i in 0..9 do
if result[i*16+l]&.to_i&.to_s(16) == png_header[l]
li << i
end
end
a << li
end
# = > [[8], [8], [2], [9], [2], [4], [2, 6], [4], [7], [3, 4], [3, 4], [4, 6], [0], [4], [8], [6]]
# 全組み合わせ
pattern = a[0]
a.delete_at(0)
a.each{|x| pattern = pattern.product(x).map{|y| y.join}}
# => ["8829242473340486", "8829242473360486", "8829242473440486", "8829242473460486", "8829242474340486", "8829242474360486", "8829242474440486", "8829242474460486", "8829246473340486", "8829246473360486", "8829246473440486", "8829246473460486", "8829246474340486", "8829246474360486", "8829246474440486", "8829246474460486"]
# 本来は奇数番目に無駄な文字が入っている
pattern.map!{|x| x.chars.map!{|y| y+"0"}.join}
p pattern
# => ["80802090204020407030304000408060", "80802090204020407030306000408060", "80802090204020407030404000408060", "80802090204020407030406000408060", "80802090204020407040304000408060", "80802090204020407040306000408060", "80802090204020407040404000408060", "80802090204020407040406000408060", "80802090204060407030304000408060", "80802090204060407030306000408060", "80802090204060407030404000408060", "80802090204060407030406000408060", "80802090204060407040304000408060", "80802090204060407040306000408060", "80802090204060407040404000408060", "80802090204060407040406000408060"]
18 25 55 252 248 230 248 246 124 43 141 211 73 205 162 187 16 223 0 142 73 3 78 227 145 65 142 127 0 50 31 182 123 59 78 196 13 253 26 63 58 66 96 116 154 53 19 231 166 201 1 193 0 69 1 68 38 0 0 172 56 0 254 120 42 106 0 96 147 10 68 10 93 0 0 13 97 72 191 255 227 31 70 128 198 0 90 114 34 120 156 130 64 192 222 0 227 141 156 39 244 73 26 65 174 7 232 13 120 77 201 82 0 0 13 222 80 134 105 58 0 131 131 0 69 55 0 108 137 80 21 0 126 1 9 236 1 212 163 237 155 59 68 228 0 0 188 71 243 1 76 17 84 141 55 163 230 40 95 51 164 0 248 114 124 124 85 7 48 204 128 102 251 227 138 51 48 12 219 2 171 136 248 107 101 154 202 248 62 110 152 100 205 205 190 159 38 84 254 213 236 50 34 222 66 253 245 55 12 53 2 163 21 199 104 157 227 198 239 204 34 85 150 175 137 242 111 233 145 34 136 104 223 127 55 69 86 135 141 86 254 95 192 91 11 228 213 61 12 64 1 52 239 255 182 102 170 223 200 116 60 252 46 223 249 255 95 195 81 233 158 128 1 92 126 39 35 228 124 244 61 61 157 31 221 34 100 234 21 40 63 29 86 80 68 42 198 44 147 98 200 143 189 187 171 44 133 253 104 52 53 74 160 102 128 252 223 127 114 19 174 255 170 18 39 252 194 85 27 63 177 62 16 205 161 59 122 165 41 252 161 122 161 253 51 155 127 67 46 166 34 61 64 241 130 109 132 107 81 13 123 206 201 80 124 119 241 33 241 45 8 92 198 145 7 187 37 196 84 86 211 179 123 170 253 198 245 111 150 15 172 202 198 87 209 79 49 50 78 106 212 1 173 177 183 127 199 175 239 99 252 230 44 42 182 237 104 10 90 142 57 105 17 142 246 101 223 189 235 207 255 21 6 192 238 87 26 29 215 91 36 221 71 84 191 243 241 129 252 21 10 173 161 212 40 186 154 20 180 94 19 126 10 8 250 234 253 34 133 42 77 168 212 130 194 231 41 126 50 176 38 160 168 61 98 76 253 56 206 79 108 235 204 67 175 254 253 59 187 175 148 95 211 191 195 43 139 61 195 181 171 201 136 71 244 9 255 118 252 252 213 203 91 242 46 242 23 86 38 127 246 235 44 126 146 48 21 53 21 156 172 174 79 191 143 252 49 17 162 61 228 56 241 61 198 223 57 128 90 63 21 223 31 87 219 109 85 227 109 134 56 69 33 223 215 138 154 129 58 40 217 203 19 170 161 220 93 143 169 54 163 197 89 124 163 21 1 152 159 204 102 114 107 239 217 54 210 191 164 67 179 11 234 183 124 244 72 32 124 4 247 139 204 115 35 242 237 24 35 148 24 40 48 158 219 60 111 56 156 119 2 2 61 41 180 228 93 217 171 255 56 93 117 166 159 115 102 190 181 79 54 245 83 191 175 148 30 120 47 11 95 214 102 254 99 189 99 122 107 166 5 202 87 222 62 229 223 211 242 221 215 63 153 156 203 182 6 84 172 63 178 252 149 34 233 120 231 49 175 179 147 39 15 106 101 227 0 74 214 253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment