antfarm 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/CHANGELOG +9 -0
  2. data/{README → README.rdoc} +39 -5
  3. data/bin/antfarm +37 -4
  4. data/db/migrate/010_create_dns_entries.rb +32 -0
  5. data/db/migrate/011_create_actions.rb +34 -0
  6. data/db/migrate/012_create_services.rb +36 -0
  7. data/db/migrate/013_create_operating_systems.rb +34 -0
  8. data/db/schema.rb +30 -22
  9. data/lib/antfarm.jar +0 -0
  10. data/lib/antfarm.rb +4 -0
  11. data/lib/antfarm/action.rb +29 -0
  12. data/lib/antfarm/dns_entry.rb +23 -0
  13. data/lib/antfarm/ip_interface.rb +38 -26
  14. data/lib/antfarm/ip_network.rb +3 -3
  15. data/lib/antfarm/layer2_interface.rb +16 -3
  16. data/lib/antfarm/layer3_network.rb +4 -4
  17. data/lib/antfarm/node.rb +6 -0
  18. data/lib/antfarm/operating_system.rb +25 -0
  19. data/lib/antfarm/service.rb +25 -0
  20. data/lib/console.rb +9 -0
  21. data/lib/cpscript.rb +70 -0
  22. data/lib/dbmanage.rb +34 -5
  23. data/lib/init/initializer.rb +25 -3
  24. data/lib/scparse.rb +14 -1
  25. data/lib/scripts/cisco/parse-pix-config.rb +5 -14
  26. data/lib/scripts/manipulate-dns.rb +87 -0
  27. data/lib/scripts/nmap/parse-xml.rb +147 -0
  28. data/lib/scripts/pcap/parse-pcap-file.rb +83 -21
  29. data/lib/scripts/viz/display-networks.rb +16 -25
  30. data/lib/scripts/viz/display-traffic.rb +111 -0
  31. data/lib/scripts/viz/dump-graphml.rb +1 -1
  32. data/lib/version.rb +5 -0
  33. data/rails/app/controllers/actions_controller.rb +5 -0
  34. data/rails/app/controllers/dns_entries_controller.rb +4 -0
  35. data/rails/app/controllers/layer3_interfaces_controller.rb +2 -2
  36. data/rails/app/controllers/nodes_controller.rb +4 -4
  37. data/rails/app/controllers/operating_systems_controller.rb +5 -0
  38. data/rails/app/controllers/services_controller.rb +5 -0
  39. data/rails/app/controllers/traffic_controller.rb +1 -0
  40. data/rails/app/views/layouts/application.html.erb +35 -0
  41. data/rails/public/stylesheets/site.css +11 -0
  42. metadata +26 -35
  43. data/lib/scripts/load-route.rb +0 -79
  44. data/lib/scripts/load-router-nomac.rb +0 -60
  45. data/lib/scripts/load-router.rb +0 -59
  46. data/lib/scripts/nmap/parse-xml-results.rb +0 -240
  47. data/lib/scripts/route.rb +0 -89
  48. data/lib/scripts/tethereal/load-arp.rb +0 -67
  49. data/lib/scripts/tethereal/load-ip.rb +0 -65
  50. data/rails/app/helpers/application_helper.rb +0 -3
  51. data/rails/app/helpers/ethernet_interfaces_helper.rb +0 -2
  52. data/rails/app/helpers/ip_interfaces_helper.rb +0 -2
  53. data/rails/app/helpers/ip_networks_helper.rb +0 -2
  54. data/rails/app/helpers/layer2_interfaces_helper.rb +0 -2
  55. data/rails/app/helpers/layer3_interfaces_helper.rb +0 -5
  56. data/rails/app/helpers/layer3_networks_helper.rb +0 -2
  57. data/rails/app/helpers/nodes_helper.rb +0 -2
  58. data/rails/app/helpers/private_networks_helper.rb +0 -2
  59. data/rails/app/helpers/traffic_helper.rb +0 -2
  60. data/rails/app/views/layouts/ethernet_interfaces.html.erb +0 -15
  61. data/rails/app/views/layouts/ip_interfaces.html.erb +0 -15
  62. data/rails/app/views/layouts/ip_networks.html.erb +0 -15
  63. data/rails/app/views/layouts/layer2_interfaces.html.erb +0 -15
  64. data/rails/app/views/layouts/layer3_interfaces.html.erb +0 -15
  65. data/rails/app/views/layouts/layer3_networks.html.erb +0 -15
  66. data/rails/app/views/layouts/nodes.html.erb +0 -15
  67. data/rails/app/views/layouts/private_networks.html.erb +0 -15
  68. data/rails/app/views/layouts/traffic.html.erb +0 -15
  69. data/rails/public/000-index.html +0 -277
