This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http/httputil" | |
"github.com/joncooperworks/judas/plugins" | |
) | |
type loggingPlugin struct{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
transactions := make(chan plugins.HTTPTransaction) | |
// Process all the plugin arguments. | |
for plugin, arguments := range installedPlugins { | |
go plugin.ProcessTransactions(transactions, arguments) | |
} | |
for { | |
conn, err := server.Accept() | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loadPluginsFromDirectory(pluginsDirectory string) (map[plugins.Plugin]plugins.PluginArguments, error) { | |
pluginFilePaths, err := filepath.Glob(pluginsDirectory) | |
if err != nil { | |
return nil, err | |
} | |
installedPlugins := map[plugins.Plugin]plugins.PluginArguments{} | |
for _, filepath := range pluginFilePaths { | |
plugin, err := plugins.New(filepath) | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HTTPTransaction represents a complete request - response flow. | |
type HTTPTransaction struct { | |
Request http.Request | |
Response http.Response | |
} | |
// PluginArguments is a map[string]interface{} of arguments to be passed to your ProcessTransactions function. | |
type PluginArguments map[string]interface{} | |
// Plugin contains functions and variables that Judas will be looking for in your plugin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cer, err := tls.LoadX509KeyPair(certPath, privateKeyPath) | |
if err != nil { | |
exitWithError("Error loading keypair") | |
} | |
config := &tls.Config{Certificates: []tls.Certificate{cer}} | |
server, err := tls.Listen("tcp", address, config) | |
if err != nil { | |
exitWithError("Error starting TLS server") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dialer, err := proxy.SOCKS5("tcp", proxyAddress, nil, proxy.Direct) | |
if err != nil { | |
exitWithError(err.Error()) | |
} | |
httpTransport := &http.Transport{} | |
httpTransport.Dial = dialer.Dial | |
client.Transport = httpTransport | |
phishingProxy := &PhishingProxy{ | |
client: client, | |
targetURL: u, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ResponseTransformer modifies a response in any way we see fit, such as inserting extra JavaScript. | |
type ResponseTransformer interface { | |
Transform(response *http.Response) error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScriptInjectionTransformer holds JavaScript filename for injecting into response. | |
type JavaScriptInjectionTransformer struct { | |
javascriptURL string | |
} | |
// Transform Injects JavaScript into an HTML response. | |
func (j JavaScriptInjectionTransformer) Transform(response *http.Response) error { | |
if !strings.Contains(response.Header.Get("Content-Type"), "text/html") { | |
return nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _, transformer := range p.responseTransformers { | |
transformer.Transform(resp) | |
} | |
modifiedResponse, err := httputil.DumpResponse(resp, true) | |
if err != nil { | |
log.Println("Error converting requests to bytes:", err.Error()) | |
return | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
target := request.URL | |
target.Scheme = p.targetURL.Scheme | |
target.Host = p.targetURL.Host | |
req, err := http.NewRequest(request.Method, target.String(), request.Body) | |
if err != nil { | |
return nil, err | |
} | |
for key, _ := range request.Header { | |
req.Header.Set(key, request.Header.Get(key)) |