Posts Tagged ‘code’

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 OpenSSH <=5.2 Exploit / Vulnerability

Here you go kiddies, enjoy this succulent fruit.

http://www.nopaste.com/p/aDTdT5s1C

oh btw, use it at your own risk.

PostHeaderIcon Programming – 5 Files

Warindustries: An Intro to Programming for Hackers Part 1

Warindustries: An Intro to Programming for Hackers Part 2

Warindustries: An Intro to Programming for Hackers Part 3

Warindustries: An Intro to Programming for Hackers Part 4

Introduction to Shell coding

PostHeaderIcon PHP/Java Bridge – Ubuntu Server 7.10

phpjava-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.


< ?php

java_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.

JSPHPBridgeScreeny

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.

PostHeaderIcon C++ CMD Line Port Scanner

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

Read the rest of this entry »

PostHeaderIcon Network Sniffing Tool with Scapy and Threads

network-sniffing-tool-with-scapy-and-threads

Here is a simple guide to building a network sniffing tool. This tutorial assumes knowledge of Python and that you Have Scapy installed on your system

First we do our imports


import time, random from Tkinter import *
from threading import *
from scapy import *
import tkFileDialog
conf.verb = 1

Now we set up our GUI I made a very simple GUI for this Project

class ThreadedClient:
def __init__(self, master=None):
self.ok =1
self.master = master

self.thread = Thread(target=self.sniffit)
self.frame = frame = Frame(master)

self.labelip = Label(frame, text=”Count”)
self.labelip.pack(side=LEFT)

self.entrycount = Entry(frame)
self.entrycount.pack(side=LEFT, fill=X, expand=True)
self.entrycount.insert(END, “10″)

self.labelip = Label(frame, text=”Filter”)
self.labelip.pack(side=LEFT)

self.entryfilter = Entry(frame)
self.entryfilter.pack(side=LEFT, fill=X, expand=True)

self.labeli = Label(frame, text=”Iface”)
self.labeli.pack(side=LEFT)

self.entryiface = Entry(frame)
self.entryiface.pack(side=LEFT, fill=X, expand=True)
self.entryiface.insert(END, “eth0″)

self.start = Button(frame, text=”Sniff It”, command=self.run)
self.start.pack(side=LEFT)
##
self.save = Button(frame, text=”Save It”, command=self.windowit)
self.save.pack(side=LEFT)

self.btn = Button(frame, text=’Exit’, command=self.shutdown)
self.btn.pack(side=LEFT)

frame.pack(fill=X)

self.frame2 = frame2 = Frame(master)
self.scrollbar = Scrollbar(frame2)
self.scrollbar.pack(side=RIGHT, fill=Y)

self.textbox = Text(frame2)
self.textbox.pack(side=LEFT, fill=BOTH, expand=True)
self.textbox.config(yscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.textbox.yview)
self.frame2.pack(fill=BOTH, expand=True)

Read the rest of this entry »

PostHeaderIcon Md5 Hash Directory tool in Python

md5-hash-directory-tool-in-python

Hey everyone here is how I built this tool that creates md5 hashes of all files in a given directory and allows for comparison between the two using difflib

first our import statements note we use standard python libraries

from Tkinter import *
import tkFileDialog
import md5, os

Next our functions

def opendirectory():
try:
entry.delete(0, END)
fileopen = tkFileDialog.askdirectory()
entry.insert(END, fileopen)
except:
textbox.insert(END, "There was an error opening ")
textbox.insert(END, fileopen)
textbox.insert(END, "\n")

def saveit():
try:
output1 = textbox.get(1.0, END)
str(output1)
filename = tkFileDialog.asksaveasfilename()
entry2.insert(END, filename)
fileit = open(filename, “w”)
fileit.write(output1)
except:
textbox.insert(END, “Failed Saving Data\n”)

def windowit():
top = Toplevel(root)
top.title(“Save Data”)
top.wm_resizable(0, 0)
top.wm_iconbitmap(“shinobi.ico”)
frame = Frame(top)
global entry2
entry2 = Entry(frame)
entry2.pack(side=LEFT)
entry2.insert(END, “Path Automatically Inserted”)
savebutton = Button(frame, text=”Save Reference”, command=saveit)
savebutton.pack(side=LEFT)
frame.pack()

