Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ported to python3 and some minor changes #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 43 additions & 35 deletions Linux/pifinger.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3
# coding=utf-8
from termcolor import colored
import netifaces
import socket
import commands
import subprocess
from time import gmtime, strftime
import os, sys

Expand All @@ -19,6 +20,9 @@
[---] Just for fun and security @octosec [---]
[---] W:besimaltinok.com | T:altnokbesim [---]
[---] G:besimaltnok [---]
---------------------------------------------------
Ported to Python3 by @xcod3
https://cs-academy.org
---------------------------------------------------
"""

Expand All @@ -28,7 +32,7 @@ def wifi_score_logging(timelog, mac, ssid, score, is_pineapple):
f.write(str(log)+"\n")
f.flush()
f.close()


def previous_wifi():
open_wifi = []
Expand All @@ -37,9 +41,9 @@ def previous_wifi():
data = open("/etc/NetworkManager/system-connections/"+w).read()
if "wifi-security" not in data:
open_wifi.append(w)
print "[=] ", w
print("[=] ", w)
return open_wifi


def default_port(gateway):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand All @@ -53,68 +57,72 @@ def default_port(gateway):


def default_hostname(gateway):
hostname = commands.getoutput("nslookup " + gateway +" | grep 'name = ' | awk '{print $4}'")
hostname = subprocess.getoutput("nslookup " + gateway +" | grep 'name = ' | awk '{print $4}'")
if "Pineapple.lan." in hostname:
return 1
return 0

def manufacturer_mac(manufmac, interface):
output = commands.getoutput("iwconfig " + interface + " | awk '/Access Point:/ {print $6}'")
output = subprocess.getoutput("iwconfig " + interface + " | awk '/Access Point:/ {print $6}'")
m = output[0:8]
for i in manufmac:
if i == output[0:8]:
return 1
if i == output[0:8]:
return 1
return 0


def root_check():
if os.geteuid() != 0:
print os.geteuid()
print "[--] You have need root permission for run this tool"
print(os.geteuid())
print("[--] You have need root permission for run this tool")
sys.exit()

if __name__ == "__main__":
def piFinger():
root_check()
is_pineapple = False
timelog = strftime("%Y-%m-%d %H:%M:%S", gmtime())
manufmac = ["00:C0:CA", "00:13:37"]
print banner
print(banner)
ifaces = netifaces.interfaces()
print "[*] Available interfaces: ", ifaces
interface = raw_input("[*] Please select the wireless interface you wish to use: ")
print "-----------------------------------------------------\n"
print("[*] Available interfaces: ", ifaces)
interface = input("[*] Please select the wireless interface you wish to use: ")
print("-----------------------------------------------------\n")
if interface in ifaces:
internet = commands.getoutput("iwconfig " + interface + "| awk '/Access Point:/ {print $4}'")
internet = subprocess.getoutput("iwconfig " + interface + "| awk '/Access Point:/ {print $4}'")
if internet != "Not-Associated" and "no wireless extensions" not in internet:
gateway = commands.getoutput("ip route show default | grep " + interface + "| awk '/default/ {print $3}'")
ssid = commands.getoutput("iwconfig "+ interface +"| awk '/ESSID:/ {print $4}'")
gateway = subprocess.getoutput("ip route show default | grep " + interface + "| awk '/default/ {print $3}'")
ssid = subprocess.getoutput("iwconfig "+ interface +"| awk '/ESSID:/ {print $4}'")
ssid = ssid.split("ESSID")[-1][2:-1]
mac = commands.getoutput("iwconfig " + interface + " | awk '/Access Point:/ {print $6}'")
mac = subprocess.getoutput("iwconfig " + interface + " | awk '/Access Point:/ {print $6}'")
port = default_port(gateway)
manuf = manufacturer_mac(manufmac, interface)
hostname = default_hostname(gateway)
print "\033[1m[--] Access Point:\t", mac
print "\033[1m[--] SSID:\t\t", ssid
print "\033[1m[--] --------------------------------\n"
print "\033[1m[###] Previous Connected WiFi - OPN:\n"
print("\033[1m[--] Access Point:\t", mac)
print("\033[1m[--] SSID:\t\t", ssid)
print("\033[1m[--] --------------------------------\n")
print("\033[1m[###] Previous Connected WiFi - OPN:\n")
open_w = previous_wifi()
score = port + manuf + hostname + len(open_w)
print colored("\n\033[1mCalculate risk score for your network:\n", "green")
print "[*] Manufacturer:\t", manuf
print "[*] Port:\t\t", port
print "[*] Nslookup:\t\t", hostname
print "[*] OPN Network count:\t", len(open_w)
print colored("\n\033[1m[?] Your wifi score: " + str(score), "green")
print(colored("\n\033[1mCalculate risk score for your network:\n", "green"))
print("[*] Manufacturer:\t", manuf)
print("[*] Port:\t\t", port)
print("[*] Nslookup:\t\t", hostname)
print("[*] OPN Network count:\t", len(open_w))
print(colored("\n\033[1m[?] Your wifi score: " + str(score), "green"))
if score > 2 and 1 in (port, hostname, manuf):
is_pineapple = True
print colored("\033[1m[-*-] You can fall into the trap - Fake access points", "yellow")
print colored("\033[1m[!!!] This network can be dangerous - WiFi-Pineapple", "red")
print(colored("\033[1m[-*-] You can fall into the trap - Fake access points", "yellow"))
print(colored("\033[1m[!!!] This network can be dangerous - WiFi-Pineapple", "red"))
wifi_score_logging(timelog, mac, ssid, score, is_pineapple)
elif score > 2:
print colored("\033[1m[-*-] You can fall into the trap - Fake access points", "yellow")
print(colored("\033[1m[-*-] You can fall into the trap - Fake access points", "yellow"))
print(colored("\033[1m[-*-] No WiFi-Pineapple network detected!", "green"))
wifi_score_logging(timelog, mac, ssid, score, is_pineapple)

else:
print "[!!] \033[1mNot-Associated with any wireless network"
print("[!!] \033[1mNot-Associated with any wireless network")
else:
print "[!!] Please select available interfaces"
print("[!!] Please select available interfaces")

if __name__ == "__main__":
piFinger()
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
```

<p align="center">
<img src="https://img.shields.io/badge/Python-2-yellow.svg"></a> <img src="https://img.shields.io/badge/license-GPLv3-red.svg">
<img src="https://img.shields.io/badge/Python-3-yellow.svg"></a> <img src="https://img.shields.io/badge/license-GPLv3-red.svg">
<a href="http://www.blackhat.com/eu-17/arsenal/schedule/#wipi-hunter---wifi-pineapple-activities-detection-9091"><img src="https://rawgit.com/toolswatch/badges/master/arsenal/europe/2017.svg"></a>
<a href="https://www.blackhat.com/asia-18/arsenal/schedule/index.html#wipi-hunter---detects-illegal-wireless-network-activities-9854"><img src="https://rawgit.com/toolswatch/badges/master/arsenal/asia/2018.svg"></a>
<a href="https://defcon.org/html/defcon-26/dc-26-demolabs.html#WiPi-Hunter"><img src="https://hackwith.github.io/badges/defcon/26/demolabs.svg"></a>
Expand Down Expand Up @@ -63,16 +63,16 @@ we too can catch them with the default settings in their software and hardware."
#### Requirements

* **Modules:** time, termcolor, sys, commands, interfaces, os
* **OS:** Kali, Ubuntu
* **Python Version:** 2.x
* **OS:** Parrot, Kali, Ubuntu
* **Python Version:** 3.x

Download pifinger:

`git clone https://github.com/besimaltnok/PiFinger.git`
`git clone https://github.com/xcod3/PiFinger.git`

Install Python librarie(s):

`pip install -r requirements.txt`
`pip3 install -r requirements.txt`

It's done!

Expand All @@ -82,7 +82,7 @@ Run:

```python
cd PiFinger/Linux
python pifinger.py
python3 pifinger.py
```

### Screenshots
Expand Down