shifter [misc]

shifter

What a strange challenge... It'll be no problem for you, of course!

  • Netcat: nc misc.2020.chall.actf.co 20300

Recon

If we connect to the service we get the following message:

$ nc misc.2020.chall.actf.co 20300
Solve 50 of these epic problems in a row to prove you are a master crypto man like Aplet123!
You'll be given a number n and also a plaintext p.
Caesar shift `p` with the nth Fibonacci number.
n < 50, p is completely uppercase and alphabetic, len(p) < 50
You have 60 seconds!
--------------------
Shift QUYOHMIXBXMNRSZLNKI by n=22
: MQUKDIETXTIJNOVHJGE
Sorry, you got it wrong. The answer was VZDTMRNCGCRSWXEQSPN. Better luck next time!

If we enter a wrong code, we get the correct answer. With this information we can create a script which solves this challenge.

Code

from pwn import *
import string

fibo = [0,1]
s = remote("misc.2020.chall.actf.co", 20300)

def caesar(plaintext, shift):
    shift %= 26
    alphabet = string.ascii_uppercase
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    table = string.maketrans(alphabet, shifted_alphabet)
    return plaintext.translate(table)


for i in range(48):
    fibo.append(fibo[-1] + fibo[-2])

for i in range(50):
    s.recvuntil("Shift ")
    ciph = s.recvuntil("by n=")[0:-6]
    n = int(s.recvline())
    print "[+] Shifting {} by {}: {}".format(ciph, n, caesar(ciph, fibo[n]))
    s.send(caesar(ciph, fibo[n]) + "\n")

print s.recvline()

Output:

