forked from GoSecure/php7-opcache-override
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_id_scraper.py
More file actions
executable file
·64 lines (49 loc) · 1.63 KB
/
Copy pathsystem_id_scraper.py
File metadata and controls
executable file
·64 lines (49 loc) · 1.63 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# Copyright (c) 2016 GoSecure Inc.
import sys
import re
import requests
from md5 import md5
if len(sys.argv) != 2:
print sys.argv[0] + " [file|URL]"
exit(0)
if (sys.argv[1].startswith("http")):
text = requests.get(sys.argv[1]).text
else:
with open(sys.argv[1]) as file:
text = file.read()
file.close()
# PHP Version
php_version = re.search('<tr><td class="e">PHP Version </td><td class="v">(.*) </td></tr>', text)
if php_version == None:
php_version = re.search('<h1 class="p">PHP Version (.*)', text)
if php_version == None:
print "No PHP version found, is this a phpinfo file?"
exit(0)
php_version = php_version.group(1)
# Zend Extension Build ID
zend_extension_id = re.search('<tr><td class="e">Zend Extension Build </td><td class="v">(.*) </td></tr>', text)
if zend_extension_id == None:
print "No Zend Extension Build found."
exit(0)
zend_extension_id = zend_extension_id.group(1)
# Architecture
architecture = re.search('<tr><td class="e">System </td><td class="v">(.*) </td></tr>', text)
if architecture == None:
print "No System info found."
exit(0)
architecture = architecture.group(1).split()[-1]
# Zend Bin ID suffix
if architecture == "x86_64":
bin_id_suffix = "48888"
else:
bin_id_suffix = "44444"
zend_bin_id = "BIN_SIZEOF_CHAR" + bin_id_suffix
# Logging
print "PHP version : " + php_version
print "Zend Extension ID : " + zend_extension_id
print "Zend Bin ID : " + zend_bin_id
print "Assuming " + architecture + " architecture"
digest = md5(php_version + zend_extension_id + zend_bin_id).hexdigest()
print "------------"
print "System ID : " + digest