Skip to content

Commit 8642719

Browse files
committed
Initial Open Source Release
0 parents  commit 8642719

File tree

17 files changed

+5739
-0
lines changed

17 files changed

+5739
-0
lines changed

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Dependency directories (remove the comment below to include it)
15+
# vendor/
16+
17+
# Go workspace file
18+
go.work

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Marasi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<div align="center">
2+
3+
# Marasi
4+
5+
[![GoDoc](https://godoc.org/github.com/tfkr-ae/marasi?status.png)](https://godoc.org/github.com/tfkr-ae/marasi)
6+
7+
<img src="images/logo.svg" width="150" alt="Marasi">
8+
9+
A Go library for building application security testing proxies.
10+
11+
[marasi.app](https://marasi.app)
12+
</div>
13+
14+
## Features
15+
16+
- **HTTP/HTTPS Proxy**: TLS-capable proxy server with certificate management
17+
- **Request/Response Interception**: Modify traffic in real-time
18+
- **Lua Extensions**: Scriptable proxy behavior with built-in extensions
19+
- **Application Data Format**: SQLite-based storage for all proxy data (requests, responses, metadata)
20+
- **Launchpad**: Replay and modify HTTP requests
21+
- **Scope Management**: Filter traffic with inclusion/exclusion rules
22+
- **Waypoints**: Override hostnames for request routing
23+
- **Chrome Integration**: Auto-configure Chrome with proxy settings
24+
25+
## Core Components
26+
27+
### Proxy Engine
28+
- Built on [Google Martian Proxy](https://github.com/google/martian)
29+
- Automatic content decoding
30+
- Content prettification (JSON, XML, HTML)
31+
- Concurrent request/response processing
32+
33+
### Extension System
34+
Lua based extension support, three built-in extensions:
35+
- **Compass**: Scope management and traffic filtering
36+
- **Checkpoint**: Request/response interception rules
37+
- **Workshop**: Lua development environment
38+
39+
The ability to add custom extensions coming soon.
40+
41+
42+
### Application File Format
43+
SQLite-based application file format stores:
44+
- Complete request/response data with timing
45+
- Extension management and settings
46+
- Launchpad entries for request replay
47+
- Comprehensive logging system
48+
- User notes and hostname waypoints
49+
50+
## Library Usage
51+
52+
This library is designed for building web appilcation security proxies.
53+
54+
Basic integration (for full implementation see marasi-app):
55+
56+
```go
57+
// Create proxy with options
58+
proxy, err := marasi.New(
59+
marasi.WithConfigDir("/path/to/config"),
60+
marasi.WithDatabase(repo),
61+
)
62+
63+
// Set up handlers for your application
64+
proxy.WithOptions(
65+
marasi.WithRequestHandler(func(req marasi.ProxyRequest) error {
66+
// Handle Requests in your application
67+
return nil
68+
}),
69+
marasi.WithResponseHandler(func(res marasi.ProxyResponse) error {
70+
// Handle Responses in your application
71+
return nil
72+
}),
73+
marasi.WithLogHandler(func(logItem marasi.Log) error {
74+
// Handle log messages
75+
return nil
76+
}),
77+
marasi.WithInterceptHandler(func(intercepted *marasi.Intercepted) error {
78+
switch intercepted.Type {
79+
case "request":
80+
// Handle Request interception
81+
case "response":
82+
// Handle Response interception
83+
}
84+
return nil
85+
}),
86+
)
87+
88+
// Start proxy server
89+
listener, err := proxy.GetListener("127.0.0.1", "8080")
90+
proxy.Serve(listener)
91+
```
92+
# GitHub Discussion
93+
Use the [GitHub Discussion](https://github.com/tfkr-ae/marasi/discussions) to provide feedback, ask questions or discuss the project.

chrome.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package marasi
2+
3+
import (
4+
"fmt"
5+
"os/exec"
6+
"path"
7+
"runtime"
8+
)
9+
10+
// getChromePath determines the Chrome executable path based on the operating system.
11+
// It checks common installation locations for Chrome and Chromium on macOS, Windows, and Linux.
12+
//
13+
// Returns:
14+
// - string: Path to Chrome executable, or empty string if not found
15+
func getChromePath() string {
16+
var paths []string
17+
switch runtime.GOOS {
18+
case "darwin":
19+
paths = []string{
20+
`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,
21+
`/Applications/Chromium.app/Contents/MacOS/Chromium`,
22+
`/usr/local/bin/chrome`, // Alternative common symlink
23+
`/usr/local/bin/chromium`, // Alternative common symlink for Chromium
24+
}
25+
case "windows":
26+
paths = []string{
27+
`C:\Program Files\Google\Chrome\Application\chrome.exe`,
28+
`C:\Program Files (x86)\Google\Chrome\Application\chrome.exe`,
29+
`C:\Program Files\Chromium\Application\chrome.exe`,
30+
}
31+
case "linux":
32+
paths = []string{
33+
`/usr/bin/google-chrome`,
34+
`/usr/bin/chromium-browser`,
35+
`/usr/bin/chromium`,
36+
`/snap/bin/chromium`,
37+
}
38+
default:
39+
return ""
40+
}
41+
42+
// Find the first valid path
43+
for _, path := range paths {
44+
if _, err := exec.LookPath(path); err == nil {
45+
return path
46+
}
47+
}
48+
return ""
49+
}
50+
51+
// StartChrome launches Chrome with proxy configuration and security settings.
52+
// It configures Chrome to use the proxy server, creates an isolated user profile,
53+
// and disables various Chrome features that might interfere with testing.
54+
//
55+
// Returns:
56+
// - error: Chrome launch error if executable not found or process fails to start
57+
func (proxy *Proxy) StartChrome() error {
58+
// Determine Chrome path based on OS
59+
chromePath := getChromePath()
60+
if chromePath == "" {
61+
return fmt.Errorf("unsupported operating system")
62+
}
63+
64+
// Set flags for Chrome
65+
flags := []string{
66+
fmt.Sprintf("--user-data-dir=%s", path.Join(proxy.ConfigDir, "chrome-profile")),
67+
fmt.Sprintf("--proxy-server=http://%s:%s", proxy.Addr, proxy.Port),
68+
fmt.Sprintf("--ignore-certificate-errors-spki-list=%s", proxy.SPKIHash),
69+
"--disable-background-networking",
70+
"--disable-client-side-phishing-detection",
71+
"--disable-default-apps",
72+
"--disable-features=NetworkPrediction,OmniboxUIExperimentMaxAutocompleteMatches",
73+
"--disable-sync",
74+
"--metrics-recording-only",
75+
"--disable-domain-reliability",
76+
"--no-first-run",
77+
"--disable-component-update",
78+
"--disable-suggestions-service",
79+
"--disable-search-geolocation-disclosure",
80+
"--disable-search-engine-choice",
81+
"--disable-omnibox-autocomplete-offers", // Disables autocomplete suggestions
82+
"--proxy-bypass-list=<-loopback>",
83+
"about:blank",
84+
}
85+
86+
// Start Chrome process
87+
cmd := exec.Command(chromePath, flags...)
88+
if err := cmd.Start(); err != nil {
89+
return fmt.Errorf("starting chrome : %w", err)
90+
}
91+
92+
return nil
93+
}

0 commit comments

Comments
 (0)