-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsmoke_ring.rb
executable file
·74 lines (68 loc) · 2.13 KB
/
smoke_ring.rb
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
#!/usr/bin/env ruby
#
# Remove closed ports
#
$LOAD_PATH << '/home/scanner/brisket/lib'
require 'analysis'
require 'geoip'
require 'directories'
require 'fileutils'
commands = []
ARGV.each {|arg| commands << arg}
# [0]=type, [1]=date in D/M/YYYY
# ./smoke_ring.rb masscan 3/12/2013
ip = []
fqdn = []
Analysis.dateinput ARGV[1]
rb_file_location = "./analysis/"+Analysis.scan_date+"/"
path = "tmp"
tmp_file_location = rb_file_location+path
FileUtils.mkdir_p tmp_file_location
rb_file_master = Dir.glob(rb_file_location+"*"+ARGV[0]+"*")
rb_file_master.each do |rb_file|
filename = rb_file.to_s.gsub("./analysis/"+Analysis.scan_date, '')
filename2 = "title_"+filename.gsub("/", '')
filename3 = "banner_"+filename.gsub("/", '')
new_file = File.open(rb_file_location+"tmp"+filename, "a")
puts "[+] "+rb_file.gsub(/\.\/analysis\//, '')
if ARGV[0] == "masscan"
new_file_title = File.open(rb_file_location+"tmp/"+filename2, "a")
new_file_banner = File.open(rb_file_location+"tmp/"+filename3, "a")
IO.foreach(rb_file) do |x|
if x =~ /closed/
elsif x =~ /service name="title"/
new_file_title.write(x)
elsif x =~ /<service name="http"><banner>/
new_file_banner.write(x)
elsif x =~ /<service name="ssl"><banner>/
new_file_banner.write(x)
else new_file.write(x)
end
end
new_file_banner.close
new_file_title.close
elsif ARGV[0] == "nmap"
IO.foreach(rb_file) do |x|
if x =~ /\<\w{7,8} \w{4}\="(.+)" \w+\="\w{3,4}"\/\>/
#if x =~ Analysis.
# ip << Analysis.ip_strip.match(x)[1].to_s
#end
#if Analysis.ip_strip.match(x)[1].to_s != nil
# fqdn = Analysis.fqdn_strip.match(x)[1].to_s
# puts fqdn
#end
#puts ip+","+fqdn
end
#puts ip+","+fqdn
#new_file.write(ip+","+fqdn)
end
elsif ARGV[0] == "help" && ARGV[0] == "-h"
puts "[+] Usage: ./smoke_ring.rb <scanner> d/m/yyyy"
else puts "[+] Usage: ./smoke_ring.rb <scanner> d/m/yyyy"
end
new_file.close
FileUtils.mv(rb_file_location+"tmp"+filename, rb_file_location)
FileUtils.mv(rb_file_location+"tmp/"+filename2, rb_file_location)
FileUtils.mv(rb_file_location+"tmp/"+filename3, rb_file_location)
end
FileUtils.rm_rf(rb_file_location+"tmp")