diff --git a/Linux/pifinger.py b/Linux/pifinger.py index 918bcf3..410da58 100644 --- a/Linux/pifinger.py +++ b/Linux/pifinger.py @@ -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 @@ -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 --------------------------------------------------- """ @@ -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 = [] @@ -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) @@ -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() \ No newline at end of file diff --git a/README.md b/README.md index c295e18..67006bc 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ```
-
+
@@ -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!
@@ -82,7 +82,7 @@ Run:
```python
cd PiFinger/Linux
-python pifinger.py
+python3 pifinger.py
```
### Screenshots