1 | | - | import os, time |
| 1 | + | import os |
| 2 | + | import time |
2 | 3 | | from core import execute |
3 | 4 | | from core import slack |
4 | 5 | | from core import utils |
| skipped 14 lines |
19 | 20 | | 'title': "{0} | {1}".format(self.options['TARGET'], self.module_name), |
20 | 21 | | 'content': 'Start ScreenShot for {0}'.format(self.options['TARGET']) |
21 | 22 | | }) |
| 23 | + | |
| 24 | + | |
22 | 25 | | self.initial() |
| 26 | + | |
23 | 27 | | slack.slack_noti('good', self.options, mess={ |
24 | 28 | | 'title': "{0} | {1} ".format(self.options['TARGET'], self.module_name), |
25 | 29 | | 'content': 'Done ScreenShot for {0}'.format(self.options['TARGET']) |
26 | 30 | | }) |
27 | 31 | | utils.print_line() |
28 | 32 | | |
| 33 | + | # check if this was run on subdomain module or direct mode from screenshot |
| 34 | + | def check_direct(self): |
| 35 | + | all_subdomain = utils.replace_argument( |
| 36 | + | self.options, '$WORKSPACE/subdomain/final-$OUTPUT.txt') |
| 37 | + | |
| 38 | + | if utils.not_empty_file(all_subdomain): |
| 39 | + | return False |
| 40 | + | |
| 41 | + | self.is_direct = utils.is_direct_mode(self.options, require_input=True) |
| 42 | + | return True |
29 | 43 | | |
30 | 44 | | def initial(self): |
31 | | - | self.run() |
| 45 | + | if self.check_direct(): |
| 46 | + | self.screenshots(self.is_direct) |
| 47 | + | else: |
| 48 | + | self.run() |
32 | 49 | | utils.just_waiting(self.options, self.module_name, seconds=10) |
33 | | - | #this gonna run after module is done to update the main json |
| 50 | + | # this gonna run after module is done to update the main json |
34 | 51 | | # self.conclude() |
35 | 52 | | |
36 | 53 | | def run(self): |
| skipped 1 lines |
38 | 55 | | |
39 | 56 | | for item in commands: |
40 | 57 | | utils.print_good('Starting {0}'.format(item.get('banner'))) |
41 | | - | #really execute it |
| 58 | + | # really execute it |
42 | 59 | | execute.send_cmd(self.options, item.get('cmd'), item.get( |
43 | 60 | | 'output_path'), item.get('std_path'), self.module_name) |
44 | 61 | | time.sleep(1) |
45 | 62 | | |
46 | 63 | | utils.just_waiting(self.options, self.module_name, seconds=30) |
47 | | - | #just save commands |
| 64 | + | # just save commands |
48 | 65 | | logfile = utils.replace_argument(self.options, '$WORKSPACE/log.json') |
49 | 66 | | utils.save_all_cmd(self.options, logfile) |
50 | 67 | | |
| 68 | + | def screenshots(self, input_file): |
| 69 | + | if not utils.not_empty_file(input_file): |
| 70 | + | return False |
51 | 71 | | |
52 | | - | # #update the main json file |
53 | | - | # def conclude(self): |
54 | | - | # output_path = utils.replace_argument( |
55 | | - | # self.options, '$WORKSPACE/subdomain/massdns-IP-$OUTPUT.txt') |
| 72 | + | data = utils.just_read(input_file).splitlines() |
| 73 | + | self.aquatone(input_file) |
| 74 | + | self.gowithness(data) |
| 75 | + | |
| 76 | + | def aquatone(self, input_file): |
| 77 | + | cmd = "cat {0} | $GO_PATH/aquatone -threads 20 -out $WORKSPACE/screenshot/$OUTPUT-aquatone".format(input_file) |
| 78 | + | |
| 79 | + | cmd = utils.replace_argument(self.options, cmd) |
| 80 | + | output_path = utils.replace_argument( |
| 81 | + | self.options, "$WORKSPACE/screenshot/$OUTPUT-aquatone/aquatone_report.html") |
| 82 | + | std_path = utils.replace_argument( |
| 83 | + | self.options, "$WORKSPACE/screenshot/std-$OUTPUT-aquatone.std") |
| 84 | + | |
| 85 | + | execute.send_cmd(self.options, cmd, output_path, |
| 86 | + | std_path, self.module_name) |
| 87 | + | |
| 88 | + | def gowithness(self, data): |
| 89 | + | # add http:// and https:// prefix to domain |
| 90 | + | domains = [] |
| 91 | + | utils.make_directory( |
| 92 | + | self.options['WORKSPACE'] + '/screenshot/screenshoots-gowitness') |
| 93 | + | for item in data: |
| 94 | + | host = utils.get_domain(item) |
| 95 | + | domains.append("http://" + host) |
| 96 | + | domains.append("https://" + host) |
| 97 | + | http_file = utils.replace_argument( |
| 98 | + | self.options, '$WORKSPACE/screenshot/$OUTPUT-hosts.txt') |
| 99 | + | utils.just_write(http_file, "\n".join(domains)) |
| 100 | + | utils.clean_up(http_file) |
| 101 | + | time.sleep(2) |
56 | 102 | | |
57 | | - | # # matching IP with subdomain |
58 | | - | # main_json = utils.reading_json(utils.replace_argument( |
59 | | - | # self.options, '$WORKSPACE/$COMPANY.json')) |
60 | | - | # with open(output_path, 'r') as i: |
61 | | - | # data = i.read().splitlines() |
62 | | - | # ips = [] |
63 | | - | # for line in data: |
64 | | - | # if " A " in line: |
65 | | - | # subdomain = line.split('. A ')[0] |
66 | | - | # ip = line.split('. A ')[1] |
67 | | - | # ips.append(ip) |
68 | | - | # for i in range(len(main_json['Subdomains'])): |
69 | | - | # if subdomain == main_json['Subdomains'][i]['Domain']: |
70 | | - | # main_json['Subdomains'][i]['IP'] = ip |
| 103 | + | # screenshots with gowitness |
| 104 | + | cmd = "$GO_PATH/gowitness file -s $WORKSPACE/screenshot/$OUTPUT-hosts.txt -t 30 --log-level fatal --destination $WORKSPACE/screenshot/screenshoots-gowitness/ --db $WORKSPACE/screenshot/screenshoots-gowitness/gowitness.db" |
| 105 | + | |
| 106 | + | execute.send_cmd(self.options, utils.replace_argument( |
| 107 | + | self.options, cmd), '', '', self.module_name) |
71 | 108 | | |
72 | | - | # final_ip = utils.replace_argument( |
73 | | - | # self.options, '$WORKSPACE/subdomain/final-IP-$OUTPUT.txt') |
| 109 | + | utils.just_waiting(self.options, self.module_name, seconds=10) |
74 | 110 | | |
75 | | - | # with open(final_ip, 'w+') as fip: |
76 | | - | # fip.write("\n".join(str(ip) for ip in ips)) |
| 111 | + | cmd = "$GO_PATH/gowitness generate -n $WORKSPACE/screenshot/$OUTPUT-gowitness-screenshots.html --destination $WORKSPACE/screenshot/screenshoots-gowitness/ --db $WORKSPACE/screenshot/screenshoots-gowitness/gowitness.db" |
77 | 112 | | |
78 | | - | # utils.just_write(utils.replace_argument( |
79 | | - | # self.options, '$WORKSPACE/$COMPANY.json'), main_json, is_json=True) |
| 113 | + | html_path = utils.replace_argument( |
| 114 | + | self.options, "$WORKSPACE/portscan/$OUTPUT-gowitness-screenshots.html") |
| 115 | + | execute.send_cmd(self.options, utils.replace_argument( |
| 116 | + | self.options, cmd), html_path, '', self.module_name) |
80 | 117 | | |