patch impersonation bug
This commit is contained in:
parent
e8dd843ecf
commit
8b621c16d4
13
croxy.py
13
croxy.py
|
@ -33,6 +33,8 @@ import typer
|
|||
DEFAULT_SALT = b"CROXYSALT IS A LOW SODIUM SALT" # For pbkdf2 only
|
||||
PBKDF2_ITERATIONS = 5000
|
||||
|
||||
|
||||
|
||||
def main(host:str="ircd.chat", port:int=6697, password:str=None, listen_port:int=6667):
|
||||
if not password:
|
||||
password = getpass.getpass("Today's password: ")
|
||||
|
@ -206,8 +208,10 @@ def handle_server_line(line, password, local_f):
|
|||
|
||||
try:
|
||||
body = croxy_decrypt(body, password)
|
||||
body = body.replace("\r", "<CR>")
|
||||
body = body.replace("\n", "<LF>")
|
||||
except NotEncrypted:
|
||||
body = "(I) " + body
|
||||
body = "(UNENCRYPTED) " + body
|
||||
|
||||
line = start + body + "\r\n"
|
||||
|
||||
|
@ -275,7 +279,7 @@ class CloseException(Exception):
|
|||
## CRYPTO LIBRARY WRAPPERS
|
||||
# This is our only entry points to the next section.
|
||||
|
||||
def croxy_encrypt(msg, key):
|
||||
def croxy_encrypt(msg, key, discard=False):
|
||||
"""AES-256 encrypt the msg (str) with key (str).
|
||||
Returns base64 encoded (str).
|
||||
"""
|
||||
|
@ -284,6 +288,11 @@ def croxy_encrypt(msg, key):
|
|||
derived = croxy_pbkdf2(key)
|
||||
iv = os.urandom(16)
|
||||
|
||||
flags = 0b0000000
|
||||
|
||||
if discard:
|
||||
flags = flags | FLAG_DISCARD
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
cipher = AES.new(derived, AES.MODE_CBC, iv)
|
||||
|
||||
|
|
Loading…
Reference in New Issue