Codebase list osrframework / 5315caf osrframework / transforms / emailToSkypeAccounts.py
5315caf

Tree @5315caf (Download .tar.gz)

emailToSkypeAccounts.py @5315cafraw · history · blame

# !/usr/bin/python
# -*- coding: cp1252 -*-
#
##################################################################################
#
#    Copyright 2015 FĂ©lix Brezo and Yaiza Rubio (i3visio, [email protected])
#
#    This program is part of OSRFramework. You can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##################################################################################

import json
import sys

from osrframework.transforms.lib.maltego import *
import osrframework.thirdparties.skype.checkInSkype as skype

def emailToSkypeAccount(query=None):
    ''' 
        Method that checks if the given email is appears in Skype.

        :param query:    query to verify.

    '''
    me = MaltegoTransform()

    jsonData = skype.checkInSkype(query=query)

    # This returns a dictionary like:
    # [{}]
    newEntities = []

    for user in jsonData:
	    # Defining the main entity
        aux ={}
        aux["type"] = user["type"]
        aux["value"] =  user["value"]
        aux["attributes"] = []    

        for field in user.keys():
            # [TO-DO] Appending all the information from the json:
            if user[field] != None:
                try:
                    att ={}
                    att["type"] = field
                    att["value"] =  str(user[field]).encode('utf-8')
                    att["attributes"] = []
                    aux["attributes"].append(att)                
                except:
                    # Something passed...
                    pass
        # Appending the entity
        newEntities.append(aux)

    me.addListOfEntities(newEntities)
        
    # Returning the output text...
    me.returnOutput()

if __name__ == "__main__":
    emailToSkypeAccount(query=sys.argv[1])