Files
theZoo/malware-db.py
2014-02-03 00:57:14 +02:00

138 lines
4.0 KiB
Python

#!/usr/bin/env python
#Malware DB - the most awesome free malware database on the air
#Copyright (C) 2014, Yuval Nativ, Lahad Ludar, 5Fingers
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
from imports import muchmuchstrings
__version__ = "0.4.2 Arthur"
__appname__ = "Malware DB"
__authors__ = ["Yuval Nativ","Lahad Ludar","5Fingers"]
__licensev__ = "GPL v3.0"
__maintainer = "Yuval Nativ"
__status__ = "Development"
import sys
import getopt
import csv
import os
from imports.updatehandler import Updater
from imports.eula_handler import EULA
from imports.globals import vars
from imports.terminal_handler import Controller
def main():
# Much much imports :)
updateHandler = Updater
eulaHandler = EULA()
bannerHandler = muchmuchstrings.banners()
terminalHandler = Controller()
def checkresults(array):
if len(array) == 0:
print "No results found\n\n"
sys.exit(1)
def checkargs():
print "Type: " + type_of_mal
print "Lang: " + pl
print "Search: " + search
def filter_array(array, colum, value):
ret_array = [row for row in array if value in row[colum]]
return ret_array
def print_results(array):
# print_results will suprisingly print the results...
answer = array[vars.column_for_uid] + "\t" + array[vars.column_for_name]+ "\t" + array[vars.column_for_version] + "\t\t"
answer += array[vars.column_for_location] + "\t\t" + array[vars.colomn_for_time]
print answer
# Here actually starts Main()
options, remainder = getopt.getopt(sys.argv[1:], 'hwuvs:p:t:', ['type=', 'language=', 'search=', 'help', 'update', 'version', 'dbv' ])
# Zeroing everything
type_of_mal = ""
pl = ""
search = ""
new =""
update=0
m=[];
f = ""
# Checking for EULA Agreement
a = eulaHandler.check_eula_file()
if a == 0:
eulaHandler.prompt_eula()
# Get arguments
for opt, arg in options:
if opt in ('-h', '--help'):
print vars.fulllicense
print vars.useage
sys.exit(1)
elif opt in ('-u', '--update'):
updateHandler.update_db()
sys.exit(1)
elif opt in ('-v', '--version'):
bannerHandler.versionbanner()
sys.exit(1)
elif opt in '-w':
bannerHandler.print_license()
sys.exit(1)
elif opt in ('-t', '--type'):
type_of_mal = arg
elif opt in ('-p', '--language'):
pl = arg
elif opt in ('-s', '--search'):
search = arg
elif opt in '--dbv':
# Getting version of malware-DB's database
a = updateHandler.get_maldb_ver()
if a == 0:
sys.exit(0)
elif len(a) > 0:
print ''
print "Malware-DB Database's version is: " + a
sys.exit()
# Take index.csv and convert into array m
csvReader = csv.reader(open(vars.main_csv_file, 'rb'), delimiter=',')
for row in csvReader:
m.append(row)
# Filter by type
if len(type_of_mal) > 0:
m = filter_array(m, vars.column_for_type, type_of_mal)
# Filter by programming language
if len(pl) > 0:
m = filter_array(m, vars.column_for_pl, pl)
os.system('clear')
print vars.maldb_banner
while 1:
terminalHandler.MainMenu()
sys.exit(1)
if __name__ == "__main__":
main()