Skip to content

Commit

Permalink
Revert to 0387d82
Browse files Browse the repository at this point in the history
  • Loading branch information
flashnuke committed Nov 3, 2023
1 parent 99e4177 commit 2a4ae9a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 67 deletions.
Binary file modified apk/bin/deadnet-1.0-arm64-v8a_armeabi-v7a-debug.apk
Binary file not shown.
29 changes: 3 additions & 26 deletions apk/deadnet_apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import ipaddress
import subprocess
import platform as pt
from threading import Condition

from utils import *

from android.permissions import request_permissions, Permission
request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.INTERNET, Permission.ACCESS_WIFI_STATE,
Permission.ACCESS_NETWORK_STATE, Permission.ACCESS_FINE_LOCATION, Permission.CHANGE_WIFI_STATE])

logging.getLogger("scapy.runtime").setLevel(logging.ERROR) # suppress warnings
from scapy.all import *
Expand All @@ -38,17 +39,12 @@ class DeadNetAPK:
"aarch64": "arm64",
"i386": "i386",
}
MISSING_ANDROID_PERMISSIONS = [Permission.WRITE_EXTERNAL_STORAGE, Permission.INTERNET, Permission.ACCESS_WIFI_STATE,
Permission.ACCESS_NETWORK_STATE, Permission.ACCESS_FINE_LOCATION,
Permission.CHANGE_WIFI_STATE]
CONDITION_ANDROID_PERMISSIONS = Condition()

def __init__(self, iface, gateway_ipv4, gateway_ipv6, gateway_mac=None, print_mtd=None):
self.print_mtd = print_mtd

self.network_interface = iface
conf.iface = self.network_interface

self.print_mtd = print_mtd
self.my_mac = netifaces.ifaddresses(iface)[netifaces.AF_LINK][0]['addr']
self.loop_count = 0

Expand Down Expand Up @@ -102,16 +98,6 @@ def __init__(self, iface, gateway_ipv4, gateway_ipv6, gateway_mac=None, print_mt
f"IPv4 subnet range - {self.subnet_ipv4_sr}\n" \
f"IPv4 gateway - {self.gateway_ipv4}\n\n"

@staticmethod
def permissions_callback(permissions, results):
DeadNetAPK.MISSING_ANDROID_PERMISSIONS.clear()
if not all(results):
for perm, result in zip(permissions, results):
if not result:
DeadNetAPK.MISSING_ANDROID_PERMISSIONS.append(perm)
with DeadNetAPK.CONDITION_ANDROID_PERMISSIONS:
DeadNetAPK.CONDITION_ANDROID_PERMISSIONS.notify()

def get_ipv6_data(self):
prefix, preflen = str(), int()
try:
Expand Down Expand Up @@ -172,12 +158,3 @@ def start_attack(self):
self.print_mtd(f"{self.abort}", True)
else:
self.print_mtd(f"{self.intro}{self.abort}")


def request_user_permissions():
request_permissions(DeadNetAPK.MISSING_ANDROID_PERMISSIONS, DeadNetAPK.permissions_callback)
with DeadNetAPK.CONDITION_ANDROID_PERMISSIONS:
DeadNetAPK.CONDITION_ANDROID_PERMISSIONS.wait()


request_user_permissions()
67 changes: 26 additions & 41 deletions apk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import threading
import netifaces
import subprocess
import traceback

from utils import *
from deadnet_apk import DeadNetAPK, request_user_permissions
from deadnet_apk import DeadNetAPK
from kivy.app import App
from jnius import autoclass

Expand All @@ -19,13 +18,13 @@ def __init__(self, **kwargs):
self.ssid_name = "undefined"

self._abort_lck = threading.RLock()
self.setup_network_data()
self._deadnet_ins = None

self._root_status = False
try:
subprocess.call(["su"]) # test root
self._root_status = True
self.setup_network_data() # if not root - should not get here
except (PermissionError, FileNotFoundError):
pass

Expand Down Expand Up @@ -64,25 +63,28 @@ def set_ssid_name(self):
@staticmethod
def init_gateway():
gateway_ipv4, gateway_ipv6, iface, gateway_hwaddr = "undefined", "undefined", "undefined", "undefined"
gateways = netifaces.gateways()
ipv4_data = gateways[netifaces.AF_INET][0] # take first for IPv4
gateway_ipv4 = ipv4_data[0]
iface = ipv4_data[1]

ipv6_data = gateways.get(netifaces.AF_INET6, list())
for d in ipv6_data:
if d[1] == iface:
gateway_ipv6 = d[0]

result = subprocess.run(['ip', 'neighbor', 'show', 'default'], capture_output=True, text=True)
output = result.stdout.strip()

for line in output.split('\n'):
columns = line.split()
if len(columns) >= 4:
if columns[3] == 'lladdr' and columns[4] != '<incomplete>' and columns[2] == iface:
gateway_hwaddr = columns[4]
break
try:
gateways = netifaces.gateways()
ipv4_data = gateways[netifaces.AF_INET][0] # take first for IPv4
gateway_ipv4 = ipv4_data[0]
iface = ipv4_data[1]

ipv6_data = gateways.get(netifaces.AF_INET6, list())
for d in ipv6_data:
if d[1] == iface:
gateway_ipv6 = d[0]

result = subprocess.run(['ip', 'neighbor', 'show', 'default'], capture_output=True, text=True)
output = result.stdout.strip()

for line in output.split('\n'):
columns = line.split()
if len(columns) >= 4:
if columns[3] == 'lladdr' and columns[4] != '<incomplete>' and columns[2] == iface:
gateway_hwaddr = columns[4]
break
except Exception as exc:
pass

return gateway_ipv4, gateway_ipv6, gateway_hwaddr, iface

Expand All @@ -92,12 +94,6 @@ def is_root(self):
return False
return True

def has_permissions(self):
if len(DeadNetAPK.MISSING_ANDROID_PERMISSIONS) > 0:
self.printf(f"Mandatory permissions are not granted:\n{','.join(DeadNetAPK.MISSING_ANDROID_PERMISSIONS)}")
return False
return True

def on_ref_credit_press(self, *args, **kwargs):
import webbrowser
webbrowser.open("https://github.com/flashnuke")
Expand All @@ -106,27 +102,16 @@ def on_start_press(self):
if self.is_root():
threading.Thread(target=self.do_attack, args=tuple()).start()

def ssid_is_set(self):
if "<unknown ssid>" in self.ssid_name:
self.setup_network_data()
return "<unknown ssid>" not in self.ssid_name

def do_attack(self):
if self.is_root():
if not self.has_permissions():
request_user_permissions()
self.setup_network_data()
return
if not self.ssid_is_set():
return
if self.is_root() and "<unknown ssid>" not in self.ssid_name:
with self._abort_lck:
if self._deadnet_ins:
return
try:
self._deadnet_ins = DeadNetAPK(self._IFACE, self._GATEWAY_IPV4, self._GATEWAY_IPV6, self._GATEWAY_HWDDR,
self.printf)
except Exception as exc:
self.printf(f"error during setup -> {exc}\n{traceback.format_exc()}")
self.printf(f"error during setup -> {exc}")
return
self._deadnet_ins.start_attack()

Expand Down

0 comments on commit 2a4ae9a

Please sign in to comment.