|
6 | 6 | from packaging import version
|
7 | 7 | import re
|
8 | 8 | import requests
|
9 |
| -from md5 import md5 |
| 9 | + |
| 10 | +def md5(data): |
| 11 | + if type(data) is str: |
| 12 | + data = bytes(data, encoding='utf-8') |
| 13 | + return __import__('hashlib').md5(data).hexdigest() |
10 | 14 |
|
11 | 15 | if len(sys.argv) != 2:
|
12 |
| - print sys.argv[0] + " [file|URL]" |
| 16 | + print(sys.argv[0] + " [file|URL]") |
13 | 17 | exit(0)
|
14 | 18 |
|
15 | 19 | if (sys.argv[1].startswith("http")):
|
|
26 | 30 | php_version = re.search('<h1 class="p">PHP Version (.*)', text)
|
27 | 31 |
|
28 | 32 | if php_version == None:
|
29 |
| - print "No PHP version found, is this a phpinfo file?" |
| 33 | + print("No PHP version found, is this a phpinfo file?") |
30 | 34 | exit(0)
|
31 | 35 |
|
32 | 36 | php_version = php_version.group(1)
|
33 | 37 | php_greater_74 = (version.parse("7.4.0") < version.parse(php_version.split("-")[0]))
|
34 |
| - |
35 | 38 | # Zend Extension Build ID
|
36 | 39 | zend_extension_id = re.search('<tr><td class="e">Zend Extension Build </td><td class="v">(.*) </td></tr>', text)
|
37 | 40 | if zend_extension_id == None:
|
38 |
| - print "No Zend Extension Build found." |
| 41 | + print("No Zend Extension Build found.") |
39 | 42 | exit(0)
|
40 | 43 | zend_extension_id = zend_extension_id.group(1)
|
41 | 44 |
|
42 | 45 | # Architecture
|
43 | 46 | architecture = re.search('<tr><td class="e">System </td><td class="v">(.*) </td></tr>', text)
|
44 | 47 | if architecture == None:
|
45 |
| - print "No System info found." |
| 48 | + print("No System info found.") |
46 | 49 | exit(0)
|
47 | 50 | architecture = architecture.group(1).split()[-1]
|
48 | 51 |
|
|
69 | 72 |
|
70 | 73 |
|
71 | 74 | # Logging
|
72 |
| -print "PHP version : " + php_version |
73 |
| -print "Zend Extension ID : " + zend_extension_id |
74 |
| -print "Zend Bin ID : " + zend_bin_id |
75 |
| -print "Assuming " + architecture + " architecture" |
| 75 | +print("PHP version : " + php_version) |
| 76 | +print("Zend Extension ID : " + zend_extension_id) |
| 77 | +print("Zend Bin ID : " + zend_bin_id) |
| 78 | +print("Assuming " + architecture + " architecture") |
76 | 79 |
|
77 |
| -digest = md5(php_version + zend_extension_id + zend_bin_id).hexdigest() |
78 |
| -print "------------" |
79 |
| -print "System ID : " + digest |
| 80 | +digest = md5(php_version + zend_extension_id + zend_bin_id) |
| 81 | +print("------------") |
| 82 | +print("System ID : " + digest) |
80 | 83 |
|
81 | 84 | if not php_greater_74:
|
82 |
| - alt_digest = md5(php_version + zend_extension_id + alt_zend_bin_id).hexdigest() |
83 |
| - print "PHP lower than 7.4 detected, an alternate Bin ID is possible:" |
84 |
| - print "Alternate Zend Bin ID : " + alt_zend_bin_id |
85 |
| - print "Alternate System ID : " + alt_digest |
| 85 | + alt_digest = md5(php_version + zend_extension_id + alt_zend_bin_id) |
| 86 | + print("PHP lower than 7.4 detected, an alternate Bin ID is possible:") |
| 87 | + print("Alternate Zend Bin ID : " + alt_zend_bin_id) |
| 88 | + print("Alternate System ID : " + alt_digest) |
0 commit comments