February 03, 2012, 09:30:28 pm
Maltego Forum

Username
Password

Pages: [1]
Print
Author Topic: OO Python Lib  (Read 101870 times)
konrads
Newbie
*
Posts: 7



« on: February 25, 2009, 01:53:11 am »

Hi,

I took a slightly different approach to MaltegoEntity (I learned about this, existing lib after the fact).

I am using DOM (xml.dom.minidom) instead of print and text concatenation. Each entity is a subclass of MaltegoEntity and is responsible for transforming itself into DOM.

Under what license is Your library published? Perhaps we can merge our approaches under BSD?

* entities.py (2.57 KB - downloaded 7574 times.)
Logged
AndrewMacPherson
Administrator
Full Member
*****
Posts: 132


« Reply #1 on: February 25, 2009, 06:11:18 am »

I think this would be a great idea, whereby we merge the generic nature of the original libs with the DOM model of yours!
Logged
konrads
Newbie
*
Posts: 7



« Reply #2 on: February 26, 2009, 06:53:32 pm »

Hi,

Here is my version of API. It uses ElementTree for DOM.

Some example usage patterns:
Attempt one, make a person
Code:
from maltego import *
mt=MaltegoTransform()
person=GenericMaltegoEntity("Person", "Konrads Smelkovs")
person.addAdditionalField("My name", "Konrads")
mt.message.addEntity(person)
mt.printMessage()

Let''''s try some inheritance (hopefuly, we''''ll have a nice type library in no time!
Code:
from maltego import *
class Person(GenericMaltegoEntity):
    """
    A smarter person class
    """
    entityType="Person"
    def __init__(self,value):
        self.value=value
        (fn,ln)=self.value.split(" ",2)
        self.addAdditionalField("firstName", fn,"My First name")
        self.addAdditionalField("lastName", ln,"My Last Name")
mt=MaltegoTransform()
person=Person("Konrads Smelkovs")

mt.message.addEntity(person)
mt.printMessage()
Three files (attached):

  • maltego.py - the API library
  • cdata_etree.py - an extension to ElementTree that supports CDATA section(I did not write it, see top comment)
  • whois2.py - an example transformation

What this needs is unittests, an API description - both inline via docstrings and external as AndrewMohawk did for his, and of course testing. Probably a SVN server would be helpful.

* cdata_etree.py (3.92 KB - downloaded 7495 times.)
* maltego.py (8.71 KB - downloaded 7485 times.)
* whois2.py (4.48 KB - downloaded 7441 times.)
« Last Edit: February 26, 2009, 06:59:44 pm by konrads » Logged
konrads
Newbie
*
Posts: 7



« Reply #3 on: February 26, 2009, 06:57:07 pm »

Just a few comments:
  • There are no setters/getters for fields where they do not have value added, e.g. ent.setValue(), user should just ent.value="mystr"
  • The reason why stderr and stdout can be done as parameters is: I hope there will be unittests for this at some point
Logged
konrads
Newbie
*
Posts: 7



« Reply #4 on: March 02, 2009, 09:07:51 am »

Hi, there is a subversion repository for this library @
http://rogue.smelkovs.com/svn/pymaltego/trunk/

If You want write access, mail me 

You can also just download the source dist as zip file

* pymaltego-0.1.zip (5.4 KB - downloaded 7376 times.)
« Last Edit: March 04, 2009, 04:18:18 pm by konrads » Logged
H
Newbie
*
Posts: 9


« Reply #5 on: May 22, 2009, 09:44:20 am »

I had some issues with IconURL and additionalFields for entities not being output correctly in the XML output of a transform using pymaltego.

Both of those issues are fixed in the current version in the SVN.

Thanks konrads!
Logged
konrads
Newbie
*
Posts: 7



« Reply #6 on: May 28, 2009, 03:39:37 am »

Hi,
Indeed there are some bug fixes now. See attached file for a "release" or use SVN

* pymaltego-0.2.zip (5.45 KB - downloaded 7306 times.)
Logged
Pages: [1]
Print
Jump to: