File size: 5,295 Bytes
3ea44ec | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | # ******************************************************
# Copyright 2004: Commonwealth of Australia.
#
# Developed by the Computer Network Vulnerability Team,
# Information Security Group.
# Department of Defence.
#
# Michael Cohen <scudette@users.sourceforge.net>
#
# ******************************************************
# Version: FLAG $Version: 0.87-pre1 Date: Thu Jun 12 00:48:38 EST 2008$
# ******************************************************
#
# * 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 2
# * 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, write to the Free Software
# * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# ******************************************************
""" Creates a new case database for flag """
import pyflag.Reports as Reports
import pyflag.FlagFramework as FlagFramework
import pyflag.FileSystem as FileSystem
import pyflag.DB as DB
import os
import pyflag.IO as IO
import pyflag.conf
config=pyflag.conf.ConfObject()
import pyflag.Registry as Registry
import time
import pyflag.pyflagsh as pyflagsh
description = "Case management"
order = 10
class NewCase(Reports.report):
""" Creates a new flag case database."""
parameters = {"create_case":"sqlsafe"}
name = "Create new case"
family = "Case Management"
description = "Create database for new case to load data into"
order = 10
def form(self,query,result):
result.defaults = query
result.textfield("Please enter a new case name:","create_case")
result.tz_selector("Case Timezone", "TZ")
return result
def display(self,query,result):
## Use the shell to do the heavy lifting.
try:
pyflagsh.shell_execv(command='create_case',
argv=[ query['create_case'], "TZ=%s" % query.get('TZ',"SYSTEM") ])
except RuntimeError, e:
result.heading("Problem Creating Case!")
result.para("There was a problem creating the case. Are you sure "\
"that this wasn't because a database with the same "\
"name already existed in the DB?")
result.para("Perhaps try again with a different name.")
result.link("Try again", family="Case Management",
report="Create new case")
return result
#Get handle to flag db
result.heading("Case Created")
result.para("\n\nThe database for case %s has been created" %query['create_case'])
result.link("Load a Disk Image", FlagFramework.query_type((), case=query['create_case'], family="Load Data", report="Load IO Data Source"))
result.para('')
result.link("Load a preset Log File", FlagFramework.query_type((), case=query['create_case'], family="Load Data", report="Load Preset Log File"))
return result
class DelCase(Reports.report):
""" Removes a flag case database """
parameters = {"remove_case":"flag_db"}
name = "Remove case"
family = "Case Management"
description="Remove database for specified case"
order = 20
def do_reset(self,query):
pass
def form(self,query,result):
query['remove_case']=query['case']
result.para("Please select the case to delete. Note that all data in this case will be lost.")
result.case_selector(case="remove_case")
return result
def display(self,query,result):
try:
FlagFramework.delete_case(query['remove_case'])
except DB.DBError:
pass
result.heading("Deleted case")
result.para("Case %s has been deleted" % query['remove_case'])
return result
class ResetCase(Reports.report):
""" Resets a flag case database """
parameters = {"reset_case":"flag_db"}
name = "Reset Case"
family = "Case Management"
description = "Reset a case database (delete data)"
order = 30
def form(self,query,result):
query['reset_case']=query['case']
result.para("Please select the case to reset. Note that all data in this case will be lost.")
result.case_selector(case="reset_case")
return result
def display(self,query,result):
result.heading("Reset case")
query['remove_case'] = query['reset_case']
query['create_case'] = query['reset_case']
tmp = result.__class__(result)
dbh = DB.DBO(query['reset_case'])
tz = dbh.get_meta("TZ")
report = DelCase(self.flag, self.ui)
report.display(query,tmp)
query['TZ'] = tz
report = NewCase(self.flag, self.ui)
report.display(query,tmp)
query['case'] = query['reset_case']
result.para("Case %s has been reset" % query['reset_case'])
|