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

Commit

Permalink
Fixed various issues for agent profile setting/handling
Browse files Browse the repository at this point in the history
'DefaultProfile' option in listener menu is now tab-completable and can take a path to a profile.txt
  • Loading branch information
HarmJ0y committed Dec 29, 2015
1 parent d152e71 commit 82fed97
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/common/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ def add_agent(self, sessionID, externalIP, delay, jitter, profile, killDate, wor
if len(parts) == 2:
requestUris = parts[0]
userAgent = parts[1]
elif len(parts) == 3:
elif len(parts) > 2:
requestUris = parts[0]
userAgent = parts[1]
additionalHeaders = parts[2]
additionalHeaders = "|".join(parts[2:])

cur.execute("INSERT INTO agents (name,session_id,delay,jitter,external_ip,session_key,checkin_time,lastseen_time,uris,user_agent,headers,kill_date,working_hours,lost_limit) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", (sessionID,sessionID,delay,jitter,externalIP,sessionKey,checkinTime,lastSeenTime,requestUris,userAgent,additionalHeaders,killDate,workingHours,lostLimit))
cur.close()

# initialize the tasking/result buffers along with the client session key
sessionKey = self.get_agent_session_key(sessionID)
self.agents[sessionID] = [sessionKey, [],[],[], requestUris, ""]
Expand Down
45 changes: 35 additions & 10 deletions lib/common/empire.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

# make version for Empire
VERSION = "1.3.9"
VERSION = "1.3.10"


from pydispatch import dispatcher
Expand Down Expand Up @@ -475,18 +475,24 @@ def do_set(self, line):
else:
if parts[0].lower() == "ip_whitelist":
if parts[1] != "" and os.path.exists(parts[1]):
f = open(parts[1], 'r')
ipData = f.read()
f.close()
self.agents.ipWhiteList = helpers.generate_ip_list(ipData)
try:
f = open(parts[1], 'r')
ipData = f.read()
f.close()
self.agents.ipWhiteList = helpers.generate_ip_list(ipData)
except:
print helpers.color("[!] Error opening ip file %s" %(parts[1]))
else:
self.agents.ipWhiteList = helpers.generate_ip_list(",".join(parts[1:]))
elif parts[0].lower() == "ip_blacklist":
if parts[1] != "" and os.path.exists(parts[1]):
f = open(parts[1], 'r')
ipData = f.read()
f.close()
self.agents.ipBlackList = helpers.generate_ip_list(ipData)
try:
f = open(parts[1], 'r')
ipData = f.read()
f.close()
self.agents.ipBlackList = helpers.generate_ip_list(ipData)
except:
print helpers.color("[!] Error opening ip file %s" %(parts[1]))
else:
self.agents.ipBlackList = helpers.generate_ip_list(",".join(parts[1:]))
else:
Expand Down Expand Up @@ -1614,6 +1620,7 @@ def do_updateprofile(self, line):
# strip out profile comments and blank lines
profile = [l for l in profile if (not l.startswith("#") and l.strip() != "")]
profile = profile[0]

if not profile.strip().startswith("\"/"):
print helpers.color("[!] Task URIs in profiles must start with / and be enclosed in quotes!")
else:
Expand Down Expand Up @@ -1998,7 +2005,22 @@ def do_set(self, line):
"Set a listener option."
parts = line.split(" ")
if len(parts) > 1:
self.mainMenu.listeners.set_listener_option(parts[0], " ".join(parts[1:]))

if parts[0].lower() == "defaultprofile" and os.path.exists(parts[1]):
try:
f = open(parts[1], 'r')
profileDataRaw = f.readlines()

profileData = [l for l in profileDataRaw if (not l.startswith("#") and l.strip() != "")]
profileData = profileData[0].strip("\"")

f.close()
self.mainMenu.listeners.set_listener_option(parts[0], profileData)

except:
print helpers.color("[!] Error opening profile file %s" %(parts[1]))
else:
self.mainMenu.listeners.set_listener_option(parts[0], " ".join(parts[1:]))
else:
print helpers.color("[!] Please enter a value to set for the option")

Expand Down Expand Up @@ -2143,6 +2165,9 @@ def complete_set(self, text, line, begidx, endidx):

elif line.split(" ")[1].lower() == "certpath":
return helpers.complete_path(text,line,arg=True)

elif line.split(" ")[1].lower() == "defaultprofile":
return helpers.complete_path(text,line,arg=True)

mline = line.partition(' ')[2]
offs = len(mline) - len(text)
Expand Down

0 comments on commit 82fed97

Please sign in to comment.