thanthus 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ module Xanthus
2
+ class Repository
3
+
4
+ def initialize
5
+ end
6
+
7
+ def prepare_xanthus_file
8
+ script = ''
9
+ File.readlines('../../.xanthus').each do |line|
10
+ script += line unless line.include?('github.token') || line.include?('dataverse.token')
11
+
12
+ # remove github token
13
+ script += "\t\t# github.token = 'REMOVED'\n" unless !line.include? 'github.token'
14
+ # remove dataverse token
15
+ script += "\t\t# dataverse.token = 'REMOVED'\n" unless !line.include? 'dataverse.token'
16
+ end
17
+ File.open('.xanthus', 'w+') do |f|
18
+ f.write(script)
19
+ end
20
+ end
21
+
22
+ def prepare_readme_file config
23
+ File.open('README.md', 'w+') do |f|
24
+ f.write(config.to_readme_md)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ module Xanthus
2
+ class Script
3
+ attr_accessor :script
4
+
5
+
6
+ def initialize array, config
7
+ script = ''
8
+ array.each do |t|
9
+ v = eval(config.scripts[t])
10
+ if v.kind_of?(Array)
11
+ v.each do |w|
12
+ script+=w+"\n"
13
+ end
14
+ else
15
+ script+=v
16
+ end
17
+ end
18
+ script_to_clean = script
19
+ script = ''
20
+ script_to_clean.each_line do |s|
21
+ script += s.strip + "\n" unless s=="\n"
22
+ end
23
+ script = script.gsub "\n\n", "\n"
24
+ @script = script
25
+ end
26
+
27
+ def to_s
28
+ @script
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ module Xanthus
2
+ VERSION = "0.2.3"
3
+
4
+ def self.version
5
+ puts VERSION
6
+ end
7
+ end
@@ -0,0 +1,119 @@
1
+ require_relative '../utils/os'
2
+
3
+ module Xanthus
4
+ class VirtualMachine
5
+ attr_accessor :name
6
+ attr_accessor :box
7
+ attr_accessor :version
8
+ attr_accessor :cpus
9
+ attr_accessor :cpu_cap
10
+ attr_accessor :memory
11
+ attr_accessor :ip
12
+ attr_accessor :gui
13
+ attr_accessor :boxing
14
+ attr_accessor :ssh_username
15
+ attr_accessor :ssh_key_path
16
+ attr_accessor :on_aws
17
+ attr_accessor :aws_env_key_id
18
+ attr_accessor :aws_env_key_secret
19
+ attr_accessor :aws_key_pair_name
20
+ attr_accessor :aws_region
21
+ attr_accessor :aws_ami
22
+ attr_accessor :aws_instance_type
23
+ attr_accessor :aws_security_group
24
+
25
+ def initialize
26
+ @name = :default
27
+ @box = 'jhcook/fedora27'
28
+ @version = '4.13.12.300'
29
+ @ip = '192.168.33.8'
30
+ @memory = 4096
31
+ @cpus = 2
32
+ @cpu_cap = 70
33
+ @gui = false
34
+ @boxing = nil
35
+ @ssh_username = nil
36
+ @ssh_key_path = nil
37
+ end
38
+
39
+ def to_vagrant
40
+ script = %Q{
41
+ Vagrant.configure(2) do |config|
42
+ config.vm.box = "#{@box}"
43
+ config.vm.box_version = "#{@version}"
44
+ config.vm.network "private_network", ip: "#{@ip}"
45
+ }
46
+ script += %Q{
47
+ if Vagrant.has_plugin?("vagrant-vbguest")
48
+ config.vbguest.auto_update = false
49
+ end
50
+ }
51
+ script += %Q{
52
+ config.vm.synced_folder ".", "/vagrant", disabled: false, type: 'rsync'
53
+ } unless !@on_aws
54
+ script += %Q{
55
+ config.ssh.username = "#{@ssh_username}"
56
+ } unless ssh_username.nil?
57
+ script += %Q{
58
+ config.ssh.private_key_path = "#{@ssh_key_path}"
59
+ } unless ssh_key_path.nil?
60
+ script += %Q{
61
+ config.vm.provider "virtualbox" do |vb, override|
62
+ vb.gui = #{@gui}
63
+ vb.memory = #{@memory}
64
+ vb.customize ["modifyvm", :id, "--cpuexecutioncap", "#{@cpu_cap}"]
65
+ vb.cpus = #{@cpus}
66
+ vb.name = "#{@name}"
67
+ end
68
+ } unless @on_aws
69
+ script += %Q{
70
+ config.vm.provider "aws" do |aws, override|
71
+ aws.access_key_id = ENV['#{@aws_env_key_id}']
72
+ aws.secret_access_key = ENV['#{@aws_env_key_secret}']
73
+ aws.keypair_name = '#{@aws_key_pair_name}'
74
+ aws.region = '#{@aws_region}'
75
+ aws.ami = '#{@aws_ami}'
76
+ aws.instance_type = '#{@aws_instance_type}'
77
+ aws.security_groups = ['#{@aws_security_group}']
78
+ end
79
+ } unless !@on_aws
80
+
81
+ # add simple support for Windows
82
+ script += %Q{ config.vm.provision "shell", path: "provision.sh"
83
+
84
+ config.trigger.before :halt do |trigger|
85
+ trigger.info = "Retrieving data before halt..."
86
+ trigger.run = {path: "before_halt.#{sys_script_ext}"}
87
+ end
88
+ end
89
+ }
90
+ return script
91
+ end
92
+
93
+ def generate_box config
94
+ return unless !boxing.nil?
95
+ puts 'Generating box...'
96
+
97
+ FileUtils.mkdir_p 'boxing'
98
+ Dir.chdir 'boxing' do
99
+ File.open('Vagrantfile', 'w+') do |f|
100
+ f.write(self.to_vagrant)
101
+ end
102
+
103
+ script = Script.new(boxing, config).to_s
104
+ File.open('provision.sh', 'w+') do |f|
105
+ f.write(script)
106
+ end
107
+
108
+ system('vagrant', 'up')
109
+ system('vagrant', 'halt')
110
+ system('vagrant', 'package', '--output', "#{name}.box")
111
+ puts "#{name}.box created."
112
+ system('vagrant', 'box', 'add', '--force', "local/#{name}", "#{name}.box")
113
+ system('vagrant', 'destroy', '-f')
114
+ @box = "local/#{name}"
115
+ @version = '0'
116
+ end
117
+ end
118
+ end
119
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thanthus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ platform: ruby
6
+ authors:
7
+ - Thomas Pasquier
8
+ - Xueyuan "Michael" Han
9
+ - Yilun Sun
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2021-01-14 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.3'
29
+ - !ruby/object:Gem::Dependency
30
+ name: bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '2.0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '13'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '13'
57
+ description: This version is forked from xanthus. As I finished this work when studying
58
+ in THU, I name this version `thanthus`
59
+ email:
60
+ - syl1887415157@126.com
61
+ executables:
62
+ - xanthus
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - LICENSE
67
+ - README.md
68
+ - bin/xanthus
69
+ - lib/utils/os.rb
70
+ - lib/xanthus.rb
71
+ - lib/xanthus/configuration.rb
72
+ - lib/xanthus/dataverse.rb
73
+ - lib/xanthus/default.rb
74
+ - lib/xanthus/github.rb
75
+ - lib/xanthus/init.rb
76
+ - lib/xanthus/job.rb
77
+ - lib/xanthus/repository.rb
78
+ - lib/xanthus/script.rb
79
+ - lib/xanthus/version.rb
80
+ - lib/xanthus/virtual_machine.rb
81
+ homepage: http://camflow.org
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubygems_version: 3.1.4
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Automated intrusion detection dataset generation framework.
104
+ test_files: []