rahulreshma's picture
download
raw
2.08 kB
import os
from multiprocessing.dummy import Pool as ThreadPool
from datetime import timezone, datetime as dat
import time
import sys
import requests
import glob
def get_snap(port):
if (p_chk(port)):
try:
cmd=f""" vncdo -t {tmout} -s {ip}::{port} -p trofacor capture VNC_Snaps/{dt}/{ip_dir}/{port}/{tm}.jpg """
os.system(f""" mkdir -p VNC_Snaps/{dt}/{ip_dir} """)
os.system(f""" mkdir -p VNC_Snaps/{dt}/{ip_dir}/{port} """)
if os.system(cmd) == 0:
wrkng_p.append(port)
if len(glob.glob(f"VNC_Snaps/{dt}/{ip_dir}/{port}/{tm}.jpg"))>0:
sccs_port.append(port)
#print(port)
else:
print(cmd.strip())
except Exception as e:
#print(e, port)
pass
else:
pass
def p_chk(port):
try:
rsp=requests.get(f"http://{ip}:{port}", timeout=30)
except requests.exceptions.ConnectionError as e:
if ('RFB' in str(e)):
op_ports.append(port)
#print("Prt", port)
#get_snap(ip,port)
return True
except Exception as e:
print(str(e))
return False
return False
op_ports=[]
wrkng_p=[]
sccs_port=[]
#ip="176.9.28.121"
ip=sys.argv[2]
ip_dir=ip.replace(".","_")
p_st=sys.argv[3]
p_end=sys.argv[4]
dt=sys.argv[5]
tm=f"{dat.now(timezone.utc):%Y%m%d_%H%M%S}"
tmout=sys.argv[1]
ports=[i for i in range(int(p_st),int(p_end))]
st_time=str(time.ctime())
pool = ThreadPool(7)
pool.map(get_snap, ports)
pool.close()
pool.join()
end_time=str(time.ctime())
print(f"\nDone\nStart: {st_time}\nEnd: {end_time}\n")
op_ports.sort()
wrkng_p.sort()
sccs_port.sort()
print(ip)
print("Open: ", op_ports)
print("Active: ", wrkng_p)
print("Success: ", sccs_port)
os.system(f""" mkdir -p VNC_Snaps/Active_{ip_dir} """)
os.system(f""" rm -rf VNC_Snaps/Active_{ip_dir}/*.jpg """)
try:
for i in sccs_port:
os.system(f""" cp -f VNC_Snaps/{dt}/{ip_dir}/{i}/{tm}.jpg VNC_Snaps/Active_{ip_dir}/{i}.jpg """)
except:
pass

Xet Storage Details

Size:
2.08 kB
·
Xet hash:
f8355e8abeaab4f181c292a4ea318305431f2df119f2b984bd743968ee3bc76f

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.