data/CHANGELOG CHANGED
@@ -1,5 +1,14 @@
1
1
  ANTFARM CHANGELOG
2
2
 
3
+ VERSION 0.4.0
4
+ * Added support for PostgreSQL database
5
+ * Added ANTFARM console command, which initializes an IRB console with the ANTFARM environment
6
+ * Added ANTFARM db --console option, which determines the database adapter being used and executes the appropriate database console command
7
+ * Added ANTFARM cp-script command, which takes an existing ANTFARM core script and copies it to the user's custom script directory for use as a template
8
+ * Updated Nmap XML parser script
9
+ * Added visualization file for the traffic table
10
+ * Modified the visualization file for networks to leave out traffic data
11
+
3
12
  VERSION 0.3.0
4
13
  * Added Prefuse-based vizualization application and script to execute it with
5
14
  * Added defaults file so users can specify default environment and log level
@@ -3,7 +3,8 @@
3
3
  ANTFARM is a passive network mapping application that utilizes
4
4
  output from existing network examination tools to populate its
5
5
  OSI-modeled database. This data can then be used to form a
6
- 'picture' of the network being analyzed.
6
+ 'picture' of the network being analyzed. This documentation is
7
+ consistent with version 0.3.0 of the ANTFARM software.
7
8
 
8
9
  == More About ANTFARM
9
10
 
@@ -36,6 +37,12 @@ and running with ANTFARM.
36
37
  ANTFARM is packaged as a Ruby Gem, so the easiest way to install
37
38
  it is to run 'gem install ANTFARM' from the command line.
38
39
 
40
+ The default database for ANTFARM is SQLite3, so at a minimum you will
41
+ need libsqlite3-dev installed. The PostgreSQL database is also
42
+ supported (good for concurrent access), which requires the development
43
+ files for the PostgreSQL server to be installed, as well as the server
44
+ and client software and the postgres Ruby Gem.
45
+
39
46
  === Initialization
40
47
 
41
48
  ANTFARM can be ran purely from within the Gem environment, but users
@@ -54,6 +61,15 @@ Last, you need to create an actual database to store the data in.
54
61
 
55
62
  antfarm db --migrate
56
63
 
64
+ The above command will work out of the box if the SQLite3 database is used.
65
+ If you intend to use the PostgreSQL database, you must first create a database
66
+ in PostgreSQL. The name of the database should match the name of the environment
67
+ you wish to use it in.
68
+
69
+ su - postgres
70
+ createuser <username> (you will only have to do this once)
71
+ createdb antfarm (or whatever environment name you want)
72
+
57
73
  Now you're ready to start parsing files and filling the database!
58
74
 
59
75
  == Description of Contents
@@ -74,6 +90,19 @@ you do not have to specify it on the command line every time. This is probably
74
90
  also the __safer__ way to go... if you forget one time to pass the <tt>-e</tt>
75
91
  argument when using the non-default environment you could corrupt some data!
76
92
 
93
+ You can also tell the ANTFARM application to use the PostgreSQL database for
94
+ a particular environment by adding something similar to the following to your
95
+ defaults.yml file:
96
+
97
+ <env name>:
98
+ adapter: postgresql
99
+
100
+ For example, the following will tell ANTFARM to use the PostgreSQL database for
101
+ the default 'antfarm' environment:
102
+
103
+ antfarm:
104
+ adapter: postgresql
105
+
77
106
  == Example Usage
78
107
 
79
108
  Scripts are used to input data into the ANTFARM database. Multiple scripts already
@@ -152,16 +181,21 @@ If you look at <tt>HOME_DIR/.antfarm/config/colors.xml</tt>, you'll see the defa
152
181
  this application uses to decide what colors to use for nodes and edges. Modify this file
153
182
  to get the colors you want.
154
183
 
155
- == Brought To You By
156
-
157
- Original Project Author: Michael Berg, Sandia National Laboratories <mjberg@sandia.gov>
184
+ == Homepage
158
185
 
