2014-01-15 11:01:23 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
2014-02-03 00:57:14 +02:00
|
|
|
#Malware DB - the most awesome free malware database on the air
|
|
|
|
|
#Copyright (C) 2014, Yuval Nativ, Lahad Ludar, 5Fingers
|
2014-01-15 11:01:23 +02:00
|
|
|
|
2014-02-03 00:57:14 +02:00
|
|
|
#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.
|
2014-01-15 11:01:23 +02:00
|
|
|
|
2014-02-03 00:57:14 +02:00
|
|
|
#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.
|
2014-01-15 11:01:23 +02:00
|
|
|
|
2014-02-03 00:57:14 +02:00
|
|
|
#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
|
2014-01-15 11:01:23 +02:00
|
|
|
|
2014-02-03 00:57:14 +02:00
|
|
|
__version__ = "0.4.2 Arthur"
|
2014-01-15 19:01:37 +02:00
|
|
|
__appname__ = "Malware DB"
|
2014-02-03 00:57:14 +02:00
|
|
|
__authors__ = ["Yuval Nativ","Lahad Ludar","5Fingers"]
|
2014-01-15 19:01:37 +02:00
|
|
|
__licensev__ = "GPL v3.0"
|
2014-02-03 00:57:14 +02:00
|
|
|
__maintainer = "Yuval Nativ"
|
2014-01-15 19:01:37 +02:00
|
|
|
__status__ = "Development"
|
|
|
|
|
|
2014-01-15 11:01:23 +02:00
|
|
|
import sys
|
|
|
|
|
import getopt
|
|
|
|
|
import csv
|
2014-02-03 00:57:14 +02:00
|
|
|
import os
|
|
|
|
|
from imports.updatehandler import Updater
|
|
|
|
|
from imports.eula_handler import EULA
|
|
|
|
|
from imports.globals import vars
|
|
|
|
|
from imports.terminal_handler import Controller
|
2014-01-20 10:21:05 +02:00
|
|
|
|
2014-01-15 11:01:23 +02:00
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
2014-02-03 00:57:14 +02:00
|
|
|
# Much much imports :)
|
|
|
|
|
updateHandler = Updater
|
|
|
|
|
eulaHandler = EULA()
|
|
|
|
|
bannerHandler = muchmuchstrings.banners()
|
|
|
|
|
terminalHandler = Controller()
|
2014-01-20 10:21:05 +02:00
|
|
|
|
2014-01-20 12:28:57 +02:00
|
|
|
|
2014-01-20 10:21:05 +02:00
|
|
|
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
|
|
|
|
|
|
2014-01-20 12:28:57 +02:00
|
|
|
def filter_array(array, colum, value):
|
2014-01-20 10:21:05 +02:00
|
|
|
ret_array = [row for row in array if value in row[colum]]
|
|
|
|
|
return ret_array
|
|
|
|
|
|
|
|
|
|
def print_results(array):
|
2014-02-03 00:57:14 +02:00
|
|
|
# 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]
|
2014-01-20 10:21:05 +02:00
|
|
|
print answer
|
|
|
|
|
|
2014-02-03 00:57:14 +02:00
|
|
|
|
|
|
|
|
# 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 = ""
|
2014-01-20 10:21:05 +02:00
|
|
|
|
|
|
|
|
# Checking for EULA Agreement
|
2014-02-03 00:57:14 +02:00
|
|
|
a = eulaHandler.check_eula_file()
|
2014-01-20 10:21:05 +02:00
|
|
|
if a == 0:
|
2014-02-03 00:57:14 +02:00
|
|
|
eulaHandler.prompt_eula()
|
2014-01-20 10:21:05 +02:00
|
|
|
|
|
|
|
|
# Get arguments
|
|
|
|
|
for opt, arg in options:
|
|
|
|
|
if opt in ('-h', '--help'):
|
2014-02-03 00:57:14 +02:00
|
|
|
print vars.fulllicense
|
|
|
|
|
print vars.useage
|
2014-01-20 10:21:05 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
elif opt in ('-u', '--update'):
|
2014-02-03 00:57:14 +02:00
|
|
|
updateHandler.update_db()
|
|
|
|
|
sys.exit(1)
|
2014-01-20 10:21:05 +02:00
|
|
|
elif opt in ('-v', '--version'):
|
2014-02-03 00:57:14 +02:00
|
|
|
bannerHandler.versionbanner()
|
2014-01-20 10:21:05 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
elif opt in '-w':
|
2014-02-03 00:57:14 +02:00
|
|
|
bannerHandler.print_license()
|
2014-01-20 10:21:05 +02:00
|
|
|
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
|
2014-02-03 00:57:14 +02:00
|
|
|
a = updateHandler.get_maldb_ver()
|
2014-01-20 10:21:05 +02:00
|
|
|
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
|
2014-02-03 00:57:14 +02:00
|
|
|
csvReader = csv.reader(open(vars.main_csv_file, 'rb'), delimiter=',')
|
2014-01-20 10:21:05 +02:00
|
|
|
for row in csvReader:
|
|
|
|
|
m.append(row)
|
|
|
|
|
|
|
|
|
|
# Filter by type
|
|
|
|
|
if len(type_of_mal) > 0:
|
2014-02-03 00:57:14 +02:00
|
|
|
m = filter_array(m, vars.column_for_type, type_of_mal)
|
2014-01-20 10:21:05 +02:00
|
|
|
|
|
|
|
|
# Filter by programming language
|
|
|
|
|
if len(pl) > 0:
|
2014-02-03 00:57:14 +02:00
|
|
|
m = filter_array(m, vars.column_for_pl, pl)
|
2014-01-20 10:21:05 +02:00
|
|
|
|
2014-02-03 00:57:14 +02:00
|
|
|
os.system('clear')
|
|
|
|
|
print vars.maldb_banner
|
|
|
|
|
while 1:
|
|
|
|
|
terminalHandler.MainMenu()
|
|
|
|
|
sys.exit(1)
|
2014-01-15 11:01:23 +02:00
|
|
|
|
2014-01-20 12:28:57 +02:00
|
|
|
|
2014-01-15 11:01:23 +02:00
|
|
|
if __name__ == "__main__":
|
2014-01-20 10:21:05 +02:00
|
|
|
main()
|