-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpcheck.py
executable file
·64 lines (59 loc) · 2.02 KB
/
httpcheck.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python3
# Retrieving SSH host key and verifying SSH host key using Paramiko
import paramiko
import hashlib
import base64
import subprocess
import json
import sys
sys.path.append("/usr/local/src/security/lib/")
from db_functions import read_ip_open_port_v4,write_into_ip_service_http
import requests
from selenium import webdriver
from selenium.webdriver import FirefoxOptions
import time
def get_screenshot(host,destport):
#driver = webdriver.PhantomJS()
opts = FirefoxOptions()
opts.add_argument("--headless")
driver = webdriver.Firefox(options=opts)
driver.set_window_size(1120, 550)
driver.get("http://"+host+":"+destport+"/")
time.sleep(3)
driver.get_screenshot_as_file("/usr/local/src/security/display/static/http-screenshots/"+host+"-"+destport+".png")
driver.close()
driver.quit()
def httpgetrequest(host,destport):
uri = "http://"+host+":"+destport
print(uri)
try:
response = requests.get(uri, timeout=1, verify=False)
print(response)
except:
print("false")
response = "false"
return(response)
if __name__ == '__main__':
open_ports = read_ip_open_port_v4()
for x in open_ports:
host = str(x['ip4'])
port = str(x['port'])
raw = httpgetrequest(host,port)
if raw != "false":
#print(raw.headers)
#print(raw.content)
headers = str(raw.headers)
headers_bytes = headers.encode('ascii')
base64_headers_bytes = base64.b64encode(headers_bytes)
content = str(raw.content)
content_bytes = content.encode('ascii')
base64_content_bytes = base64.b64encode(content_bytes)
#print(base64_headers_bytes)
b64content = str(base64_content_bytes)[1:]
b64headers = str(base64_headers_bytes)[1:]
#print(b64content)
try:
get_screenshot(host,port)
except:
print("screenshot did not work")
write_into_ip_service_http(host,port,b64headers,b64content)