Commit 84fc8321 authored by root's avatar root

Other fucked things

parent 3a987222
......@@ -2,7 +2,7 @@
import iw_parse
from pprint import pprint
import psutil
import sys
import sys, os
from shell_cmd import sh
try:
......@@ -15,6 +15,8 @@ except:
boot=False
auto=False
NETPATH='/etc/fuswin/networks'
class colors:
RED = '\033[31m'
ENDC = '\033[m'
......@@ -38,6 +40,57 @@ def sigcol(qual):
return rcol
def detect_ifaces():
iplinks=sh("/sbin/ip link show").split()
j, interfaces = 1,[]
for i in range(len(iplinks)):
if iplinks[i] == str(j)+':':
j=j+1
iface=iplinks[i+1]
interfaces.append(iface[:-1])
return interfaces
def checkYN(res, default='N'):
if not res:
res=default
if res.lower()=='y' or res.lower()=='fuck yeah!':
return True
elif res.lower()=='n' or res.lower()=='fuck no!':
return False
print(colors.RED+'WHAT? "'+res+'"? WHAT THE FUCK? I take it as a fuck no!'+colors.ENDC)
return False
def read_netconf(net):
p="/".join([NETPATH, net])
conf = {
'auto': False,
'prio': 100,
'crypt': 'WPA2',
'psk': '12345678',
'dhcp': True,
'ip': '192.168.42.42',
'nmask': '255.255.255.0',
'gw': '192.168.42.1'
}
if os.path.isfile(p):
try:
with open(p) as f:
lines = f.readlines()
for line in lines:
if ":" in line:
k, v = line.split(":", 1)
if k in ['auto', 'dhcp']:
v=checkYN(v)
conf[k] = v
return conf
except:
pass
return False
def kill_proc(name, ops=False):
for process in psutil.process_iter():
......@@ -66,30 +119,6 @@ if sys.argv[-1] not in ['auto','boot',sys.argv[0]]:
interface = sys.argv[-1]
def detect_ifaces():
iplinks=sh("/sbin/ip link show").split()
j, interfaces = 1,[]
for i in range(len(iplinks)):
if iplinks[i] == str(j)+':':
j=j+1
iface=iplinks[i+1]
interfaces.append(iface[:-1])
return interfaces
def checkYN(res, default='N'):
if not res:
print(' '+default)
res=default
if res.lower()=='y' or res.lower()=='fuck yeah!':
return True
elif res.lower()=='n' or res.lower()=='fuck no!':
return False
print(colors.RED+'WHAT? "'+res+'"? WHAT THE FUCK? I take it as a fuck no!'+colors.ENDC)
return False
if not interface in detect_ifaces():
print(colors.RED+"OH FUCK! Interface "+interface+" doesn't exists. Exiting..."+colors.ENDC)
sys.exit(1)
......@@ -139,15 +168,25 @@ for net in netw:
nets[name] = net
print('Here it is your fucking networks...:')
i=0
for net in nets.keys():
netconf=""
sig=nets[net]['Signal Level']
qual=nets[net]['Quality']
enc='Open'
if 'Encryption' in nets[net].keys():
enc=nets[net]['Encryption']
freq=nets[net]['Frequency']
print(" "+str(i)+": "+colors.BLUE+net+colors.ENDC+" ("+sigcol(qual)+"sig: "+sig+", qual: "+nets[net]['Quality']+", freq: "+freq+", enc: "+enc+colors.ENDC+")")
nconf = read_netconf(net)
if nconf:
nauto = 'NO'
if nconf['auto']:
nauto = 'YES'
netconf="AUTO: "+nauto+", PRIO: "+str(nconf['prio'])
print(" "+str(i)+": "+colors.BLUE+net+colors.ENDC+" ("+sigcol(qual)+"sig: "+sig+", qual: "+qual+", freq: "+freq+", enc: "+enc+colors.ENDC+") "+netconf)
i=i+1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment