visidata timefromts fixed

This commit is contained in:
TKE
2021-02-22 16:07:21 +01:00
parent 6116d23d30
commit db2c3f0a26

View File

@@ -3,15 +3,30 @@
from datetime import datetime from datetime import datetime
import functools import functools
def timefromts(val): def timefromts(val):
try:
return datetime.fromtimestamp(float(val)) return datetime.fromtimestamp(float(val))
except ValueError:
pass
try:
return datetime.fromtimestamp(float(val)/1000)
except ValueError:
pass
try:
return datetime.fromtimestamp(float(val)/1000000)
except ValueError:
pass
# sym-ts = hexNcoded NT-Timestamp = Nanoseconds since 01.01.1601 # sym-ts = hexNcoded NT-Timestamp = Nanoseconds since 01.01.1601
def sym_time(val): def sym_time(val):
a = int(val, 16) # decode hex a = int(val, 16) # decode hex
b=(a / 10000000) - 11644473600 #convert to seconds and subtract offset to 01.01.1970 # convert to seconds and subtract offset to 01.01.1970
b = (a / 10000000) - 11644473600
return datetime.fromtimestamp(b) return datetime.fromtimestamp(b)
@functools.lru_cache() @functools.lru_cache()
def vendor(mac): def vendor(mac):
try: try:
@@ -22,6 +37,7 @@ def vendor(mac):
except ModuleNotFoundError: except ModuleNotFoundError:
return "module not available" return "module not available"
@functools.lru_cache() @functools.lru_cache()
def dns_lookup(domain, record='A'): def dns_lookup(domain, record='A'):
if len(domain.split(",")) > 1: if len(domain.split(",")) > 1:
@@ -39,6 +55,7 @@ def dns_lookup(domain,record='A'):
except ModuleNotFoundError: except ModuleNotFoundError:
return "module not available" return "module not available"
@functools.lru_cache() @functools.lru_cache()
def _ipinfo(ip): def _ipinfo(ip):
try: try:
@@ -51,6 +68,7 @@ def _ipinfo(ip):
except ModuleNotFoundError: except ModuleNotFoundError:
return None return None
@functools.lru_cache() @functools.lru_cache()
def ipinfo(ip, type="country"): def ipinfo(ip, type="country"):
if len(ip.split(",")) > 1: if len(ip.split(",")) > 1:
@@ -60,6 +78,7 @@ def ipinfo(ip,type="country"):
except: except:
return "" return ""
@functools.lru_cache() @functools.lru_cache()
def mx_lookup(domain): def mx_lookup(domain):
domain = domain.lstrip("www.") domain = domain.lstrip("www.")
@@ -70,6 +89,7 @@ def mx_lookup(domain):
except Exception as e: except Exception as e:
return str(e) return str(e)
@functools.lru_cache() @functools.lru_cache()
def grab_banner(ip, port=25): def grab_banner(ip, port=25):
if len(ip.split(",")) > 1: if len(ip.split(",")) > 1:
@@ -85,8 +105,6 @@ def grab_banner(ip,port=25):
return "" return ""
def sym_id(val): def sym_id(val):
event_ids = { event_ids = {
"2": "Scan Stopped", "2": "Scan Stopped",