Skip to content

Commit

Permalink
[target] Change HOST_NAME to host_name (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
DePierre committed Sep 8, 2014
1 parent b573024 commit c0aa1b2
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 110 deletions.
6 changes: 3 additions & 3 deletions framework/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def DeriveConfigFromURL(self, target_URL):
# Some tools need this!
target_config['PORT_NUMBER'] = port
# Set the top URL.
target_config['HOST_NAME'] = host
target_config['host_name'] = host

host_IP = self.GetIPFromHostname(host)
host_IPs = self.GetIPsFromHostname(host)
Expand All @@ -223,9 +223,9 @@ def DeriveConfigFromURL(self, target_URL):

ip_url = target_config['TARGET_URL'].replace(host, host_IP)
target_config['ip_url'] = ip_url
target_config['top_domain'] = target_config['HOST_NAME']
target_config['top_domain'] = target_config['host_name']

hostname_chunks = target_config['HOST_NAME'].split('.')
hostname_chunks = target_config['host_name'].split('.')
if self.IsHostNameNOTIP(host, host_IP) and len(hostname_chunks) > 2:
# Get "example.com" from "www.example.com"
target_config['top_domain'] = '.'.join(hostname_chunks[1:])
Expand Down
2 changes: 1 addition & 1 deletion framework/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def GetCommand(self, argv):

def AnonymiseCommand(self, command):
# Host name setting value for all targets in scope.
for host in self.DB.Target.GetAll('HOST_NAME'):
for host in self.DB.Target.GetAll('host_name'):
if host: # Value is not blank
command = command.replace(host, 'some.target.com')
for ip in self.DB.Target.GetAll('host_ip'):
Expand Down
16 changes: 8 additions & 8 deletions framework/db/target_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
TARGET_CONFIG = {
'id': 0,
'TARGET_URL': '',
'HOST_NAME': '',
'host_name': '',
'HOST_PATH': '',
'URL_SCHEME': '',
'PORT_NUMBER': '', # In str form
Expand Down Expand Up @@ -141,7 +141,7 @@ def AddTarget(self, TargetURL, session_id=None):
target_config = self.Core.Config.DeriveConfigFromURL(TargetURL)
# ----------- Target model object creation -----------
config_obj = models.Target(target_url=TargetURL)
config_obj.host_name = target_config["HOST_NAME"]
config_obj.host_name = target_config["host_name"]
config_obj.host_path = target_config["HOST_PATH"]
config_obj.url_scheme = target_config["URL_SCHEME"]
config_obj.port_number = target_config["PORT_NUMBER"]
Expand Down Expand Up @@ -244,12 +244,12 @@ def GetTargetConfigs(self, filter_data=None, session_id=None):
filter_data["scope"] = filter_data["scope"][0]
query = query.filter_by(
scope=self.Core.Config.ConvertStrToBool(filter_data.get("scope")))
if filter_data.get("HOST_NAME", None):
if isinstance(filter_data["HOST_NAME"], (str, unicode)):
query = query.filter_by(host_name=filter_data["HOST_NAME"])
if isinstance(filter_data["HOST_NAME"], list):
if filter_data.get("host_name", None):
if isinstance(filter_data["host_name"], (str, unicode)):
query = query.filter_by(host_name=filter_data["host_name"])
if isinstance(filter_data["host_name"], list):
query = query.filter(models.Target.host_name.in_(
filter_data.get("HOST_NAME")))
filter_data.get("host_name")))
try:
if filter_data.get("id", None):
if isinstance(filter_data["id"], (str, unicode)):
Expand Down Expand Up @@ -308,7 +308,7 @@ def GetAllInScope(self, Key):
def IsInScopeURL(self, URL): # To avoid following links to other domains.
ParsedURL = urlparse(URL)
# Get all known Host Names in Scope.
for HostName in self.GetAll('HOST_NAME'):
for HostName in self.GetAll('host_name'):
if ParsedURL.hostname == HostName:
return True
return False
2 changes: 1 addition & 1 deletion framework/http/proxy/transaction_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_owtf_transactions(self, hash_list):
target_list = self.core.DB.Target.GetIndexedTargets()
if target_list: # If there are no targets in db, where are we going to add. OMG
transactions_dict = {}
host_list = self.core.DB.Target.GetAllInScope('HOST_NAME')
host_list = self.core.DB.Target.GetAllInScope('host_name')

for request_hash in hash_list:
request = request_from_cache(request_hash, self.cache_dir)
Expand Down
2 changes: 1 addition & 1 deletion framework/zest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def GetTargetConfig(self, target_id):
target_config['ZEST_DIR'] = os.path.join(target_config['OUTPUT_DIR'], "zest")
target_config['CREATE_SCRIPT_PATH'] = os.path.join(target_config['ROOT_DIR'], "zest", "zest_create.sh")
target_config['RUNNER_SCRIPT_PATH'] = os.path.join(target_config['ROOT_DIR'], "zest","zest_runner.sh")
target_config['HOST_AND_PORT'] = ((self.Core.DB.Target.GetTargetConfigForID(target_id))['HOST_NAME']
target_config['HOST_AND_PORT'] = ((self.Core.DB.Target.GetTargetConfigForID(target_id))['host_name']
+ ":" + (self.Core.DB.Target.GetTargetConfigForID(target_id))['PORT_NUMBER'])
self.Core.CreateMissingDirs(target_config['ZEST_DIR'])
return target_config
Expand Down
2 changes: 1 addition & 1 deletion plugins/web/active/HTTP_Methods_and_XST@OWTF-CM-008.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

def run(Core, PluginInfo):
#Core.Config.Show()
#Transaction = Core.Requester.TRACE(Core.Config.Get('HOST_NAME'), '/')
#Transaction = Core.Requester.TRACE(Core.Config.Get('host_name'), '/')
URL = Core.DB.Target.Get('top_url')
# TODO: PUT not working right yet
#PUT_URL = URL+"/_"+get_random_str(20)+".txt"
Expand Down
Loading

0 comments on commit c0aa1b2

Please sign in to comment.