def compute():
from difflib import Differ
filename1it = fil1.get()
filename1it2 = fil2.get()
filer = open(filename1it, ‘rb’)
filer2 = open(filename1it2, ‘rb’)
data1 = filer.read()
data1 = data1.rstrip()
data2 = filer2.read()
data2 = data2.rstrip()
d = Differ()
result = list(d.compare(data1, data2))
s = “\n”.join(result)
s = s.rstrip()
textbox.insert(END, “The two files compared with Difflib are ” + filename1it + ” and ” + filename1it2 + “\n\n”)
textbox.insert(END, s)

def create():
for root, dirs, files in os.walk(entry.get()):
for name in files:
filepath = os.path.join(root, name)
global value
value = md5.new(filepath).hexdigest()
textbox.insert(END, value +”\n”)

You will notice the create function is to create an md5 hash of all fles in the given directory and the compute function compares between a second file

the rest of the functions are for saving the information

— —

Now we create our GUI


root = Tk()
root.wm_resizable(0, 0)
root.wm_iconbitmap("shinobi.ico")
root.title("Tech Shinobi File System Integrity Tools")
root.option_readfile("optionDB")
frame = Frame(root)
entry = Entry(frame)
entry.pack(side=LEFT, fill=X, expand=True)

openit = Button(frame, text=”Open Directory”, command=opendirectory)
openit.pack(side=LEFT)
createit = Button(frame, text=”Create MD5″, command=create)
createit.pack(side=LEFT)
save = Button(frame, text=”Save”, command=windowit)
save.pack(side=LEFT)

frame.pack(fill=X, expand=True)

frameverify = Frame(root)
fil1 = Entry(frameverify)
fil1.pack(side=LEFT, fill=X, expand=True)

openit = Label(frameverify, text=”Path to original saved file”)
openit.pack(side=LEFT)

fil2 = Entry(frameverify)
fil2.pack(side=LEFT, fill=X, expand=True)

openit = Label(frameverify, text=”Path to new saved file”)
openit.pack(side=LEFT)

verifyfiles = Button(frameverify, text=”Verify/Compare”, command=compute)
verifyfiles.pack(side=LEFT)
frameverify.pack(fill=X, expand=True)

frame2 = Frame(root)
scrollbar = Scrollbar(frame2)
scrollbar.pack(side=RIGHT, fill=Y)

textbox = Text(frame2)
textbox.pack(side=LEFT, fill=BOTH, expand=True)
textbox.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=textbox.yview)
frame2.pack(fill=BOTH, expand=True)

root.mainloop()

PostHeaderIcon Assembly in Python

assembly-in-python

Well I am a total Python freak and so when I found an assembler written in Python I had to play with it.I am just learning assembler and decided I wanted to learn by doing! Reading through the docs for this Assembler and looking at the examples, I managed to get a basic code example to work in PyASM

Here is the code in Full

from pyasm.x86asm import assembler
from pyasm.x86cpToCoff import *

a = assembler()
a.AP(“_main”)
a.AI(“XOR EAX, EAX”)
a.AI(“MOV EBX, 0x7d4d14e0″) #address of Sleep
a.AI(“MOV AX, 5000″)
a.AI(“PUSH EAX”)
a.AI(“CALL EBX”)
a.EP()

cp = a.Compile()
coff = CpToCoff(cp).makeReleaseCoff()
f = file(“D:\\worktests\\obj.obj”, “wb”)
coff.WriteToFile(f)
f.close()

#######

This code was based on the examples at http://www.vividmachines.com/shellcode/shellcode.html

Ok so first we need to compile and then run arwin.c to get the address of “Sleep” from Kernel32.dll

So follow the instructions on above mentioned site

#######

I am just going to explain the PyASM Code


from pyasm.x86asm import assembler
from pyasm.x86cpToCoff import *
a = assembler()

Create our import statements and make a reference to our assembler() function


a.AP("_main")

AP = ADD PROCEDURE

a.AI(“XOR EAX, EAX”)

AI = ADD INSTRUCTION

Our Assembly instructions continue

a.EP()

EP = END PROCEDURE

cp = a.Compile()
coff = CpToCoff(cp).makeReleaseCoff()
f = file(“D:\\worktests\\obj.obj”, “wb”)
coff.WriteToFile(f)
f.close()

This generates our .obj file and writes all necessary info to it

Search
Awesome Links
Subscribe
Vote for Flyninja
Random Reading