Module: Dorothy::DoroConfig
Instance Method Summary collapse
- #create ⇒ Object
-
#create_sandbox(sboxfile) ⇒ Object
Creates the sandbox configuration file.
- #init_home(home) ⇒ Object
-
#init_sandbox(file = "../etc/sandboxes.yml") ⇒ Object
This method will populate the dorothive table sandboxes.
Instance Method Details
#create ⇒ Object
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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/dorothy2/do-init.rb', line 31 def create puts " [WARNING]".red + " It seems that the Dorothy configuration file is not present, please answer to the following question in order to create it now. " correct = false until correct conf = Hash.new conf["sandbox"] = Hash.new conf["env"] = Hash.new conf["dorothive"] = Hash.new conf["nam"] = Hash.new conf["virustotal"] = Hash.new conf["esx"] = Hash.new conf["pcapr"] = Hash.new ################################################ ###DOROTHY ENVIRONMENT ################################################ puts "\n######### [" + " Dorothy Environment settings ".red + "] #########" puts "Please insert the home folder for dorothy [#{File.("~")}/Dorothy]" conf["env"]["home"] = (t = gets.chop).empty? ? "#{File.("~")}/Dorothy" : t home = conf["env"]["home"] puts "The Dorothy home directory is #{home}" conf["env"]["pidfile"] = "#{home}/var/dorothy.pid" conf["env"]["pidfile_parser"] = "#{home}/var/doroParser.pid" conf["env"]["analysis_dir"] = "#{home}/opt/analyzed" conf["env"]["geoip"] = "#{home}/etc/geo/GeoLiteCity.dat" conf["env"]["geoasn"] = "#{home}/etc/geo/GeoIPASNum.dat" conf["env"]["dtimeout"] = 3600 conf["env"]["logfile"] = "#{home}/var/log/dorothy.log" conf["env"]["logfile_parser"] = "#{home}/var/log/parser.log" conf["env"]["loglevel"] = 0 conf["env"]["logage"] = "weekly" ###################################################### ###DOROTHIVE ###################################################### puts "\n######### [" + " Dorothive (Dorothy DB) settings ".red + "] #########" puts "DB hostname/IP address [localhost]:" conf["dorothive"]["dbhost"] = (t = gets.chop).empty? ? "localhost" : t puts "DB Name [dorothive]:" conf["dorothive"]["dbname"] = (t = gets.chop).empty? ? "dorothive" : t puts "DB Username [postgres]:" conf["dorothive"]["dbuser"] = (t = gets.chop).empty? ? "postgres" : t puts "DB Password" conf["dorothive"]["dbpass"] = gets.chop conf["dorothive"]["ddl"] = "#{HOME}/etc/ddl/dorothive.ddl" ###################################################### ###ESX ###################################################### puts "######### [" + " ESX Environment settings ".red + "] #########" puts "Please insert the IP address of your ESX server" conf["esx"]["host"] = gets.chop puts "Please insert the ESX username" conf["esx"]["user"] = gets.chop puts "Please insert the ESX password" conf["esx"]["pass"] = gets.chop ################################################# ###SANDBOX ################################################ puts "\n######### [" + " Sandbox configuration settings ".red + "] #########" puts "Insert the time (seconds) that the Sandbox should be run before it's reverted [60]" conf["sandbox"]["sleeptime"] = (t = gets.chop).empty? ? 60 : t puts "Insert how many screenshots do you want to take [1]" conf["sandbox"]["num_screenshots"] = (t = gets.chop).empty? ? 1 : t.to_i if conf["sandbox"]["num_screenshots"] > 1 puts "Insert the time interval (seconds) between each screenshot [5] " conf["sandbox"]["screen2time"] = (t = gets.chop).empty? ? 5 : t end puts "After how many seconds do you want to take the first screenshot? [1]" conf["sandbox"]["screen1time"] = (t = gets.chop).empty? ? 1 : t ###################################################### ###NAM ###################################################### puts "\n######### [" + " Network Analysis Module (NAM) configuration ".red + "] #########" puts "Please insert the information of the host that you will use for sniffing the Sandbox traffic" puts "IP Address:" conf["nam"]["host"] = gets.chop puts "Network interface for the network sniffing: [eth0]" conf["nam"]["interface"] = (t = gets.chop).empty? ? "eth0" : t puts "Username [dorothy] :" conf["nam"]["user"] = (t = gets.chop).empty? ? "dorothy" : t puts "Password:" conf["nam"]["pass"] = gets.chop puts "SSH Port [22] :" conf["nam"]["port"] = (t = gets.chop).empty? ? 22 : t puts "Folder where to store PCAP files [/home/#{conf["nam"]["user"]}/pcaps]" conf["nam"]["pcaphome"] = (t = gets.chop).empty? ? "/home/#{conf["nam"]["user"]}/pcaps" : t ###################################################### ###PCAPR ###################################################### puts "\n######### [" + " Pcapr configuration ".red + "] #########" puts "Are you going to use Pcapr on this machine? [yes] WARNING: Pcapr is only compatible with Linux " t = gets.chop if t.empty? || t == "y" || t == "yes" conf["pcapr"]["local"] = true puts "[WARNING]".yellow + " Be careful in setting Pcapr to scan #{conf["env"]["analysis_dir"]}" conf["pcapr"]["host"] = "localhost" else conf["pcapr"]["local"] = false puts "Pcapr Host [NAM: #{conf["nam"]["host"]}]:" conf["pcapr"]["host"] = (t = gets.chop).empty? ? conf["nam"]["host"] : t end puts "Pcapr HTTP Port [8080]:" conf["pcapr"]["port"] = (t = gets.chop).empty? ? 8080 : t ###################################################### ###VIRUS TOTAL ###################################################### puts "\n######### [" + " Virus Total API ".red + "] #########" puts "In order to retrieve Virus signatures, Dorothy needs to contact VirusTotal,\n please enter your VT API key here, if you don't have one yet, go here (or press enter):\nhttps://www.virustotal.com/en/#dlg-join " conf["virustotal"]["vtapikey"] = gets.chop puts "Enable test mode? In test mode dorothy will avoid to poll Virustotal [y]" t = gets.chop (t.empty? || t == "y" || t == "yes") ? conf["env"]["testmode"] = true : conf["env"]["testmode"] = false ##########CONF FINISHED################## puts "\n######### [" + " Configuration finished ".yellow + "] #########" puts "Confirm? [y]" t = gets.chop if t.empty? || t == "y" || t == "yes" begin self.init_home(home) File.open("#{File.("~")}/.dorothy.yml", 'w+') {|f| f.write(conf.to_yaml) } FileUtils.ln_s("#{File.("~")}/.dorothy.yml", "#{home}/etc/dorothy.yml") unless Util.exists?("#{home}/etc/dorothy.yml") #copy the default extension file to the user-defined home FileUtils.cp("#{HOME}/etc/extensions.yml", "#{home}/etc/extensions.yml") correct = true puts "Configuration file has been saved in ~/.dorothy.conf and a symlink has been created in\n#{home}/etc/dorothy.yml for an easier edit." puts "\n######### [" + " Now you can restart dorothy, enjoy! ".yellow + "] #########" rescue => e puts e.inspect puts "[ERROR]".red + " Configuration aborted, please redo." FileUtils.rm("#{home}/etc/dorothy.yml") end else puts "Please reinsert the info" correct = false end end end |
#create_sandbox(sboxfile) ⇒ Object
Creates the sandbox configuration file
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/dorothy2/do-init.rb', line 228 def create_sandbox(sboxfile) correct = false until correct conf = Hash.new finished = false until finished puts "Please insert a unique name for your Sandbox (Must be the same name of the one it has in the ESX library) e.g. WinXP1" name = gets.chop conf[name] = Hash.new puts "Please insert the type of the sandbox (virtual|phisical|mobile-virtual|external) [virtual]" conf[name]["type"] = (t = gets.chop).empty? ? "virtual" : t puts ">" + conf[name]["type"] puts "Please insert the OS name [Windows]" conf[name]["os"] = (t = gets.chop).empty? ? "Windows" : t puts ">" + conf[name]["os"] puts "Please insert the OS version [XP SP2]" conf[name]["version"] = (t = gets.chop).empty? ? "XP SP2" : t puts ">" + conf[name]["version"] puts "Please insert the OS language [eng]" conf[name]["os_lang"] = (t = gets.chop).empty? ? "eng" : t puts ">" + conf[name]["os_lang"] puts "Please insert the Sandbox ipaddress" conf[name]["ipaddress"] = gets.chop puts ">" + conf[name]["ipaddress"] puts "Please insert the Sandbox username [administrator]" conf[name]["username"] = (t = gets.chop).empty? ? "administrator" : t puts ">" + conf[name]["username"] puts "Please insert the Sandbox password" conf[name]["password"] = gets.chop puts ">" + conf[name]["password"] puts "Sandbox configured. Want you to configure another one? [n]" t = gets.chop if t == "y" || t == "yes" finished = false else finished = true end end puts "Configuration finished" puts "Confirm? [y]" t = gets.chop puts t if t.empty? || t == "y" || t == "yes" File.open(sboxfile, 'w+') {|f| f.write(conf.to_yaml) } correct = true puts "Configuration file has been saved in #{sboxfile}\nYou can either modify such file directly. Enjoy!" else puts "Please reinsert the info" correct = false end end end |
#init_home(home) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dorothy2/do-init.rb', line 12 def init_home(home) puts "[INIT]".yellow + " Creating Directoy structure in #{home}" Dir.mkdir(home) unless Util.exists?("#{home}") unless Util.exists?("#{home}/opt") Dir.mkdir("#{home}/opt") Dir.mkdir("#{home}/opt/bins") Dir.mkdir("#{home}/opt/analyzed") end unless Util.exists?("#{home}/etc") Dir.mkdir("#{home}/etc") Dir.mkdir("#{home}/etc/geo") end unless Util.exists?("#{home}/var") Dir.mkdir("#{home}/var") Dir.mkdir("#{home}/var/log") end puts "[INIT]".yellow + " Done\n\n" end |
#init_sandbox(file = "../etc/sandboxes.yml") ⇒ Object
This method will populate the dorothive table sandboxes
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/dorothy2/do-init.rb', line 302 def init_sandbox(file="../etc/sandboxes.yml") conf = YAML.load_file(file) db = Insertdb.new db.begin_t LOGGER.warn "INIT", "Waring, the SandBox table is gonna be flushed, and updated with the new file" db.flush_table("sandboxes") conf.each_key do |sbox| LOGGER.info "INIT", "Inserting #{sbox}" values = conf[sbox].values_at("type", "os", "version", "os_lang", "ipaddress", "username", "password") values.insert(0, "default") values.insert(1, sbox) values.push("default") unless db.insert("sandboxes", values) #no it isn't, insert it LOGGER.fatal "INIT", " ERROR-DB, please redo the operation" db.rollback next end end db.commit db.close LOGGER.info "INIT", "Sandboxes correctly inserted into the database" end |