pwn 0.4.679 → 0.4.681

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98918a56d63ac8ef47261e94f0b9d00e42b90e0c60ccaaeecfa0f1c28591af50
4
- data.tar.gz: 55e972d187270c847d7729278ee155a99afbe3d348b72202125becbaeaa584af
3
+ metadata.gz: 717524d6d611b962be2b71ffb95c427abd3c173347b651904b2a1b1294fd807b
4
+ data.tar.gz: 894b9128466217e15befedcc67296d47de56e61640eb88c119512994a9db98f1
5
5
  SHA512:
6
- metadata.gz: c8ad1f6d63ad8d3162c74b31ee24e0be22360dc739039a236f6dfd00bf53cdb8a8e91f630d42d27f5300537c06a06ffaca59f943eb6827caa68cb822722b1004
7
- data.tar.gz: 987790249425f4580f251a11ae284c78b2b0f88278e0fd4be7ac22c91700a8fb70cf4f1da854bd4d7eab56542ac6810578b9e3ddeadd59fce5456f30982ab918
6
+ metadata.gz: e129b34830468a21f9fa339af587f3c8428cd0328dfa27c8dc5b1e78dc76264dba7398a2341c47f558f072cc36a6024c93ada70564b97fe8b9cbfbd440aa34bc
7
+ data.tar.gz: 6e9383ba997f1146c6196720e4d2ff0c33b8b982814d37d373eb7888b1a4a21d721e0d35aeb629da10e4c93c497ce7716120220769e131f41eb13415125dc720
data/README.md CHANGED
@@ -37,7 +37,7 @@ $ rvm use ruby-3.2.2@pwn
37
37
  $ rvm list gemsets
38
38
  $ gem install --verbose pwn
39
39
  $ pwn
