Tags: python3 crypto 

Rating:

Python code for this challenge.
* Bacon
* rot13
* atbash
* base64
```
# You can install these packages to help w/ solving unless you have others in mind
# i.e. python3 -m pip install {name of package}
from pwn import *
import codecs
from base64 import b64decode
from secretpy import Atbash
from secretpy import CryptMachine
from secretpy import alphabets
import secretpy.cmdecorators as md

HOST = 'chal.ctf.b01lers.com' #nc chal.ctf.b01lers.com 2008
PORT = 2008

r = remote(HOST,PORT)

bacon_dict = {}
for i in range(0, 26):
tmp = bin(i)[2:].zfill(5)
tmp = tmp.replace('0', 'a')
tmp = tmp.replace('1', 'b')
bacon_dict[tmp] = chr(65 + i)

def bacon(words, bacon_dict):
cipher = ''
words = words.lower()
words = re.sub(r'[^ab]+', '', words)
for i in range(0, int(len(words) / 5)):
cipher += bacon_dict.get(words[i * 5:i * 5 + 5], ' ')
return cipher.lower()
#-----------------------Copy from github https://raw.githubusercontent.com/Lellansin/Cipher-examples/master/python/Bacon.py------------------------------#
def rot13(cipher):
return codecs.decode(cipher,'rot_13')

def atbash(cipher):
cm = CryptMachine(Atbash())
cm = md.NoSpaces(md.UpperCase(cm))
if cipher.islower():
return cm.decrypt(cipher).lower()
if cipher.isupper():
return cm.decrypt(cipher).lower()

def Base64(cipher):
return base64.b64decode(cipher).decode('utf-8')

flag = True
try:
while flag:
r.recvuntil('Method: ')
method = r.recvuntil('\n').strip()
method = method.decode('utf-8')
print(method)
r.recvuntil('Ciphertext: ')
cipher = r.recvuntil('\n').strip()
cipher = cipher.decode('utf-8')
print(cipher)
result = ""
if method == "bacon":
result = bacon(cipher,bacon_dict)
result = result.lower()
r.sendline(result)
elif method == "rot13":
result = rot13(cipher)
result = result.lower()
r.sendline(result)
elif method == "atbash":
result = atbash(cipher)
result = result.lower()
r.sendline(result)
elif method == "Base64":
result = Base64(cipher)
result = result.lower()
r.sendline(result)
if "flag{" in (result,method,cipher):
flag = False
r.recv()
except:
print(r.recvall())

```

> flag is ctf{4n_313g4nt_s01ut10n_f0r_tr4cking_r341ity}