コード例 #1
0
    def test_spf_record_unparse(self):
        self.assertEqual(spf.record_unparse(('all', '+', None)), 'all')
        self.assertEqual(spf.record_unparse(('all', '-', None)), '-all')

        self.assertEqual(
            spf.record_unparse(('include', '+', '_spf.wonderland.com')),
            'include:_spf.wonderland.com')
        self.assertEqual(spf.record_unparse(('ip4', '+', '10.0.0.0/24')),
                         'ip4:10.0.0.0/24')
コード例 #2
0
ファイル: spf_check.py プロジェクト: vysecurity/king-phisher
def main():
    parser = argparse.ArgumentParser(
        description='King Phisher SPF Check Utility',
        conflict_handler='resolve')
    utilities.argp_add_args(parser)
    parser.add_argument('smtp_server_ip',
                        help='the ip address of the sending smtp server')
    parser.add_argument('target_email',
                        help='the email address that messages are from')
    arguments = parser.parse_args()

    utilities.configure_stream_logger(arguments.loglvl, arguments.logger)

    server_ip = arguments.smtp_server_ip
    target_email = arguments.target_email

    if not ipaddress.is_valid(server_ip):
        color.print_error('the smtp server ip address specified is invalid')
        return

    if not '@' in target_email:
        target_email = utilities.random_string_lower_numeric(
            8) + '@' + target_email
        color.print_status(
            'target email appears to be just a domain, changed to: ' +
            target_email)

    if not utilities.is_valid_email_address(target_email):
        color.print_error('the email address specified is invalid')
        return

    spf_sender, spf_domain = target_email.split('@')
    spf_test = spf.SenderPolicyFramework(server_ip, spf_domain, spf_sender)
    try:
        result = spf_test.check_host()
    except spf.SPFPermError as error:
        color.print_error('check_host failed with error: permerror')
        color.print_error('error reason: ' + error.message)
        return
    except spf.SPFTempError as error:
        color.print_error('check_host failed with error: temperror')
        color.print_error('error reason: ' + error.message)
        return
    if not result:
        color.print_status('no spf policy was found for the specified domain')
        return

    color.print_good("spf policy result: {0}".format(result))
    color.print_status('top level spf records found:')
    for rid in range(len(spf_test.spf_records)):
        record = spf.record_unparse(spf_test.spf_records[rid])
        color.print_status("  #{0} {1: <10} {2}".format(
            rid + 1, ('(matched)' if rid == spf_test.spf_record_id else ''),
            record))
コード例 #3
0
def main():
	parser = argparse.ArgumentParser(description='King Phisher SPF Check Utility', conflict_handler='resolve')
	utilities.argp_add_args(parser)
	parser.add_argument('smtp_server_ip', help='the ip address of the sending smtp server')
	parser.add_argument('target_email', help='the email address that messages are from')
	arguments = parser.parse_args()

	utilities.configure_stream_logger(arguments.loglvl, arguments.logger)

	server_ip = arguments.smtp_server_ip
	target_email = arguments.target_email

	if not utilities.is_valid_ip_address(server_ip):
		color.print_error('the smtp server ip address specified is invalid')
		return

	if not '@' in target_email:
		target_email = utilities.random_string_lower_numeric(8) + '@' + target_email
		color.print_status('target email appears to be just a domain, changed to: ' + target_email)

	if not utilities.is_valid_email_address(target_email):
		color.print_error('the email address specified is invalid')
		return

	spf_sender, spf_domain = target_email.split('@')
	spf_test = spf.SenderPolicyFramework(server_ip, spf_domain, spf_sender)
	try:
		result = spf_test.check_host()
	except spf.SPFPermError as error:
		color.print_error('check_host failed with error: permerror')
		color.print_error('error reason: ' + error.message)
		return
	except spf.SPFTempError as error:
		color.print_error('check_host failed with error: temperror')
		color.print_error('error reason: ' + error.message)
		return
	if not result:
		color.print_status('no spf policy was found for the specified domain')
		return

	color.print_good("spf policy result: {0}".format(result))
	color.print_status('top level spf records found:')
	for rid in range(len(spf_test.spf_records)):
		record = spf.record_unparse(spf_test.spf_records[rid])
		color.print_status("  #{0} {1: <10} {2}".format(rid + 1, ('(matched)' if rid == spf_test.spf_record_id else ''), record))