159
- Contributing Author: Bryan T. Richardson, Sandia National Laboratories <btricha@sandia.gov>
186
+ http://antfarm.rubyforge.org
160
187
 
161
188
  == RubyForge Project
162
189
 
163
190
  http://rubyforge.org/projects/antfarm
164
191
 
192
+ == GitHub Project
193
+
194
+ http://github.com/btrichardson/antfarm
195
+
196
+ All code development will take place from GitHub. The latest source code for each
197
+ ANTFARM release will be mirrored at the RubyForge project SCM as well.
198
+
165
199
  == Legal Stuff
166
200
 
167
201
  Copyright (2008) Sandia Corporation.
@@ -26,6 +26,7 @@ require 'find'
26
26
  require 'ostruct'
27
27
  require 'scparse'
28
28
  require 'dbmanage'
29
+ require 'cpscript'
29
30
  require 'yaml'
30
31
 
31
32
  if (defined? USER_DIR) && File.exists?("#{USER_DIR}/config/defaults.yml")
@@ -54,6 +55,14 @@ end
54
55
 
55
56
  app.add_command(SCParse::HelpCommand.new)
56
57
  app.add_command(Antfarm::DBManager.new)
58
+ app.add_command(Antfarm::CPScript.new)
59
+
60
+ version = SCParse::Script.new('version', 'version.rb', false)
61
+ version.set_execution_block do |cmd,args|
62
+ ARGV.clear
63
+ load cmd.path
64
+ end
65
+ app.add_command(version)
57
66
 
58
67
  rails = SCParse::Script.new('rails', 'script/server')
59
68
  rails.set_execution_block do |cmd,args|
@@ -66,6 +75,14 @@ rails.set_execution_block do |cmd,args|
66
75
  end
67
76
  app.add_command(rails)
68
77
 
78
+ console = SCParse::Script.new('console', 'console.rb', false)
79
+ console.set_execution_block do |cmd,args|
80
+ ARGV.clear
81
+ ARGV << @opts.environment
82
+ load cmd.path
83
+ end
84
+ app.add_command(console)
85
+
69
86
  # TODO: Take into account situation where a directory
70
87
  # in the user's script directory might have the same
71
88
  # name as a directory in the application's script
@@ -105,8 +122,16 @@ if defined? USER_DIR
105
122
  if File.directory?(path)
106
123
  base_name = File.basename(path)
107
124
  unless base_name == 'scripts'
125
+ # Checks to see if the 'custom' command already
126
+ # exists, and if not, creates one.
127
+ # Not doing this up front so a custom command
128
+ # will only be created if custom scripts exist.
129
+ if (custom = app.has_command?('custom')) == nil
130
+ custom = SCParse::Command.new('custom')
131
+ app.add_command(custom)
132
+ end
108
133
  command = SCParse::Command.new(base_name)
109
- app.add_command(command)
134
+ custom.add_command(command)
110
135
  sub_commands[base_name] = command
111
136
  end
112
137
  elsif File.file?(path) && path =~ /rb$/
@@ -119,7 +144,16 @@ if defined? USER_DIR
119
144
  load cmd.path
120
145
  end
121
146
  if dir == 'scripts'
122
- app.add_command(script)
147
+ # Checks to see if the 'custom' command already
148
+ # exists, and if not, creates one. Not doing this
149
+ # up front so a custom command will only be created
150
+ # if custom scripts exist.
151
+ if (custom = app.has_command?('custom')) == nil
152
+ custom = SCParse::Command.new('custom')
153
+ app.add_command(custom)
154
+ sub_commands['custom'] = custom
155
+ end
156
+ custom.add_command(script)
123
157
  else
124
158
  sub_commands[dir].add_command(script)
125
159
  end
@@ -130,8 +164,7 @@ end
130
164
  def bootstrap
131
165
  ENV['ANTFARM_ENV'] = @opts.environment
132
166
  ENV['ANTFARM_LOG_LEVEL'] = @opts.log_level
133
- require ANTFARM_ROOT + "/config/environment"
167
+ require "#{ANTFARM_ROOT}/config/environment"
134
168
  end
135
169
 
136
170
  app.parse!
