Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Apr 7, 2019. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbotnet.py
More file actions
Latest commit
252 lines (212 loc) · 9.37 KB
/
Copy pathbotnet.py
File metadata and controls
252 lines (212 loc) · 9.37 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/usr/bin/python2.7
# -*- coding: utf-8
fromutilsimportUtils
importjson
importlogging
importrandom
importconfig
logger=logging.getLogger(__name__)
classBotnet:
ut=Utils()
def__init__(self, player):
self.username=player.username
self.password=player.password
self.uhash=player.uhash
self.botNetServers=3
self.botnet= []
self.p=player
self.ofwhat=config.BotNet_updates
self.energy=0
self._initbot()
def_initbot(self):
"""
Grab the amount of bots in the botnet
and populate and array of Bot class
:return: none
"""
if(self.ofwhat=="ALL"):
self.ofwhat= ["fw", "av", "smash", "mwk"]
data=self._botnetInfo()
bots=json.loads(data)
self.botnet= []
ifint(bots['count']) >0:
foriinbots['data']:
bot=Bot(i['running'], self.ofwhat[random.randint(0,len(self.ofwhat)-1)], self.energy, i['hostname'], self.username, self.password, self.uhash)
self.botnet.append(bot)
defprintbots(self):
"""
Print a list of player PCs in the botnet
:return: None
"""
forbotinself.botnet:
logger.info(bot)
defgetbotnetdata(self):
"""
Return an array of bot class.
Contains all the bots in the botnet.
:return: list of bot class
"""
returnself.botnet
defgetInfo(self):
"""
Get info about the entire botnet.
Including if you can attack bot net servers etc.
Also botnet PC info.
:return: list of vHack serves that can be hacked.
['1','2','1']. '1' = can be hacked, '2' time not elapsed.
"""
response=self.ut.requestString(self.username, self.password, self.uhash, "vh_botnetInfo.php")
response=json.loads(response)
returnresponse
defattack(self):
"""
Check if vHack server botnet is attackable,
then attack if can.
:return: none
"""
self._initbot()
logger.info("Trying Bot Net")
cinfo=self.getInfo()
foriinrange(1, self.botNetServers+1):
ifcinfo[i-1] =='1':
logger.debug('I am attacking #{}'.format(i))
ifi==1:
response=self.ut.requestString(self.username, self.password, self.uhash, "vh_attackCompany.php", company=str(i))
else:
response=self.ut.requestString(self.username, self.password, self.uhash, "vh_attackCompany"+str(i) +".php", company=str(i))
logger.debug('I attacked #{} with response {}'.format(i, response))
ifresponse=='0':
logger.info('#{} Netcoins gained'.format(i))
else:
logger.info('#{} Failed! No netcoins...'.format(i))
else:
logger.info("Botnet #{} not hackable yet".format(i))
defupgradebotnet(self, hostname, running, count):
"""
Check if there is enough money to upgrade a botnet PC.
Cycle through and upgrade until no money.
:return: None
"""
ofwhat=self.ofwhat[random.randint(0,len(self.ofwhat)-1)]
logger.info("Prepare attempting to upgrade bot net PC '"+hostname+"'")
get_infobot=self.getInfo()
if (int(get_infobot['data'][count]['strength']) ==1120andint(get_infobot['data'][count]['stars']) ==4):
logger.info("Bot '"+hostname+"' has max strength [1120] for level "+str(get_infobot['data'][count]['stars']))
returnFalse
elif (int(get_infobot['data'][count]['strength']) ==840andint(get_infobot['data'][count]['stars']) ==3):
logger.info("Bot '"+hostname+"' has max strength [840] for level "+str(get_infobot['data'][count]['stars']))
returnFalse
elif (int(get_infobot['data'][count]['strength']) ==600andint(get_infobot['data'][count]['stars']) ==2):
logger.info("Bot '"+hostname+"' has max strength [600] for level "+str(get_infobot['data'][count]['stars']))
returnFalse
elif (int(get_infobot['data'][count]['strength']) ==400andint(get_infobot['data'][count]['stars']) ==1):
logger.info("Bot '"+hostname+"' has max strength [400] for level "+str(get_infobot['data'][count]['stars']))
returnFalse
elif (int(get_infobot['data'][count]['strength']) ==3000andint(get_infobot['data'][count]['stars']) ==0):
logger.info("Bot '"+hostname+"' has max strength [3000] for level "+str(get_infobot['data'][count]['stars']))
returnFalse
if (int(get_infobot['data'][count]['running']) ==0andint(get_infobot['energy']) >0):
ifint(get_infobot['data'][count]['stars']) >0:
maxofwhat=20+ (5*int(get_infobot['data'][count]['stars']))
elifint(get_infobot['data'][count]['stars']) ==0:
maxofwhat=250
remove=0
fora, iinenumerate(xrange(0, len(self.ofwhat)-1)):
ifint(get_infobot['data'][count][unicode(self.ofwhat[i-remove])]) ==int(maxofwhat):
self.ofwhat.remove(self.ofwhat[i-remove])
remove=remove+1
ifi==3:
break
ofwhat=self.ofwhat[random.randint(0,(len(self.ofwhat)-1))]
new_bal=self.upgradesinglebot(hostname, ofwhat)
ifnew_bal:
logger.info("Waiting! Doing updates for bot '"+hostname+"', ["+ofwhat+"]")
returnTrue
elif (int(get_infobot['energy']) ==0):
logger.info("You don't have enough energy to upgrade '"+hostname+"'! :(")
returnFalse
elif (int(get_infobot['data'][count]['running']) ==1):
logger.info("Waiting! Doing updates for bot '"+hostname+"', ["+ofwhat+"]")
returnFalse
logger.debug("The bot '{}' is not upgradeable".format(hostname))
returnFalse
def_botnetInfo(self):
"""
Get the botnet information including vHack servers and PC data.
:return: string
'{"count":"14",
"data":[{"bID":"1","bLVL":"100","bSTR":"100","bPRICE":"10000000"},
{"bID":"2","bLVL":"100","bSTR":"100","bPRICE":"10000000"}],
"strength":23,"resethours1":"","resetminutes1":"14","resethours2":"4","resetminutes2":"15",
"resethours3":"3","resetminutes3":"15",
"canAtt1":"2","canAtt2":"2","canAtt3":"2"}'
"""
temp=self.ut.requestString(self.username, self.password, self.uhash, "vh_botnetInfo.php")
returntemp
defupgradesinglebot(self, hostname, ofwhat):
"""
Pass in bot class object and call upgrade function based on bot ID.
details :
{u'strength': u'22', u'old': u'30', u'mm': u'68359859',
u'money': u'66259859', u'costs': u'2100000',
u'lvl': u'21', u'new': u'22'}
current lvl, bot number, x, x, upgrade cost, lvl, next lvl
:return: None
"""
response=self.ut.requestString(self.username, self.password, self.uhash, "vh_upgradePC.php", hostname=hostname, ofwhat=ofwhat, inst="0", much="1")
jsons=json.loads(response)
ifint(jsons['result']) ==0:
returnTrue
else:
logger.error("Upgrades on "+hostname+" Failed !")
returnFalse
def__repr__(self):
return"Botnet details: vHackServers: {0}, Bot Net PC's: {1}".format(self.botNetServers, self.botnet)
classBot:
ut=Utils()
def__init__(self, running, ofwhat, energy, hostname, username, password, uhash):
self.username=username
self.uhash=uhash
self.password=password
self.running=int(running)
self.ofwhat=ofwhat
self.energy=energy
self.hostname=hostname
defbotupgradable(self, running):
"""
Determine if botnet PC is at max level or not.
:return: Bool
"""
ifrunning==0:
returnTrue
else:
returnFalse
defnextlevelcostenergy(self):
"""
Return the cost of upgrading bot to the next level
:return:int
"""
returnself.energy
defparse_json_stream(self, stream):
decoder=json.JSONDecoder()
whilestream:
obj, idx=decoder.raw_decode(stream)
yieldobj
stream=stream[idx:].lstrip()
defupgradesinglebot(self, hostname, ofwhat):
"""
Pass in bot class object and call upgrade function based on bot ID.
details :
{u'strength': u'22', u'old': u'30', u'mm': u'68359859',
u'money': u'66259859', u'costs': u'2100000',
u'lvl': u'21', u'new': u'22'}
current lvl, bot number, x, x, upgrade cost, lvl, next lvl
:return: None
"""
response=self.ut.requestString(self.username, self.password, self.uhash, "vh_upgradePC.php", hostname=hostname, ofwhat=ofwhat)
#response = response.split('}{')[0] + '}'
#jsons = json.loads(response)
#logger.info(jsons)
returnTrue
def__repr__(self):
return"Bot details: running: {0}, energy: {1}, upgrade: {2}, botname: {3}".format(self.running, self.energy, self.ofwhat, self.hostname)