Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
fuswim
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sysadmin
fuswim
Commits
84fc8321
Commit
84fc8321
authored
4 years ago
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Other fucked things
parent
3a987222
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
26 deletions
+65
-26
fuswim
fuswim
+65
-26
No files found.
fuswim
View file @
84fc8321
...
...
@@ -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
)
...
...
@@ -137,17 +166,27 @@ for net in netw:
name
=
'NoEssid_'
+
str
(
i
)
i
=
i
+
1
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
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment