-
Notifications
You must be signed in to change notification settings - Fork 166
/
start_campaign.py
executable file
·216 lines (190 loc) · 10.5 KB
/
start_campaign.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import random
from datetime import datetime
from os import mkdir
from rich.pretty import pprint
from rich.console import Console
console = Console()
log = Console(style="bold green")
beacon = ''
IP = ''
PORT = ''
SSL = ''
cert = ''
key = ''
date = ''
Dount = ''
name = ''
def campaign_name():
global name
name = console.input('\n[cyan][-] Enter Campaign name:[/cyan] ')
def initiate_url():
identifiers = ["raw_payload", "b52_payload", "b64_stager", "b52_stager", "hjf_payload", "b64_payload",
"hjfs_payload", "sct_payload", "hta_payload", "register_url", "download_url", "upload_url",
"image_url", "command_url", "result_url", "modules_url","follina_url"]
global urls
urls = {}
# list_full=['path','pdf','perl','perl5','personal','personals','pgsql','phone','php','phpmyadmin','phpMyAdmin','pics','ping','pix','pl','pls','plx','pol','policy','poll','pop','portal','portlet','portlets','post','postgres','power','press','preview','print','printenv','priv','private','privs','process','processform','prod','production','products','professor','profile','program','project','proof','properties','protect','protected','proxy','ps','pub','public','publish','publisher','purchase','purchases','put','pw','pwd','python','queries','query','queue','quote','ramon','random','rank','rcs','readme','redir','redirect','reference','references','reg','reginternal','regional','register','registered','release','remind','reminder','remote','removed','report','reports','requisite','research','reseller','resource','resources','responder','restricted','retail','right','robot','robotics','root','route','router','rpc','rss','rules','run','sales','sample','samples','save','saved','schema','scr','scratc','script','scripts','sdk','search','secret','secrets','section','sections','secure','secured','security','select','sell','send','sendmail','sensepost','sensor','sent','server','servers','server_stats','service','services','servlet','Servlet','servlets','Servlets','session','sessions','set','setting','settings','setup','share','shared','shell','shit','shop','shopper','show','showcode','shtml','sign','signature','signin','simple','single','site','sitemap','sites','SiteServer','small','snoop','soap','soapdocs','software','solaris','solutions','somebody','source','sources','Sources','spain','spanish','sql','sqladmin','src','srchad','srv','ssi','ssl','staff','start','startpage','stat','statistic','statistics','Statistics','stats','Stats','status','stop','store','story','string','student','stuff','style','stylesheet','stylesheets','submit','submitter','sun','super','support','supported','survey','svc','svn','svr','sw','sys','sysadmin','system','table','tag','tape','tar','target','tech','temp','template','templates','temporal','temps','terminal','test','testing','tests','text','texts','ticket','tmp','today','tool','toolbar','tools','top','topics','tour','tpv','trace','traffic','transaction','transactions','transfer','transport','trap','trash','tree','trees','tutorial','uddi','uninstall','unix','up','update','updates','upload','uploader','uploads','usage','user','users','usr','ustats','util','utilities','utility','utils','validation','validatior','vap','var','vb','vbs','vbscript','vbscripts','vfs','view','viewer','views','virtual','visitor','vpn','w','w3','w3c','W3SVC','W3SVC1','W3SVC2','W3SVC3','warez','wdav','web','webaccess','webadmin','webapp','webboard','webcart','webdata','webdav','webdist','webhits','WEB-INF','weblog','weblogic','weblogs','webmail','webmaster','websearch','webservice','webservices','website','webstat','webstats','webvpn','welcome','wellcome','whatever','whatnot','whois','will','win','windows','word','work','workplace','workshop','ws','wstats','wusage','www','wwwboard','wwwjoin','wwwlog','wwwstats','xcache','xfer','xml','xmlrpc','xsl','xsql','xyz','zap','zip','zipfiles','zips']
f = open("utils/links.txt")
links = f.read()
list_full = links.strip().replace("\r", "").split("\n") # replace("\0","").replace("\n",",").split(",")
for i in identifiers:
uri = random.choice(list_full)
urls[i] = "/" + uri
list_full.remove(uri)
log.log(f"[+] Urls will be used in this campaign:\n")
pprint(urls)
def get_ip():
global IP, PORT
while True:
try:
CC = console.input('[cyan][-] Enter a DN/IP:Port for this campaign:[/cyan] ')
CC = CC.split(':')
IP = CC[0]
PORT = CC[1]
break
except IndexError:
console.print("[-] Please enter a valid DN/IP:Port", style="red")
continue
log.log(f"[+] You chose: {IP}:{PORT}")
def get_beacon():
global beacon
CC = ''
while len(CC) == 0:
CC = console.input(
'[cyan][-] Enter the default beacon period (connect back) for this campaign in seconds:[cyan] ')
beacon = CC
def log_campaign():
try:
mkdir("logs")
except FileExistsError:
pass
global beacon, IP, PORT, date, url, name
current_date = datetime.now()
Log = "=================================================================================\n"
Log += "==========================New Campaign==========================================\n"
Log += f"[*] Campaign started at: {current_date.strftime('[%H:%M:%S]-[%d/%m/%Y]')}\n\n"
Log += "[+] Campaign Name:\n" + name
Log += "[+] Urls for this campaign:\n" + url
Log += "\n[+] IP/Domain:Port for this Campaign : " + IP + ":" + PORT + "\n"
Log += "[+] Beacon period for this campaign : " + beacon + "\n\n\n"
Log += "[+] kill date for this campaign : " + date + "\n\n\n"
file = open("logs/c2-logs.txt", "a+")
file.write(Log)
file.close()
def kill_date():
global date
CC = ''
while len(CC) == 0:
CC = console.input(
'[cyan][-] Please enter kill date for this campaign ([green]format dd/MM/yyyy[/green]): [/cyan]')
if len(CC.split("/")) > 2:
try:
date = datetime.strptime(CC, '%d/%m/%Y')
except:
console.print("[!] Please enter a valid date", style="red")
CC = ''
continue
date = CC
break
else:
continue
def get_ssl():
global SSL, key, cert
CC = ''
while len(CC) == 0:
CC = console.input('[cyan][-] Do you want to use SSL?[cyan] [green](yes/no)[/green]: ')
if CC == "yes":
SSL = "True"
break
if CC == "no":
SSL = "False"
return
else:
continue
CC = ''
while len(CC) == 0:
CC = console.input(
'[cyan][-] Do you want to use default self signed SSL certificate?[/cyan] [green](yes/no)[/green]: ')
if CC == "yes":
cert = 'utils/Certificate/ninja.crt'
key = 'utils/Certificate/ninja.key'
return
if CC == "no":
break
else:
continue
CC = ''
while len(CC) == 0:
CC = console.input(
'[cyan][-] Enter the full path for certificate[/cyan] [green]( ex : /root/certificate.crt )[/green]: ')
cert = CC
CC = ''
while len(CC) == 0:
CC = console.input(
'[cyan][-] Enter the full path for private key[/cyan] [green]( ex : /root/private.key )[/green]: ')
key = CC
def Disable_Donut():
global Donut
CC = ''
while len(CC) == 0:
CC = console.input(
'[cyan][-] Some users reported issues with donut, so if you have startup crash then disable it.\n[-] Do you want to disable donut shellcodes? ([green]this will disable migrate command in the agents[/green]) [green](yes/no)[/green]: ')
CC = CC.split(':')
Choice = CC[0]
if Choice.lower() != "yes" and Choice.lower() != "no":
CC = ''
if Choice.lower() == "yes":
Donut = 'False'
log.log("[+] Donut will be disabled", style="bold green")
if Choice.lower() == "no":
Donut = 'True'
log.log("[+] Donut will be Enabled", style="bold green")
def update_template():
global beacon, IP, PORT, date, Donut, url, name
name = name + "-campaign"
url = ''
for k, v in urls.items():
url += f'{k}="{v}"\n'
template = open("core/config.template", "r")
config = open("core/config.py", "w")
mkdir(name)
campaign_config = open(name + "/" + "config.py", "w")
data = template.read()
data = data.replace('{IP}', IP).replace('{beacon_time}', beacon).replace('{PORT}', PORT).replace('{URL}',
url).replace(
'{SSL}', SSL).replace('{CERT}', cert).replace('{KEY}', key).replace('{KDATE}', date).replace('{DONUT}',
Donut).replace(
'{NAME}', str(name))
config.write(data)
campaign_config.write(data)
campaign_config.close()
config.close()
template.close()
def banner():
console.print("""
████ ██ ██ ██ ████
░██░██ ░██░░ ░░ █░░░ █
░██░░██ ░██ ██ ███████ ██ ██████ █████ ░ ░█
░██ ░░██ ░██░██░░██░░░██ ░██ ░░░░░░██ ██░░░██ ███
░██ ░░██░██░██ ░██ ░██ ░██ ███████ ░██ ░░ █░░
░██ ░░████░██ ░██ ░██ ██░██ ██░░░░██ ░██ ██ █
░██ ░░███░██ ███ ░██░░███ ░░████████ ░░█████ ░██████
░░ ░░░ ░░ ░░░ ░░ ░░░ ░░░░░░░░ ░░░░░ ░░░░░░
[bold cyan]By: Ahmad khlief
----------------[/bold cyan]
\n\n""", style="red")
if __name__ == '__main__':
try:
banner()
initiate_url()
campaign_name()
get_ip()
get_beacon()
kill_date()
get_ssl()
Disable_Donut()
update_template()
log_campaign()
console.print("\t\t\t\t\t[++] Done, you can now run ninja by: python3 Ninja.py", style="bold italic green")
except KeyboardInterrupt:
console.print("\n[!] Ctrl+C detected", style="bold red")