summaryrefslogtreecommitdiffstats
path: root/sockettest.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-31 15:09:58 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-31 15:09:58 +0200
commit69f765b2476b77967588c0751be8afda7dc3adaf (patch)
tree086bc81759dc588d7845a15e43b61867fcac591f /sockettest.py
parentMerging false heads. fix for forced commit. (diff)
downloadpyload-69f765b2476b77967588c0751be8afda7dc3adaf.tar.xz
new socket encryption
Diffstat (limited to 'sockettest.py')
-rw-r--r--sockettest.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/sockettest.py b/sockettest.py
index 882895b57..eab6608c2 100644
--- a/sockettest.py
+++ b/sockettest.py
@@ -7,31 +7,31 @@ script only for socket testing
"""
import base64
-import cPickle
+import hashlib
import random
import string
-from Crypto.Cipher import AES
-from Crypto.Hash import SHA
-from Crypto.Hash import MD5
-from module.remote.RequestObject import RequestObject
+import cPickle
+from Crypto.Cipher import Blowfish
+from module.remote.RequestObject import RequestObject
+from module.remote.ClientSocket import ClientSocket
class Handler:
def __init__(self):
- key = SHA.new("pwhere")
- key = MD5.new(key.hexdigest())
- self.aes = AES.new(key.hexdigest(), AES.MODE_ECB)
+ key = hashlib.sha256("pwhere")
+ print key.hexdigest()
+ self.bf = Blowfish.new(key.hexdigest(), Blowfish.MODE_ECB)
def proceed(self, data):
- return self.decrypt(self.encrypt(str(("lol","mehrlol","pff"))))
+ return self.decrypt(self.encrypt(str(("lol", "mehrlol", "pff"))))
def decrypt(self, dec_str):
try:
dec_str = base64.standard_b64decode(dec_str)
- dec_str = self.aes.decrypt(dec_str)
+ dec_str = self.bf.decrypt(dec_str)
- dec_str = dec_str[:-(int(dec_str[-1],16)+1)]
+ dec_str = dec_str[:-(int(dec_str[-1], 16) + 1)]
obj = cPickle.loads(dec_str)
except:
obj = None
@@ -44,11 +44,11 @@ class Handler:
p_str = ""
for i in range(padding - 1):
- p_str += random.choice(string.letters+string.digits)
- p_str += hex(len(p_str)).replace("0x","")
+ p_str += random.choice(string.letters + string.digits)
+ p_str += hex(len(p_str)).replace("0x", "")
enc_str += p_str
- enc_str = self.aes.encrypt(enc_str)
+ enc_str = self.bf.encrypt(enc_str)
enc_str = base64.standard_b64encode(enc_str)
return enc_str
@@ -65,7 +65,7 @@ obj = RequestObject()
obj.command = "exec"
obj.function = "get_downloads"
-sock.sendall(handler.encrypt(obj)+"\n")
+sock.sendall(handler.encrypt(obj) + "\n")
response = sock.recv(8192)