aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--docbook/release-notes.adoc2
-rw-r--r--epan/wslua/CMakeLists.txt1
-rw-r--r--epan/wslua/browser_sslkeylog.lua147
-rw-r--r--packaging/nsis/CMakeLists.txt2
-rw-r--r--packaging/wix/CMakeLists.txt4
6 files changed, 154 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2bd2f594f9..c0fa9effec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2384,6 +2384,7 @@ if(LUA_FOUND AND ENABLE_LUA)
set(_lua_files
"${CMAKE_SOURCE_DIR}/epan/wslua/init.lua"
"${CMAKE_SOURCE_DIR}/epan/wslua/console.lua"
+ "${CMAKE_SOURCE_DIR}/epan/wslua/browser_sslkeylog.lua"
"${CMAKE_SOURCE_DIR}/epan/wslua/dtd_gen.lua"
)
foreach(_lua_file ${_lua_files})
diff --git a/docbook/release-notes.adoc b/docbook/release-notes.adoc
index fc553eeac5..6037a4f874 100644
--- a/docbook/release-notes.adoc
+++ b/docbook/release-notes.adoc
@@ -27,6 +27,8 @@ A new display filter feature for filtering raw bytes has been added.
Display filter autocomplete is smarter about not suggesting invalid syntax.
+menu:Tools[Lua Scripts,Launch with SSLKEYLOGFILE] can launch your web browser with the SSLKEYLOGFILE environment variable set to the appropriate value.
+
The Windows build has a new SpeexDSP external dependency (https://www.speex.org).
The speex code that was previously bundled has been removed.
diff --git a/epan/wslua/CMakeLists.txt b/epan/wslua/CMakeLists.txt
index a79835118a..f33e588780 100644
--- a/epan/wslua/CMakeLists.txt
+++ b/epan/wslua/CMakeLists.txt
@@ -112,6 +112,7 @@ set_target_properties(register_wslua PROPERTIES FOLDER "Libs/epan/wslua")
install(
FILES
console.lua
+ browser_sslkeylog.lua
dtd_gen.lua
init.lua
DESTINATION
diff --git a/epan/wslua/browser_sslkeylog.lua b/epan/wslua/browser_sslkeylog.lua
new file mode 100644
index 0000000000..ceb7a34c06
--- /dev/null
+++ b/epan/wslua/browser_sslkeylog.lua
@@ -0,0 +1,147 @@
+-- browser_sslkeylog.lua
+--
+-- Run a browser with SSLKEYLOG set.
+--
+-- (c) 2021 Gerald Combs <gerald@wireshark.org>
+--
+-- Wireshark - Network traffic analyzer
+-- By Gerald Combs <gerald@wireshark.org>
+-- Copyright 1998 Gerald Combs
+--
+-- SPDX-License-Identifier: GPL-2.0-or-later
+
+-- To do:
+-- - Support more browsers.
+-- - Add stat() to the API and use it.
+-- - Add OS detection to the API and use it.
+
+if not gui_enabled() then return end
+
+do
+ local function is_file(path)
+ f = io.open(path, 'rb')
+ if f ~= nil then
+ io.close(f)
+ return true
+ end
+ return false
+ end
+
+ local function show_skl_window()
+ local prefs_ok = false
+
+ local skl_win = TextWindow.new("Launch with SSLKEYLOG")
+ skl_win:set_editable(false)
+ skl_win:set(
+ "This will run either Chrome or Firefox with the SSLKEYLOG environment variable set to the file specified by the TLS protocol (Pre)-Master-Secret log filename preference."
+ )
+
+ local chrome_cmd = nil
+ local function launch_chrome()
+ os.execute(chrome_cmd)
+ skl_win:close()
+ end
+
+ local firefox_cmd = nil
+ local function launch_firefox()
+ os.execute(firefox_cmd)
+ skl_win:close()
+ end
+
+ -- Check our preferences.
+ local keylog_path = get_preference("tls.keylog_file")
+ if (keylog_path == nil or string.len(keylog_path) < 2) then -- "/x" is the minimum usable path.
+ skl_win:append(
+ "\n\n" ..
+ "Your key log preference isn't set. Please go to \"Preferences → Protocols → TLS → (Pre)-Master-Secret log filename\" and add a filename."
+ )
+ else
+ skl_win:append(
+ "\n\n" ..
+ "TLS keys will be logged to " .. keylog_path .. "."
+ )
+ prefs_ok = true
+ end
+
+ -- Look for browsers.
+ local win_programfiles = os.getenv("ProgramFiles")
+ local has_applications = Dir.exists("/Applications")
+ local has_usr_bin = Dir.exists("/usr/bin")
+ if (win_programfiles ~= nil and string.len(win_programfiles) > 3) then -- "C:\x"
+ local path_prefixes = { win_programfiles }
+ local chrome_suf = "\\Google\\Chrome\\Application\\chrome.exe"
+ local firefox_suf = "\\Mozilla Firefox\\firefox.exe"
+ local win_localappdata = os.getenv("LocalAppData")
+ if (win_localappdata ~= nil and string.len(win_localappdata) > 3) then
+ table.insert(path_prefixes, win_localappdata)
+ end
+ local win_programfiles_x86 = os.getenv("ProgramFiles(x86)")
+ if (win_programfiles_x86 ~= nil and string.len(win_programfiles_x86) > 3) then
+ table.insert(path_prefixes, win_programfiles_x86)
+ end
+ for _, path_prefix in ipairs(path_prefixes) do
+ chrome_path = path_prefix .. chrome_suf
+ if (is_file(chrome_path)) then
+ chrome_cmd = "cmd /c \"set SSLKEYLOGFILE=" .. keylog_path .. " && cmd /c ^\"" .. chrome_path .. "^\"\""
+ break
+ end
+ end
+ for _, path_prefix in ipairs(path_prefixes) do
+ firefox_path = path_prefix .. firefox_suf
+ if (is_file(firefox_path)) then
+ firefox_cmd = "cmd /c \"set SSLKEYLOGFILE=" .. keylog_path .. " && cmd /c ^\"" .. firefox_path .. "^\"\""
+ break
+ end
+ end
+ elseif (has_applications) then
+ if (Dir.exists("/Applications/Google Chrome.app")) then
+ chrome_cmd = "open --env=SSLKEYLOGFILE=\"" .. keylog_path .. "\" '/Applications/Google Chrome.app'"
+ end
+ if (Dir.exists("/Applications/Firefox.app")) then
+ firefox_cmd = "open --env=SSLKEYLOGFILE=\"" .. keylog_path .. "\" '/Applications/Firefox.app'"
+ end
+ elseif (has_usr_bin) then
+ local path_prefixes = { "/usr/bin/", "/usr/local/bin/" }
+ for _, path_prefix in ipairs(path_prefixes) do
+ chrome_path = path_prefix .. "chrome"
+ if (is_file(chrome_path)) then
+ chrome_cmd = "SSLKEYLOGFILE=\"" .. keylog_path .. "\" " .. chrome_path
+ break
+ end
+ end
+ for _, path_prefix in ipairs(path_prefixes) do
+ firefox_path = path_prefix .. "firefox"
+ if (is_file(firefox_path)) then
+ firefox_cmd = "SSLKEYLOGFILE=\"" .. keylog_path .. "\" " .. firefox_path
+ break
+ end
+ end
+ end
+
+ if (chrome_cmd == nil and firefox_cmd == nil) then
+ skl_win:append(
+ "\n\n" ..
+ "Unable to find Chrome or Firefox."
+ )
+ elseif (prefs_ok) then
+ skl_win:append(
+ "\n\n" ..
+ "If your desired browser is currently running, close it first before launching it below."
+ )
+ if (chrome_cmd) then
+ skl_win:add_button("Launch Chrome", launch_chrome)
+ end
+
+ if (firefox_cmd) then
+ skl_win:add_button("Launch Firefox", launch_firefox)
+ end
+ end
+
+ end
+
+ register_menu("Lua Scripts/Launch with SSLKEYLOG", show_skl_window, MENU_TOOLS_UNSORTED)
+
+ -- menu_pfx = "Lua Scripts/Launch with SSLKEYLOG/"
+ -- register_menu(menu_pfx .. "Chrome",run_chrome,MENU_TOOLS_UNSORTED)
+ -- register_menu(menu_pfx .. "Firefox",run_firefox,MENU_TOOLS_UNSORTED)
+end
diff --git a/packaging/nsis/CMakeLists.txt b/packaging/nsis/CMakeLists.txt
index e30eb5d875..5929164f84 100644
--- a/packaging/nsis/CMakeLists.txt
+++ b/packaging/nsis/CMakeLists.txt
@@ -180,7 +180,7 @@ if (BUILD_wireshark)
endforeach()
endif()
if(LUA_FOUND)
- foreach(_script "init.lua" "console.lua" "dtd_gen.lua")
+ foreach(_script "init.lua" "console.lua" "browser_sslkeylog.lua" "dtd_gen.lua")
set(_all_manifest_contents "${_all_manifest_contents}File \"\${STAGING_DIR}\\${_script}\"\n")
endforeach()
endif()
diff --git a/packaging/wix/CMakeLists.txt b/packaging/wix/CMakeLists.txt
index 35ce634a3c..c436e2dbe0 100644
--- a/packaging/wix/CMakeLists.txt
+++ b/packaging/wix/CMakeLists.txt
@@ -144,7 +144,7 @@ foreach(_dll ${CARES_DLL} ${PCRE2_DLL} ${GCRYPT_DLLS}
SET(unique_component ${unique_component} ${_dll})
ENDIF(NOT "${unique_component}" MATCHES "(^|;)${_dll}(;|$)")
endforeach()
-foreach(_script "init.lua" "console.lua" "dtd_gen.lua")
+foreach(_script "init.lua" "console.lua" "browser_sslkeylog.lua" "dtd_gen.lua")
STRING(REGEX REPLACE "[-|\\.]" "_" _wix_name ${_script})
file(APPEND "${_all_manifest_wix}" " <Component Id=\"cmp${_wix_name}\" Guid=\"*\">\n")
file(APPEND "${_all_manifest_wix}" " <File Id=\"fil${_wix_name}\" KeyPath=\"yes\" Source=\"$(var.Staging.Dir)\\${_script}\"/>\n")
@@ -182,7 +182,7 @@ foreach(_dll ${CARES_DLL} ${PCRE2_DLL} ${GCRYPT_DLLS}
SET(unique_file ${unique_file} ${_dll})
ENDIF(NOT "${unique_file}" MATCHES "(^|;)${_dll}(;|$)")
endforeach()
-foreach(_script "init.lua" "console.lua" "dtd_gen.lua")
+foreach(_script "init.lua" "console.lua" "browser_sslkeylog.lua" "dtd_gen.lua")
STRING(REGEX REPLACE "[-|\\.]" "_" _wix_name ${_script})
file(APPEND "${_all_manifest_wix}" " <ComponentRef Id=\"cmp${_wix_name}\" />\n")
endforeach()