Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #809 from lsfxz/master
Browse files Browse the repository at this point in the history
Make compatible with more recent pyopenssl
  • Loading branch information
xorrior authored Nov 9, 2017
2 parents d1b9683 + 774a439 commit 41bfb6c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
11 changes: 3 additions & 8 deletions data/agent/stagers/dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,9 @@

# If a secure random number generator is unavailable, exit with an error.
try:
try:
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except (AttributeError, ImportError):
import OpenSSL
random_function = OpenSSL.rand.bytes
random_provider = "OpenSSL"
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except:
random_function = os.urandom
random_provider = "os.urandom"
Expand Down
11 changes: 3 additions & 8 deletions data/agent/stagers/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,9 @@

# If a secure random number generator is unavailable, exit with an error.
try:
try:
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except (AttributeError, ImportError):
import OpenSSL
random_function = OpenSSL.rand.bytes
random_provider = "OpenSSL"
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except:
random_function = os.urandom
random_provider = "os.urandom"
Expand Down
11 changes: 5 additions & 6 deletions lib/common/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import base64
import hashlib
import hmac
import os
import string
import M2Crypto

Expand Down Expand Up @@ -57,11 +58,9 @@ def _get_byte(c):
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except (AttributeError, ImportError):
import OpenSSL
random_function = OpenSSL.rand.bytes
random_provider = "OpenSSL"

except:
random_function = os.urandom
random_provider = "os.urandom"

def pad(data):
"""
Expand Down Expand Up @@ -285,7 +284,7 @@ def genRandom(self, bits):
_rand = int.from_bytes(random_function(_bytes), byteorder='big')
except:
# Python 2
_rand = int(OpenSSL.rand.bytes(_bytes).encode('hex'), 16)
_rand = int(random_function(_bytes).encode('hex'), 16)

return _rand

Expand Down
8 changes: 4 additions & 4 deletions setup/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if lsb_release -d | grep -q "Fedora"; then
pip install flask
pip install macholib
pip install dropbox
pip install 'pyopenssl==17.2.0'
pip install pyopenssl
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
Expand All @@ -44,7 +44,7 @@ elif lsb_release -d | grep -q "Kali"; then
pip install flask
pip install macholib
pip install dropbox
pip install 'pyopenssl==17.2.0'
pip install pyopenssl
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
Expand Down Expand Up @@ -85,7 +85,7 @@ elif lsb_release -d | grep -q "Ubuntu"; then
pip install pyOpenSSL
pip install macholib
pip install dropbox
pip install 'pyopenssl==17.2.0'
pip install pyopenssl
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
Expand Down Expand Up @@ -115,7 +115,7 @@ else
pip install dropbox
pip install cryptography
pip install pyOpenSSL
pip install 'pyopenssl==17.2.0'
pip install pyopenssl
pip install zlib_wrapper
pip install netifaces
pip install M2Crypto
Expand Down

0 comments on commit 41bfb6c

Please sign in to comment.