-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecipher.py
More file actions
52 lines (46 loc) · 2 KB
/
Copy pathdecipher.py
File metadata and controls
52 lines (46 loc) · 2 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
import requests
from bs4 import BeautifulSoup
import ast
import json
f = open("output.txt", "a+")
session = requests.Session()
session.headers.update({'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'})
def caesar_cipher(ciphertext):
data = {'tool': 'chiffre-cesar',
'ciphertext': ciphertext,
'method': 'bruteforce',
'shift': '1'}
doc = BeautifulSoup(session.post('https://www.dcode.fr/api/', data=data).text,
'html.parser')
answer = ast.literal_eval(doc.getText())['results']
a = "\n".join("{}\t\t{}".format(k, v.lower()) for k, v in answer.items())
f.write('==================== [ Caesar Cipher] ====================\n' + a + '\n')
f.flush()
return a
def affine_cipher(ciphertext):
data = {'tool': 'chiffre-affine',
'ciphertext': ciphertext,
'alphabet': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'method': 'bruteforce',
'a': '3',
'b': '1'}
doc = BeautifulSoup(session.post('https://www.dcode.fr/api/', data=data).text,
'html.parser')
answer = ast.literal_eval(doc.getText())['results']
a = "\n".join("{}\t\t{}".format(k, v.lower()) for k, v in answer.items())
f.write('==================== [ Affine Cipher] ====================\n' + a + '\n')
f.flush()
return a
def alberti_cipher(ciphertext):
data = {'tool': 'alberti-cipher',
'ciphertext': ciphertext,
'disk1': 'ABCDEFGILMNOPQRSTVXZ1234',
'disk2': 'c&bmdgpfznxyvtoskerlhaiq',
'bruteforce': 'true'}
doc = BeautifulSoup(session.post('https://www.dcode.fr/api/', data=data).text,
'html.parser')
answer = ast.literal_eval(doc.getText())['results']
a = "\n".join("{}\t\t{}".format(k, v.lower()) for k, v in answer.items())
f.write('==================== [ Alberti Cipher] ====================\n' + a + '\n')
f.flush()
return a