Projects STRLCPY ghauri Commits d73ef80d
🤬
  • updated code quality, fixed issue with dumping to csv file, bumped v1.0.6

  • Loading...
  • r0oth3x49 committed 2 years ago
    d73ef80d
    1 parent b5875fff
  • ■ ■ ■ ■
    ghauri/__init__.py
    skipped 23 lines
    24 24   
    25 25  """
    26 26   
    27  -__version__ = "1.0.5"
     27 +__version__ = "1.0.6"
    28 28  __author__ = "Nasir Khan (r0ot h3x49)"
    29 29  __license__ = "MIT"
    30 30  __copyright__ = "Copyright (c) 2016-2025 Nasir Khan (r0ot h3x49)"
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    ghauri/common/session.py
    skipped 125 lines
    126 126   pass
    127 127   return _temp
    128 128   
    129  - def dump_to_csv(self, cursor, filepath="", database="", table=""):
     129 + def dump_to_csv(
     130 + self, results, field_names=None, filepath="", database="", table=""
     131 + ):
    130 132   ok = False
    131 133   filepath = os.path.dirname(filepath)
    132 134   dump = os.path.join(filepath, "dump")
    skipped 6 lines
    139 141   filepath = os.path.join(dbfilepath, f"{table}.csv")
    140 142   with open(filepath, "w", encoding="utf-8") as fd:
    141 143   csv_writer = csv.writer(fd, delimiter=",")
    142  - csv_writer.writerow([i[0] for i in cursor.description])
    143  - csv_writer.writerows(cursor)
     144 + if field_names:
     145 + csv_writer.writerow([i.strip() for i in field_names])
     146 + csv_writer.writerows(results)
    144 147   ok = True
    145 148   return ok
    146 149   
    skipped 113 lines
  • ■ ■ ■ ■ ■ ■
    ghauri/extractor/advance.py
    skipped 24 lines
    25 25  """
    26 26  import random
    27 27  from ghauri.common.config import conf
     28 +from ghauri.common.session import session
    28 29  from ghauri.core.extract import ghauri_extractor
    29 30  from ghauri.logger.colored_logger import logger
    30 31  from ghauri.common.lib import collections
    skipped 564 lines
    595 596   if start == 0 and backend == "Oracle":
    596 597   start = 1
    597 598   logger.info(
    598  - f"fetching columns for table '{mc}{table}{nc}' in database '{mc}{database}{nc}'"
     599 + f"fetching columns for table '{mc}{table}{bw}' in database '{mc}{database}{bw}'"
    599 600   )
    600 601   Response = collections.namedtuple(
    601 602   "Response",
    skipped 384 lines
    986 987   logger.success(f"Table: {table}")
    987 988   logger.success(f"[{ret.entries} entries]")
    988 989   logger.success(f"{ret.data}")
     990 + try:
     991 + session.dump_to_csv(
     992 + _results,
     993 + field_names=__columns,
     994 + filepath=conf.session_filepath,
     995 + database=database,
     996 + table=table,
     997 + )
     998 + except Exception as error:
     999 + logger.debug(error)
    989 1000   return _temp
    990 1001   
    991 1002   
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    ghauri/ghauri.py
    skipped 465 lines
    466 466   
    467 467   def __end(self, database="", table="", fetched=True):
    468 468   new_line = ""
    469  - # if database and table:
    470  - # filepath = os.path.join(self._filepath, "dump")
    471  - # filepath = os.path.join(filepath, database)
    472  - # filepath = os.path.join(filepath, f"{table}.csv")
    473  - # message = (
    474  - # f"{new_line}table '{database}.{table}' dumped to CSV file '{filepath}'"
    475  - # )
    476  - # logger.info(message)
    477  - # new_line = ""
     469 + if database and table:
     470 + filepath = os.path.join(conf.filepaths.filepath, "dump")
     471 + filepath = os.path.join(filepath, database)
     472 + filepath = os.path.join(filepath, f"{table}.csv")
     473 + message = f"\ntable '{database}.{table}' dumped to CSV file '{filepath}'"
     474 + logger.info(message)
     475 + new_line = ""
    478 476   if fetched:
    479 477   logger.info(
    480 478   f"{new_line}fetched data logged to text files under '{self._filepath}'"
    481 479   )
    482  - logger.end("ending")
     480 + logger.end("ending")
    483 481   
    484 482   def extract_banner(self):
    485 483   response = target.fetch_banner(
    skipped 238 lines
    724 722   )
    725 723   fetched = response.ok
    726 724   if fetched:
    727  - logger.success("")
    728 725   if not dump_requested:
     726 + logger.success("")
    729 727   self.__end(database=database, table=table, fetched=fetched)
    730 728   else:
    731 729   if not dump_requested:
    skipped 55 lines
  • ■ ■ ■ ■ ■ ■
    ghauri/logger/colored_logger.py
    skipped 46 lines
    47 47   def format(self, record):
    48 48   message = record.getMessage()
    49 49   spaces = ""
     50 + leading_spaces_count = len(message) - len(message.lstrip())
     51 + if message.startswith("\n"):
     52 + spaces = "\n" * leading_spaces_count
     53 + message = message.lstrip()
     54 + if message.startswith("\t"):
     55 + spaces = "\t" * leading_spaces_count
     56 + message = message.lstrip()
     57 + if message.startswith(" "):
     58 + spaces = " " * leading_spaces_count
     59 + message = message.lstrip()
    50 60   levelname = record.levelname
    51 61   uses_time = self.usesTime()
    52 62   if not uses_time:
    skipped 215 lines
  • ■ ■ ■ ■
    setup.py
    skipped 4 lines
    5 5   
    6 6  setup(
    7 7   name="ghauri",
    8  - version="1.0.5",
     8 + version="1.0.6",
    9 9   description="An advanced SQL injection detection & exploitation tool.",
    10 10   classifiers=["Programming Language :: Python3"],
    11 11   author="Nasir Khan",
    skipped 28 lines
Please wait...
Page is in error, reload to recover