Writeup Cyber Jawara 2015 Hari Ke 2 - Hash |
Pada sesi ini peserta diberikan soal dalam bentuk hash yang terdapat pada file txt yang berisi seperti berikut :
..::CJ2015 Decrypt Hash::..
Pl@lél0d(mÌSväGjeecÂPM®tGhR?äMdÂA1¯d
Te#FÂO+m%OÂ:.äeKâELÂaE¯a
~k!TÌ9lgK7Â~lg`uâ_8ÈMl-TPª&
pada link soal sudah terdapat encryptor dengan menggunakan bahasa ruby.
#!/usr/bin/rubyMisalnya string flag diset “aaaaaaaa”. Jika dijalankan berkalikali, terdapat suatu pola:
flag= ???
str = "0123456789abcdef"
chr = "!\"#%&()+,-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[^_`abcdefghijklmnopqrstuvwxyz~"
bin = "0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111"
flags = flag.scan /\w/
hh=flags.map{|h| h.unpack('H*')}.join()
a=hh.scan /\w/
b=a.map{|x|str[bin.index(bin[str.index(x)*5,4].reverse)/5,1]}.join
c=[]
for y in 0..(b.length/2)
c.push(b[y*2,2].hex.chr.encode('utf-8','iso-8859-1'))
end
i=chr.length-1
d=c[0,c.length-1].join()
f=[]
e=d.split("").each do |z|
f.push(chr[rand(0..i),1] + z + chr[rand(0..i),1])
end
p f.join()
Gambar 1 : Test script ruby encrypt string |
Maka langkah yang dapat dilakukan adalah membuat mapping antara plaintext ciphertext.Untuk membuat mapping tersebut, pada script Ruby dibuat seluruh karakter yang mungkin.
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxKarakter-karakter tersebut dienkripsi menjadi:
yz_
4ÀsyÈb<ÄUGÌd,Â)TÊxxÆ&yÎg\"ÁtjÉaG(k<$^%,`I\"fM*R1&k2.RU!YF)8[%bZg1#>E+N`'0c/p>KA¨1\"¤K/¬#F¢PQª`(¦?^®h~¡1e©E(¥e_hcndw&lBPb#Kj^af>Wn7Pag3ig4Setelah dibersihkan paddingnya menjadi:
eOKmYocj?k1<g~Jo.<àe\"èEmäZHìzMâ(wê.#æIyî#kájBé:Håce¯t
ÀÈÄÌÂÊÆÎÁÉ($,"*&.!)%#+'/Maka dapat dibuat mapping:
¨¤¬¢ª¦®¡©¥hdlbjfnaiemckgoàèäìâêæîáéå¯
Gambar 2 : Mapping word |
lédÌäe®hä¯Dengan script Python berikut ini dilakukan mapping tersebut:
eÂmÂäâ¯
kÌgÂgâÈ-ª
# -*- coding: utf-8 -*-
import sys
clean = u"ÀÈÄÌÂÊÆÎÁÉ($,\"*&.!)%-#+'/ ¨¤¬¢ª¦®¡©¥hdlbjfnaiemckgoàèäìâêæîáéå¯"
chars = u"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_"
dict = {}
for j in range(len(clean)):
dict[clean[j]] = chars[j]
soal1 = u"lédÌäe®hä¯"
soal2 = u"eÂmÂäâ¯"
soal3 = u"kÌgÂgâÈ-ª"
for s in soal1:
sys.stdout.write(dict[s])
print ""
for s in soal2:
sys.stdout.write(dict[s])
print ""
for s in soal3:
sys.stdout.write(dict[s])
jalankan script tersebut dan didapatkan flagnya.
Gambar 3 : Flag |
#!/usr/bin/ruby
# encoding: utf-8
chipper = ["Pl@","lél","0d(","mÌS","väG","jee","cÂP","M®t","GhR","?äM","dÂA","1¯d","Te#","FÂO","+m%","OÂ:",".äe","KâE","LÂa","E¯a","~k!","TÌ9","lgK","7Â~","lg`","uâ_","8ÈM","l-T","Pª&"];
str = "0123456789abcdef"
chr = "!\"#%&()+,-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[^_`abcdefghijklmnopqrstuvwxyz~"
bin = "0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111"
tmp = ""
for tt in 0..chipper.count
while tmp != chipper[tt] do flag= chr[rand(0..84),1]
hasil=flag
flags = flag.scan /\w/
hh=flags.map{|h| h.unpack('H*')}.join()
a=hh.scan /\w/
b=a.map{|x|str[bin.index(bin[str.index(x)*5,4].reverse)/5,1]}.join
c=[]
for y in 0..(b.length/2)
c.push(b[y*2,2].hex.chr.encode('utf-8','iso-8859-1'))
end
i=chr.length-1
d=c[0,c.length-1].join()
f=[]
e=d.split("").each do |z|
f.push(chr[rand(0..i),1] + z + chr[rand(0..i),1])
end
tmp= f.join()
end
p hasil
end
Output :
Gambar 4 : Output Solusi Lain1 |
Solusi Lainnya :
Gambar 5 : Solusi Lain |
Output :
Gambar 6 : Hasil Eksekusi |
Flag : CJ2015{cyb3rj4War4_j4k4rt4_m3n4nt1KU}
source : Cyber Security IPB
Writeup Cyber Jawara 2015 Day 2 : Hash
Reviewed by Sitakom Blog
on
10:51 PM
Rating:
No comments: