Skip to content

Commit

Permalink
enables naviScan
Browse files Browse the repository at this point in the history
  • Loading branch information
s4dhulabs committed Apr 23, 2023
1 parent 554e3c9 commit c408f30
Show file tree
Hide file tree
Showing 91 changed files with 2,060 additions and 296 deletions.
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
###############################################
###############################################
##~ Vimana Framework Docker image builder ~##
###############################################
###############################################
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

FROM python:3.9-slim-buster

LABEL MAINTAINER="s4dhu <s4dhul4bs[dot]protonmail[at]ch>"
Expand Down
13 changes: 13 additions & 0 deletions core/_dbops_/database.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
Expand Down
Binary file modified core/_dbops_/db/vmnf.db
Binary file not shown.
47 changes: 41 additions & 6 deletions core/_dbops_/db_utils.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,67 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

import os
from datetime import datetime
from res.vmnf_banners import case_header
from neotermcolor import cprint,colored as cl

def get_elapsed_time(entry):
scan_date = entry.scan_date
time_diff = datetime.now() - entry.scan_date

def get_elapsed_time(entry, str_date=False):
if str_date:
scan_date = datetime.strptime(str_date, '%Y-%m-%dT%H:%M:%S')
else:
scan_date = entry.scan_date

time_diff = datetime.now() - scan_date
hour_ = 'hour'
minute_ = 'minute'
day_ = 'day'
year_ = 'year'
month_ = 'month'

if time_diff.days > 365:
time_ = time_diff.days // 365
if time_ > 1:
year_ += 's'
exec_ = f'{time_} {year_} ago'

if time_diff.days > 1:
time_ = time_diff.days
elif time_diff.days > 30:
time_ = time_diff.days // 30
if time_ > 1:
month_ += 's'
exec_ = f'{time_} {month_} ago'

elif time_diff.days > 1:
if time_diff.days > 1:
day_ += 's'
exec_ = f'{time_} {day_} ago'
exec_ = f'{time_diff.days} {day_} ago'

elif time_diff.days == 1:
exec_ = 'Yesterday'

elif time_diff.seconds >= 3600:
time_ = time_diff.seconds // 3600
if time_ > 1:
hour_ += 's'
exec_ = f'{time_} {hour_} ago'

elif time_diff.seconds >= 60:
time_ = time_diff.seconds // 60
if time_ > 1:
minute_ += 's'
exec_ = f'{time_} {minute_} ago'

else:
exec_ = 'Just now'

Expand Down
41 changes: 39 additions & 2 deletions core/_dbops_/models/scans.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
from ..database import db
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

from ..database import db
from sqlalchemy.types import JSON

class VFScans(db.Model):
__tablename__ = '_SCANS_'
Expand Down Expand Up @@ -33,6 +46,10 @@ class VFScans(db.Model):
db.String(100),
nullable = False
)
scan_target_full_path = db.Column(
db.String(300),
nullable = False
)
scan_cache_dir = db.Column(
db.String(300),
nullable = False
Expand Down Expand Up @@ -65,6 +82,26 @@ class VFScans(db.Model):
db.Integer,
nullable = False
)
scan_scope = db.Column(
JSON,
unique = False,
nullable = False
)
scan_plugin = db.Column(
db.String(20),
unique = False,
nullable = True
)
vmnf_handler = db.Column(
JSON,
unique = False,
nullable = False
)
plugin_instance = db.Column(
JSON,
unique = False,
nullable = False
)

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand All @@ -73,5 +110,5 @@ def to_dict(self) -> dict:
return {c.name: getattr(self, c.name) for c in self.__table__.columns}

def __repr__(self):
return f"<VFAnalysis: session={self.scan_id}>"
return f"<VFScans: scan_id={self.scan_id}>"

13 changes: 13 additions & 0 deletions core/_dbops_/models/sessions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

from ..database import db


Expand Down
13 changes: 13 additions & 0 deletions core/_dbops_/models/siddhis.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

from ..database import db
from sqlalchemy.ext.mutable import MutableList
from sqlalchemy import PickleType
Expand Down
24 changes: 23 additions & 1 deletion core/_dbops_/vmnf_dbops.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

