pwn 0.4.636 → 0.4.637

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a53e0d51559f7f2ef0d158dad69d01317a5b3d1effc551bdc2864296472ce1ca
4
- data.tar.gz: b3c9a88c2fae88c35bc97d6461107482bc33565d60d2c8acaa714debcc400999
3
+ metadata.gz: ed890d64be30032f92cd57c59abfe52a7b568816945c9196fcc46adb1ccdeb7e
4
+ data.tar.gz: 9e5f0acbfeaea73f98b1dc14e4ec3e54dc8bb71c654ffcf4d0ca14a7ee2e344d
5
5
  SHA512:
6
- metadata.gz: 0e03ec1ebe7a078a6c2872172d28e7af661905e0612b5768ddec77621a86635a79a2c6a3f3b2fe1e9a00d1bbad0802dbf08b8ee5095d9387eeb557aa0e603c2c
7
- data.tar.gz: 3dcd87ad285151b44c6f3d1d6bb4d8944b668db44b836d46a956470040fe5ab3cca9d665802420bf9da6602bdebd4474cbefafb09d05ddfd0cb169c3dc43d61b
6
+ metadata.gz: 26a50246edaa50f39dba47018111e7803891daea153f9ed2bf5b2dd916613eac40d30f66fbb6c6f5a5e3f0a2aa5b470715d2848b9a68219d59afc23533800fb7
7
+ data.tar.gz: 63dd51a285d26aa58d4a5de34000c2d28bbdee18333841ea3d09a2b003052141c094fe4c94d89d03da2030c74a4f2802487b8d1255c735ea846d422f49bb1e48
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.636]:001 >>> PWN.help
40
+ pwn[v0.4.637]: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.636]:001 >>> PWN.help
55
+ pwn[v0.4.637]:001 >>> PWN.help
56
56
  ```
57
57
 
58
58
 
@@ -84,12 +84,13 @@ module PWN
84
84
  raise "no http_listen value found in #{config}." if http_list_entry.empty?
85
85
 
86
86
  # Update http_listen value in respective config with random available port
87
- random_port = -1
88
- port_in_use = true
89
- while port_in_use
90
- random_port = Random.rand(1024..65_535)
91
- port_in_use = PWN::Plugins::Sock.check_port_in_use(port: random_port)
92
- end
87
+ # random_port = -1
88
+ # port_in_use = true
89
+ # while port_in_use
90
+ # random_port = Random.rand(1024..65_535)
91
+ # port_in_use = PWN::Plugins::Sock.check_port_in_use(port: random_port)
92
+ # end
93
+ random_port = PWN::Plugins::Sock.get_random_unused_port
93
94
  http_listen_ip_port = "127.0.0.1:#{random_port}"
94
95
 
95
96
  updated_config_content = ''
@@ -40,8 +40,11 @@ module PWN
40
40
  burp_obj = {}
41
41
  burp_obj[:pid] = Process.spawn(burp_cmd_string)
42
42
  rest_browser = PWN::Plugins::TransparentBrowser.open(browser_type: :rest)
43
- burp_obj[:mitm_proxy] = '127.0.0.1:8080'
44
- burp_obj[:burpbuddy_api] = '127.0.0.1:8001'
43
+ random_mitm_port = PWN::Plugins::Sock.get_random_unused_port
44
+ random_bb_port = random_mitm_port
45
+ random_bb_port = PWN::Plugins::Sock.get_random_unused_port while random_bb_port == random_mitm_port
46
+ burp_obj[:mitm_proxy] = "127.0.0.1:#{random_mitm_port}"
47
+ burp_obj[:burpbuddy_api] = "127.0.0.1:#{random_bb_port}"
45
48
  burp_obj[:rest_browser] = rest_browser
46
49
 
47
50
  # Proxy always listens on localhost...use SSH tunneling if remote access is required
@@ -54,7 +57,7 @@ module PWN
54
57
 
55
58
  # Wait for TCP 8001 to open prior to returning burp_obj
56
59
  loop do
57
- s = TCPSocket.new('127.0.0.1', 8001)
60
+ s = TCPSocket.new('127.0.0.1', random_bb_port)
58
61
  s.close
59
62
  break
60
63
  rescue Errno::ECONNREFUSED
@@ -75,7 +75,7 @@ module PWN
75
75
  # api_key: 'required - api key for API authorization',
76
76
  # zap_bin_path: 'optional - path to zap.sh file'
77
77
  # headless: 'optional - run zap headless if set to true',
78
- # proxy: 'optional - change local zap proxy listener (defaults to http://127.0.0.1:8080)',
78
+ # proxy: 'optional - change local zap proxy listener (defaults to http://127.0.0.1:<Random 1024-65535>)',
79
79
  # )
80
80
 
81
81
  public_class_method def self.start(opts = {})
@@ -118,7 +118,8 @@ module PWN
118
118
  proxy_uri = URI.parse(proxy)
119
119
  owasp_zap_cmd = "#{owasp_zap_cmd} -host #{proxy_uri.host} -port #{proxy_uri.port}"
120
120
  else
121
- proxy = 'http://127.0.0.1:8080'
121
+ random_port = PWN::Plugins::Sock.get_random_unused_port
122
+ proxy = "http://127.0.0.1:#{random_port}"
122
123
  proxy_uri = URI.parse(proxy)
123
124
  end
124
125
  zap_obj[:host] = proxy_uri.host.to_s.scrub
@@ -499,7 +500,7 @@ module PWN
499
500
  api_key: 'required - api key for API authorization',
500
501
  zap_bin_path: 'optional - path to zap.sh file',
501
502
  headless: 'optional - run zap headless if set to true',
502
- proxy: 'optional - change local zap proxy listener (defaults to http://127.0.0.1:8080)'
503
+ proxy: 'optional - change local zap proxy listener (defaults to http://127.0.0.1:<Random 1024-65535>)'
503
504
  )
504
505
  puts zap_obj.public_methods
505
506
 
@@ -47,10 +47,40 @@ module PWN
47
47
  raise e
48
48
  end
49
49
 
50
+ # Supported Method Parameters::
51
+ # PWN::Plugins::Sock.get_random_unused_port(
52
+ # server_ip: 'optional - target host or ip to check (Defaults to 127.0.0.1)',
53
+ # protocol: 'optional - :tcp || :udp (defaults to tcp)'
54
+ # )
55
+
56
+ public_class_method def self.get_random_unused_port(opts = {})
57
+ server_ip = opts[:server_ip]
58
+ server_ip ||= '127.0.0.1'
59
+ port = -1
60
+ protocol = opts[:protocol]
61
+ protocol ||= :tcp
62
+
63
+ port_in_use = true
64
+ while port_in_use
65
+ port = Random.rand(1024..65_535)
66
+ port_in_use = check_port_in_use(
67
+ server_ip: server_ip,
68
+ port: port,
69
+ protocol: protocol
70
+ )
71
+ end
72
+
73
+ port
74
+ rescue Errno::ECONNREFUSED,
75
+ Errno::EHOSTUNREACH,
76
+ Errno::ETIMEDOUT
77
+ false
78
+ end
79
+
50
80
  # Supported Method Parameters::
51
81
  # PWN::Plugins::Sock.check_port_in_use(
52
- # port: 'required - target port',
53
82
  # server_ip: 'optional - target host or ip to check (Defaults to 127.0.0.1)',
83
+ # port: 'required - target port',
54
84
  # protocol: 'optional - :tcp || :udp (defaults to tcp)'
55
85
  # )
56
86
 
@@ -163,9 +193,14 @@ module PWN
163
193
  tls: 'optional - boolean connect to target socket using TLS (defaults to false)'
164
194
  )
165
195
 
166
- #{self}.check_port_availability(
167
- port: 'required - target port',
196
+ port = #{self}.get_random_unused_port(
197
+ server_ip: 'optional - target host or ip to check (Defaults to 127.0.0.1)',
198
+ protocol: 'optional - :tcp || :udp (defaults to tcp)'
199
+ )
200
+
201
+ #{self}.check_port_in_use(
168
202
  server_ip: 'optional - target host or ip to check (Defaults to 127.0.0.1)',
203
+ port: 'required - target port',
169
204
  protocol: 'optional - :tcp || :udp (defaults to tcp)'
170
205
  )
171
206
 
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.636'
4
+ VERSION = '0.4.637'
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.636
4
+ version: 0.4.637
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.