コード例 #4
0
def main():
	parser = argparse.ArgumentParser(description='King Phisher SPF Check Utility', conflict_handler='resolve')
	parser.add_argument('-v', '--version', action='version', version=parser.prog + ' Version: ' + version.version)
	parser.add_argument('-L', '--log', dest='loglvl', action='store', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], default='CRITICAL', help='set the logging level')
	parser.add_argument('smtp_server_ip', help='the ip address of the sending smtp server')
	parser.add_argument('target_email', help='the email address that messages are from')
	arguments = parser.parse_args()

	logging.getLogger('').setLevel(logging.DEBUG)
	console_log_handler = logging.StreamHandler()
	console_log_handler.setLevel(getattr(logging, arguments.loglvl))
	console_log_handler.setFormatter(logging.Formatter("%(levelname)-8s %(message)s"))
	logging.getLogger('').addHandler(console_log_handler)

	server_ip = arguments.smtp_server_ip
	target_email = arguments.target_email

	if not utilities.is_valid_ip_address(server_ip):
		color.print_error('the smtp server ip address specified is invalid')
		return

	if not utilities.is_valid_email_address(target_email):
		color.print_error('the email address specified is invalid')
		return

	spf_sender, spf_domain = target_email.split('@')
	spf_test = spf.SenderPolicyFramework(server_ip, spf_domain, spf_sender)
	try:
		result = spf_test.check_host()
	except spf.SPFPermError:
		color.print_error('check_host failed with error: permerror')
		return
	except spf.SPFTempError:
		color.print_error('check_host failed with error: temperror')
		return
	if not result:
		color.print_status('no spf policy was found for the specified domain')
		return

	color.print_good("spf policy result: {0}".format(result))
	color.print_status('top level spf records found:')
	for rid in range(len(spf_test.spf_records)):
		record = spf.record_unparse(spf_test.spf_records[rid])
		color.print_status("  #{0} {1: <10} {2}".format(rid + 1, ('(matched)' if rid == spf_test.spf_record_id else ''), record))
コード例 #5
0
ファイル: spf_check.py プロジェクト: junk13/king-phisher
def main():
	parser = argparse.ArgumentParser(description='King Phisher SPF Check Utility', conflict_handler='resolve')
	parser.add_argument('-v', '--version', action='version', version=parser.prog + ' Version: ' + version.version)
	parser.add_argument('-L', '--log', dest='loglvl', action='store', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], default='CRITICAL', help='set the logging level')
	parser.add_argument('smtp_server_ip', help='the ip address of the sending smtp server')
	parser.add_argument('target_email', help='the email address that messages are from')
	arguments = parser.parse_args()

	logging.getLogger('').setLevel(logging.DEBUG)
	console_log_handler = logging.StreamHandler()
	console_log_handler.setLevel(getattr(logging, arguments.loglvl))
	console_log_handler.setFormatter(logging.Formatter("%(levelname)-8s %(message)s"))
	logging.getLogger('').addHandler(console_log_handler)

	server_ip = arguments.smtp_server_ip
	target_email = arguments.target_email

	if not utilities.is_valid_ip_address(server_ip):
		print('[-] the smtp server ip address specified is invalid')
		return

	if not utilities.is_valid_email_address(target_email):
		print('[-] the email address specified is invalid')
		return

	spf_sender, spf_domain = target_email.split('@')
	spf_test = spf.SenderPolicyFramework(server_ip, spf_domain, spf_sender)
	try:
		result = spf_test.check_host()
	except spf.SPFPermError:
		print('[-] check_host failed with error: permerror')
		return
	except spf.SPFTempError:
		print('[-] check_host failed with error: temperror')
		return
	if not result:
		print('[*] no spf policy was found for the specified domain')
		return

	print("[+] spf policy result: {0}".format(result))
	print('[*] top level spf records found:')
	for rid in range(len(spf_test.spf_records)):
		record = spf.record_unparse(spf_test.spf_records[rid])
		print("[*]   #{0} {1: <10} {2}".format(rid + 1, ('(matched)' if rid == spf_test.spf_record_id else ''), record))
コード例 #6
0
ファイル: spf.py プロジェクト: baubaubau/king-phisher
	def test_spf_record_unparse(self):
		self.assertEqual(spf.record_unparse(('all', '+', None)), 'all')
		self.assertEqual(spf.record_unparse(('all', '-', None)), '-all')

		self.assertEqual(spf.record_unparse(('include', '+', '_spf.wonderland.com')), 'include:_spf.wonderland.com')
		self.assertEqual(spf.record_unparse(('ip4', '+', '10.0.0.0/24')), 'ip4:10.0.0.0/24')
コード例 #7
0
ファイル: spf.py プロジェクト: guitarmanj/king-phisher
    def test_spf_record_unparse(self):
        self.assertEqual(spf.record_unparse(("all", "+", None)), "all")
        self.assertEqual(spf.record_unparse(("all", "-", None)), "-all")

        self.assertEqual(spf.record_unparse(("include", "+", "_spf.wonderland.com")), "include:_spf.wonderland.com")
        self.assertEqual(spf.record_unparse(("ip4", "+", "10.0.0.0/24")), "ip4:10.0.0.0/24")