diff --git a/lib/__init__.py b/lib/__init__.py
old mode 100644
new mode 100755
diff --git a/lib/graphs.py b/lib/graphs.py
old mode 100644
new mode 100755
index 4a81981f..2918d0e9
--- a/lib/graphs.py
+++ b/lib/graphs.py
@@ -26,26 +26,25 @@
=====================================================================================================
"""
-import re
import math
+import re
class BarGraph:
- """creates horizontal and vertical bar graphs, progress bars and faders"""
+ """Creates horizontal and vertical bar graphs, progress bars, and faders."""
def __init__(self, type=''):
-#-------------------------------------------------------------------------
-# Configuration
-#-------------------------------------------------------------------------
+ #-------------------------------------------------------------------------
+ # Configuration
+ #-------------------------------------------------------------------------
# graph type: "hBar", "vBar", "pBar", or "fader"
self.type = type and type or 'hBar'
self.values = [] # graph data: list
# graph background color: string
self.graphBGColor = ''
- # graph border: string (CSS-spec: "size style color"; doesn't work with
- # NN4)
+ # graph border: string (CSS-spec: "size style color"; doesn't work with NN4)
self.graphBorder = ''
# graph padding: integer (pixels)
self.graphPadding = 0
@@ -90,11 +89,9 @@ def __init__(self, type=''):
self.barColors = []
# bar background color: string
self.barBGColor = ''
- # bar border: string (CSS-spec: "size style color"; doesn't work with
- # NN4)
+ # bar border: string (CSS-spec: "size style color"; doesn't work with NN4)
self.barBorder = '2px outset white'
- # bar level colors: ascending list (bLevel, bColor[,...]); draw bars >=
- # bLevel with bColor
+ # bar level colors: ascending list (bLevel, bColor[,...]); draw bars >= bLevel with bColor
self.barLevelColors = []
# show values: 0 = % only, 1 = abs. and %, 2 = abs. only, 3 = none
@@ -106,8 +103,7 @@ def __init__(self, type=''):
self.absValuesColor = 'black'
# abs. values background color: string
self.absValuesBGColor = '#C0E0FF'
- # abs. values border: string (CSS-spec: "size style color"; doesn't
- # work with NN4)
+ # abs. values border: string (CSS-spec: "size style color"; doesn't work with NN4)
self.absValuesBorder = '2px groove white'
# abs. values font family: string (CSS-spec)
self.absValuesFont = 'Arial, Helvetica'
@@ -135,8 +131,7 @@ def __init__(self, type=''):
self.legendColor = 'black' # legend font color: string
# legend background color: string
self.legendBGColor = '#F0F0F0'
- # legend border: string (CSS-spec: "size style color"; doesn't work
- # with NN4)
+ # legend border: string (CSS-spec: "size style color"; doesn't work with NN4)
self.legendBorder = '2px groove white'
# legend font family: string (CSS-spec)
self.legendFont = 'Arial, Helvetica'
@@ -147,7 +142,7 @@ def __init__(self, type=''):
# debug mode: 0 = off, 1 = on; just views some extra information
self.debug = 0
-#-------------------------------------------------------------------------
+ #-------------------------------------------------------------------------
# default bar colors; only used if barColors isn't set
__colors = (
@@ -158,10 +153,10 @@ def __init__(self, type=''):
'#FFA0A0',
'#00A000')
- # error messages
+ # Error messages.
__err_type = 'ERROR: Type must be "hBar", "vBar", "pBar", or "fader"'
- # CSS names (don't change)
+ # CSS names (don't change).
__cssGRAPH = ''
__cssBAR = ''
__cssBARBG = ''
@@ -173,7 +168,7 @@ def __init__(self, type=''):
__cssABSVALUES = ''
__cssPERCVALUES = ''
- # search pattern for images
+ # Search pattern for images.
__img_pattern = re.compile(r'\.(jpg|jpeg|jpe|gif|png)')
def set_styles(self):
@@ -223,29 +218,25 @@ def set_styles(self):
if self.legendSize:
self.__cssLEGEND += 'font-size:' + str(self.legendSize) + 'px;'
if self.legendBGColor:
- self.__cssLEGENDBG += 'background-color:' + \
- self.legendBGColor + ';'
+ self.__cssLEGENDBG += 'background-color:' + self.legendBGColor + ';'
if self.legendBorder:
self.__cssLEGENDBG += 'border:' + self.legendBorder + ';'
if self.absValuesColor:
self.__cssABSVALUES += 'color:' + self.absValuesColor + ';'
if self.absValuesBGColor:
- self.__cssABSVALUES += 'background-color:' + \
- self.absValuesBGColor + ';'
+ self.__cssABSVALUES += 'background-color:' + self.absValuesBGColor + ';'
if self.absValuesBorder:
self.__cssABSVALUES += 'border:' + self.absValuesBorder + ';'
if self.absValuesFont:
self.__cssABSVALUES += 'font-family:' + self.absValuesFont + ';'
if self.absValuesSize:
- self.__cssABSVALUES += 'font-size:' + \
- str(self.absValuesSize) + 'px;'
+ self.__cssABSVALUES += 'font-size:' + str(self.absValuesSize) + 'px;'
if self.percValuesColor:
self.__cssPERCVALUES += 'color:' + self.percValuesColor + ';'
if self.percValuesFont:
self.__cssPERCVALUES += 'font-family:' + self.percValuesFont + ';'
if self.percValuesSize:
- self.__cssPERCVALUES += 'font-size:' + \
- str(self.percValuesSize) + 'px;'
+ self.__cssPERCVALUES += 'font-size:' + str(self.percValuesSize) + 'px;'
def level_color(self, value, color):
"""return bar color for each level"""
@@ -253,7 +244,7 @@ def level_color(self, value, color):
for i in range(0, len(self.barLevelColors), 2):
try:
if (self.barLevelColors[i] > 0 and value >= self.barLevelColors[i]) or \
- (self.barLevelColors[i] < 0 and value <= self.barLevelColors[i]):
+ (self.barLevelColors[i] < 0 and value <= self.barLevelColors[i]):
color = self.barLevelColors[i + 1]
except IndexError:
pass
@@ -266,8 +257,7 @@ def build_bar(self, value, width, height, color):
bar = '
'
bar += '' or '>'
- bar += ''
bar += ' |
'
return bar
@@ -291,11 +281,9 @@ def build_value(self, val, max_dec, sum=0, align=''):
if align:
value += ' align=' + align
value += ' nowrap>'
- value += ' ' + self.absValuesPrefix + \
- str(val) + self.absValuesSuffix
+ value += ' ' + self.absValuesPrefix + str(val) + self.absValuesSuffix
if sum:
- value += ' / ' + self.absValuesPrefix + \
- str(sum) + self.absValuesSuffix
+ value += ' / ' + self.absValuesPrefix + str(sum) + self.absValuesSuffix
value += ' '
return value
@@ -317,13 +305,12 @@ def build_legend(self, barColors):
text = ''
legend += ''
legend += '' + \
- self.build_bar(
- '',
- self.barWidth,
- self.barWidth,
- color) + ' | '
- legend += '' + text + ' | '
+ self.build_bar(
+ '',
+ self.barWidth,
+ self.barWidth,
+ color) + ''
+ legend += '' + text + ' | '
legend += '
'
i += 1
@@ -336,7 +323,7 @@ def build_hTitle(self, titleLabel, titleValue, titleBar):
title += '' + titleLabel + ' | '
if titleValue != '':
title += '' + titleValue + ' | '
+ '">' + titleValue + ''
title += '' + titleBar + ' | '
title += ''
return title
@@ -349,36 +336,29 @@ def create_hBar(self, value, percent, mPerc, mPerc_neg,
if percent < 0:
percent *= -1
bar += ''
+ str(self.barWidth) + ' width=' + \
+ str(int(round((mPerc_neg - percent) * mul + valSpace))) + \
+ ' align=right nowrap>'
if self.showValues < 2:
bar += '' + \
- str(_number_format(percent, self.percValuesDecimals)) + \
- '%'
+ str(_number_format(percent, self.percValuesDecimals)) + '%'
bar += ' | '
- bar += self.build_bar(value, int(round(percent * mul)),
- self.barWidth, bColor)
+ bar += self.build_bar(value, int(round(percent * mul)), self.barWidth, bColor)
bar += ' | | '
else:
if max_neg:
- bar += ''
+ bar += ' | '
bar += ' | '
if percent:
bar += ''
- bar += self.build_bar(value, int(round(percent * mul)),
- self.barWidth, bColor)
+ bar += self.build_bar(value, int(round(percent * mul)), self.barWidth, bColor)
bar += ' | '
else:
- bar += ' | '
+ bar += ' | '
bar += ''
+ str(int(round((mPerc - percent) * mul + valSpace))) + ' align=left nowrap>'
if self.showValues < 2:
- bar += ' ' + \
- str(_number_format(percent, self.percValuesDecimals)) + '%'
+ bar += ' ' + str(_number_format(percent, self.percValuesDecimals)) + '%'
bar += ' | '
bar += ''
@@ -392,37 +372,32 @@ def create_vBar(self, value, percent, mPerc, mPerc_neg,
if percent < 0:
percent *= -1
bar += ' | '
- bar += self.build_bar(value, self.barWidth,
- int(round(percent * mul)), bColor)
+ str(spacer) + '> |
'
+ bar += self.build_bar(value, self.barWidth, int(round(percent * mul)), bColor)
bar += ' |
'
bar += ''
+ str(int(round((mPerc_neg - percent) * mul + valSpace))) + ' nowrap>'
bar += (self.showValues < 2) and '' + \
- str(_number_format(percent, self.percValuesDecimals)) + \
- '%' or ' '
+ str(_number_format(percent, self.percValuesDecimals)) + \
+ '%' or ' '
bar += ' | '
else:
bar += ''
+ str(int(round((mPerc - percent) * mul + valSpace))) + ' nowrap>'
if self.showValues < 2:
- bar += str(_number_format(percent, self.percValuesDecimals)) + \
- '%'
+ bar += str(_number_format(percent, self.percValuesDecimals)) + '%'
bar += ' | '
if percent:
bar += '
'
- bar += self.build_bar(value, self.barWidth,
- int(round(percent * mul)), bColor)
+ bar += self.build_bar(value, self.barWidth, int(round(percent * mul)), bColor)
bar += ' | '
else:
bar += '
| '
+ str(self.barWidth + (border * 2)) + ' height=1>'
if max_neg:
bar += '
'
+ '" height=' + str(spacer_neg) + '>'
bar += ' | '
bar += '
'
@@ -462,10 +437,10 @@ def create(self):
self.set_styles()
graph = ''
+ str(self.graphPadding) + '>
'
graph += ''
+ (self.__cssGRAPH and ' style="' +
+ self.__cssGRAPH + '"' or '') + '>'
if self.legend and self.type != 'pbar' and self.type != 'fader':
graph += ''
@@ -546,7 +521,7 @@ def create(self):
if self.showValues < 2:
if self.type == 'hbar':
valSpace = (self.percValuesDecimals * (self.percValuesSize / 1.6)) + \
- (self.percValuesSize * 3.2)
+ (self.percValuesSize * 3.2)
else:
valSpace = self.percValuesSize * 1.2
else:
@@ -583,16 +558,14 @@ def create(self):
if self.type == 'hbar':
if len(t) > 0:
- graph += self.build_hTitle(titleLabel,
- titleValue, titleBar)
+ graph += self.build_hTitle(titleLabel, titleValue, titleBar)
for i in range(len(v)):
label = (
- lcnt < len(r)) and r[lcnt].strip() or str(lcnt + 1)
+ lcnt < len(r)) and r[lcnt].strip() or str(lcnt + 1)
rowspan = len(v[i])
graph += ' | 1) and ' rowspan=' + str(rowspan) or '') + \
- '>'
+ ((rowspan > 1) and ' rowspan=' + str(rowspan) or '') + '>'
graph += ' ' + label + ' | '
for j in range(len(v[i])):
@@ -606,8 +579,8 @@ def create(self):
[j], max_dec, 0, 'right')
graph += ''
+ ' height=100% width=' + \
+ str(maxSize) + '>'
graph += self.create_hBar(
value, percent, mPerc, mPerc_neg,
max_neg, mul, valSpace, bColor, border, spacer, spacer_neg)
@@ -617,7 +590,7 @@ def create(self):
if self.labelSpace and i < len(v) - 1:
graph += ' | | '
+ str(self.labelSpace) + '>'
lcnt += 1
elif self.type == 'vbar':
@@ -625,8 +598,7 @@ def create(self):
if titleBar != '':
titleBar = titleBar.replace('-', '- ')
- graph += '' + titleBar + ' | '
+ graph += '' + titleBar + ' | '
for i in range(len(v)):
for j in range(len(v[i])):
@@ -636,8 +608,8 @@ def create(self):
bColor = self.level_color(v[i][j], bc[j])
graph += ''
+ (self.__cssBARBG and ' style="' +
+ self.__cssBARBG + '"' or '') + '>'
graph += self.create_vBar(
value, percent, mPerc, mPerc_neg,
max_neg, mul, valSpace, bColor, border, spacer, spacer_neg)
@@ -650,27 +622,24 @@ def create(self):
graph += ' | '
if titleValue != '':
graph += '' + titleValue + ' | '
+ '">' + titleValue + ''
for i in range(len(v)):
for j in range(len(v[i])):
graph += self.build_value(v[i][j], max_dec)
if self.labelSpace:
- graph += ' | '
+ graph += ' | '
graph += ' '
if titleLabel != '':
- graph += '' + titleLabel + ' | '
+ graph += '' + titleLabel + ' | '
for i in range(len(v)):
label = (
- lcnt < len(r)) and r[lcnt].strip() or str(lcnt + 1)
+ lcnt < len(r)) and r[lcnt].strip() or str(lcnt + 1)
colspan = len(v[i])
graph += ' 1) and ' colspan=' + str(colspan) or '') + \
- '>'
+ ((colspan > 1) and ' colspan=' + str(colspan) or '') + '>'
graph += ' ' + label + ' | '
if self.labelSpace:
graph += ' | '
@@ -680,8 +649,7 @@ def create(self):
elif self.type == 'pbar' or self.type == 'fader':
if len(t) > 0:
- graph += self.build_hTitle(titleLabel,
- titleValue, titleBar)
+ graph += self.build_hTitle(titleLabel, titleValue, titleBar)
for i in range(len(v)):
try:
@@ -691,7 +659,7 @@ def create(self):
if m or not i:
label = (
- lcnt < len(r)) and r[lcnt].strip() or str(i + 1)
+ lcnt < len(r)) and r[lcnt].strip() or str(i + 1)
graph += ' '
if len(r):
@@ -711,11 +679,11 @@ def create(self):
[0], max_dec, sum, 'right')
graph += ''
+ (self.__cssBARBG and ' style="' +
+ self.__cssBARBG + '"' or '') + '>'
self.barColors = (
- len(drc) >= i + 1) and drc[i].strip() or self.__colors[0]
+ len(drc) >= i + 1) and drc[i].strip() or self.__colors[0]
bColor = self.level_color(v[i][0], self.barColors)
graph += ''
if self.type == 'fader':
@@ -726,16 +694,15 @@ def create(self):
graph += self.build_bar(value,
int(round(percent * mul)), self.barWidth, bColor)
graph += ' | | '
+ str(int(round((100 - percent) * mul))) + '>'
graph += '
| '
if self.showValues < 2:
graph += ' ' + \
- str(_number_format(percent, self.percValuesDecimals)) + \
- '% | '
+ str(_number_format(percent, self.percValuesDecimals)) + '%'
graph += ' '
if self.labelSpace and i < len(v) - 1:
graph += ' | '
+ str(self.labelSpace) + '>'
lcnt += 1
else:
@@ -756,16 +723,13 @@ def create(self):
if self.legend and self.type != 'pbar' and self.type != 'fader':
graph += ' | '
+ (self.legendAlign and ' valign=' + self.legendAlign or '') + '>'
graph += self.build_legend(bc)
graph += ' | '
if self.debug:
- graph += " sum=%s max=%s max_neg=%s max_dec=%s " % (sum,
- max, max_neg, max_dec)
- graph += "mPerc=%s mPerc_neg=%s mul=%s valSpace=%s" % (mPerc,
- mPerc_neg, mul, valSpace)
+ graph += " sum=%s max=%s max_neg=%s max_dec=%s " % (sum, max, max_neg, max_dec)
+ graph += "mPerc=%s mPerc_neg=%s mul=%s valSpace=%s" % (mPerc, mPerc_neg, mul, valSpace)
graph += ' |
'
return graph
diff --git a/lib/hostchecker.py b/lib/hostchecker.py
old mode 100644
new mode 100755
index 36a65b13..aebc0947
--- a/lib/hostchecker.py
+++ b/lib/hostchecker.py
@@ -4,9 +4,9 @@
Created by laramies on 2008-08-21.
"""
-
import socket
+
class Checker():
def __init__(self, hosts):
diff --git a/lib/htmlExport.py b/lib/htmlExport.py
old mode 100644
new mode 100755
index 7c625599..3aa83209
--- a/lib/htmlExport.py
+++ b/lib/htmlExport.py
@@ -1,12 +1,14 @@
-from lib import markup
-from lib import graphs
+
import re
+from lib import graphs
+from lib import markup
+
class htmlExport():
- def __init__(self, users, hosts, vhosts, dnsres,
- dnsrev, file, domain, shodan, tldres):
+
+ def __init__(self, users, hosts, vhosts, dnsres, dnsrev, file, domain, shodan, tldres):
self.users = users
self.hosts = hosts
self.vhost = vhosts
@@ -50,7 +52,6 @@ def styler(self):
font-size: 15px;
line-height: 15px;
letter-spacing: 0.4px;
-
}
h2{
@@ -62,7 +63,6 @@ def styler(self):
margin: 0 0 0 0;
padding: 0 0 0 0;
font-weight: 100;
-
}
pre {
@@ -84,8 +84,6 @@ def styler(self):
def writehtml(self):
page = markup.page()
- # page.init (title="theHarvester
- # Results",css=('edge.css'),footer="Edge-security 2011")A
page.html()
self.styler()
page.head(self.style)
@@ -103,20 +101,20 @@ def writehtml(self):
graph.labels = ['Emails', 'hosts', 'Vhost', 'TLD', 'Shodan']
graph.showValues = 1
page.body(graph.create())
- page.h3("E-mails names found:")
+ page.h3("Emails found:")
if self.users != []:
page.ul(class_="userslist")
page.li(self.users, class_="useritem")
page.ul.close()
else:
- page.h2("No emails found")
+ page.h2("No emails found.")
page.h3("Hosts found:")
if self.hosts != []:
page.ul(class_="softlist")
page.li(self.hosts, class_="softitem")
page.ul.close()
else:
- page.h2("No hosts found")
+ page.h2("No hosts found.")
if self.tldres != []:
page.h3("TLD domains found in TLD expansion:")
page.ul(class_="tldlist")
@@ -128,7 +126,7 @@ def writehtml(self):
page.li(self.dnsres, class_="dnsitem")
page.ul.close()
if self.dnsrev != []:
- page.h3("Hosts found with reverse lookup :")
+ page.h3("Hosts found with reverse lookup:")
page.ul(class_="dnsrevlist")
page.li(self.dnsrev, class_="dnsrevitem")
page.ul.close()
@@ -143,7 +141,7 @@ def writehtml(self):
for x in self.shodan:
res = x.split("SAPO")
page.h3(res[0])
- page.a("Port :" + res[2])
+ page.a("Port:" + res[2])
page.pre(res[1])
page.pre.close()
ban = res[1]
@@ -166,7 +164,7 @@ def writehtml(self):
try:
file.write(x)
except:
- print("Exception" + x) # send to logs
+ print("Exception" + x) # Send to logs.
pass
file.close()
return "ok"
diff --git a/lib/markup.py b/lib/markup.py
old mode 100644
new mode 100755
index afa8f85a..ae359f55
--- a/lib/markup.py
+++ b/lib/markup.py
@@ -1,6 +1,5 @@
-# This code is in the public domain, it comes
-# with absolutely no warranty and you can do
-# absolutely whatever you want with it.
+# This code is in the public domain, it comes with absolutely no
+# warranty and you can do absolutely whatever you want with it.
__date__ = '17 May 2007'
__version__ = '1.7'
@@ -21,6 +20,7 @@
Installation: drop markup.py somewhere into your Python path.
""" % ( __version__, __date__ )
+
class element:
"""This class handles the addition of a new element."""
@@ -37,7 +37,7 @@ def __call__(self, *args, **kwargs):
if len(args) > 1:
raise ArgumentError(self.tag)
- # if class_ was defined in parent it should be added to every element
+ # If class_ was defined in parent, it should be added to every element.
if self.parent is not None and self.parent.class_ is not None:
if 'class_' not in kwargs:
kwargs['class_'] = self.parent.class_
@@ -57,7 +57,7 @@ def __call__(self, *args, **kwargs):
elif self.tag in self.parent.onetags:
if len(args) == 0:
for myarg, mydict in _argsdicts(args, kwargs):
- # here myarg is always None, because len( args ) = 0
+ # Here myarg is always None, because len( args ) = 0.
self.render(self.tag, True, myarg, mydict)
else:
raise ClosingError(self.tag)
@@ -71,11 +71,11 @@ def render(self, tag, single, between, kwargs):
out = "<%s" % tag
for key, value in kwargs.items():
- # when value is None that means stuff like <... checked>
+ # When value is None, that means stuff like <... checked>.
if value is not None:
- # strip this so class_ will mean class, etc.
+ # Strip this so class_ will mean class, etc.
key = key.strip('_')
- # special cases, maybe change _ to - overall?
+ # Special cases, maybe change _ to - overall?
if key == 'http_equiv':
key = 'http-equiv'
elif key == 'accept_charset':
@@ -116,8 +116,8 @@ def open(self, **kwargs):
class page:
- """This is our main class representing a document. Elements are added
- as attributes of an instance of this class."""
+ """This is our main class representing a document. Elements are added as
+ attributes of an instance of this class."""
def __init__(self, mode='strict_html', case='lower',
onetags=None, twotags=None, separator='\n', class_=None):
@@ -178,8 +178,7 @@ def __init__(self, mode='strict_html', case='lower',
self.case = case
self.separator = separator
- # init( ) sets it to True so we know that