text stringlengths 0 828 |
|---|
1678,"def get_file_name(query): |
""""""get_file_name(query) -> filename -- return the filename found in a |
given, found by matching a regular expression. |
"""""" |
match = re.search(r'\S*\.[\d\w]{1,4}', query) |
if(match): |
filename = match.group() |
return filename |
else: |
start = match.start() |
end = match.end() |
spaces = re.finditer(r' ', query) |
space_index = [] |
for space in spaces: |
space_index.append(space.start()) |
space_index.pop() |
for i in space_index: |
filename = query[i+1:end] |
if(os.path.isfile(filename)): |
return filename |
return None" |
1679,"def get_path(query): |
""""""get_path(query) -> pathname -- return the path found in a |
given, found by matching a regular expression. |
"""""" |
match = re.search(r'/(.*/)+(\S*(\.[\d\w]{1,4})?)', query) |
if(os.path.isfile(match.group()) or os.path.isdir(match.group())): |
return match.group() |
else: |
return None" |
1680,"def get_readable_filesize(size): |
""""""get_readable_filesize(size) -> filesize -- return human readable |
filesize from given size in bytes. |
"""""" |
if(size < 1024): |
return str(size)+' bytes' |
temp = size/1024.0 |
level = 1 |
while(temp >= 1024 and level< 3): |
temp = temp/1024 |
level += 1 |
if(level == 1): |
return str(round(temp,2))+' KB' |
elif(level == 2): |
return str(round(temp,2))+' MB' |
else: |
return str(round(temp,2))+' GB'" |
1681,"def list(self, svc_rec=None, hostfilter=None, compromised=False): |
"""""" |
List user accounts |
:param svc_rec: db.t_services.id |
:param hostfilter: |
:param compromised: Show only compromised accounts |
:return: [acct.t_accounts.f_services_id, acct.t_hosts.f_ipaddr, |
acct.t_hosts.f_hostname, |
acct.t_accounts.id, acct.t_accounts.f_username, |
acct.t_accounts.f_fullname, acct.t_accounts.f_password, |
acct.t_accounts.f_compromised, acct.t_accounts.f_hash1, |
acct.t_accounts.f_hash1_type, acct.t_accounts.f_hash2, |
acct.t_accounts.f_hash2_type, acct.t_accounts.f_source, |
acct.t_accounts.f_uid, acct.t_accounts.f_gid, |
acct.t_accounts.f_level, acct.t_accounts.f_domain, |
acct.t_accounts.f_message, acct.t_accounts.f_lockout, |
acct.t_accounts.f_duration, acct.t_accounts.f_active, |
acct.t_accounts.f_description, |
acct.t_services.f_proto, acct.t_services.f_number, |
] |
"""""" |
return self.send.accounts_list(svc_rec, hostfilter, compromised)" |
1682,"def upload_file(self, service_rec=None, host_service=None, filename=None, |
pw_data=None, f_type=None, add_to_evidence=True): |
"""""" |
Upload a password file |
:param service_rec: db.t_services.id |
:param host_service: db.t_hosts.id |
:param filename: Filename |
:param pw_data: Content of file |
:param f_type: Type of file |
:param add_to_evidence: True/False to add to t_evidence |
:return: (True/False, Response Message) |
"""""" |
return self.send.accounts_upload_file(service_rec, host_service, filename, pw_data, f_type, add_to_evidence)" |
1683,"def _columns_to_kwargs(conversion_table, columns, row): |
"""""" |
Given a list of column names, and a list of values (a row), return a dict |
of kwargs that may be used to instantiate a MarketHistoryEntry |
or MarketOrder object. |
:param dict conversion_table: The conversion table to use for mapping |
spec names to kwargs. |
:param list columns: A list of column names. |
:param list row: A list of values. |
"""""" |
kwdict = {} |
counter = 0 |
for column in columns: |
# Map the column name to the correct MarketHistoryEntry kwarg. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.