137
-
@@ -0,0 +1,32 @@
1
+ # Copyright (2008) Sandia Corporation.
2
+ # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
3
+ # the U.S. Government retains certain rights in this software.
4
+ #
5
+ # Original Author: Bryan T. Richardson, Sandia National Laboratories <btricha@sandia.gov>
6
+ #
7
+ # This library is free software; you can redistribute it and/or modify it
8
+ # under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation; either version 2.1 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # This library is distributed in the hope that it will be useful, but WITHOUT
13
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15
+ # details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this library; if not, write to the Free Software Foundation, Inc.,
19
+ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+
21
+ class CreateDnsEntries < ActiveRecord::Migration
22
+ def self.up
23
+ create_table :dns_entries do |t|
24
+ t.string :address
25
+ t.string :hostname
26
+ end
27
+ end
28
+
29
+ def self.down
30
+ drop_table :dns_entries
31
+ end
32
+ end
@@ -0,0 +1,34 @@
1
+ # Copyright (2008) Sandia Corporation.
2
+ # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
3
+ # the U.S. Government retains certain rights in this software.
4
+ #
5
+ # Original Author: Bryan T. Richardson, Sandia National Laboratories <btricha@sandia.gov>
6
+ #
7
+ # This library is free software; you can redistribute it and/or modify it
8
+ # under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation; either version 2.1 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # This library is distributed in the hope that it will be useful, but WITHOUT
13
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15
+ # details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this library; if not, write to the Free Software Foundation, Inc.,
19
+ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+
21
+ class CreateActions < ActiveRecord::Migration
22
+ def self.up
23
+ create_table :actions do |t|
24
+ t.string :tool
25
+ t.string :description
26
+ t.string :start
27
+ t.string :end
28
+ end
29
+ end
30
+
31
+ def self.down
32
+ drop_table :actions
33
+ end
34
+ end
@@ -0,0 +1,36 @@
1
+ # Copyright (2008) Sandia Corporation.
2
+ # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
3
+ # the U.S. Government retains certain rights in this software.
4
+ #
5
+ # Original Author: Bryan T. Richardson, Sandia National Laboratories <btricha@sandia.gov>
6
+ #
7
+ # This library is free software; you can redistribute it and/or modify it
8
+ # under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation; either version 2.1 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # This library is distributed in the hope that it will be useful, but WITHOUT
13
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15
+ # details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this library; if not, write to the Free Software Foundation, Inc.,
19
+ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+
21
+ class CreateServices < ActiveRecord::Migration
22
+ def self.up
23
+ create_table :services do |t|
24
+ t.float :certainty_factor, :null => false
25
+ t.references :node
26
+ t.references :action
27
+ t.string :protocol
28
+ t.integer :port
29
+ t.string :name
30
+ end
31
+ end
32
+
33
+ def self.down
34
+ drop_table :services
35
+ end
36
+ end
@@ -0,0 +1,34 @@
1
+ # Copyright (2008) Sandia Corporation.
2
+ # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
3
+ # the U.S. Government retains certain rights in this software.
4
+ #
5
+ # Original Author: Bryan T. Richardson, Sandia National Laboratories <btricha@sandia.gov>
6
+ #
7
+ # This library is free software; you can redistribute it and/or modify it
8
+ # under the terms of the GNU Lesser General Public License as published by
9
+ # the Free Software Foundation; either version 2.1 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # This library is distributed in the hope that it will be useful, but WITHOUT
13
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15
+ # details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with this library; if not, write to the Free Software Foundation, Inc.,
19
+ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
+
21
+ class CreateOperatingSystems < ActiveRecord::Migration
22
+ def self.up
23
+ create_table :operating_systems do |t|
24
+ t.float :certainty_factor, :null => false
25
+ t.references :node
26
+ t.references :action
27
+ t.text :fingerprint
28
+ end
29
+ end
30
+
31
+ def self.down
32
+ drop_table :operating_systems
33
+ end
34
+ end
@@ -1,25 +1,5 @@
1
- # Copyright (2008) Sandia Corporation.
2
- # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
3
- # the U.S. Government retains certain rights in this software.
4
- #
5
- # Original Author: Bryan T. Richardson, Sandia National Laboratories <btricha@sandia.gov>
6
- #
7
- # This library is free software; you can redistribute it and/or modify it
8
- # under the terms of the GNU Lesser General Public License as published by
9
- # the Free Software Foundation; either version 2.1 of the License, or (at
10
- # your option) any later version.
11
- #
12
- # This library is distributed in the hope that it will be useful, but WITHOUT
13
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
- # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15
- # details.
16
- #
17
- # You should have received a copy of the GNU Lesser General Public License
18
- # along with this library; if not, write to the Free Software Foundation, Inc.,
19
- # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
-
21
1
  # This file is auto-generated from the current state of the database. Instead of editing this file,
