def run(self):
        data = self.get_data()

        try:
            emailRep = EmailRep(self.key)
            result = emailRep.query(data)
            self.report(result)
        except Exception as e:
            self.error(str(e))
Exemple #2
0
def emailrep(email):
    emailinfo = []
    apikey = getapikey("emailrepkey")
    if apikey == "None" or len(apikey) != 48:
        emailrep = EmailRep()
    else:
        emailrep = EmailRep(apikey)
    info = emailrep.query(email)
    for key in info:
        if 'details' in key:
            stuff = info[key]
            for x in stuff:
                if 'profiles' in x:
                    profiles = str(stuff[x]).replace("'",
                                                     "").strip("[").strip("]")
                    emailrep = f"{themecolor}{x}{reset}: {profiles}"
                    emailinfo.append(emailrep)
                else:
                    emailrep = f"{themecolor}{x}{reset}: {stuff[x]}"
                    emailinfo.append(emailrep)
        else:
            emailrep = f"{themecolor}{key}{reset}: {info[key]}"
            emailinfo.append(emailrep)
    return emailinfo
Exemple #3
0
def main():
    (action, args, proxy) = parse_args()
    config = load_config()

    emailrep = EmailRep(key=config.get('emailrep', 'key'), proxy=proxy)

    try:
        if action == EmailRep.QUERY:
            result = emailrep.query(args.query)

            if result.get("status") and result["status"] == "fail":
                print("Failed: %s" % result["reason"])
                sys.exit()

            emailrep.format_query_output(result)

        elif action == EmailRep.REPORT:
            email = args.report
            tags = args.tags.split(",")

            if args.timestamp:
                try:
                    timestamp = parser.parse(args.timestamp)
                    timestamp = int(timestamp.timestamp())
                except Exception as e:
                    print("invalid timestamp: %s" % str(e))
                    sys.exit()
            else:
                timestamp = None

            result = emailrep.report(email, tags, args.description, timestamp,
                                     args.expires)
            if result.get("status") and result["status"] == "success":
                print("Successfully reported %s" % email)
            else:
                print("Failed to report %s. Reason: %s" %
                      (email, result["reason"]))

    except Exception as e:
        print(e)
Exemple #4
0
    def _api(self):
        """Instantiates EmailRep API"""

        emlrep = EmailRep(self.api_key)

        return emlrep
Exemple #5
0
def Search(Query_List, Task_ID):

    try:
        Data_to_Cache = []
        Directory = General.Make_Directory(Concat_Plugin_Name)
        logger = logging.getLogger()
        logger.setLevel(logging.INFO)
        Log_File = General.Logging(Directory, Concat_Plugin_Name)
        handler = logging.FileHandler(os.path.join(Directory, Log_File), "w")
        handler.setLevel(logging.DEBUG)
        formatter = logging.Formatter("%(levelname)s - %(message)s")
        handler.setFormatter(formatter)
        logger.addHandler(handler)
        Cached_Data_Object = General.Cache(Directory, Plugin_Name)
        Cached_Data = Cached_Data_Object.Get_Cache()
        Query_List = General.Convert_to_List(Query_List)
        Email_Rep_API_Key = Load_Configuration()

        for Query in Query_List:

            if Common.Regex_Handler(Query, Type="Email"):
                API = EmailRep(Email_Rep_API_Key)
                JSON_Output_Response = API.query(Query)
                Link = f"https://{Domain}/{Query}"
                JSON_Object = Common.JSON_Handler(JSON_Output_Response)
                JSON_Output_Response = JSON_Object.Dump_JSON()
                JSON_Response = JSON_Object.To_JSON_Loads()

                if JSON_Response["reputation"] != "none":
                    Table_JSON = {}

                    for Key, Value in JSON_Response.items():

                        if Key != "details":
                            Table_JSON[Key] = Value

                        else:

                            for Det_Key, Det_Val in JSON_Response["details"].items():
                                Table_JSON[Det_Key] = Det_Val

                    Filter_JSON = [Table_JSON]
                    Output_Connections = General.Connections(Query, Plugin_Name, Domain, "Email Information", Task_ID, Concat_Plugin_Name)

                    if Query not in Cached_Data and Query not in Data_to_Cache:
                        Responses = Common.Request_Handler(Link, Filter=True, Host=f"https://{Domain}")
                        Filtered_Response = Responses["Filtered"]
                        Title = f"Email Reputation | {Query}"
                        Main_File = General.Main_File_Create(Directory, Concat_Plugin_Name, JSON_Output_Response, Query, The_File_Extensions["Main"])
                        Output_file = General.Create_Query_Results_Output_File(Directory, Query, Concat_Plugin_Name, Filtered_Response, Title, The_File_Extensions["Query"])

                        if Output_file:
                            Output_Connections.Output([Main_File, Output_file], Link, Title, Concat_Plugin_Name)
                            Data_to_Cache.append(Link)

                        else:
                            logging.warning(f"{Common.Date()} - {__name__.strip('plugins.')} - Failed to create output file. File may already exist.")

        Cached_Data_Object.Write_Cache(Data_to_Cache)

    except Exception as e:
        logging.warning(f"{Common.Date()} - {__name__.strip('plugins.')} - {str(e)}")