40
- pwn[v0.4.679]:001 >>> PWN.help
40
+ pwn[v0.4.681]:001 >>> PWN.help
41
41
  ```
42
42
 
43
43
  [![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
@@ -52,7 +52,7 @@ $ rvm use ruby-3.2.2@pwn
52
52
  $ gem uninstall --all --executables pwn
53
53
  $ gem install --verbose pwn
54
54
  $ pwn
55
- pwn[v0.4.679]:001 >>> PWN.help
55
+ pwn[v0.4.681]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
 
@@ -15,7 +15,7 @@ OptionParser.new do |options|
15
15
  opts[:target_range] = t
16
16
  end
17
17
 
18
- options.on('-eFILE', '--target-exclude-file=FILE', '<Optional - nmap excludes file>') do |e|
18
+ options.on('-eFILE', '--target-exclude-file=FILE', '<Optional - IP excludes file>') do |e|
19
19
  opts[:exclude_file] = e
20
20
  end
21
21
 
@@ -23,6 +23,10 @@ OptionParser.new do |options|
23
23
  opts[:interface] = i
24
24
  end
25
25
 
26
+ options.on('-rDIR', '--results-root=DIR', '<Optional - nmap results root (Default: /tmp)>') do |r|
27
+ opts[:results_root] = r
28
+ end
29
+
26
30
  options.on('-T', '--tor', '<Optional - Source Scans from Tor Nodes>') do |t|
27
31
  opts[:with_tor] = t
28
32
  end
@@ -41,22 +45,28 @@ puts "\n\n\n#{banner}"
41
45
  puts "- STARTED: #{started_at} "
42
46
 
43
47
  target_range = opts[:target_range]
48
+
49
+ results_root = opts[:results_root]
50
+ results_root ||= '/tmp'
51
+ FileUtils.mkdir_p results_root
52
+ puts "Results Saved in: #{results_root}"
53
+
44
54
  exclude_file = opts[:exclude_file]
45
- exclude_file ||= '/tmp/nmap_targets_exclude.txt'
55
+ exclude_file ||= "#{results_root}/nmap_targets_exclude.txt"
56
+ # We create an exclude file (even if its empty)
57
+ File.new(exclude_file, 'w') unless File.exist?(exclude_file)
58
+
46
59
  interface = opts[:interface]
47
60
  interface ||= 'eth0'
61
+
48
62
  with_tor = true if opts[:with_tor]
49
63
  with_tor ||= false
64
+
50
65
  if with_tor
51
66
  tor_obj = PWN::Plugins::Tor.start
52
67
  proxy = ["socks4://#{tor_obj[:ip]}:#{tor_obj[:port]}"]
53
68
  end
54
69
 
55
- File.new(exclude_file, 'w') unless File.exist?(exclude_file)
56
- nmap_results_root = File.dirname(exclude_file)
57
- FileUtils.mkdir_p nmap_results_root
58
- puts "nmap Results Saved in: #{nmap_results_root}"
59
-
60
70
  discovery_tcp_ports = {
61
71
  ftp: 21,
62
72
  ssh: 22,
@@ -126,10 +136,10 @@ discovery_sctp_ports = {
126
136
  sicc: 38_412
127
137
  }
128
138
 
129
- target_file = "#{nmap_results_root}/nmap_targets.txt"
130
- latest_discovery_results = "#{nmap_results_root}/nmap_discovery_results.xml"
131
- latest_tcp_results = "#{nmap_results_root}/nmap_tcp_results"
132
- latest_udp_results = "#{nmap_results_root}/nmap_udp_results"
139
+ target_file = "#{results_root}/nmap_targets.txt"
140
+ latest_discovery_results = "#{results_root}/nmap_discovery_results.xml"
141
+ latest_tcp_results = "#{results_root}/nmap_tcp_results"
142
+ latest_udp_results = "#{results_root}/nmap_udp_results"
133
143
 
134
144
  begin
135
145
  # Per man nmap:
@@ -151,7 +161,7 @@ begin
151
161
  # Target Discovery Scan
152
162
  # Using -T5 template to reduce number of
153
163
  # retransmission attempts on filtered ports.
154
- puts "\n\n\n#{banner}"
164
+ puts banner
155
165
  puts '- PHASE 1: Target Discovery'
156
166
  PWN::Plugins::NmapIt.port_scan do |nmap|
157
167
  if with_tor
@@ -188,16 +198,32 @@ begin
188
198
  next if File.read(exclude_file).include?(host.ip) ||
189
199
  host.status.state != :up
190
200
 
191
- hosts_arr = host.hostnames.map { |h| h[:name] }
192
- f.print host.ip
193
- f.puts " # { \"hostnames\": #{hosts_arr}}, \"mac\": \"#{host.mac}\" }"
201
+ f.puts host.ip
194
202
  end
195
203
  end
196
204
  end
197
205
 
198
- # Produce a good targets.txt redacting duplicates
199
- sorted_targets = File.readlines(target_file).sort.join
200
- File.write(target_file, sorted_targets)
206
+ # Produce a good targets.txt redacting duplicates && sorting by IP
207
+ sorted_ips = File.readlines(target_file).uniq.map do |ip|
208
+ IPAddr.new(ip.chomp)
209
+ end
210
+ sorted_ips = sorted_ips.sort_by(&:hton)
211
+
212
+ # Now Add additional info about the IP as a comment
213
+ File.open(target_file, 'w') do |f|
214
+ sorted_ips.each do |ip|
215
+ PWN::Plugins::NmapIt.parse_xml_results(
216
+ xml_file: latest_discovery_results
217
+ ) do |xml|
218
+ xml.each_host do |host|
219
+ next unless host.ip.to_s == ip.to_s
220
+
221
+ hosts_arr = host.hostnames.map { |h| h[:name] }
222
+ f.puts "#{ip} # { \"hostnames\": #{hosts_arr}}, \"mac\": \"#{host.mac}\" }"
223
+ end
224
+ end
225
+ end
226
+ end
201
227
 
202
228
  phase1_ended_at = Time.now.strftime(ftimestr)
203
229
  phase1_ended_at_parse = Time.parse(phase1_ended_at)
data/lib/pwn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PWN
4
- VERSION = '0.4.679'
4
+ VERSION = '0.4.681'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.679
4
+ version: 0.4.681
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.