lib/pwn/plugins/transparent_browser.rb in pwn-0.5.186 vs lib/pwn/plugins/transparent_browser.rb in pwn-0.5.187
- old
+ new
@@ -283,12 +283,11 @@
return nil
end
if devtools_supported.include?(browser_type)
rand_tab = SecureRandom.hex(8)
- browser_obj[:browser].goto('about:about')
- browser_obj[:browser].execute_script("document.title = '#{rand_tab}'")
+ browser_obj[:browser].goto("about:about##{rand_tab}")
if with_devtools
driver = browser_obj[:browser].driver
browser_obj[:devtools] = driver.devtools
@@ -490,13 +489,12 @@
browser = browser_obj[:browser]
browser_type = browser_obj[:type]
devtools = browser_obj[:devtools]
browser.execute_script('window.open()')
jmp_tab(browser_obj: browser_obj, keyword: 'about:blank')
- browser.goto('about:about') if url.nil?
rand_tab = SecureRandom.hex(8)
- browser.execute_script("document.title = '#{rand_tab}'")
+ browser.goto("about:about##{rand_tab}") if url.nil?
# Open the DevTools for Firefox, Chrome opens them automatically
browser.body.send_keys(:f12) if firefox_types.include?(browser_type)
# Open Console drawer if DevTools are open
browser.body.send_keys(:escape) if devtools
browser.goto(url) unless url.nil?
@@ -518,10 +516,17 @@
keyword = opts[:keyword]
raise 'ERROR: keyword parameter is required' if keyword.nil?
browser = browser_obj[:browser]
+ # Switch to an inactive tab before closing the active tab if it's currently active
+ active_tab = list_tabs(browser_obj: browser_obj).find { |tab| tab[:state] == :active }
+ if active_tab[:url] == browser.url
+ invalid_tab = list_tabs(browser_obj: browser_obj).find { |tab| tab[:url] != browser.url }
+ keyword = invalid_tab[:url]
+ jmp_tab(browser_obj: browser_obj, keyword: keyword)
+ end
all_tabs = browser.windows
tab_sel = all_tabs.select { |tab| tab.close if tab.title.include?(keyword) || tab.url.include?(keyword) }
{ title: tab_sel.last.title, url: tab_sel.last.url, state: :closed } if tab_sel.any?
rescue StandardError => e
raise e
@@ -657,9 +662,11 @@
panel = opts[:panel] ||= :elements
browser = browser_obj[:browser]
browser_type = browser_obj[:type]
firefox_types = %i[firefox headless_firefox]
chrome_types = %i[chrome headless_chrome]
+
+ hotkey = []
case PWN::Plugins::DetectOS.type
when :linux, :openbsd, :windows
hotkey = %i[control shift]
when :macos