netscan_calife 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f9c3330ddd5d520d03737c94bdadc066d2ef3d1c
4
+ data.tar.gz: 72ded442a7356063822b0d102bbdd7b257d4d1d2
5
+ SHA512:
6
+ metadata.gz: ed75e577d6f60655662954c70099af0198dc386e6b84ac0db77546122d8c428a15d35f10dd8ac110a78e7f6b202543ee8030a617fb48367a6f8e7fffdd19114d
7
+ data.tar.gz: 7abdfaaf4809d474e0c4b60e7dc0ac1104186ae01a0afda9218e1c0dd9d4a0cd2fbc0e96d1bce53e703cd979b7965ef07a4f8ddec44fe686494cfe7e40dba722
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in netscan_calife.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # NetscanCalife
2
+
3
+ Netscan application
4
+
5
+ ## Build the gem file
6
+
7
+ Using Bundler with Rubygem gemspecs
8
+ If you're creating a gem from scratch, you can use bundler's built in gem skeleton to create a base gem for you to edit.
9
+
10
+ % bundle gem netscan_calife
11
+
12
+ % gem build netscan_calife.gemspec
13
+ Successfully built RubyGem
14
+ Name: netscan_calife
15
+ Version: 0.0.0
16
+ File: netscan_calife-0.1.0.gem
17
+
18
+ % gem install netscan_calife-0.1.0.gem
19
+ Successfully installed netscan_calife-0.1.0
20
+ 1 gem installed
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ ```ruby
27
+ gem 'netscan_calife'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ $ bundle
33
+
34
+ Or install it yourself as:
35
+
36
+ $ gem install netscan_calife
37
+
38
+ ## Usage
39
+
40
+ ./netscan_calife -n 10.10.203.0 -m 255.255.255.0
41
+
42
+ ## Development
43
+
44
+ push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it ( https://bitbucket.org/calife/netscan_calife )
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "netscan_calife"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+ require "netscan_calife/utils"
3
+ require "netscan_calife/ip_scan"
4
+ require 'optparse'
5
+ require 'pp'
6
+
7
+ options = {}
8
+
9
+ parser=OptionParser.new do |opts|
10
+ opts.banner = "Usage:#{ __FILE__} [options]"
11
+
12
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
13
+ options[:verbose] = v
14
+ end
15
+
16
+ opts.on('-n', '--net NETWORK', 'Network') do |network|
17
+ options[:network] = network
18
+ end
19
+
20
+ opts.on('-m', '--mask NETMASK', 'Netmask') do |netmask|
21
+ options[:netmask] = netmask
22
+ end
23
+
24
+ opts.on('-h', '--help', 'Displays Help') do
25
+ puts opts
26
+ exit
27
+ end
28
+
29
+ opts.on("--version", "print Version") do |v|
30
+ puts NetscanCalife::VERSION
31
+ exit
32
+ end
33
+
34
+ end
35
+
36
+ parser.parse!
37
+
38
+ required=[:network,:netmask]
39
+ required.select! { |x|
40
+ options[x].nil?
41
+ }
42
+
43
+ # Begin check
44
+ unless required.empty?
45
+ puts "Missing options: #{required.join(', ')}"
46
+ puts parser
47
+ exit
48
+ end
49
+
50
+ unless NetscanCalife::Utils.valid_ipnetwork?(options[:network])
51
+ puts "Invalid network"
52
+ puts parser
53
+ exit
54
+ end
55
+
56
+ unless NetscanCalife::Utils.valid_ipnetmask?(options[:netmask])
57
+ puts "Invalid netmask"
58
+ puts parser
59
+ exit
60
+ end
61
+ # End check
62
+
63
+ # Main Run
64
+ NetscanCalife::IpScan.scan(options[:network].to_s,options[:netmask].to_s)
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,44 @@
1
+ require 'benchmark'
2
+ require 'ipaddr'
3
+ require 'pp'
4
+
5
+ module NetscanCalife
6
+
7
+ class IpScan
8
+
9
+ def self.scan(network,netmask)
10
+
11
+ total_elapsed= Benchmark.measure {
12
+
13
+ net1 = IPAddr.new(network).mask(netmask)
14
+
15
+ statuses=net1.to_range.map do |host|
16
+
17
+ pid=fork {
18
+ exec("ping", "-c 3", "#{host}",:out=>"/dev/null",err: :out)
19
+ }
20
+
21
+ [pid,host.to_s]
22
+
23
+ end
24
+
25
+ statuses.each { |p,h|
26
+
27
+ Process.wait(p)
28
+
29
+ printf("%s\n","Host found #{h}") if $?.exitstatus.zero?
30
+
31
+ }
32
+
33
+ puts "Fine main process #{Process.pid}"
34
+
35
+ }
36
+
37
+ puts "##############################"
38
+ puts "Total Elapsed " + "#{total_elapsed}"
39
+ puts "##############################"
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,15 @@
1
+ module NetscanCalife
2
+
3
+ class Utils
4
+
5
+ def self.valid_ipnetmask?(netmask)
6
+ /^\d{,3}\.\d{,3}\.\d{,3}\.\d{,3}$/.match(netmask)
7
+ end
8
+
9
+ def self.valid_ipnetwork?(network)
10
+ /^\d{,3}\.\d{,3}\.\d{,3}\.\d{,3}$/.match(network)
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,3 @@
1
+ module NetscanCalife
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "netscan_calife/version"
2
+
3
+ module NetscanCalife
4
+ # Your code goes here...
5
+
6
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'netscan_calife/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "netscan_calife"
8
+ spec.version = NetscanCalife::VERSION
9
+ spec.authors = ["calife"]
10
+ spec.email = ["califerno@gmail.com"]
11
+
12
+ # This allow push to rubygems.org
13
+ # if spec.respond_to?(:metadata)
14
+ # spec.metadata['allowed_push_host'] = "https://rubygems.org/"
15
+ # end
16
+
17
+ spec.summary = %q{Netscan Calife}
18
+ spec.description = %q{This gem allow to performa a network ping scan}
19
+ spec.homepage = "https://bitbucket.org/calife/netscan_calife"
20
+ spec.license = "MIT"
21
+
22
+ # spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+
24
+ # spec.files = `git ls-files`.split("
25
+ #")
26
+
27
+ spec.files = `git ls-files`.split($/)
28
+
29
+ spec.bindir = "bin"
30
+ spec.executables << 'netscan_calife'
31
+
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.8"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: netscan_calife
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - calife
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: This gem allow to performa a network ping scan
42
+ email:
43
+ - califerno@gmail.com
44
+ executables:
45
+ - netscan_calife
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/netscan_calife
55
+ - bin/setup
56
+ - lib/netscan_calife.rb
57
+ - lib/netscan_calife/ip_scan.rb
58
+ - lib/netscan_calife/utils.rb
59
+ - lib/netscan_calife/version.rb
60
+ - netscan_calife.gemspec
61
+ homepage: https://bitbucket.org/calife/netscan_calife
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.8
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Netscan Calife
85
+ test_files: []