mirror of
https://github.com/MythicC2Profiles/http
synced 2026-06-08 11:56:36 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b1e40fdd95 | |||
| 20c9d37f76 | |||
| b91bd3eae2 | |||
| 200bb3f339 | |||
| 7dbe513591 | |||
| 68f4c32f00 |
@@ -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} \
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user