Skip to content

Commit 379de83

Browse files
authored
Minor Fixes
Minor Fixes
2 parents a17deac + 74ea957 commit 379de83

File tree

1 file changed

+85
-30
lines changed

1 file changed

+85
-30
lines changed

ghost/modules/network.py

Lines changed: 85 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,101 @@ def __init__(self):
1515
'Loubaris - module developer'
1616
],
1717
'Description': "Retrieve network informations.",
18-
'Usage': "network [option]",
19-
'MinArgs': 1,
2018
'NeedsRoot': False,
21-
'Options': {
22-
'arptable': ['', 'Show device ARP table.'],
23-
'ipconfig': ['', 'Show device IP configuration.'],
24-
'iproute': ['', 'Show device route table.'],
25-
'location': ['', 'Show device location.'],
26-
'statistics': ['', 'Show network stats.'],
27-
'open_ports': ['', 'Show opened ports.'],
28-
'service_list': ['', 'Show services list.'],
29-
'forwarding': ['', 'Show forwarding rules.']
30-
}
19+
'MinArgs': 1,
20+
'Options': [
21+
(
22+
('-a', '--arp'),
23+
{
24+
'help': "Show device ARP table.",
25+
'action': 'store_true'
26+
}
27+
),
28+
(
29+
('-i', '--ipconfig'),
30+
{
31+
'help': "Show device IP configuration.",
32+
'action': 'store_true'
33+
}
34+
),
35+
(
36+
('-I', '--iproute'),
37+
{
38+
'help': "Show device route table.",
39+
'action': 'store_true'
40+
}
41+
),
42+
(
43+
('-l', '--locate'),
44+
{
45+
'help': "Show device location.",
46+
'action': 'store_true'
47+
}
48+
),
49+
(
50+
('-s', '--stats'),
51+
{
52+
'help': "Show device network stats.",
53+
'action': 'store_true'
54+
}
55+
),
56+
(
57+
('-p', '--ports'),
58+
{
59+
'help': "Show device open ports.",
60+
'action': 'store_true'
61+
}
62+
),
63+
(
64+
('-S', '--services'),
65+
{
66+
'help': "Show device services.",
67+
'action': 'store_true'
68+
}
69+
),
70+
(
71+
('-f', '--forwarding'),
72+
{
73+
'help': "Show device forwarding rules.",
74+
'action': 'store_true'
75+
}
76+
)
77+
]
3178
})
3279

3380
def run(self, args):
34-
output = ""
81+
outputs = []
3582

36-
if args[1] == 'arptable':
37-
output = self.device.send_command('cat /proc/net/arp')
83+
if args.arp:
84+
outputs.append(
85+
self.device.send_command('cat /proc/net/arp'))
3886

39-
elif args[1] == 'ipconfig':
40-
output = self.device.send_command('ip addr show')
87+
if args.ipconfig:
88+
outputs.append(
89+
self.device.send_command('ip addr show'))
4190

42-
elif args[1] == 'iproute':
43-
output = self.device.send_command('ip route show')
91+
if args.iproute:
92+
outputs.append(
93+
self.device.send_command('ip route show'))
4494

45-
elif args[1] == 'location':
46-
output = self.device.send_command('dumpsys location')
95+
if args.locate:
96+
outputs.append(
97+
self.device.send_command('dumpsys location'))
4798

48-
elif args[1] == 'statistics':
49-
output = self.device.send_command('cat /proc/net/netstat')
99+
if args.stats:
100+
outputs.append(
101+
self.device.send_command('cat /proc/net/netstat'))
50102

51-
elif args[1] == 'open_ports':
52-
output = self.device.send_command('busybox netstat -an')
103+
if args.ports:
104+
outputs.append(
105+
self.device.send_command('busybox netstat -an'))
53106

54-
elif args[1] == 'service_list':
55-
output = self.device.send_command('service list')
107+
if args.services:
108+
outputs.append(
109+
self.device.send_command('service list'))
56110

57-
elif args[1] == 'forwarding':
58-
output = self.device.send_command('cat /proc/sys/net/ipv4/ip_forward')
111+
if args.forwarding:
112+
outputs.append(
113+
self.device.send_command('cat /proc/sys/net/ipv4/ip_forward'))
59114

60-
self.print_empty(output)
115+
self.print_empty('\n'.join(outputs))

0 commit comments

Comments
 (0)