yasint 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
yasint/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ from ._version import __version__
2
+ from .cli import *
yasint/__main__.py ADDED
@@ -0,0 +1,8 @@
1
+ #! /usr/bin/env python3
2
+ """
3
+ Entrypoint
4
+ """
5
+ from .cli import run
6
+
7
+ if __name__ == "__main__":
8
+ run()
yasint/_version.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = '0.3.0'
yasint/cli.py ADDED
@@ -0,0 +1,260 @@
1
+ """
2
+ Commandline interface
3
+ """
4
+ import asyncio
5
+ import logging
6
+ import os
7
+ import platform
8
+ import sys
9
+
10
+ from argparse import ArgumentParser, RawDescriptionHelpFormatter
11
+
12
+ from .core import *
13
+ from .report import *
14
+
15
+
16
+ def setup_arguments_parser():
17
+ from aiohttp import __version__ as aiohttp_version
18
+ from ._version import __version__
19
+
20
+ version_string = '\n'.join(
21
+ [
22
+ f'%(prog)s {__version__}',
23
+ f'Python: {platform.python_version()}',
24
+ f'Aiohttp: {aiohttp_version}',
25
+ ]
26
+ )
27
+
28
+ parser = ArgumentParser(
29
+ formatter_class=RawDescriptionHelpFormatter,
30
+ description=f"OSINT tool v{__version__}\n"
31
+ )
32
+ target_group = parser.add_argument_group(
33
+ 'INPUT', 'Options for input data'
34
+ )
35
+ target_group.add_argument(
36
+ "target",
37
+ nargs='*',
38
+ metavar="TARGET",
39
+ help="One or more target to get info by.",
40
+ )
41
+ target_group.add_argument(
42
+ "--target-list",
43
+ action="store",
44
+ dest="target_list_filename",
45
+ default='',
46
+ help="Path to text file with list of targets.",
47
+ )
48
+ target_group.add_argument(
49
+ "--targets-from-stdin",
50
+ action="store_true",
51
+ dest="target_list_stdin",
52
+ default=False,
53
+ help="Read all the lines from standard input.",
54
+ )
55
+ out_group = parser.add_argument_group(
56
+ 'OUTPUT', 'Options for output reports'
57
+ )
58
+ out_group.add_argument(
59
+ "--csv-report",
60
+ "-oC",
61
+ action="store",
62
+ dest="csv_filename",
63
+ default='',
64
+ help="Path to file for saving CSV report.",
65
+ )
66
+ out_group.add_argument(
67
+ "--text-report",
68
+ "-oT",
69
+ action="store",
70
+ dest="txt_filename",
71
+ default='',
72
+ help="Path to file for saving TXT report (grepable console output).",
73
+ )
74
+ parser.add_argument(
75
+ "--version",
76
+ action="version",
77
+ version=version_string,
78
+ help="Display version information and dependencies.",
79
+ )
80
+ parser.add_argument(
81
+ "--timeout",
82
+ action="store",
83
+ metavar='TIMEOUT',
84
+ dest="timeout",
85
+ default=100,
86
+ help="Time in seconds to wait for execution.",
87
+ )
88
+ parser.add_argument(
89
+ "--cookie-jar-file",
90
+ metavar="COOKIE_FILE",
91
+ dest="cookie_file",
92
+ default='',
93
+ help="File with cookies.",
94
+ )
95
+ parser.add_argument(
96
+ "--proxy",
97
+ "-p",
98
+ metavar='PROXY_URL',
99
+ action="store",
100
+ dest="proxy",
101
+ default='',
102
+ help="Make requests over a proxy. e.g. socks5://127.0.0.1:1080",
103
+ )
104
+ parser.add_argument(
105
+ "--verbose",
106
+ "-v",
107
+ action="store_true",
108
+ dest="verbose",
109
+ default=False,
110
+ help="Display extra information and metrics.",
111
+ )
112
+ parser.add_argument(
113
+ "--silent",
114
+ "-s",
115
+ action="store_true",
116
+ dest="silent",
117
+ default=False,
118
+ help="Suppress console output.",
119
+ )
120
+ parser.add_argument(
121
+ "--info",
122
+ "-vv",
123
+ action="store_true",
124
+ dest="info",
125
+ default=False,
126
+ help="Display extra/service information and metrics.",
127
+ )
128
+ parser.add_argument(
129
+ "--debug",
130
+ "-vvv",
131
+ "-d",
132
+ action="store_true",
133
+ dest="debug",
134
+ default=False,
135
+ help="Display extra/service/debug information and metrics, save responses in debug.log.",
136
+ )
137
+ parser.add_argument(
138
+ "--no-color",
139
+ action="store_true",
140
+ dest="no_color",
141
+ default=False,
142
+ help="Don't color terminal output",
143
+ )
144
+ parser.add_argument(
145
+ "--no-progressbar",
146
+ action="store_true",
147
+ dest="no_progressbar",
148
+ default=False,
149
+ help="Don't show progressbar.",
150
+ )
151
+
152
+ return parser
153
+
154
+
155
+ async def main():
156
+ # Logging
157
+ log_level = logging.ERROR
158
+ logging.basicConfig(
159
+ format='[%(filename)s:%(lineno)d] %(levelname)-3s %(asctime)s %(message)s',
160
+ datefmt='%H:%M:%S',
161
+ level=log_level,
162
+ )
163
+ logger = logging.getLogger('osint-cli-tool-skeleton')
164
+ logger.setLevel(log_level)
165
+
166
+ arg_parser = setup_arguments_parser()
167
+ args = arg_parser.parse_args()
168
+
169
+ if args.debug:
170
+ log_level = logging.DEBUG
171
+ elif args.info:
172
+ log_level = logging.INFO
173
+ elif args.verbose:
174
+ log_level = logging.WARNING
175
+
176
+ logger.setLevel(log_level)
177
+
178
+ input_data = []
179
+
180
+ # read from file
181
+ if args.target_list_filename:
182
+ if not os.path.exists(args.target_list_filename):
183
+ print(f'There is no file {args.target_list_filename}')
184
+ else:
185
+ with open(args.target_list_filename) as f:
186
+ input_data = [InputData(t) for t in f.read().splitlines()]
187
+
188
+ # or read from stdin
189
+ # e.g. cat list.txt | ./run.py --targets-from-stdin
190
+ elif args.target_list_stdin:
191
+ for line in sys.stdin:
192
+ input_data.append(InputData(line.strip()))
193
+
194
+ # or read from arguments
195
+ elif args.target:
196
+ input_data = [InputData(t) for t in args.target]
197
+
198
+ if not input_data:
199
+ print('There are no targets to check!')
200
+ sys.exit(1)
201
+
202
+ # convert input to output
203
+ processor = Processor(
204
+ no_progressbar=args.no_progressbar,
205
+ no_color=args.no_color,
206
+ proxy=args.proxy,
207
+ cookie_file=args.cookie_file,
208
+ )
209
+
210
+ output_data = await processor.process(input_data)
211
+
212
+ auxiliary_report_messages = []
213
+ for output in output_data:
214
+ session_dir = getattr(output, 'session_dir', '')
215
+ if not session_dir:
216
+ continue
217
+
218
+ auxiliary_report_messages.append(
219
+ TXTOutput([output], filename=os.path.join(session_dir, 'auxiliary_report.txt')).put()
220
+ )
221
+ auxiliary_report_messages.append(
222
+ CSVOutput([output], filename=os.path.join(session_dir, 'auxiliary_report.csv')).put()
223
+ )
224
+
225
+ # console output
226
+ if not args.silent:
227
+ r = PlainOutput(output_data, colored=not args.no_color)
228
+ print(r.put())
229
+ if auxiliary_report_messages:
230
+ print('\n'.join(auxiliary_report_messages))
231
+
232
+ # save CSV report
233
+ if args.csv_filename:
234
+ r = CSVOutput(output_data, filename=args.csv_filename)
235
+ print(r.put())
236
+
237
+ # save TXT report
238
+
239
+ if args.txt_filename:
240
+ r = TXTOutput(output_data, filename=args.txt_filename)
241
+ print(r.put())
242
+
243
+ await processor.close()
244
+
245
+
246
+ def run():
247
+ # Python 3.14+: asyncio.get_event_loop() raises if no loop is set.
248
+ # asyncio.run() is the recommended high-level entrypoint.
249
+ if sys.version_info >= (3, 7):
250
+ asyncio.run(main())
251
+ else:
252
+ loop = asyncio.new_event_loop()
253
+ asyncio.set_event_loop(loop)
254
+ try:
255
+ loop.run_until_complete(main())
256
+ finally:
257
+ loop.close()
258
+
259
+ if __name__ == "__main__":
260
+ run()