Compare commits

...

6 Commits

Author SHA1 Message Date
github-actions b1e40fdd95 Bump Dockerfile tag to match release 'v0.0.2.6' 2024-10-07 20:58:34 +00:00
its-a-feature 20c9d37f76 updated to forward more data 2024-10-07 15:51:51 -05:00
github-actions b91bd3eae2 Bump Dockerfile tag to match release 'v0.0.2.5' 2024-09-13 20:30:34 +00:00
its-a-feature 200bb3f339 adding support to forward user-agent and full url 2024-09-13 15:24:06 -05:00
github-actions 7dbe513591 Bump Dockerfile tag to match release 'v0.0.2.4' 2024-09-11 22:06:48 +00:00
its-a-feature 68f4c32f00 fixing rewrite rules with multiple bound ports 2024-09-11 17:00:09 -05:00
5 changed files with 27 additions and 13 deletions
+2 -2
View File
@@ -20,10 +20,10 @@ run:
cd http/c2_code && make run
./${BINARY_NAME}
build_macos:
local:
CGO_ENABLED=0 go build -o ${BINARY_NAME} .
run_custom: build_macos
run_custom: local
DEBUG_LEVEL=${DEBUG_LEVEL} \
RABBITMQ_HOST=${RABBITMQ_HOST} \
RABBITMQ_PASSWORD=${RABBITMQ_PASSWORD} \
+1 -1
View File
@@ -19,7 +19,7 @@ run:
build_macos:
CGO_ENABLED=0 go build -o ${BINARY_NAME} .
run_custom:
run_custom: build_local
DEBUG_LEVEL=${DEBUG_LEVEL} \
MYTHIC_SERVER_HOST=${MYTHIC_SERVER_HOST} \
MYTHIC_SERVER_PORT=${MYTHIC_SERVER_PORT} \
@@ -131,11 +131,15 @@ func InitializeGinLogger(configInstance instanceConfig) gin.HandlerFunc {
func setRoutes(r *gin.Engine, configInstance instanceConfig) {
// define generic get/post routes
director := func(req *http.Request) {
req.Header.Add("mythic", "http")
req.Header.Add("X-forwarded-user-agent", req.Header.Get("User-Agent"))
req.Header.Add("x-forwarded-url", req.URL.RequestURI())
req.Header.Add("x-forwarded-for", req.RemoteAddr)
req.Header.Add("x-forwarded-host", req.Host)
req.URL.Scheme = "http"
req.URL.Host = fmt.Sprintf("%s:%d", mythicConfig.MythicConfig.MythicServerHost, mythicConfig.MythicConfig.MythicServerPort)
req.Host = fmt.Sprintf("%s:%d", mythicConfig.MythicConfig.MythicServerHost, mythicConfig.MythicConfig.MythicServerPort)
req.URL.Path = "/agent_message"
req.Header.Add("mythic", "http")
}
modifyResponse := func(resp *http.Response) error {
//logging.LogInfo("hitting modify response", "responseCode", resp.StatusCode)
@@ -184,11 +188,15 @@ func setRoutes(r *gin.Engine, configInstance instanceConfig) {
for path, value := range configInstance.PayloadHostPaths {
localVal := value
directorForFiles := func(req *http.Request) {
req.Header.Add("mythic", "http")
req.Header.Add("X-forwarded-user-agent", req.Header.Get("User-Agent"))
req.Header.Add("x-forwarded-url", req.URL.RequestURI())
req.Header.Add("x-forwarded-for", req.RemoteAddr)
req.Header.Add("x-forwarded-host", req.Host)
req.URL.Scheme = "http"
req.URL.Host = fmt.Sprintf("%s:%d", mythicConfig.MythicConfig.MythicServerHost, mythicConfig.MythicConfig.MythicServerPort)
req.Host = fmt.Sprintf("%s:%d", mythicConfig.MythicConfig.MythicServerHost, mythicConfig.MythicConfig.MythicServerPort)
req.URL.Path = fmt.Sprintf("/direct/download/%s", localVal)
req.Header.Add("mythic", "http")
}
proxyForFiles := httputil.ReverseProxy{
Director: directorForFiles,
+13 -7
View File
@@ -207,19 +207,25 @@ RewriteEngine On
## Logic: If a requested URI AND the User-Agent matches, proxy the connection to the Teamserver
## Consider adding other HTTP checks to fine tune the check. (HTTP Cookie, HTTP Referer, HTTP Query String, etc)
## Refer to http://httpd.apache.org/docs/current/mod/mod_rewrite.html
## Only allow GET and POST methods to pass to the C2 server
RewriteCond %%{REQUEST_METHOD} ^(GET|POST) [NC]
## Profile URIs
RewriteCond %%{REQUEST_URI} ^(%s)$
## Profile UserAgent
RewriteCond %%{HTTP_USER_AGENT} "%s"
%s
## Redirect all other traffic here
RewriteRule ^.*$ redirect/? [L,R=302]
## .htaccess END
########################################
`
htaccess := fmt.Sprintf(htaccessTemplate, urisString, uaString, strings.Join(c2RewriteOutput, "\n"))
htaccessConditionTemplate := `
## Only allow GET and POST methods to pass to the C2 server
RewriteCond %%{REQUEST_METHOD} ^(GET|POST) [NC]
## Profile URIs
RewriteCond %%{REQUEST_URI} ^(%s)$
## Profile UserAgent
RewriteCond %%{HTTP_USER_AGENT} "%s"`
htaccessConditions := fmt.Sprintf(htaccessConditionTemplate, urisString, uaString)
allHtaccessConditions := ""
for _, c2Entry := range c2RewriteOutput {
allHtaccessConditions += htaccessConditions + "\n" + c2Entry + "\n"
}
htaccess := fmt.Sprintf(htaccessTemplate, allHtaccessConditions)
output += "#\tReplace 'redirect' with the http(s) address of where non-matching traffic should go, ex: https://redirect.com\n"
output += "\n" + htaccess
response.Message = output
+1 -1
View File
@@ -5,6 +5,6 @@
"exclude_documentation_c2": false,
"exclude_agent_icons": false,
"remote_images": {
"http": "ghcr.io/mythicc2profiles/http:v0.0.2.3"
"http": "ghcr.io/mythicc2profiles/http:v0.0.2.6"
}
}