22
- # please use the migrations feature of ActiveRecord to incrementally modify your database, and
2
+ # please use the migrations feature of Active Record to incrementally modify your database, and
23
3
  # then regenerate this schema definition.
24
4
  #
25
5
  # Note that this schema.rb definition is the authoritative source for your database schema. If you need
@@ -29,7 +9,19 @@
29
9
  #
30
10
  # It's strongly recommended to check this file into your version control system.
31
11
 
32
- ActiveRecord::Schema.define(:version => 9) do
12
+ ActiveRecord::Schema.define(:version => 13) do
13
+
14
+ create_table "actions", :force => true do |t|
15
+ t.string "tool"
16
+ t.string "description"
17
+ t.string "start"
18
+ t.string "end"
19
+ end
20
+
21
+ create_table "dns_entries", :force => true do |t|
22
+ t.string "address"
23
+ t.string "hostname"
24
+ end
33
25
 
34
26
  create_table "ethernet_interfaces", :force => true do |t|
35
27
  t.string "address", :null => false
@@ -69,10 +61,26 @@ ActiveRecord::Schema.define(:version => 9) do
69
61
  t.string "device_type"
70
62
  end
71
63
 
64
+ create_table "operating_systems", :force => true do |t|
65
+ t.float "certainty_factor", :null => false
66
+ t.integer "node_id"
67
+ t.integer "action_id"
68
+ t.text "fingerprint"
69
+ end
70
+
72
71
  create_table "private_networks", :force => true do |t|
73
72
  t.string "description"
74
73
  end
75
74
 
75
+ create_table "services", :force => true do |t|
76
+ t.float "certainty_factor", :null => false
77
+ t.integer "node_id"
78
+ t.integer "action_id"
79
+ t.string "protocol"
80
+ t.integer "port"
81
+ t.string "name"
82
+ end
83
+
76
84
  create_table "traffic", :force => true do |t|
77
85
  t.string "description"
78
86
  t.integer "port", :default => 0, :null => false
Binary file
@@ -30,6 +30,10 @@ require 'antfarm/layer3_network'
30
30
  require 'antfarm/node'
31
31
  require 'antfarm/private_network'
32
32
  require 'antfarm/traffic'
33
+ require 'antfarm/dns_entry'
34
+ require 'antfarm/action'
35
+ require 'antfarm/service'
36
+ require 'antfarm/operating_system'
33
37
 
34
38
  module Antfarm
35
39
 
@@ -0,0 +1,29 @@
1
+ # Copyright (2008) Sandia Corporation.
2
+ # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
3
+ # the U.S. Government retains certain rights in this software.
4
+ #
5
+ # Original Author: Bryan T. Richardson, Sandia National Laboratories <btricha@sandia.gov>
6
+ # Derived From: code written by Michael Berg <mjberg@sandia.gov>
7
+ #
8
+ # This library is free software; you can redistribute it and/or modify it
9
+ # under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation; either version 2.1 of the License, or (at
11
+ # your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful, but WITHOUT
14
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16
+ # details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with this library; if not, write to the Free Software Foundation, Inc.,
20
+ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+
22
+ class Action < ActiveRecord::Base
23
+ has_many :operating_systems
24
+ has_many :services
25
+
26
+ def to_label
27
+ return tool
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # Copyright (2008) Sandia Corporation.
2
+ # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
3
+ # the U.S. Government retains certain rights in this software.
4
+ #
5
+ # Original Author: Bryan T. Richardson, Sandia National Laboratories <btricha@sandia.gov>
6
+ # Derived From: code written by Michael Berg <mjberg@sandia.gov>
7
+ #
8
+ # This library is free software; you can redistribute it and/or modify it
9
+ # under the terms of the GNU Lesser General Public License as published by
10
+ # the Free Software Foundation; either version 2.1 of the License, or (at
11
+ # your option) any later version.
12
+ #
13
+ # This library is distributed in the hope that it will be useful, but WITHOUT
14
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15
+ # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16
+ # details.
17
+ #
18
+ # You should have received a copy of the GNU Lesser General Public License
19
+ # along with this library; if not, write to the Free Software Foundation, Inc.,
20
+ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
+
22
+ class DnsEntry < ActiveRecord::Base
23
+ end