$ ./solve.py 
[+] Opening connection to misc.2020.chall.actf.co on port 20300: Done
[+] Shifting VXTNCMSGA by 19: QSOIXHNBV
[+] Shifting TGVXVXJMDWLCBZJJDQK by 24: DQFHFHTWNGVMLJTTNAU
[+] Shifting NGQIGDMJBELOBAVCOLGUKJOKCKGGSJOCEDBCGBU by 40: OHRJHENKCFMPCBWDPMHVLKPLDLHHTKPDFECDHCV
[+] Shifting ZWUXXOHTDDSUBPNPCMLHOYQXJSPPBFXD by 44: YVTWWNGSCCRTAOMOBLKGNXPWIROOAEWC
[+] Shifting PCQECKANVDKULAPMDYUAJZHX by 33: HUIWUCSFNVCMDSHEVQMSBRZP
[+] Shifting TWXGHGONSVPEICPZVTZPLJLGHBPCKEHL by 16: SVWFGFNMRUODHBOYUSYOKIKFGAOBJDGK
[+] Shifting UJZNJEEBEWSSCAGPMPFBPZEY by 46: RGWKGBBYBTPPZXDMJMCYMWBV
[+] Shifting MEWQZBRP by 21: MEWQZBRP
[+] Shifting VVEUERWROLPUHGYVRDS by 1: WWFVFSXSPMQVIHZWSET
[+] Shifting FFYWDXDZF by 2: GGZXEYEAG
[+] Shifting FTCDNAGAFODKQJIWYCLFWCWDSQZDPZ by 24: PDMNXKQKPYNUATSGIMVPGMGNCAJNZJ
[+] Shifting K by 19: F
[+] Shifting NPBDOAQEZXTREAUIUNRQUJWZYVOPXA by 39: LNZBMYOCXVRPCYSGSLPOSHUXWTMNVY
[+] Shifting CXODQ by 26: BWNCP
[+] Shifting LUZMJSPEHXQSVUN by 23: QZEROXUJMCVXAZS
[+] Shifting HFEEIBJVYMEFQUURPDCC by 35: USRRVOWILZRSDHHECQPP
[+] Shifting SOCTOHOYLNBZCEWCFSEUFHXXFOPNEEH by 37: NJXOJCJTGIWUXZRXANZPACSSAJKIZZC
[+] Shifting XFIBILACYEFOYLZKDXYJXBDH by 40: YGJCJMBDZFGPZMALEYZKYCEI
[+] Shifting  by 25: 
[+] Shifting CTLNIVQVXHCBELTPPGLIDACGLLJSNVYGVQ by 43: BSKMHUPUWGBADKSOOFKHCZBFKKIRMUXFUP
[+] Shifting FSTJQTFEHFTDKYWKQHTAHSAPDRGUTJFIEJSLHKYKWQWGJH by 11: QDEUBEQPSQEOVJHVBSELSDLAOCRFEUQTPUDWSVJVHBHRUS
[+] Shifting PKFCMGELBHLKRAFOLPYUHNCQCS by 0: PKFCMGELBHLKRAFOLPYUHNCQCS
[+] Shifting KUVRFJPRSFYHGUEM by 43: JTUQEIOQREXGFTDL
[+] Shifting ZSUZFAMMIGKZTLJP by 10: CVXCIDPPLJNCWOMS
[+] Shifting JVJQIIYHGFCZZXKLWMPHNISIVLYUGZPJVCJWL by 22: OAOVNNDMLKHEECPQBRUMSNXNAQDZLEUOAHOBQ
[+] Shifting  by 3: 
[+] Shifting EANCAESRHTPQRMH by 13: DZMBZDRQGSOPQLG
[+] Shifting GEUNGSLRVIFHPZQBMDPVDTCCLDQDFEQJPI by 42: GEUNGSLRVIFHPZQBMDPVDTCCLDQDFEQJPI
[+] Shifting XMYJGAXLFTMPIFYMADNXBVKUWLPGB by 37: SHTEBVSGAOHKDATHVYISWQFPRGKBW
[+] Shifting HTWELEJXRPVBSDVDM by 14: UGJRYRWKECIOFQIQZ
[+] Shifting PXBUKFRKFTOGVOPKOOTNZDQOYRDVYJLCMXST by 1: QYCVLGSLGUPHWPQLPPUOAERPZSEWZKMDNYTU
[+] Shifting FLVCJTSWQXHAXFPPOZGZPBYMTVAWKSDZXTSOFNKFOVZV by 1: GMWDKUTXRYIBYGQQPAHAQCZNUWBXLTEAYUTPGOLGPWAW
[+] Shifting FVTOSRJBFTGUFSHTVKRVUTLPUPTTC by 30: TJHCGFXPTHUITGVHJYFJIHZDIDHHQ
[+] Shifting PEYPYVPPEGZLYOKLREOJRSRLZPBFAY by 26: ODXOXUOODFYKXNJKQDNIQRQKYOAEZX
[+] Shifting PFWEXLUCBMXQWBGPHAPBJK by 38: SIZHAOXFEPATZEJSKDSEMN
[+] Shifting EHLLRGXFMKEGKEIPWDLTIJJ by 10: HKOOUJAIPNHJNHLSZGOWLMM
[+] Shifting JNZAPUMHFMFPSKY by 10: MQCDSXPKIPISVNB
[+] Shifting LMXAVSHJJBQABQHJLRCRABFMC by 10: OPADYVKMMETDETKMOUFUDEIPF
[+] Shifting NJILHRXOXEILTTIBWUQLPAAQTBLFUACPIQNZPZPXHZJK by 44: MIHKGQWNWDHKSSHAVTPKOZZPSAKETZBOHPMYOYOWGYIJ
[+] Shifting LWQOHDZFWUEIUFRQVHHBXVEHXEYQDOMYADRTVAJIZDBEAUTGD by 28: YJDBUQMSJHRVHSEDIUUOKIRUKRLDQBZLNQEGINWVMQORNHGTQ
[+] Shifting ZLDKBEDPACOHHIFFUDKHIMFYMTPXSELCLIMPJSM by 38: COGNEHGSDFRKKLIIXGNKLPIBPWSAVHOFOLPSMVP
[+] Shifting JJOQUAEYYXHRFJXBGPFVFZQTWQQH by 14: WWBDHNRLLKUESWKOTCSISMDGJDDU
[+] Shifting QFMATIWXAZOGZHIHAXZPHSKCLQYJRNFUSQOYSMG by 22: VKRFYNBCFETLEMNMFCEUMXPHQVDOWSKZXVTDXRL
[+] Shifting VIEDZIUEVUJADWJYA by 1: WJFEAJVFWVKBEXKZB
[+] Shifting UTZQBBAVUQXEQHJ by 0: UTZQBBAVUQXEQHJ
[+] Shifting CXKJHJXVQNAGTGHKZEVX by 41: BWJIGIWUPMZFSFGJYDUW
[+] Shifting XXQXFYXKTZDTHXU by 23: CCVCKDCPYEIYMCZ
[+] Shifting GWAVY by 17: RHLGJ
[+] Shifting YMABDVHBNDVHITWMDBCTFVYVFPNDGFWTFRYR by 13: XLZACUGAMCUGHSVLCABSEUXUEOMCFEVSEQXQ
[+] Shifting TROMXTOZXMVQDFXWBPPRUVVREDXFBZASCTLAYYDGSG by 30: HFCALHCNLAJERTLKPDDFIJJFSRLTPNOGQHZOMMRUGU
: actf{h0p3_y0u_us3d_th3_f0rmu14-1985098}

Flag

actf{h0p3_y0u_us3d_th3_f0rmu14-1985098}