Skip to content
This repository has been archived by the owner on Apr 19, 2020. It is now read-only.

Commit

Permalink
fixed improvements fuctions get_interfaces #109
Browse files Browse the repository at this point in the history
  • Loading branch information
mh4x0f committed Nov 8, 2016
1 parent 1c0dea4 commit 1203db4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Version 0.8.3
- fixed Error nmcli exceptions.OSError #104
- added error messages more explained
- added option to set Hostapd binary path (support hostapd-mana)
- fixed improvements fuctions get_interfaces #109

Version 0.8.1
-------------
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ refer to the wiki for [Installation](https://github.com/P0cL4bs/WiFi-Pumpkin/wik
``` python
import logging
from Plugin import PluginProxy
from core.Utils import setup_logger
from core.utils import setup_logger

class blurpage(PluginProxy):
''' this module proxy set blur into body page html response'''
Expand Down
1 change: 1 addition & 0 deletions core/config/commits/Lcommits.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ master:
{ changelog : 'fixed Error nmcli exceptions.OSError #104' },
{ changelog : 'added error messages more explained ' },
{ changelog : 'added option to set Hostapd binary path (support hostapd-mana)' },
{ changelog : 'fixed improvements fuctions get_interfaces #109' },
]

WiFiPumpkin081:
Expand Down
21 changes: 9 additions & 12 deletions core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@

from os import (
system,path,getcwd,
popen,listdir,mkdir,chown,remove
popen,listdir,mkdir,chown
)
from subprocess import (
Popen,PIPE,STDOUT,call,check_output,
CalledProcessError
Popen,PIPE,call,check_output,
)

from core.utils import (
Expand All @@ -47,11 +46,10 @@
import modules as GUIModules
from core.helpers.about import frmAbout
from core.helpers.update import frm_githubUpdate
from isc_dhcp_leases.iscdhcpleases import IscDhcpLeases
from core.widgets.docks.dockmonitor import dockAreaAPI
from core.utility.settings import frm_Settings
from core.helpers.update import ProgressBarWid
from core.helpers.report import frm_ReportLogger
from isc_dhcp_leases.iscdhcpleases import IscDhcpLeases
from netfilterqueue import NetfilterQueue

"""
Expand Down Expand Up @@ -1040,13 +1038,13 @@ def Start_PumpAP(self):

# check connection with internet
self.interfacesLink = Refactor.get_interfaces()
if len(self.EditGateway.text()) == 0 or self.interfacesLink['activated'] == None:
if len(self.EditGateway.text()) == 0 or self.interfacesLink['activated'][0] == None:
return QMessageBox.warning(self,'Internet Connection','No internet connection not found, '
'sorry WiFi-Pumpkin tool requires an internet connection to mount MITM attack. '
'check your connection and try again')

# check if Wireless interface is being used
if str(self.selectCard.currentText()) == self.interfacesLink['activated']:
if str(self.selectCard.currentText()) == self.interfacesLink['activated'][0]:
iwconfig = Popen(['iwconfig'], stdout=PIPE,shell=False,stderr=PIPE)
for line in iwconfig.stdout.readlines():
if str(self.selectCard.currentText()) in line:
Expand All @@ -1057,7 +1055,7 @@ def Start_PumpAP(self):
str(self.selectCard.currentText()),line))

# check if kali linux is using wireless interface for share internet
if str(self.interfacesLink['activated']).startswith('wl') and dist()[0] == 'Kali':
if self.interfacesLink['activated'][1] == 'wireless' and dist()[0] == 'Kali':
return QMessageBox.information(self,'Network Information',
"The Kali Linux don't have support to use with 2 wireless"
"(1 for connected internet/2 for WiFi-Pumpkin AP)."
Expand All @@ -1084,8 +1082,7 @@ def Start_PumpAP(self):
# check if using ethernet or wireless connection
print('[*] Configuring hostapd...')
self.ConfigTwin['AP_iface'] = str(self.selectCard.currentText())
if str(self.interfacesLink['activated']).startswith('eth') or \
str(self.interfacesLink['activated']).startswith('enp'):
if self.interfacesLink['activated'][1] == 'ethernet' or self.interfacesLink['activated'][1] == 'ppp':
# change Wi-Fi state card
try:
check_output(['nmcli','radio','wifi',"off"]) # old version
Expand All @@ -1097,7 +1094,7 @@ def Start_PumpAP(self):
return QMessageBox.warning(self,'Error nmcli',str(e))
finally:
call(['rfkill', 'unblock' ,'wifi'])
elif str(self.interfacesLink['activated']).startswith('wl'):
elif self.interfacesLink['activated'][1] == 'wireless':
# exclude USB wireless adapter in file NetworkManager
if not Refactor.settingsNetworkManager(self.ConfigTwin['AP_iface'],Remove=False):
return QMessageBox.warning(self,'Network Manager',
Expand Down Expand Up @@ -1210,7 +1207,7 @@ def Start_PumpAP(self):
iptables.append(str(self.FSettings.ListRules.item(index).text()))
for rulesetfilter in iptables:
if '$inet' in rulesetfilter:
rulesetfilter = rulesetfilter.replace('$inet',str(Refactor.get_interfaces()['activated']))
rulesetfilter = rulesetfilter.replace('$inet',str(Refactor.get_interfaces()['activated'][0]))
if '$wlan' in rulesetfilter:
rulesetfilter = rulesetfilter.replace('$wlan',self.ConfigTwin['AP_iface'])
popen(rulesetfilter)
Expand Down
53 changes: 34 additions & 19 deletions core/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from sys import exit,stdout
from struct import pack
from time import sleep,asctime,strftime
from time import sleep,asctime
from random import randint
from base64 import b64encode
from os import popen,path,walk,system,getpid,stat
from subprocess import call,check_output,Popen,PIPE,STDOUT
from os import popen,path,walk,stat
from subprocess import check_output,Popen,PIPE,STDOUT
from re import search,compile,VERBOSE,IGNORECASE
import threading
import netifaces
from threading import Thread
import Queue
from scapy.all import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
Expand All @@ -22,7 +18,7 @@
for modules.
Copyright:
Copyright (C) 2015 Marcos Nesster P0cl4bs Team
Copyright (C) 2015-2016 Marcos Nesster P0cl4bs Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
Expand All @@ -38,6 +34,7 @@
"""

class set_monitor_mode(QDialog):
''' enable/disable interface for monitor mode '''
def __init__(self,interface,parent = None):
super(set_monitor_mode, self).__init__(parent)
self.interface = interface
Expand All @@ -59,6 +56,7 @@ def setDisable(self):


class ThreadPhishingServer(QThread):
''' thread for get ouput the Phishing file .log requests '''
send = pyqtSignal(str)
def __init__(self,cmd,):
QThread.__init__(self)
Expand Down Expand Up @@ -123,6 +121,7 @@ def htmlContent(title):

@staticmethod
def get_content_by_session(filelines,sessionID=str):
''' find lines in session by ID '''
filterSession = []
sessiongrap = 'SessionID[{}]'.format(sessionID)
for line in filelines:
Expand All @@ -132,6 +131,7 @@ def get_content_by_session(filelines,sessionID=str):

@staticmethod
def exportHtml(unchecked={},sessionID='',dataLogger=[],APname=''):
''' funtion for get and check report files '''
readFile = {
'dhcp': {'logs/AccessPoint/dhcp.log':[]},
'urls': {'logs/AccessPoint/urls.log':[]},
Expand Down Expand Up @@ -210,6 +210,7 @@ def settingsNetworkManager(interface=str,Remove=False):

@staticmethod
def set_ip_forward(value):
'''set forward to redirect packets '''
with open('/proc/sys/net/ipv4/ip_forward', 'w') as file:
file.write(str(value))
file.close()
Expand All @@ -218,30 +219,44 @@ def set_ip_forward(value):
'''
@staticmethod
def getHwAddr(ifname):
''' another functions for get mac adreess '''
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
info = ioctl(s.fileno(), 0x8927, pack('256s', ifname[:15]))
return ':'.join(['%02x' % ord(char) for char in info[18:24]])

@staticmethod
def get_interfaces():
interfaces = {'activated':None,'all':[],'gateway':None,'IPaddress':None}
''' get interfaces and check status connection '''
interfaces = {'activated':[None,None],'all':[],'gateway':None,'IPaddress':None}
interfaces['all'] = netifaces.interfaces()
try:
interfaces['gateway'] = netifaces.gateways()['default'][netifaces.AF_INET][0]
interfaces['activated'] = netifaces.gateways()['default'][netifaces.AF_INET][1]
interfaces['IPaddress'] = Refactor.get_Ipaddr(interfaces['activated'])
interfaces['activated'][0] = netifaces.gateways()['default'][netifaces.AF_INET][1]
interfaces['IPaddress'] = Refactor.get_Ipaddr(interfaces['activated'][0])
# check type interfaces connected with internet
itype = None
iface = interfaces['activated'][0]
if iface[:-1] in ['ppp']:
itype = 'ppp'
elif iface[:2] in ['wl', 'wi', 'ra', 'at']:
itype = 'wireless'
elif iface[:2] in ['en','et']:
itype = 'ethernet'
interfaces['activated'][1] = itype
except KeyError:
print('Error: find network interface information ')
return interfaces

@staticmethod
def get_Ipaddr(card):
''' get ipadress from send arg None or interface name '''
if card == None:
return get_if_addr(Refactor.get_interfaces()['activated'])
return get_if_addr(Refactor.get_interfaces()['activated'][0])
return get_if_addr(card)

@staticmethod
def get_mac(host):
''' return mac by ipadress local network '''
fields = popen('grep "%s " /proc/net/arp' % host).read().split()
if len(fields) == 6 and fields[3] != "00:00:00:00:00:00":
return fields[3]
Expand All @@ -250,6 +265,7 @@ def get_mac(host):

@staticmethod
def get_interface_mac(device):
''' get mac from interface local system '''
result = check_output(["ifconfig", device], stderr=STDOUT, universal_newlines=True)
m = search("(?<=HWaddr\\s)(.*)", result)
n = search("(?<=ether\\s)(.*)", result)
Expand All @@ -259,43 +275,42 @@ def get_interface_mac(device):

@staticmethod
def randomMacAddress(prefix):
'''generate random mac for prefix '''
for _ in xrange(6-len(prefix)):
prefix.append(randint(0x00, 0x7f))
return ':'.join('%02x' % x for x in prefix)


@staticmethod
def check_is_mac(value):
'''check if mac is mac type '''
checked = compile(r"""(
^([0-9A-F]{2}[-]){5}([0-9A-F]{2})$
|^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$
)""",VERBOSE|IGNORECASE)
if checked.match(value) is None:return False
else:
return True
@staticmethod
def threadRoot(sudo_password):
call(['sudo','-k'])
p = Popen(['sudo', '-S','./wifi-pumpkin.py'], stdin=PIPE, stderr=PIPE,
universal_newlines=True)
waiter().start()
p.communicate(str(sudo_password) + '\n')[1]

@staticmethod
def find(name, paths):
''' find all files in directory '''
for root, dirs, files in walk(paths):
if name in files:
return path.join(root, name)
@staticmethod
def getSize(filename):
''' return files size by pathnme '''
st = stat(filename)
return st.st_size

@staticmethod
def generateSessionID():
''' generate session encoded base64 '''
return str(b64encode(str(random.randint(0,100000))))

class waiterSleepThread(QThread):
''' Simples Thread for wait 10 segunds for check update app'''
quit = pyqtSignal(object)
def __int__(self,parent=None):
super(waiterSleepThread, self).__init__(self,parent)
Expand Down
2 changes: 1 addition & 1 deletion modules/poisoners/ArpPosion.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def ConfigureEdits(self):
if x['gateway'] != None:
self.txt_gateway.setText(x['gateway'])
self.txt_redirect.setText(x['IPaddress'])
self.txt_mac.setText(Refactor.getHwAddr(x['activated']))
self.txt_mac.setText(Refactor.getHwAddr(x['activated'][0]))
self.connect(self.ComboIface, SIGNAL("currentIndexChanged(QString)"), self.discoveryIface)
n = self.interfaces['all']
for i,j in enumerate(n):
Expand Down

0 comments on commit 1203db4

Please sign in to comment.