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 at 06:54:40 | Permalink | No Comments »

Thursday, January 17, 2008

Python v/s Ruby or how I re implemented Unni’s idea

 Today I happen to meet Unni , my hostelmate and a very brillian Linux programmer, in Gtalk. We talked about the job and the current technologies as usual . After some talks about his career move, he showed me what he has done in his first ‘Open friday’ — in his company friday is an open source day.. you can do what ever you want to do except the usual company’s work :)
It was a nice implementation of xmpp chat program used to chat with friends in Gtalk. He used Ruby to implement the program which can send chat messages to your friends and also use the program as sort of bot which will go on chatting with your friends even if you are not there to type Cool

But he implemented it in Ruby .. that was the only thing that I didn’t like..  Being a python lover, I have decided to “port” his application to Python . And before dawn, I sent my pythohic automagic chats to Ciril with his consent :) ( my aim is not to flood somebody’s chat window.. it is just to show that python is not behind Ruby… Embarassed)

First I have installed the xmpppy package from http://xmpppy.sourceforge.net/ .. The usual
python setup.py install  type installation ..
after that tried this program :
####################################
#  Program to send 1 to 100 from my account #
####################################

import xmpp
import time
jid = xmpp.protocol.JID(’maxinbjohn@gmail.com’)
cl = xmpp.Client(’gmail.com’)
cl.connect((’talk.google.com’,5223))
cl.auth(jid.getNode(),’my very secret password here’)
for i in range(1,100):
        text = i
        cl.send(xmpp.protocol.Message(’ciril4u@gmail.com’,text,typ=”chat”))
        time.sleep(1)
        print str(text)+’sent ‘
#######################################
Well, it just works ..  My wildest dream is to connect the chat bot to Eliza , the AI program and confuse the people who ‘thinks’ that they are chatting with me Innocent

Cheers to Unni

Posted by maxinbjohn at 14:18:31 | Permalink | Comments (2)