from .models.sessions import VFSessions as VFS
from .models.siddhis import Siddhis as VFSD
from .models.scans import VFScans
Expand Down Expand Up @@ -28,6 +41,9 @@ def __init__(self, **vmnf_handler):

def list_resource(self, _TABLE_, filters):
if not self.table_exists(_TABLE_):
if _TABLE_ != '_SIDDHIS_':
return False

handle_OpErr('no such table:')

vf_model = self.tbl_model[_TABLE_]
Expand Down Expand Up @@ -66,10 +82,16 @@ def getall(self, _MODEL_):
handle_OpErr(str(OE.orig))

def get_by_id(self, _MODEL_, obj_id_col, obj_id):
vf_model = self.tbl_model[_MODEL_]
if not self.table_exists(_MODEL_):
# plugins should be loaded with load --plugins
if _MODEL_ not in ['_SIDDHIS_']:
self.create_table(vf_model)
# id doesn't exist
return False

handle_OpErr('no such table:')

vf_model = self.tbl_model[_MODEL_]
model_attr = getattr(vf_model, obj_id_col)
return vf_model.query.filter(model_attr==obj_id).first()

Expand Down
13 changes: 13 additions & 0 deletions core/load_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

import yaml
from os.path import dirname

Expand Down
19 changes: 17 additions & 2 deletions core/vmnf_arg_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# -*- coding: utf-8 -*-

# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

from neotermcolor import colored,cprint
from datetime import datetime
Expand Down Expand Up @@ -72,6 +82,8 @@ def parse_args(self):
list_cmd.add_argument('--plugins', action='store_true',dest='module_list')
list_cmd.add_argument('--siddhis', action='store_true',dest='module_list')
list_cmd.add_argument('--scans', action='store_true',dest='list_scans')
list_cmd.add_argument('-i', '--interactive', action='store_true', dest='navigation_mode')
list_cmd.add_argument('--nav', action='store_true', dest='navigation_mode')
list_cmd.add_argument('-t', '--type', action='store')
list_cmd.add_argument('-c', '--category', action='store', dest='category')
list_cmd.add_argument('-f', '--framework', action='store', dest='framework')
Expand Down Expand Up @@ -136,6 +148,7 @@ def parse_args(self):
run_cmd.add_argument('--exec-case', action='store_true', default=False)
run_cmd.add_argument("--exit-on-trigger", action="store_true", dest='exit_on_trigger')
run_cmd.add_argument("--disable-external", action="store_true", dest='external_disabled')
run_cmd.add_argument("--vf-debugger", action="store_true", dest='vf_debugger')
# -----------------------------------------------------------------
# 'info' command overview
# -----------------------------------------------------------------
Expand Down Expand Up @@ -244,13 +257,15 @@ def start_handler(self):
list_cases = False,
list_sessions = False,
list_scans = False,
navigation_mode = False,
navi = False,
save_case = False,
case_file = False,
runner_mode = False,
runner_tasks = False,
docker_scope = False,
exit_on_trigger = False,
vmnf_debugger = False,
vf_debugger = False,
load_session = False,
load_plugins = False,
flush_sessions = False,
Expand Down
13 changes: 13 additions & 0 deletions core/vmnf_asserts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

from helpers.vmnf_helpers import VimanaHelp
from res.vmnf_banners import s4dhu0nv1m4n4

Expand Down
19 changes: 13 additions & 6 deletions core/vmnf_cases.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.


from res.vmnf_banners import mdtt1,case_header,vmn05,create_status
from res.vmnf_validators import check_file
Expand All @@ -8,12 +21,6 @@
from time import sleep








class CasManager:
def __init__(self, search_case, handler):
self.handler = handler
Expand Down
13 changes: 13 additions & 0 deletions core/vmnf_check_target.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# -*- coding: utf-8 -*-
# __ _
# \/imana 2016
# [|-ramewørk
#
#
# Author: s4dhu
# Email: <s4dhul4bs[at]prontonmail[dot]ch
# Git: @s4dhulabs
# Mastodon: @s4dhu
#
# This file is part of Vimana Framework Project.

from res.session.vmnf_proxies import _set_socks_
from settings.siddhis_shared_settings import common
from neotermcolor import colored,cprint
Expand Down
Loading

0 comments on commit c408f30

Please sign in to comment.