-
Notifications
You must be signed in to change notification settings - Fork 121
/
siteinfo.py
1477 lines (1245 loc) · 52 KB
/
siteinfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
The siteinfo.py module provides site lookup and result
storage for those sites based on the xml config
file and the arguments sent in to the Automater.
Class(es):
SiteFacade -- Class used to run the automation necessary to retrieve
site information and store results.
Site -- Parent Class used to store sites and information retrieved.
SingleResultsSite -- Class used to store information from a site that
only has one result requested and discovered.
MultiResultsSite -- Class used to store information from a site that
has multiple results requested and discovered.
PostTransactionPositiveCapableSite -- Class used to store information
from a site that has single or multiple results requested and discovered.
This Class is utilized to post information to web sites if a post is
required and requested via a --p argument utilized when the program is
called. This Class expects to find the first regular expression listed
in the xml config file. If that regex is found, it tells the class
that a post is necessary.
Function(s):
No global exportable functions are defined.
Exception(s):
No exceptions exported.
"""
import requests
import re
import time
import os
from os import listdir
from os.path import isfile, join
from requests.exceptions import ConnectionError
from outputs import SiteDetailOutput
from inputs import SitesFile
from utilities import VersionChecker
requests.packages.urllib3.disable_warnings()
__TEKDEFENSEXML__ = 'tekdefense.xml'
__SITESXML__ = 'sites.xml'
class SiteFacade(object):
"""
SiteFacade provides a Facade to run the multiple requirements needed
to automate the site retrieval and storage processes.
Public Method(s):
runSiteAutomation
(Property) Sites
Instance variable(s):
_sites
"""
def __init__(self, verbose):
"""
Class constructor. Simply creates a blank list and assigns it to
instance variable _sites that will be filled with retrieved info
from sites defined in the xml configuration file.
Argument(s):
No arguments are required.
Return value(s):
Nothing is returned from this Method.
"""
self._sites = []
self._verbose = verbose
def runSiteAutomation(self, webretrievedelay, proxy, targetlist, sourcelist,
useragent, botoutputrequested, refreshremotexml, versionlocation):
"""
Builds site objects representative of each site listed in the xml
config file. Appends a Site object or one of it's subordinate objects
to the _sites instance variable so retrieved information can be used.
Returns nothing.
Argument(s):
webretrievedelay -- The amount of seconds to wait between site retrieve
calls. Default delay is 2 seconds.
proxy -- proxy server address as server:port_number
targetlist -- list of strings representing targets to be investigated.
Targets can be IP Addresses, MD5 hashes, or hostnames.
sourcelist -- list of strings representing a specific site that should only be used
for investigation purposes instead of all sites listed in the xml
config file.
useragent -- String representing user-agent that will be utilized when
requesting or submitting data to or from a web site.
botoutputrequested -- true or false representing if a minimalized output
will be required for the site.
refreshremotexml -- true or false representing if Automater will refresh
the tekdefense.xml file on each run.
Return value(s):
Nothing is returned from this Method.
Restriction(s):
The Method has no restrictions.
"""
if refreshremotexml:
SitesFile.updateTekDefenseXMLTree(proxy, self._verbose)
remotesitetree = SitesFile.getXMLTree(__TEKDEFENSEXML__, self._verbose)
localsitetree = SitesFile.getXMLTree(__SITESXML__, self._verbose)
if not localsitetree and not remotesitetree:
print 'Unfortunately there is neither a {tekd} file nor a {sites} file that can be utilized for proper' \
' parsing.\nAt least one configuration XML file must be available for Automater to work properly.\n' \
'Please see {url} for further instructions.'\
.format(tekd=__TEKDEFENSEXML__, sites=__SITESXML__, url=versionlocation)
else:
if localsitetree:
for siteelement in localsitetree.iter(tag="site"):
if self.siteEntryIsValid(siteelement):
for targ in targetlist:
for source in sourcelist:
sitetypematch, targettype, target = self.getSiteInfoIfSiteTypesMatch(source, targ,
siteelement)
if sitetypematch:
self.buildSiteList(siteelement, webretrievedelay, proxy, targettype, target,
useragent, botoutputrequested)
else:
print 'A problem was found in the {sites} file. There appears to be a site entry with ' \
'unequal numbers of regexs and reporting requirements'.format(sites=__SITESXML__)
if remotesitetree:
for siteelement in remotesitetree.iter(tag="site"):
if self.siteEntryIsValid(siteelement):
for targ in targetlist:
for source in sourcelist:
sitetypematch, targettype, target = self.getSiteInfoIfSiteTypesMatch(source, targ,
siteelement)
if sitetypematch:
self.buildSiteList(siteelement, webretrievedelay, proxy, targettype, target,
useragent, botoutputrequested)
else:
print 'A problem was found in the {sites} file. There appears to be a site entry with ' \
'unequal numbers of regexs and reporting requirements'.format(sites=__SITESXML__)
def getSiteInfoIfSiteTypesMatch(self, source, target, siteelement):
if source == "allsources" or source == siteelement.get("name"):
targettype = self.identifyTargetType(target)
for st in siteelement.find("sitetype").findall("entry"):
if st.text == targettype:
return True, targettype, target
return False, None, None
def siteEntryIsValid(self, siteelement):
reportstringcount = len(siteelement.find("reportstringforresult").findall("entry"))
sitefriendlynamecount = len(siteelement.find("sitefriendlyname").findall("entry"))
regexcount = len(siteelement.find("regex").findall("entry"))
importantpropertycount = len(siteelement.find("importantproperty").findall("entry"))
if reportstringcount == sitefriendlynamecount and reportstringcount == regexcount and reportstringcount == importantpropertycount:
return True
return False
def buildSiteList(self, siteelement, webretrievedelay, proxy, targettype, targ, useragent, botoutputrequested):
site = Site.buildSiteFromXML(siteelement, webretrievedelay, proxy, targettype, targ, useragent,
botoutputrequested, self._verbose)
if site.Method == "POST":
self._sites.append(MethodPostSite(site))
elif isinstance(site.RegEx, basestring):
self._sites.append(SingleResultsSite(site))
else:
self._sites.append(MultiResultsSite(site))
@property
def Sites(self):
"""
Checks the instance variable _sites is empty or None.
Returns _sites (the site list) or None if it is empty.
Argument(s):
No arguments are required.
Return value(s):
list -- of Site objects or its subordinates.
None -- if _sites is empty or None.
Restriction(s):
This Method is tagged as a Property.
"""
if self._sites is None or len(self._sites) == 0:
return None
return self._sites
def identifyTargetType(self, target):
"""
Checks the target information provided to determine if it is a(n)
IP Address in standard; CIDR or dash notation, or an MD5 hash,
or a string hostname.
Returns a string md5 if MD5 hash is identified. Returns the string
ip if any IP Address format is found. Returns the string hostname
if neither of those two are found.
Argument(s):
target -- string representing the target provided as the first
argument to the program when Automater is run.
Return value(s):
string.
Restriction(s):
The Method has no restrictions.
"""
ipAddress = re.compile('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
ipFind = re.findall(ipAddress, target)
if ipFind is not None and len(ipFind) > 0:
return "ip"
md5 = re.compile('[a-fA-F0-9]{32}', re.IGNORECASE)
md5Find = re.findall(md5,target)
if md5Find is not None and len(md5Find) > 0:
return "md5"
return "hostname"
class Site(object):
"""
Site is the parent object that represents each site used
for retrieving information. Site stores the results
discovered from each web site discovered when running Automater.
Site is the parent object to SingleResultsSite, MultiResultsSite,
PostTransactionPositiveCapableSite and MethodPostSite.
Public Method(s):
(Class Method) buildSiteFromXML
(Class Method) buildStringOrListfromXML
(Class Method) buildDictionaryFromXML
(Property) WebRetrieveDelay
(Property) TargetType
(Property) ReportStringForResult
(Property) FriendlyName
(Property) RegEx
(Property) URL
(Property) ErrorMessage
(Property) UserMessage
(Property) FullURL
(Setter) FullURL
(Property) BotOutputRequested
(Property) SourceURL
(Property) ImportantPropertyString
(Property) Params
(Setter) Params
(Property) Headers
(Property) Target
(Property) UserAgent
(Property) Results
(Property) Method
addResults
postMessage
getImportantProperty
getTarget
getResults
getFullURL
getWebScrape
Instance variable(s):
_sites
_sourceurl
_webretrievedelay
_targetType
_reportstringforresult
_errormessage
_usermessage
_target
_userAgent
_friendlyName
_regex
_fullURL
_botOutputRequested
_importantProperty
_params
_headers
_results
_method
"""
def __init__(self, domainurl, webretrievedelay, proxy, targettype,
reportstringforresult, target, useragent, friendlyname, regex,
fullurl, boutoutputrequested, importantproperty, params, headers, method, postdata, verbose):
"""
Class constructor. Sets the instance variables based on input from
the arguments supplied when Automater is run and what the xml
config file stores.
Argument(s):
domainurl -- string defined in xml in the domainurl XML tag.
webretrievedelay -- the amount of seconds to wait between site retrieve
calls. Default delay is 2 seconds.
proxy -- will set a proxy to use (eg. proxy.example.com:8080).
targettype -- the targettype as defined. Either ip, md5, or hostname.
reportstringforresult -- string or list of strings that are entered in
the entry XML tag within the reportstringforresult XML tag in the
xml configuration file.
target -- the target that will be used to gather information on.
useragent -- the user-agent string that will be utilized when submitting
information to or requesting information from a website
friendlyname -- string or list of strings that are entered in
the entry XML tag within the sitefriendlyname XML tag in the
xml configuration file.
regex -- the regexs defined in the entry XML tag within the
regex XML tag in the xml configuration file.
fullurl -- string representation of fullurl pulled from the
xml file in the fullurl XML tag.
boutoutputrequested -- true or false representation of whether the -b option was used
when running the program. If true, it slims the output so a bot can be
used and the output is minimalized.
importantproperty -- string defined in the the xml config file
in the importantproperty XML tag.
params -- string or list provided in the entry XML tags within the params
XML tag in the xml configuration file.
headers -- string or list provided in the entry XML tags within the headers
XML tag in the xml configuration file.
method -- holds whether this is a GET or POST required site. by default = GET
postdata -- dict holding data required for posting values to a site. by default = None
verbose -- boolean representing whether text will be printed to stdout
Return value(s):
Nothing is returned from this Method.
"""
self._sourceurl = domainurl
self._webretrievedelay = webretrievedelay
self._proxy = proxy
self._targetType = targettype
self._reportstringforresult = reportstringforresult
self._errormessage = "[-] Cannot scrape"
self._usermessage = "[*] Checking"
self._target = target
self._userAgent = useragent
self._friendlyName = friendlyname
self._regex = ""
self.RegEx = regex # call the helper method to clean %TARGET% from regex string
self._fullURL = ""
self.FullURL = fullurl # call the helper method to clean %TARGET% from fullurl string
self._botOutputRequested = boutoutputrequested
self._importantProperty = importantproperty
self._params = None
if params is not None:
self.Params = params # call the helper method to clean %TARGET% from params string
self._headers = None
if headers is not None:
self.Headers = headers # call the helper method to clean %TARGET% from params string
self._postdata = None
if postdata:
self.PostData = postdata
self._method = None
self.Method = method # call the helper method to ensure result is either GET or POST
self._results = []
self._verbose = verbose
@classmethod
def checkmoduleversion(self, prefix, gitlocation, proxy, verbose):
execpath = os.path.dirname(os.path.realpath(__file__))
pythonfiles = [f for f in listdir(execpath) if isfile(join(execpath, f)) and f[-3:] == '.py']
if proxy:
proxies = {'https': proxy, 'http': proxy}
else:
proxies = None
SiteDetailOutput.PrintStandardOutput(VersionChecker.getModifiedFileInfo(prefix, gitlocation, pythonfiles),
verbose=verbose)
@classmethod
def buildSiteFromXML(self, siteelement, webretrievedelay, proxy, targettype,
target, useragent, botoutputrequested, verbose):
"""
Utilizes the Class Methods within this Class to build the Site object.
Returns a Site object that defines results returned during the web
retrieval investigations.
Argument(s):
siteelement -- the siteelement object that will be used as the
start element.
webretrievedelay -- the amount of seconds to wait between site retrieve
calls. Default delay is 2 seconds.
proxy -- sets a proxy to use in the form of proxy.example.com:8080.
targettype -- the targettype as defined. Either ip, md5, or hostname.
target -- the target that will be used to gather information on.
useragent -- the string utilized to represent the user-agent when
web requests or submissions are made.
botoutputrequested -- true or false representing if a minimalized output
will be required for the site.
Return value(s):
Site object.
Restriction(s):
This Method is tagged as a Class Method
"""
domainurl = siteelement.find("domainurl").text
try:
method = siteelement.find("method").text
if method.upper() != "GET" and method.upper() != "POST":
method = "GET"
except:
method = "GET"
postdata = Site.buildDictionaryFromXML(siteelement, "postdata")
reportstringforresult = Site.buildStringOrListfromXML(siteelement, "reportstringforresult")
sitefriendlyname = Site.buildStringOrListfromXML(siteelement, "sitefriendlyname")
regex = Site.buildStringOrListfromXML(siteelement, "regex")
fullurl = siteelement.find("fullurl").text
importantproperty = Site.buildStringOrListfromXML(siteelement, "importantproperty")
params = Site.buildDictionaryFromXML(siteelement, "params")
headers = Site.buildDictionaryFromXML(siteelement, "headers")
return Site(domainurl, webretrievedelay, proxy, targettype, reportstringforresult, target,
useragent, sitefriendlyname, regex, fullurl, botoutputrequested, importantproperty,
params, headers, method.upper(), postdata, verbose)
@classmethod
def buildStringOrListfromXML(self, siteelement, elementstring):
"""
Takes in a siteelement and then elementstring and builds a string
or list from multiple entry XML tags defined in the xml config
file. Returns None if there are no entry XML tags for this
specific elementstring. Returns a list of those entries
if entry XML tags are found or a string of that entry if only
one entry XML tag is found.
Argument(s):
siteelement -- the siteelement object that will be used as the
start element.
elementstring -- the string representation within the siteelement
that will be utilized to get to the single or multiple entry
XML tags.
Return value(s):
None if no entry XML tags are found.
List representing all entry keys found within the elementstring.
string representing an entry key if only one is found
within the elementstring.
Restriction(s):
This Method is tagged as a Class Method
"""
variablename = ""
if len(siteelement.find(elementstring).findall("entry")) == 0:
return None
if len(siteelement.find(elementstring).findall("entry")) > 1:
variablename = []
for entry in siteelement.find(elementstring).findall("entry"):
variablename.append(entry.text)
else:
variablename = ""
variablename = siteelement.find(elementstring).find("entry").text
return variablename
@classmethod
def buildDictionaryFromXML(self, siteelement, elementstring):
"""
Takes in a siteelement and then elementstring and builds a dictionary
from multiple entry XML tags defined in the xml config file.
Returns None if there are no entry XML tags for this
specific elementstring. Returns a dictionary of those entries
if entry XML tags are found.
Argument(s):
siteelement -- the siteelement object that will be used as the
start element.
elementstring -- the string representation within the siteelement
that will be utilized to get to the single or multiple entry
XML tags.
Return value(s):
None if no entry XML tags are found.
Dictionary representing all entry keys found within the elementstring.
Restriction(s):
This Method is tagged as a Class Method
"""
variablename = ""
try:
if len(siteelement.find(elementstring).findall("entry")) > 0:
variablename = {}
for entry in siteelement.find(elementstring).findall("entry"):
variablename[entry.get("key")] = entry.text
else:
return None
except:
return None
return variablename
@property
def WebRetrieveDelay(self):
"""
Returns the string representation of the number of
seconds that will be delayed between site retrievals.
Argument(s):
No arguments are required.
Return value(s):
string -- representation of an integer that is the delay in
seconds that will be used between each web site retrieval.
Restriction(s):
This Method is tagged as a Property.
"""
return self._webretrievedelay
@property
def Proxy(self):
"""
Returns the string representation of the proxy used.
Argument(s):
No arguments are required.
Return value(s):
string -- representation of the proxy used
Restriction(s):
This Method is tagged as a Property.
"""
return self._proxy
@property
def TargetType(self):
"""
Returns the target type information whether that be ip,
md5, or hostname.
Argument(s):
No arguments are required.
Return value(s):
string -- defined as ip, md5, or hostname.
Restriction(s):
This Method is tagged as a Property.
"""
return self._targetType
@property
def ReportStringForResult(self):
"""
Returns the string representing a report string tag that
precedes reporting information so the user knows what
specifics are being found.
Argument(s):
No arguments are required.
Return value(s):
string -- representing a tag for reporting information.
Restriction(s):
This Method is tagged as a Property.
"""
return self._reportstringforresult
@property
def FriendlyName(self):
"""
Returns the string representing a friendly string name.
Argument(s):
No arguments are required.
Return value(s):
string -- representing friendly name for a tag for reporting.
Restriction(s):
This Method is tagged as a Property.
"""
return self._friendlyName
@property
def URL(self):
"""
Returns the string representing the Domain URL which is
required to retrieve the information being investigated.
Argument(s):
No arguments are required.
Return value(s):
string -- representing the URL of the site.
Restriction(s):
This Method is tagged as a Property.
"""
return self._sourceurl
@property
def ErrorMessage(self):
"""
Returns the string representing the Error Message.
Argument(s):
No arguments are required.
Return value(s):
string -- representing the error message to print to
the standard output.
Restriction(s):
This Method is tagged as a Property.
"""
return self._errormessage
@property
def UserMessage(self):
"""
Returns the string representing the Full URL which is the
domain URL plus querystrings and other information required
to retrieve the information being investigated.
Argument(s):
No arguments are required.
Return value(s):
string -- representing the full URL of the site including
querystring information and any other info required.
Restriction(s):
This Method is tagged as a Property.
"""
return self._usermessage
@property
def FullURL(self):
"""
Returns the string representing the Full URL which is the
domain URL plus querystrings and other information required
to retrieve the information being investigated.
Argument(s):
No arguments are required.
Return value(s):
string -- representing the full URL of the site including
querystring information and any other info required.
Restriction(s):
This Method is tagged as a Property.
"""
return self._fullURL
@FullURL.setter
def FullURL(self, fullurl):
"""
Determines if the parameter has characters and assigns it to the
instance variable _fullURL if it does after replacing the target
information where the keyword %TARGET% is used. This keyword will
be used in the xml configuration file where the user wants
the target information to be placed in the URL.
Argument(s):
fullurl -- string representation of fullurl pulled from the
xml file in the fullurl XML tag.
Return value(s):
Nothing is returned from this Method.
Restriction(s):
This Method is tagged as a Setter.
"""
if len(fullurl) > 0:
fullurlreplaced = fullurl.replace("%TARGET%", self._target)
self._fullURL = fullurlreplaced
else:
self._fullURL = ""
@property
def RegEx(self):
"""
Returns string representing the regex being investigated.
Argument(s):
No arguments are required.
Return value(s):
string -- representation of the Regex from the _regex
instance variable.
Restriction(s):
This Method is tagged as a Property.
"""
return self._regex
@RegEx.setter
def RegEx(self, regex):
"""
Determines if the parameter has characters and assigns it to the
instance variable _regex if it does after replacing the target
information where the keyword %TARGET% is used. This keyword will
be used in the xml configuration file where the user wants
the target information to be placed in the regex.
Argument(s):
regex -- string representation of regex pulled from the
xml file in the regex entry XML tag.
Return value(s):
Nothing is returned from this Method.
Restriction(s):
This Method is tagged as a Setter.
"""
if len(regex) > 0:
try:
regexreplaced = regex.replace("%TARGET%", self._target)
self._regex = regexreplaced
except AttributeError:
regexreplaced = []
for r in regex:
regexreplaced.append(r.replace("%TARGET%", self._target))
self._regex = regexreplaced
else:
self._regex = ""
@property
def BotOutputRequested(self):
"""
Returns a true if the -b option was requested when the
program was run. This identifies if the program is to
run a more silent version of output during the run to help
bots and other small format requirements.
Argument(s):
No arguments are required.
Return value(s):
boolean -- True if the -b option was used and am more silent
output is required. False if normal output should be utilized.
Restriction(s):
This Method is tagged as a Property.
"""
return self._botOutputRequested
@property
def SourceURL(self):
"""
Returns the string representing the Source URL which is simply
the domain URL entered in the xml config file.
Argument(s):
No arguments are required.
Return value(s):
string -- representing the source URL of the site.
Restriction(s):
This Method is tagged as a Property.
"""
return self._sourceurl
@property
def ImportantPropertyString(self):
"""
Returns the string representing the Important Property
that the user wants the site to report. This is set using
the xml config file in the importantproperty XML tag.
Argument(s):
No arguments are required.
Return value(s):
string -- representing the important property of the site
that needs to be reported.
Restriction(s):
This Method is tagged as a Property.
"""
return self._importantProperty
@property
def Params(self):
"""
Determines if web Parameters were set for this specific site.
Returns the string representing the Parameters using the
_params instance variable or returns None if the instance
variable is empty or not set.
Argument(s):
No arguments are required.
Return value(s):
string -- representation of the Parameters from the _params
instance variable.
Restriction(s):
This Method is tagged as a Property.
"""
if self._params is None:
return None
if len(self._params) == 0:
return None
return self._params
@Params.setter
def Params(self, params):
"""
Determines if Parameters were required for this specific site.
If web Parameters were set, this places the target into the
parameters where required marked with the %TARGET% keyword
in the xml config file.
Argument(s):
params -- dictionary representing web Parameters required.
Return value(s):
Nothing is returned from this Method.
Restriction(s):
This Method is tagged as a Setter.
"""
if len(params) > 0:
for key in params:
if params[key] == "%TARGET%":
params[key] = self._target
self._params = params
else:
self._params = None
@property
def Headers(self):
"""
Determines if Headers were set for this specific site.
Returns the string representing the Headers using the
_headers instance variable or returns None if the instance
variable is empty or not set.
Argument(s):
No arguments are required.
Return value(s):
string -- representation of the Headers from the _headers
instance variable.
Restriction(s):
This Method is tagged as a Property.
"""
if self._headers is None:
return None
if len(self._headers) == 0:
return None
return self._headers
@Headers.setter
def Headers(self, headers):
"""
Determines if Headers were required for this specific site.
If web Headers were set, this places the target into the
headers where required or marked with the %TARGET% keyword
in the xml config file.
Argument(s):
headers -- dictionary representing web Headers required.
Return value(s):
Nothing is returned from this Method.
Restriction(s):
This Method is tagged as a Setter.
"""
if len(headers) > 0:
for key in headers:
if headers[key] == "%TARGET%":
headers[key] = self._target
self._headers = headers
else:
self._headers = None
@property
def PostData(self):
"""
Determines if PostData was set for this specific site.
Returns the dict representing the PostHeaders using the
_postdata instance variable or returns None if the instance
variable is empty or not set.
Argument(s):
No arguments are required.
Return value(s):
dict -- representation of the PostData from the _postdata
instance variable.
Restriction(s):
This Method is tagged as a Property.
"""
if self._postdata is None:
return None
if len(self._postdata) == 0:
return None
return self._postdata
@PostData.setter
def PostData(self, postdata):
"""
Determines if post data was required for this specific site.
If postdata is set, this ensures %TARGET% is stripped if necessary.
Argument(s):
postdata -- dictionary representing web postdata required.
Return value(s):
Nothing is returned from this Method.
Restriction(s):
This Method is tagged as a Setter.
"""
if len(postdata) > 0:
for key in postdata:
if postdata[key] == "%TARGET%":
postdata[key] = self._target
self._postdata = postdata
else:
self._postdata = None
@property
def Target(self):
"""
Returns string representing the target being investigated.
The string may be an IP Address, MD5 hash, or hostname.
Argument(s):
No arguments are required.
Return value(s):
string -- representation of the Target from the _target
instance variable.
Restriction(s):
This Method is tagged as a Property.
"""
return self._target
@property
def UserAgent(self):
"""
Returns string representing the user-agent that will
be used when requesting or submitting information to
a web site. This is a user-provided string implemented
on the command line at execution or provided by default
if not added during execution.
Argument(s):
No arguments are required.
Return value(s):
string -- representation of the UserAgent from the _userAgent
instance variable.
Restriction(s):
This Method is tagged as a Property.
"""
return self._userAgent
@property
def Method(self):
"""
Determines if a method (GET or POST) was established for this specific site.
Defaults to GET
Argument(s):
No arguments are required.
Return value(s):
string -- representation of the method used to access the site GET or POST.
Restriction(s):
This Method is tagged as a Property.
"""
if self._method is None:
return "GET"
if len(self._method) == 0:
return "GET"
return self._method
@Method.setter
def Method(self, method):
"""
Ensures the method type is set to either GET or POST. By default GET is assigned
Argument(s):
method -- string repr GET or POST. If neither, GET is assigned.
Return value(s):
Nothing is returned from this Method.
Restriction(s):
This Method is tagged as a Setter.
"""
if not self.PostData:
self._method = "GET"
return
if len(method) > 0:
if method.upper() == "GET" or method.upper() == "POST":
self._method = method.upper()
return
self._method = "GET"