forked from PaloAltoNetworks/WireLurkerDetector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecryptor.py
40 lines (27 loc) · 992 Bytes
/
decryptor.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Decrypting the encrypted C&C traffic in version C of WireLurker. """
__copyright__ = "Copyright (c) 2014, Palo Alto Networks, Inc."
__author__ = "Claud Xiao"
import sys
import base64
try:
import pyDes
except ImportError:
print 'ERROR: the script requires pyDes library installed! ' \
'Please run this command to install it: \n' \
'# pip install pyDes --allow-external pyDes --allow-unverified pyDes\n'
sys.exit(-1)
def main():
if len(sys.argv) != 2:
print 'Usage: %s <encrypted_message>'
sys.exit(-1)
original_data = sys.argv[1]
session_key = '%d' % sum([int(c) for c in original_data[:10]])
key = session_key + 'dksyel'
encrypted_data = original_data[10:]
des_cryptor = pyDes.des(key, pyDes.ECB, padmode=pyDes.PAD_PKCS5)
plaintext = des_cryptor.decrypt(base64.b64decode(encrypted_data))
print plaintext
if __name__ == '__main__':
main()