Exemple #6
0
    ============*###--      '    ''--+'  '+=****'         '-++-'-   '  ''   *******
    *===========###=+ '         '  '-++  =***#=             -  -'     '  '  =******
    *===*======####-               ''-++*****-               '---       '''' =*****
    **=****===*###='     '   -+++--''--+-***'-               ' ++-      ''''  *****
    ***=***==*###*' ' '     ''''-++++++--===   ''''-''''-''''''+**+     '-'--'=****
    **=*****=##*=         '' '+=====+--'''  '     '  '  '''-''         '-+==-'=****
    **=*******='''   ' '  ' ''-+++-''''''    ''        '-+--         '  ''-+-=*****
    **=*****=*=+-''''''   '----+++--''''''    ''    ---' '-='         ''-===*******
    ******=-=*==+''-'' '''-++++====+--'''  '  '    -  '+-+*#=   ' -'+====**********
    **=***=====-''''--'''-+==========+---''''''''   ' '-+=*##= ' ''-+=====***======
    #* -U *****==-''-'''''-===*****======+++++----''''+=***===  ''' ' '++==*==++-++
    #*******==++---'-'''''' '-==*###**===========+----=*##*='  ' ' '  ''''+========
    """)


email_rep = EmailRep('<API KEY>')
email_to_check = ''


def query_email(email=''):
    email_to_check = email
    results = email_rep.query(email_to_check)
    print("=" * 25 + " Email Rep Report for " + str(sys.argv[2]) + " " +
          "=" * 25 + "\n")
    print('Email: {}'.format(results['email']))
    print('Reputation Score: {}'.format(results['reputation']).title())
    print('Is Suspicious: {}'.format(results['suspicious']))
    print('Is Blacklisted: {}'.format(results['details']['blacklisted']))
    print('Has Credentials Leaked: {}'.format(
        results['details']['credentials_leaked']))
    print('Has Credentials Leaked Recently: {}'.format(
Exemple #7
0
from emailrep import EmailRep
import json

# setup your api key (optional)
with open('auth.json') as json_file:
	data = json.load(json_file)


emailrep = EmailRep(data['emailrepiokey'])



def get_profiles(email = '*****@*****.**'):
    # query an email address
    answer = ''
    
    try:
        results = emailrep.query(email)
    
    except Exception as e:
        return "Failed Becuase of a {}".format(e)
    
    
    answer += '\nEmail: {}'.format(results['email'])
    answer += '\nReferences: {}'.format(results['references'])
    answer += '\n Profiles: {}'.format(results['details']['profiles'][:])
    answer += '\nSummary: {}'.format(results['summary'])

    return answer