21
py/Target.py
21
py/Target.py
@@ -78,7 +78,7 @@ class Target(object):
|
||||
if bssid_multicast.match(self.bssid):
|
||||
raise Exception("Ignoring target with Multicast BSSID (%s)" % self.bssid)
|
||||
|
||||
def __str__(self):
|
||||
def to_str(self, show_bssid=False):
|
||||
'''
|
||||
*Colored* string representation of this Target.
|
||||
Specifically formatted for the "scanning" table view.
|
||||
@@ -99,6 +99,11 @@ class Target(object):
|
||||
# Unknown ESSID
|
||||
essid = Color.s("{O}%s" % essid)
|
||||
|
||||
if show_bssid:
|
||||
bssid = Color.s('{O}%s ' % self.bssid)
|
||||
else:
|
||||
bssid = ''
|
||||
|
||||
channel_color = "{G}"
|
||||
if int(self.channel) > 14:
|
||||
channel_color = "{C}"
|
||||
@@ -131,24 +136,16 @@ class Target(object):
|
||||
if len(self.clients) > 0:
|
||||
clients = Color.s('{G} ' + str(len(self.clients)))
|
||||
|
||||
result = '%s %s %s %s %s %s' % (essid, channel,
|
||||
encryption, power,
|
||||
wps, clients)
|
||||
result = '%s %s%s %s %s %s %s' % (
|
||||
essid, bssid, channel, encryption, power, wps, clients)
|
||||
result += Color.s("{W}")
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def print_header():
|
||||
''' Prints header rows for "scanning" table view '''
|
||||
print ' NUM ESSID CH ENCR POWER WPS? CLIENT'
|
||||
print ' --- ------------------------- --- ---- ----- ---- ------'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
fields = 'AA:BB:CC:DD:EE:FF,2015-05-27 19:28:44,2015-05-27 19:28:46,1,54,WPA2,CCMP TKIP,PSK,-58,2,0,0.0.0.0,9,HOME-ABCD,'.split(',')
|
||||
t = Target(fields)
|
||||
t.clients.append("asdf")
|
||||
t.clients.append("asdf")
|
||||
Target.print_header()
|
||||
Color.pl(' {G}%s %s' % ('1'.rjust(3), t))
|
||||
print t.to_str()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user