Tuesday, February 19, 2008

using gtalk to create a “Non Malicious” Trojan Horse

The Trojan Horse s a piece of software which appears to perform a certain action but in fact performs another activity. Here the Non Malicious trojan horse is a chat program which logs into gtalk using your given user name and password. Whenever you type commands on the chat window, it executes them in your machine and returns the results to you.  This program can also be used for :

*) Using gtalk to control the hardwares in your home which are interfaced to your computer
*) Replacement for the famous telnet/ssh program (can’t use programs like vi , top .. though :( )
*) Lets you know the status of the programs running in your home computer like download status …. etc

and leaving others for your imagination

This program uses the command module in python to execute the commands that you type into the chat window. Be careful that if you start the program as root, then you can possibly do “anything” in your machine. Be careful.

 gtalk_trojan.py

import xmpp
import time
import commands

def execute_command(command):
    return commands.getoutput(command)

def messageCB(sess,mess):
    nick=mess.getFrom().getResource()
    text=mess.getBody()
    reply = execute_command(text)
    sess.send(xmpp.Message(mess.getFrom(),reply))

roster=[]
def presenceCB(sess,pres):
    nick=pres.getFrom().getResource()
    text=”
    if pres.getType()==’unavailable’:
        if nick in roster:
            text=nick
            roster.remove(nick)
    else:
        if nick not in roster:
            text=nick
            roster.append(nick)

def StepOn(conn):
    try:
        conn.Process(1)
    except KeyboardInterrupt: return 0
    return 1

def Cont(conn):
    while StepOn(conn): pass
   
def main_process():
    jid = xmpp.protocol.JID(’maxin.john@gmail.com’)
    cl = xmpp.Client(’gmail.com’)
    cl.connect((’talk.google.com’,5223))
    cl.RegisterHandler(’message’,messageCB)
    cl.RegisterHandler(’presence’,presenceCB)
    cl.auth(jid.getNode(), ‘my_secret_password’)
    cl.sendInitPresence()
    Cont(cl)
if __name__ == ‘__main__’:
    main_process()

Posted by maxinbjohn in 06:54:40
Comments

Leave a Reply