Skip to content
This repository was archived by the owner on Apr 7, 2019. It is now read-only.

Commit 355b1f8

Browse files
authored
Sorry for modified file my file is old version
1 parent 3dafa2e commit 355b1f8

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

botnet.py

+26-23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import logging
88
import random
9+
import config
910
logger = logging.getLogger(__name__)
1011

1112

@@ -19,7 +20,7 @@ def __init__(self, player):
1920
self.botNetServers = 3
2021
self.botnet = []
2122
self.p = player
22-
self.ofwhat = ["fw", "av", "smash", "mwk"]
23+
self.ofwhat = config.BotNet_updates
2324
self.energy = 0
2425
self._initbot()
2526

@@ -29,12 +30,14 @@ def _initbot(self):
2930
and populate and array of Bot class
3031
:return: none
3132
"""
33+
if(self.ofwhat == "ALL"):
34+
self.ofwhat = ["fw", "av", "smash", "mwk"]
3235
data = self._botnetInfo()
3336
bots = json.loads(data)
3437
self.botnet = []
3538
if int(bots['count']) > 0:
3639
for i in bots['data']:
37-
bot = Bot(i['running'], self.ofwhat[random.randint(0,3)], self.energy, i['hostname'], self.username, self.password, self.uhash)
40+
bot = Bot(i['running'], self.ofwhat[random.randint(0,len(self.ofwhat)-1)], self.energy, i['hostname'], self.username, self.password, self.uhash)
3841
self.botnet.append(bot)
3942

4043
def printbots(self):
@@ -77,46 +80,47 @@ def attack(self):
7780

7881
for i in range(1, self.botNetServers + 1):
7982
if cinfo[i - 1] == '1':
80-
logger.debug('attacking #{}'.format(i))
83+
logger.debug('I am attacking #{}'.format(i))
8184
if i == 1:
8285
response = self.ut.requestString(self.username, self.password, self.uhash, "vh_attackCompany.php", company=str(i))
8386
else:
8487
response = self.ut.requestString(self.username, self.password, self.uhash, "vh_attackCompany" + str(i) + ".php", company=str(i))
85-
logger.debug('attack #{} response {}'.format(i, response))
88+
logger.debug('I attacked #{} with response {}'.format(i, response))
8689
if response == '0':
8790
logger.info('#{} Netcoins gained'.format(i))
8891
else:
8992
logger.info('#{} Failed! No netcoins...'.format(i))
9093
else:
91-
logger.info("Botnet #{} not hackable as yet".format(i))
94+
logger.info("Botnet #{} not hackable yet".format(i))
9295

9396
def upgradebotnet(self, hostname, running, count):
9497
"""
9598
Check if there is enough money to upgrade a botnet PC.
9699
Cycle through and upgrade until no money.
97100
:return: None
98101
"""
99-
logger.info("Prepare attempting to upgrade bot net PC's "+ hostname)
102+
ofwhat = self.ofwhat[random.randint(0,len(self.ofwhat)-1)]
103+
logger.info("Prepare attempting to upgrade bot net PC '"+ hostname +"'")
100104
get_infobot = self.getInfo()
101105

102106
if (int(get_infobot['data'][count]['strength']) == 1120 and int(get_infobot['data'][count]['stars']) == 4):
103-
logger.info("bot is complet [max strength 1120] " + hostname + " for level " + str(get_infobot['data'][count]['stars']))
107+
logger.info("Bot '"+hostname+"' has max strength [1120] for level " + str(get_infobot['data'][count]['stars']))
104108
return False
105109

106110
elif (int(get_infobot['data'][count]['strength']) == 840 and int(get_infobot['data'][count]['stars']) == 3):
107-
logger.info("bot is complet [max strength 840] " + hostname + " for level " + str(get_infobot['data'][count]['stars']))
111+
logger.info("Bot '"+hostname+"' has max strength [840] for level " + str(get_infobot['data'][count]['stars']))
108112
return False
109113

110114
elif (int(get_infobot['data'][count]['strength']) == 600 and int(get_infobot['data'][count]['stars']) == 2):
111-
logger.info("bot is complet [max strength 600] " + hostname + " for level " + str(get_infobot['data'][count]['stars']))
115+
logger.info("Bot '"+hostname+"' has max strength [600] for level " + str(get_infobot['data'][count]['stars']))
112116
return False
113117

114118
elif (int(get_infobot['data'][count]['strength']) == 400 and int(get_infobot['data'][count]['stars']) == 1):
115-
logger.info("bot is complet [max strength 400] " + hostname + " for level " + str(get_infobot['data'][count]['stars']))
119+
logger.info("Bot '"+hostname+"' has max strength [400] for level " + str(get_infobot['data'][count]['stars']))
116120
return False
117121

118122
elif (int(get_infobot['data'][count]['strength']) == 3000 and int(get_infobot['data'][count]['stars']) == 0):
119-
logger.info("bot is complet [max strength 3000] " + hostname + " for level " + str(get_infobot['data'][count]['stars']))
123+
logger.info("Bot '"+hostname+"' has max strength [3000] for level " + str(get_infobot['data'][count]['stars']))
120124
return False
121125

122126
if (int(get_infobot['data'][count]['running']) == 0 and int(get_infobot['energy']) > 0):
@@ -129,29 +133,29 @@ def upgradebotnet(self, hostname, running, count):
129133

130134
remove = 0
131135

132-
for a, i in enumerate(xrange(0, 4)):
136+
for a, i in enumerate(xrange(0, len(self.ofwhat)-1)):
133137
if int(get_infobot['data'][count][unicode(self.ofwhat[i-remove])]) == int(maxofwhat):
134138
self.ofwhat.remove(self.ofwhat[i-remove])
135-
remove = remove +1
136-
139+
remove = remove + 1
137140
if i == 3:
138141
break
139142

140143
ofwhat = self.ofwhat[random.randint(0,(len(self.ofwhat)-1))]
144+
141145
new_bal = self.upgradesinglebot(hostname, ofwhat)
142146
if new_bal:
143-
logger.info("wait botnet update working for " + hostname + ", [" + ofwhat + "]")
147+
logger.info("Waiting! Doing updates for bot '" + hostname + "', [" + ofwhat + "]")
144148
return True
145149

146150
elif (int(get_infobot['energy']) == 0):
147-
logger.info("your are not energy for update " + hostname + " :(")
151+
logger.info("You don't have enough energy to upgrade '" + hostname + "'! :(")
148152
return False
149153

150154
elif (int(get_infobot['data'][count]['running']) == 1):
151-
logger.info(hostname + " running update please wait...")
155+
logger.info("Waiting! Doing updates for bot '" + hostname + "', [" + ofwhat + "]")
152156
return False
153157

154-
logger.debug("#{} not upgradeable".format(hostname))
158+
logger.debug("The bot '{}' is not upgradeable".format(hostname))
155159
return False
156160

157161
def _botnetInfo(self):
@@ -183,7 +187,7 @@ def upgradesinglebot(self, hostname, ofwhat):
183187
if int(jsons['result']) == 0:
184188
return True
185189
else:
186-
logger.error("Upgrade " + hostname + " Failed !")
190+
logger.error("Upgrades on " + hostname + " Failed !")
187191
return False
188192

189193
def __repr__(self):
@@ -237,10 +241,9 @@ def upgradesinglebot(self, hostname, ofwhat):
237241
:return: None
238242
"""
239243
response = self.ut.requestString(self.username, self.password, self.uhash, "vh_upgradePC.php", hostname=hostname, ofwhat=ofwhat)
240-
response = response.split('}{')[0] + '}'
241-
print(response)
242-
jsons = json.loads(response)
243-
logger.info(jsons)
244+
#response = response.split('}{')[0] + '}'
245+
#jsons = json.loads(response)
246+
#logger.info(jsons)
244247
return True
245248

246249

0 commit comments

Comments
 (0)