| 2 | from autorecon.io import fformat |
| 3 | |
| 4 | class CurlRobots(ServiceScan): |
| 5 | |
| 6 | def __init__(self): |
| 7 | super().__init__() |
| 8 | self.name = "Curl Robots" |
| 9 | self.tags = ['default', 'safe', 'http'] |
| 10 | |
| 11 | def configure(self): |
| 12 | self.match_service_name('^http') |
| 13 | self.match_service_name('^nacn_http$', negative_match=True) |
| 14 | |
| 15 | async def run(self, service): |
| 16 | if service.protocol == 'tcp': |
| 17 | process, stdout, _ = await service.execute('curl -sSikf {http_scheme}://{addressv6}:{port}/robots.txt', future_outfile='{protocol}_{port}_{http_scheme}_curl-robots.txt') |
| 18 | |
| 19 | lines = await stdout.readlines() |
| 20 | |
| 21 | if process.returncode == 0 and lines: |
| 22 | filename = fformat('{scandir}/{protocol}_{port}_{http_scheme}_curl-robots.txt') |
| 23 | with open(filename, mode='wt', encoding='utf8') as robots: |
| 24 | robots.write('\n'.join(lines)) |
| 25 | else: |
| 26 | service.info('{bblue}[' + fformat('{tag}') + ']{rst} There did not appear to be a robots.txt file in the webroot (/).') |
nothing calls this directly
no outgoing calls
no test coverage detected